Sum and product puzzle: Difference between revisions
Content added Content deleted
(→{{header|jq}}: works with jq) |
Walterpachl (talk | contribs) m (→{{header|REXX}}: added wordsort as internal procedure) |
||
Line 2,204: | Line 2,204: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
{{improve|REXX version 1| <br><br>Executing this REXX program causes two identical errors message: <br><br> <big> |
|||
'WORDSORT' is not recognized as an internal or external command, |
|||
operable program or batch file. </big> <br><br>}} |
|||
===version 1=== |
===version 1=== |
||
Line 2,416: | Line 2,410: | ||
s=translate(s,c,c||xrange('00'x,'ff'x)) |
s=translate(s,c,c||xrange('00'x,'ff'x)) |
||
s=space(s,0) |
s=space(s,0) |
||
Return length(s) |
Return length(s) |
||
wordsort: Procedure |
|||
/********************************************************************** |
|||
* Sort the list of words supplied as argument. Return the sorted list |
|||
**********************************************************************/ |
|||
Parse Arg wl |
|||
wa.='' |
|||
wa.0=0 |
|||
Do While wl<>'' |
|||
Parse Var wl w wl |
|||
Do i=1 To wa.0 |
|||
If wa.i>w Then Leave |
|||
End |
|||
If i<=wa.0 Then Do |
|||
Do j=wa.0 To i By -1 |
|||
ii=j+1 |
|||
wa.ii=wa.j |
|||
End |
|||
End |
|||
wa.i=w |
|||
wa.0=wa.0+1 |
|||
End |
|||
swl='' |
|||
Do i=1 To wa.0 |
|||
swl=swl wa.i |
|||
End |
|||
/* Say swl */ |
|||
Return strip(swl)</lang> |
|||
{{out}} |
{{out}} |
||
<pre>2352 possible pairs |
<pre>2352 possible pairs |