Pi Day Contest Solution
Just for fun I programmed up a Rogue solver for Pizza Hut's Pi Day contest "Option A":
http://blog.pizzahut.com/flavor-news/national-pi-day-math-contest-problems-are-here-2/
# Pizza.rogue
local digits = (0..9)->Int32[]
local permutation = Int32[]
forEach (p in 0..digits.permutation_count-1)
digits.permutation( p, permutation )
contingent
necessary (permutation[0] != 0)
forEach (n in 1..10)
necessary (to_int64(permutation,n) % n == 0)
endForEach
satisfied
println to_int64(permutation)
endContingent
endForEach
routine to_int64( digits:Int32[], n=null:Int32? )->Int64
local i2 = select{ n.exists:n.value || digits.count } - 1
local number : Real64
forEach (i in 0..i2)
number = number * 10 + digits[i]
endForEach
return number
endRoutine
The output:
3816547290