Skip to content

Instantly share code, notes, and snippets.

@nathraQ
Created July 10, 2014 22:15
Show Gist options
  • Save nathraQ/7022d3a38ba0e1f01207 to your computer and use it in GitHub Desktop.
Save nathraQ/7022d3a38ba0e1f01207 to your computer and use it in GitHub Desktop.
# ueeueeuu
# crossum 34
def cross_sum(n)
return n.to_s.chars.map(&:to_i).reduce(:+)
end
def check_pattern(n)
check = true
d1, d2, d3, d4, d5, d6, d7, d8 = n.to_s.split('').map { |digit| digit.to_i }
if(!d1.odd?) then
check = false
end
if(d2.odd?) then
check = false
end
if(d3.odd?) then
check = false
end
if(!d4.odd?) then
check = false
end
if(d5.odd?) then
check = false
end
if(d6.odd?) then
check = false
end
if(!d7.odd?) then
check = false
end
if(!d8.odd?) then
check = false
end
return check
end
puts "start"
start = 16599999
ende = 19000000
i = start
until i > ende do
if(cross_sum(i) == 34) then
if (check_pattern(i)) then
puts i
end
end
i=i+1
end
puts "end"
@nathraQ
Copy link
Author

nathraQ commented Jul 10, 2014

this is to calculate possible positions of http://www.twitch.tv/jl2579 hint for another pier ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment