diff --git a/billiard_words.hs b/billiard_words.hs index 56e4654..4d959d3 100644 --- a/billiard_words.hs +++ b/billiard_words.hs @@ -2,15 +2,17 @@ import Data.List import Data.Ord import Text.Printf -main = listWordsUpToLength 22 +main = listWordsUpToLength 200 listWordsUpToLength :: Int -> IO () listWordsUpToLength n = do - putStrLn $ unlines [printf "%d/%d\t%.7f\t%d\t%s" p q (sqrt 3 / (1 + 2*fromIntegral q / fromIntegral p) :: Double) (length w) w | ((p,q),w) <- wordlist (n`div`2) (n`div`2), length w <= n] --- putStrLn $ unlines [printf "%d/%d\t%.5f\t%.5f\t%d\t%s" p q (fromIntegral p / fromIntegral q :: Double) (sqrt 3 / (1 + 2*fromIntegral q / fromIntegral p) :: Double) (length w) w | ((p,q),w) <- wordlist (n`div`2) (n`div`2), length w <= n] + putStrLn $ unlines [printf "%d/%d\t%d/%d\t%.7f\t%d\t%s" p q (x `div` gcd x y) (y `div` gcd x y) (sqrt 3 / (1 + 2*fromIntegral q / fromIntegral p) :: Double) (length w) w | ((p,q),w) <- wordlist (n`div`2) (n`div`2), length w <= n, let x = 2*q + p, let y = 2*p + q] + + + -- putStrLn $ unlines [printf "%d/%d\t%.5f\t%.5f\t%d\t%s" p q (fromIntegral p / fromIntegral q :: Double) (sqrt 3 / (1 + 2*fromIntegral q / fromIntegral p) :: Double) (length w) w | ((p,q),w) <- wordlist (n`div`2) (n`div`2), length w <= n] wordlist :: Int -> Int -> [((Int,Int),String)] -wordlist pmax qmax = nub $ sortBy (comparing sl) [((p `div` gcd p q, q `div` gcd p q), slopeWord "bca" p q) | p <- [0..50], q <- [0..50], p /= 0 || q /= 0] +wordlist pmax qmax = nub $ sortBy (comparing sl) [((p `div` gcd p q, q `div` gcd p q), slopeWord "bca" p q) | p <- [0..200], q <- [0..200], p /= 0 || q /= 0] where sl ((p,q),_) = fromIntegral p / fromIntegral q