diff options
| author | Abigail <abigail@abigail.be> | 2021-07-24 23:11:35 +0200 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-07-24 23:11:35 +0200 |
| commit | 62818508c81af33a19e400cce9145e681920eb82 (patch) | |
| tree | f11e3508db11b31712703cf4d5d02640cadc4a3d /challenge-122/abigail/ruby | |
| parent | 52d0e0851f79fead3bdad2caed25e012a124a8eb (diff) | |
| download | perlweeklychallenge-club-62818508c81af33a19e400cce9145e681920eb82.tar.gz perlweeklychallenge-club-62818508c81af33a19e400cce9145e681920eb82.tar.bz2 perlweeklychallenge-club-62818508c81af33a19e400cce9145e681920eb82.zip | |
Solutions for week 122, part 2, in 8 different languages.
Diffstat (limited to 'challenge-122/abigail/ruby')
| -rw-r--r-- | challenge-122/abigail/ruby/ch-2.rb | 27 |
1 files changed, 27 insertions, 0 deletions
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 |
