Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mastermind game
#4
If you replace placement() with this, it seems to be working
def placement():
    paires = list(zip(t, tableauEntree))
    n = len(paires)
    paires = [(u, v) for u, v in paires if u != v]
    compteurBienPlaces = n - len(paires)
    if paires:
        a, b = zip(*paires)
        compteurMalPlaces = sum(1 for x in b if x in a)
    else:
        compteurMalPlaces = 0
    tableauPlacement[:] = [compteurBienPlaces, compteurMalPlaces]
In your code at line 28, you need tableauPlacement[:] = [0, 0] because
if you write tableauPlacement = [0, 0], this variable becomes a local variable and the global tableauPlacement is not changed, but there are other errors.

At line 70, you need 'mal' instead of 'bien'
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,995 Jul-06-2020, 12:47 PM
Last Post: deanhystad
  Mastermind Davidlit95 2 3,465 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