mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-12-16 03:05:44 +03:00
cd9ffed00b
and to squash other warnings related to the upcomming precedence change.
22 lines
761 B
Plaintext
22 lines
761 B
Plaintext
// Copyright (c) 2015-2016 Galois, Inc.
|
|
|
|
// The puzzle goes like this:
|
|
// You've got 30 coins that add up to $1.09 - what are they?
|
|
coinPuzzle : [10] -> [10] -> [10] -> [10] -> Bit
|
|
coinPuzzle a b c d = (coinCount a b c d 30) /\ (coinSum a b c d 109)
|
|
|
|
coinSum : [10] -> [10] -> [10] -> [10] -> [10] -> Bit
|
|
coinSum a b c d s = (a + 5 * b + 10 * c + 25 * d) == s
|
|
|
|
coinCount : [10] -> [10] -> [10] -> [10] -> [10] -> Bit
|
|
coinCount a b c d s = (((a + b + c + d) == s) /\ // the coin count adds up
|
|
(a <= s /\ b <= s /\ c <= s /\ d <= s)) // and we don't wrap
|
|
|
|
// run it like this:
|
|
// :set satNum = all
|
|
// :sat coinPuzzle
|
|
// coinPuzzle 19 7 3 1 = True
|
|
// coinPuzzle 24 1 3 2 = True
|
|
// coinPuzzle 14 13 3 0 = True
|
|
// coinPuzzle 19 4 7 0 = True
|