From 86cd48026409ae434f06b4332f8e2a89a00dddc6 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Tue, 30 Nov 2021 21:20:37 -0800 Subject: [PATCH] [2021][ruby][01.x] --- 2021/ruby/.ruby-version | 1 + 2021/ruby/day_01.rb | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 2021/ruby/.ruby-version create mode 100644 2021/ruby/day_01.rb diff --git a/2021/ruby/.ruby-version b/2021/ruby/.ruby-version new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/2021/ruby/.ruby-version @@ -0,0 +1 @@ +3 diff --git a/2021/ruby/day_01.rb b/2021/ruby/day_01.rb new file mode 100644 index 0000000..0448081 --- /dev/null +++ b/2021/ruby/day_01.rb @@ -0,0 +1,2 @@ +p ARGF.read.split("\n").map(&:to_i).each_cons(2).count {|x,y| x < y } +p ARGF.read.split("\n").map(&:to_i).each_cons(3).map(&:sum).each_cons(2).count {|x,y| x < y }