(euler151) ( x -- y )


Vocabulary
project-euler.151

Inputs
xan object


Outputs
yan object


Definition


: (euler151) ( x -- y )
table get [
{
{ { 0 0 0 1 } [ 0 ] }
{ { 0 0 1 0 } [ { 0 0 0 1 } (euler151) 1 + ] }
{ { 0 1 0 0 } [ { 0 0 1 1 } (euler151) 1 + ] }
{ { 1 0 0 0 } [ { 0 1 1 1 } (euler151) 1 + ] }
[
[
dup length <iota> [ pick-sheet ] with
map-sum
] [ sum ] bi /
]
} case
] cache ;