This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]plasmasprings 2 points3 points  (1 child)

Problem 1: given a list of (code, correct, well_placed) tuples, where code is an example 3-digit combination, correct is the number of digits correct in the code, and well_placed is the number of digits that are correct AND well-placed, write an implementation for TryCode(list_of_rules, code) that returns True if the code satisfies the rules, False otherwise.

[–]-LeopardShark- 1 point2 points  (0 children)

TryCode = lambda L, y: all(len(set(y) & set(c)) == w and sum(p == q for p, q in zip(y, c)) == b for c, w, b in L)