Count the coins: Difference between revisions
J: be a little clearer, in describing what we are doing
m (→{{header|REXX}}: removed a blank line, added verbage to the '''output''' section. -- ~~~~) |
(J: be a little clearer, in describing what we are doing) |
||
Line 794:
=={{header|J}}==
In this draft intermediate results are a two column array. The first column is tallies
<lang j>merge=: ({:"1 (+/@:({."1),{:@{:)/. ])@;
count=: {.@] <@,. {:@] - [ * [ i.@>:@<.@%~ {:@]
init=: (1 ,. ,.)^:(0=#@$)
nsplits=: 0 { [: +/
This implementation special cases the handling of pennies and assumes that the lowest coin value in the argument is 1. If I needed additional performance, I would next special case the handling of nickles/penny combinations...
|