Skip to content

Instantly share code, notes, and snippets.

@tuzz
Last active June 14, 2017 16:24
Show Gist options
  • Save tuzz/e47b91fc3e2f99067b6108381f1ddf99 to your computer and use it in GitHub Desktop.
Save tuzz/e47b91fc3e2f99067b6108381f1ddf99 to your computer and use it in GitHub Desktop.
# 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