I learned about this problem from Aser's post See page of tasks still without Maple implementation.

The procedure ** game24** solves the problem. In the procedure Acer's procedure **MyHandler** is used, which prevents the program to stop in case of 0 in the denominator.

**game24:=proc(a,b,c,d)**

**local MyHandler,It, K, M, i, P;**

**uses StringTools, combinat;**

** MyHandler := proc(operator,operands,default_value)**

** NumericStatus( division_by_zero = false );**

** return infinity;**

** end proc;**

** NumericEventHandler(division_by_zero=MyHandler);**** **

**It:=proc(L1,L2)**

**local i, j, L;**

**L:=[];**

**for i in L1 do**

**for j in L2 do**

**L:=[op(L), op([Substitute(Substitute("( i + j )","i",convert(i,string)),"j",convert(j,string)),Substitute(Substitute("( i - j )","i",convert(i,string)),"j",convert(j,string)),Substitute(Substitute("( i * j )","i",convert(i,string)),"j",convert(j,string)),Substitute(Substitute("( i / j )","i",convert(i,string)),"j",convert(j,string))])];**

**od; od;**

**L;**

**end proc;**** **

**P:=permute([a,b,c,d]);**** **

**K:=[];**

**for i in P do **

**K:=[op(K),op(It(It(It([i[1]],[i[2]]),[i[3]]),[i[4]])), op(It(It([i[1]],It([i[2]],[i[3]])),[i[4]])), op(It([i[1]],It(It([i[2]],[i[3]]),[i[4]]))), op(It([i[1]],It([i[2]],It([i[3]],[i[4]])))), op(It(It([i[1]],[i[2]]),It([i[3]],[i[4]])))];**

**od;**

**M:=[];**

**for i in K do**

**if parse(i)=24 then M:=[op(M), i] fi;**

**od;**

**if nops(M)=0 then return `No solutions` else**

**for i in M do**

**print(SubString(i,2..length(i)-1));**

**od; fi;**** **

**end proc:**

Two examples:

**game24(2,3,8,9);**

**game24(2,3,3,4);**

No solutions

24.mws