Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the problem is that you always work on the whole text, but apply the (new) shifting at some start inside of the text. So your check <code>is_word(wordlist,text.split()[0])</code> will <em>always</em> check the first word, which is - of course - a word after your first shift.</p> <p>What you need to do instead is to get the first word after your new starting point, so check the actually unhandled parts of the text.</p> <h3>edit</h3> <p>Another problem I noticed is the way you are trying out to find the correct shift:</p> <pre><code>for shift in range(27): text=apply_shifts(text, [(start,-shift)]) </code></pre> <p>So you basically want to try all shifts from 0 to 26 until the first word is accepted. It is okay to do it like that, but note that after the first tried shifting, <em>the text has changed</em>. As such you are not shifting it by <code>1, 2, 3, ...</code> but by <code>1, 3, 6, 10, ...</code> which is of course not what you want, and you will of course miss some shifts while doing some identical ones multiple times.</p> <p>So you need to <em>temporarily</em> shift your text and check the status of that temporary text, before you continue to work with the text. Or alternatively, you always shift by <code>1</code> instead.</p> <h3>edit²</h3> <p>And another problem I noticed is with the way you are trying to use recursion to get your final result. Usually recursion (with a result) works the way that you keep calling the function itself and pass the return values along, or <em>collect</em> the results. In your case, as you want to have multiple values, and not just a single value from somewhere inside, you need to collect each of the shifting results.</p> <p>But right now, you are throwing away the return values of the recursive calls and just return the last value. So store all the values and make sure you don't lose them.</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.
 

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