A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
22
Task/24-game-Solve/Euler-Math-Toolbox/24-game-solve-1.euler
Normal file
22
Task/24-game-Solve/Euler-Math-Toolbox/24-game-solve-1.euler
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
>function try24 (v) ...
|
||||
$n=cols(v);
|
||||
$if n==1 and v[1]~=24 then
|
||||
$ "Solved the problem",
|
||||
$ return 1;
|
||||
$endif
|
||||
$loop 1 to n
|
||||
$ w=tail(v,2);
|
||||
$ loop 1 to n-1
|
||||
$ h=w; a=v[1]; b=w[1];
|
||||
$ w[1]=a+b; if try24(w); ""+a+"+"+b+"="+(a+b), return 1; endif;
|
||||
$ w[1]=a-b; if try24(w); ""+a+"-"+b+"="+(a-b), return 1; endif;
|
||||
$ w[1]=a*b; if try24(w); ""+a+"*"+b+"="+(a*b), return 1; endif;
|
||||
$ if not b~=0 then
|
||||
$ w[1]=a/b; if try24(w); ""+a+"/"+b+"="+(a/b), return 1; endif;
|
||||
$ endif;
|
||||
$ w=rotright(w);
|
||||
$ end;
|
||||
$ v=rotright(v);
|
||||
$end;
|
||||
$return 0;
|
||||
$endfunction
|
||||
20
Task/24-game-Solve/Euler-Math-Toolbox/24-game-solve-2.euler
Normal file
20
Task/24-game-Solve/Euler-Math-Toolbox/24-game-solve-2.euler
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
>try24([1,2,3,4]);
|
||||
Solved the problem
|
||||
6*4=24
|
||||
3+3=6
|
||||
1+2=3
|
||||
>try24([8,7,7,1]);
|
||||
Solved the problem
|
||||
22+2=24
|
||||
14+8=22
|
||||
7+7=14
|
||||
>try24([8,4,7,1]);
|
||||
Solved the problem
|
||||
6*4=24
|
||||
7-1=6
|
||||
8-4=4
|
||||
>try24([3,4,5,6]);
|
||||
Solved the problem
|
||||
4*6=24
|
||||
-1+5=4
|
||||
3-4=-1
|
||||
Loading…
Add table
Add a link
Reference in a new issue