From 62818508c81af33a19e400cce9145e681920eb82 Mon Sep 17 00:00:00 2001 From: Abigail Date: Sat, 24 Jul 2021 23:11:35 +0200 Subject: Solutions for week 122, part 2, in 8 different languages. --- challenge-122/abigail/ruby/ch-2.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 challenge-122/abigail/ruby/ch-2.rb (limited to 'challenge-122/abigail/ruby') diff --git a/challenge-122/abigail/ruby/ch-2.rb b/challenge-122/abigail/ruby/ch-2.rb new file mode 100644 index 0000000000..8627a9ae8a --- /dev/null +++ b/challenge-122/abigail/ruby/ch-2.rb @@ -0,0 +1,27 @@ +#!/usr/bin/ruby + +# +# See ../README.md +# + +# +# Run as: ruby ch-2.rb < input-file +# + +n = gets . to_i + +scores = [[], [], [""]] + +for i in 1 .. n do + new = [] + for j in 1 .. 3 do + for k in scores [-j] do + new . push (j . to_s + " " + k) + end + end + scores . push (new) +end + +for score in scores [-1] do + puts (score) +end -- cgit