Note that there are some explanatory texts on larger screens.

plurals
  1. POapproach to solve two char column scramble of a text
    primarykey
    data
    text
    <p>I have a paragraph of text scrambled by columns of two chars. The purpose of my assignment is to unscramble it:</p> <pre><code>|de| | f|Cl|nf|ed|au| i|ti| |ma|ha|or|nn|ou| S|on|nd|on| |ry| |is|th|is| b|eo|as| | |f |wh| o|ic| t|, | |he|h | |ab| |la|pr|od|ge|ob| m|an| |s |is|el|ti|ng|il|d |ua|c | |he| |ea|of|ho| m| t|et|ha| | t|od|ds|e |ki| c|t |ng|br| |wo|m,|to|yo|hi|ve|u | t|ob| |pr|d |s |us| s|ul|le|ol|e | | t|ca| t|wi| M|d |th|"A|ma|l |he| p|at|ap|it|he|ti|le|er| |ry|d |un|Th|" |io|eo|n,|is| |bl|f |pu|Co|ic| o|he|at|mm| |hi| | |in| | | t| | | | |ye| |ar| |s | | |. | </code></pre> <p>My current approach to find the right order of columns is trying to recursively find each column's best position according to a word occurrence count criteria.</p> <p>The pseudo-code of the algorithm's core I have in mind would be: </p> <pre><code>function unscramble(scrambledMatrix,indexOfColumnIveJustMoved) for each column on scrambledMatrix as currentIndex=&gt;currentColumn if (currentIndex!=indexOfColumnIveJustMoved) maxRepeatedWords=0;maxIndex=0; for (i=0;i&lt;numberOfColumnsOfScrambledMatrix;i++) repWordsCount=countRepWords(moveFromToOn(currentIndex,i,scrambledMatrix)) if (maxRepeatedWords&lt;repWordsCount) maxRepeatedWords=repWordsCount; maxIndex=i; endif endfor if (maxIndex!=currentIndex) return unscramble(moveFromToOn(currentIndex,maxIndex,scrambledMatrix),maxIndex); //recursive call endif endif endfor return(scrambledMatrix); //returns the unscrambled matrix; endfunction </code></pre> <p>The algorithm stops when no column is moved after iterating on each one. I'm guessing it should work for any language (though I'm only interested on a solution for english) as long as the writing is based on words formed by letters and the sample is big enough.</p> <p>Any suggestions on any other approaches or improvements? I would like to know the best solution for this problem (probably a dictionary based one looking for occurrences of common words instead? How about rebuilding the algorithm to avoid recursion, would it be much faster?).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload