Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mastermind game
#5
Thank you for your answer !
For the "bien " and "mal", I corrected the error right after I posted here, I had tried a few more things without results

for TableauPlacement, it is because I "declared" the variable accidentaly ?
i would have never guessed.

So in the code, you are creating a sort of dictionnary, then line 4 it's an abridged version of a "for " condition, but I don't get why there is (u, v) before this,
This line also seems to exclude every "group" of numbers where numbers aren't identical,
then you're counting every pair where numbers are the same,


then I have trouble with that part:
    if paires:
        a, b = zip(*paires)
        compteurMalPlaces = sum(1 for x in b if x in a)
    else:
        compteurMalPlaces = 0
what I understand is:
if the "paires" list has some varialbes in it then new a and b lists are equal to every number in "paires"
then for each variable in b, if the variable exists in a, then you add 1 to a counter ?


that means first, you separate the numbers in two groups; those who meet the condition I set and the others,
and then you check with the others if they are just misplaced


wow that's clever, I never thought of separating my array in groups !
Reply


Messages In This Thread
Mastermind game - by Staren - Feb-03-2018, 11:39 AM
RE: Mastermind game - by Gribouillis - Feb-03-2018, 11:59 AM
RE: Mastermind game - by Staren - Feb-03-2018, 12:25 PM
RE: Mastermind game - by Gribouillis - Feb-03-2018, 01:22 PM
RE: Mastermind game - by Staren - Feb-03-2018, 02:00 PM
RE: Mastermind game - by Gribouillis - Feb-03-2018, 02:49 PM
RE: Mastermind game - by Staren - Feb-03-2018, 03:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help (mastermind game) sseansssean 2 2,956 Jul-06-2020, 12:47 PM
Last Post: deanhystad
  Mastermind Davidlit95 2 3,437 Oct-16-2017, 10:17 PM
Last Post: Davidlit95

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020