20 lines
484 B
Ruby
20 lines
484 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
MIN_8S = 0
|
||
|
|
||
|
def max_8s(str)
|
||
|
(str.scan(/8+/).max || '').length
|
||
|
end
|
||
|
|
||
|
$stdin.read.split('poem: ')
|
||
|
.map(&:strip)
|
||
|
.reject(&:empty?)
|
||
|
.to_set
|
||
|
.map { [_1, `printf "#{_1}" | openssl sha256`.strip] }
|
||
|
.filter { |(_, hash)| max_8s(hash) >= MIN_8S }
|
||
|
.sort_by { |(_, hash)| max_8s hash }
|
||
|
.each do |(amulet, hash)|
|
||
|
puts amulet
|
||
|
puts "#{max_8s hash} #{hash}#{amulet.length > 64 ? ' too long!' : ''}"
|
||
|
end
|