Created
June 18, 2014 17:11
-
-
Save hamiltondanielb/5aad59711ebc6dd1c39f to your computer and use it in GitHub Desktop.
Self Describing numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filename = ARGV[0] | |
file = File.new(filename, "r") | |
while (line = file.gets) | |
array = line.scan(/./) | |
new_array = Array.new | |
array.length.times do |var| | |
new_array << array.count(var.to_s).to_s | |
end | |
if new_array.eql? array | |
puts "1" | |
else | |
puts "0" | |
end | |
end | |
file.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment