diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-01-04 21:18:09 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-04 21:18:09 +0000 |
| commit | d1581f755d50e5b3a5ccf74a25280f39caa809fc (patch) | |
| tree | 14d50cbd3a19dddf06cb89f16ea57155024e1da6 /challenge-146/abigail/ruby | |
| parent | d8abd054e8e70147188d2b57c922ba092e2aecff (diff) | |
| parent | 41c3d16c97874e85d25f28d37e59df3e2d9a9d66 (diff) | |
| download | perlweeklychallenge-club-d1581f755d50e5b3a5ccf74a25280f39caa809fc.tar.gz perlweeklychallenge-club-d1581f755d50e5b3a5ccf74a25280f39caa809fc.tar.bz2 perlweeklychallenge-club-d1581f755d50e5b3a5ccf74a25280f39caa809fc.zip | |
Merge pull request #5463 from Abigail/abigail/week-146
Week 146
Diffstat (limited to 'challenge-146/abigail/ruby')
| -rw-r--r-- | challenge-146/abigail/ruby/ch-1.rb | 11 | ||||
| -rw-r--r-- | challenge-146/abigail/ruby/ch-2.rb | 26 |
2 files changed, 37 insertions, 0 deletions
diff --git a/challenge-146/abigail/ruby/ch-1.rb b/challenge-146/abigail/ruby/ch-1.rb new file mode 100644 index 0000000000..5c5bbf5bb5 --- /dev/null +++ b/challenge-146/abigail/ruby/ch-1.rb @@ -0,0 +1,11 @@ +#!/usr/bin/ruby + +# +# See ../README.md +# + +# +# Run as: ruby ch-1.rb +# + +puts ("104743");
\ No newline at end of file diff --git a/challenge-146/abigail/ruby/ch-2.rb b/challenge-146/abigail/ruby/ch-2.rb new file mode 100644 index 0000000000..e664fb75e2 --- /dev/null +++ b/challenge-146/abigail/ruby/ch-2.rb @@ -0,0 +1,26 @@ +#!/usr/bin/ruby + +# +# See ../README.md +# + +# +# Run as: ruby ch-2.rb < input-file +# + +ARGF . each_line do + | line | + a, b = line . strip() . split("/") . map {|x| x . to_i} + for i in 1 .. 2 do + if a < b then + b -= a + else + a -= b + end + if a == 0 || b == 0 then + next + end + print a, "/", b, " " + end + puts ("") +end |
