m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/05/a.rb
diff options
context:
space:
mode:
Diffstat (limited to '05/a.rb')
-rw-r--r--05/a.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/05/a.rb b/05/a.rb
new file mode 100644
index 0000000..877abb9
--- /dev/null
+++ b/05/a.rb
@@ -0,0 +1,11 @@
+max = 0
+File.readlines('input.txt').map do |line|
+ line.tr('FBLR', '0101')
+end.each do |line|
+ row = line.slice(0, 7).to_i 2
+ seat = line.slice(7, 3).to_i 2
+ id = row * 8 + seat
+ max = [id, max].max
+end
+
+puts max