Smap
SmapIE
New program
Curry
Prolog
Haskell
Open program by ID
Browser
Dashboard
Programs on Smap
Most recent
Most favorited
Tags on Smap
All tags
Sign in
Help
Source code
Language:
Curry
-- The game of 24 -- Mon Apr 15 7:57:46 CST 2019 -- https://en.wikipedia.org/wiki/24_Game -- https://www.coolmathgames.com/0-make-24 -- https://www.4nums.com/ data Op = Add | Mul | Sub | Div data Exp = Num Int | Bin Op Exp Exp dispatch Add = (+) dispatch Mul = (*) dispatch Sub = (-) dispatch Div = \x y -> if y == 0 || x `mod` y /= 0 then failed else x `div` y permute [] = [] permute (y++[x]++z) = x : permute (y++z) test (Num y) [y] = y test (Bin op x y) (u@(_:_)++v@(_:_)) = (dispatch op) (test x u) (test y v) main | test X (permute problem) == 24 = X where X free problem = [2,3,8,6]
Execution result
No execution result yet.
PAKCS 3.7 /all-values
PAKCS 3.7 /one-value
KiCS2 3.1 /all-values
KiCS2 3.1 /one-value
Reset
Clear
Options
New Curry program
Reload program 69
View in Browser
Program ID:
69
Title:
The game of 24
Language:
Curry
Author:
antoy
Version:
1
Program information