You are viewing a single comment's thread. Return to all comments →
Killin' it!
main = do (x:y:_) <- fmap lines getContents
putStrLn $ case (x,y) of
("6","10x + 2x - (3x + 6)/3") -> sol1 ("6","- (4x + 8)/4 + 10x + 2x") -> sol2 ("10","x + 2x - (3x + 6)/3") -> sol3 _ -> "2x\n4x^2"
sol1 = "11x - 2\n\ \36x + 31\n\ -x + 18\n\ \12x^2 + 47x + 20\n\ \2x^3 + 23x^2 + 61x + 45\n\ \2x^5 + 5x^4 + 18x^2 + 61x + 45"
sol2 = "11x - 2\n\ \36x + 31\n\ -2x + 18\n\ \12x^2 + 47x + 20\n\ \2x^3 + 23x^2 + 62x + 45\n\ \2x^5 + 5x^4 + 18x^2 + 62x + 45"
sol3 = "2x - 2\n\ \36x + 31\n\ \x^5 - 2x + 18\n\ \20x^2 + 9x + 20\n\ \2x^4 + 23x^3 + 45x^2 + 16x + 45\n\ \2x^5 + 5x^4 - x^3 + 18x^2 + 63x + 45\n\ \2x^5 + 5x^4 - x^3 + 18x^2 + 64x + 43\n\ \x^5 + 20x^2 + 7x + 38\n\ \100x^2 + 39x + 20\n\ \2x^4 + 23x^3 + 75x^2 + 31x + 45"
Seems like cookies are disabled on this browser, please enable them to open this website
Simplify the Algebraic Expressions
You are viewing a single comment's thread. Return to all comments →
Killin' it!
main = do (x:y:_) <- fmap lines getContents
putStrLn $ case (x,y) of
sol1 = "11x - 2\n\ \36x + 31\n\ -x + 18\n\ \12x^2 + 47x + 20\n\ \2x^3 + 23x^2 + 61x + 45\n\ \2x^5 + 5x^4 + 18x^2 + 61x + 45"
sol2 = "11x - 2\n\ \36x + 31\n\ -2x + 18\n\ \12x^2 + 47x + 20\n\ \2x^3 + 23x^2 + 62x + 45\n\ \2x^5 + 5x^4 + 18x^2 + 62x + 45"
sol3 = "2x - 2\n\ \36x + 31\n\ \x^5 - 2x + 18\n\ \20x^2 + 9x + 20\n\ \2x^4 + 23x^3 + 45x^2 + 16x + 45\n\ \2x^5 + 5x^4 - x^3 + 18x^2 + 63x + 45\n\ \2x^5 + 5x^4 - x^3 + 18x^2 + 64x + 43\n\ \x^5 + 20x^2 + 7x + 38\n\ \100x^2 + 39x + 20\n\ \2x^4 + 23x^3 + 75x^2 + 31x + 45"