From 2c1f146376d708959defa553cb8e3b9a0a6ae60e Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Thu, 17 Dec 2015 14:44:04 +0100 Subject: day17 --- day17.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 day17.rb (limited to 'day17.rb') diff --git a/day17.rb b/day17.rb new file mode 100644 index 0000000..465b485 --- /dev/null +++ b/day17.rb @@ -0,0 +1,29 @@ +d = File.readlines("day17").map { |x| x.to_i } +t = 150 + +d.sort! + +$c = 0 +$cs = Hash.new(0) + +def r(u, s, a, t) + if s == t + p u + $c += 1 + $cs[u.size] += 1 + elsif s > t + # too high + else + a.each_index { |i| + r(u + [a[i]], s+a[i], a[i+1..-1], t) + } + end +end + +p d + +r([], 0, d, t) +p $c +p $cs + +# 313265 too high -- cgit 1.4.1