Solved Day 4
parent
a604443d87
commit
3f01d5d654
|
@ -0,0 +1 @@
|
||||||
|
yzbqklnj
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/env ruby
|
||||||
|
require 'digest'
|
||||||
|
|
||||||
|
key = File.read('./input').strip
|
||||||
|
# Part 1
|
||||||
|
answer = false
|
||||||
|
num = 0
|
||||||
|
until answer
|
||||||
|
num += 1
|
||||||
|
answer = true if Digest::MD5.hexdigest(key + num.to_s)[0..4] == '00000'
|
||||||
|
end
|
||||||
|
|
||||||
|
puts 'Part 1 Solution is: ' + num.to_s
|
||||||
|
puts "md5sum is: #{Digest::MD5.hexdigest(key + num.to_s)}"
|
||||||
|
|
||||||
|
# Part 2
|
||||||
|
answer = false
|
||||||
|
num = 0
|
||||||
|
until answer
|
||||||
|
num += 1
|
||||||
|
answer = true if Digest::MD5.hexdigest(key + num.to_s)[0..5] == '000000'
|
||||||
|
end
|
||||||
|
|
||||||
|
puts 'Part 2 Solution is: ' + num.to_s
|
||||||
|
puts "md5sum is: #{Digest::MD5.hexdigest(key + num.to_s)}"
|
Loading…
Reference in New Issue