# [Tutor] Struggling with logic .....

Barry Drake bdrake at crosswire.org
Sat Jan 19 17:50:15 CET 2013

```On 19/01/13 14:33, Alan Gauld wrote:
>> line is:  ['1', '2', '3', '4']   Length: 4
>> Random Code:  (3, 4, 2, 3)
>> Result: 0  - you have a correct number in an incorrect position
>> Result: 0  - you have a correct number in an incorrect position
>> Result: 0  - you have a correct number in an incorrect position
>> Result: -1  - you have an incorrect number
>
> Looks good to me
>
>> line is:  ['4', '2', '1', '5']   Length: 4
>> Random Code:  (3, 4, 2, 3)
>
> Same here. Sooo... Some comments on the code.

Thanks.  I seem to have misunderstood what the original coder had
intended.  I suppose the above output is making sense after all.

> <snip>
> OK, at this point I give up, this is way too complicated for what you
> are doing.

I guess this is exactly why I have been struggling to understand some of
the logic in the original code!   I like your idea of sets of tuples for
input and solution - I'll play around with the idea. Also, I think I
want to alter the random initialisation - I don't like the way in which
four separate random digits each with a range of only six are
generated.  I think generating a four digit number and splitting the
digits will be a better option.  As you mention, the use of colours in
the original code is a distraction - I think that is the reason for
limiting the digits to numbers between 1 and 6 - simply based on the old
board-game.  There's no other logical reason so I'll do away with that
concept.

Thanks again for your time.  I'm GOING to learn to code Python!  I used
to code in C many years ago and never made the jump to C++, but Python
has much nicer features for a novice.  Incidentally, if I re-code the
example, should I alter it to Python3 syntax while I'm at it?  Is there
any good reason to move away from Python2?

Kind regards,        Barry.

-- Barry Drake is a member of the the Ubuntu Advertising team.
http://ubuntu.com/

```