Last active
June 14, 2017 16:24
-
-
Save tuzz/e47b91fc3e2f99067b6108381f1ddf99 to your computer and use it in GitHub Desktop.
A Sentient program in response to https://twitter.com/jamestanton/status/874962919963885568
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A Sentient program in response to this tweet: | |
# https://twitter.com/jamestanton/status/874962919963885568 | |
# | |
# Run it with: | |
# for i in {1..100}; do ruby search.rb $i > search.snt && sentient -c -o -r -n 0 -m lingeling search.snt; done | |
n = Integer(ARGV.first) | |
program = <<-SNT | |
array#{n}<int5> numbers; | |
invariant numbers.all?(function (n) { | |
return n.between?(0, 9); | |
}); | |
s = numbers.sum; | |
t = #{n.times.map { |i| "numbers[#{i}] * #{10 ** (n - i - 1)}" }.join(" + ") }; | |
invariant #{(["s"] * n).join(" * ")} == t; | |
expose t, numbers; | |
SNT | |
puts program |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment