module Exercise_6 where import Data.Ratio import Data.List {-WETT-} traceFractran rs n = n : concat [rs `traceFractran` numerator (r * realToFrac n) | r <- take 1 $ dropWhile (\r -> 1 /= denominator (r * realToFrac n)) rs] {-TTEW-} {-MCCOMMENT I know that in some instances of the input the code above might return duplicates, but since my solution that strips the result of the duplicates would not rank that high in the competition, thus I decided to include it here in the MCCOMMENT. If the problem with the duplicates is critical, please consider the following function as my solution, otherwise feel free to consider the 30 tokens function as my solution. traceFractran rs n = n : concat [rs `traceFractran` numerator (r * realToFrac n) | r <- take 1 $ dropWhile (\r -> 1 /= denominator (r * realToFrac n)) rs] This function is also correct, slightly better token-wise, but does not terminate on the server within 1.1s: traceFractran rs n = n : nub (concat [rs `traceFractran` numerator new_n | r <- rs, let new_n = r * realToFrac n, denominator new_n == 1]) I have some better looking solutions but token-wise they're not as good. Enjoy! traceFractran rs n = n : concat [rs `traceFractran` a | r <- rs, (a, 0) <- pure $ properFraction $ r * realToFrac n] I like this one very much, I wasn't aware that you could filter by the definition of a tuple -} primeprog = [17%91 ,78%85 ,19%51 ,23%38 ,29%33 ,77%29 ,95%23 ,77%19 ,1%17 , 11%13 ,13%11 ,15%14 ,15%2 ,55%1] isPowerOfTwo 0 = False isPowerOfTwo x = (ceiling (logBase 2.0 (fromIntegral x))) == (floor (logBase 2.0 (fromIntegral x)))