12/15/2023 0 Comments Brain teaser 1 is 3 2 is 3 3 is 5This leads new code performing explicit counting of hits, because making the above explicit through membership checks is tedious. ![]() "569": one digit is right but in the wrong place (none of the digits appears in any solution) It is correctly stated thus: "291": one digit is right and in its place The actual problem statement is sharper than suspected at first. ![]() Ready! ?- setof(L,solution(L),Solutions). % "463": two digits are right but both are in the wrong place % "245": one digit is right but in the wrong place % "291": one digit is right and in its place % This anchors the values of A,B,C to the digitsīase() :- member(A,), Here is one with the "generate, then test" approach. "569": one digit is right but in the wrong place */ "463": two digits are right but both are in the wrong place "245": one digit is right but in the wrong place * "291": one digit is right and in its place Select(A,XS,RA), select(B,RA,RB), member(C,RB), ![]() Then simply transcribe the clues, no creativity involved: puzzle( ):. ( C=Z -> NPlaces is 1+V2 NPlaces is V2 ). Straightforward coding of the check predicate: check( Solution, Guess, NValues, NPlaces ) :-įindall( t, (member(E, Guess), member(E, Solution)), Values ),
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |