Created
July 10, 2014 22:15
-
-
Save nathraQ/7022d3a38ba0e1f01207 to your computer and use it in GitHub Desktop.
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
# 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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is to calculate possible positions of http://www.twitch.tv/jl2579 hint for another pier ;)