• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jun 27th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. %- Read person saw number at position.
2. saw(alice, 1, 0).
3. saw(alice, 0, 1).
4. saw(alice, 0, 2).
5. saw(alice, 6, 3).
6.
7. saw(bob, 1, 0).
8. saw(bob, 0, 1).
9. saw(bob, 1, 2).
10. saw(bob, 6, 3).
11.
12. saw(dan, 1, 0).
13. saw(dan, 0, 1).
14. saw(dan, 2, 2).
15. saw(dan, 9, 3).
16.
17. %- Consider the case when two people see one number and one person saw a anoth-
18. % er number. This doesnt actually mean the person "definitely" misread the nu-
19. % mber, but if the problem can be solved it measns they definitely did.
21.   saw(Person, Digit, Position),
22.   saw(Q, D, Position), Q == Person, D == Digit,
23.   saw(R, D, Position), R == Q, R == Person.
24.
25. %- Read a person misread the digit at poisition at position.
27.   saw(Person, Digit, Position),
28.   not((definitely_misread(Person, D, P), D == Digit, P == Position)),
29.   (saw(Q, D1, Position), Q == Person, D1 == Digit),
30.   (saw(R, D2, Position), R == Q, R == Person, D2 == Digit).
31.
32. %- Resolve if the question is actually the correct digit at that position.
33. correct(Digit, Position) :-
34.   (saw(alice, Digit, Position), not(misread(alice, Digit, Position)));
35.   (saw(bob, Digit, Position), not(misread(bob, Digit, Position)));
36.   (saw(dan, Digit, Position), not(misread(dan, Digit, Position))).
37.
38. ?- correct(D, P).
39. D = 1,
40. P = 0 ;
41. D = 0,
42. P = 1 ;
43. D = 6,
44. P = 3 ;
45. D = 1,
46. P = 0 ;
47. D = 0,
48. P = 1 ;
49. D = 6,
50. P = 3 ;
51. D = 1,
52. P = 0 ;
53. D = 0,
54. P = 1 ;
55. D = P, P = 2 ;
56. false.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top