add charly's slope

This commit is contained in:
Florian Stecker 2021-10-23 11:41:36 -05:00
parent bcf1510c64
commit 53ae9c760b
1 changed files with 6 additions and 4 deletions

View File

@ -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