1 ! Copyright (c) 2007 Samuel Tardieu.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: kernel math math.functions ranges sequences
7 ! https://projecteuler.net/problem=173
12 ! We shall define a square lamina to be a square outline with a
13 ! square "hole" so that the shape possesses vertical and
14 ! horizontal symmetry. For example, using exactly thirty-two
15 ! square tiles we can form two different square laminae: [see
18 ! With one-hundred tiles, and not necessarily using all of the
19 ! tiles at one time, it is possible to form forty-one different
22 ! Using up to one million tiles how many different square
23 ! laminae can be formed?
31 : laminae ( upper -- n )
32 4 / dup sqrt [1..b] 0 rot [ over /i - - ] curry reduce ;
36 : euler173 ( -- answer )
39 ! [ euler173 ] 100 ave-time
40 ! 0 ms ave run time - 0.35 SD (100 trials)