Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f3ac8e1

Browse files
committed
day03
1 parent 930d9a7 commit f3ac8e1

File tree

5 files changed

+261
-2
lines changed

5 files changed

+261
-2
lines changed

‎2021/day03/main.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env ruby
22
arr = File.readlines('data.txt')
33

4-
row = Array.new((arr.first.length - 1), 0)
4+
row = Array.new((arr.first.length - 1), 0)
55

66
arr.each do |line|
77
puts [row, line.strip.each_char.map(&:to_i)].inspect
88
row = [row, line.strip.each_char.map(&:to_i)].transpose.map(&:sum)
99
end
10-
puts row.map { |v| v > arr.count / 2.0 ? 1 : 0 }.join.to_i(2) * row.map { |v| v > arr.count / 2.0 ? 0 : 1 }.join.to_i(2)
10+
puts row.map { |v| v > arr.count / 2.0 ? 1 : 0 }.join.to_i(2) * row.map { |v| v > arr.count / 2.0 ? 0 : 1 }.join.to_i(2)

‎2023/day03/.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.1.0

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /