aboutsummaryrefslogtreecommitdiff
path: root/day04/part1
diff options
context:
space:
mode:
Diffstat (limited to 'day04/part1')
-rwxr-xr-xday04/part117
1 files changed, 17 insertions, 0 deletions
diff --git a/day04/part1 b/day04/part1
new file mode 100755
index 0000000..2d8bce6
--- /dev/null
+++ b/day04/part1
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+def valid(line)
+ arr = line.split
+ (0...arr.length).each do |i|
+ (i+1...arr.length).each do |j|
+ return false if arr[i] == arr[j]
+ end
+ end
+ return true
+end
+
+input = $stdin.readlines.map(&:chomp)
+
+puts input.select { |line|
+ valid(line)
+}.length