Subset sum problem: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Only show results for up to 27, there aren't any for more words, and this cuts down the execution time significantly.) |
|||
Line 1,415: | Line 1,415: | ||
my %name = @pairs.hash.invert; |
my %name = @pairs.hash.invert; |
||
for 1.. |
.say for (1..27).hyper(:3batch).map: -> $n { |
||
given @weights.combinations($n).first({ 0 == [+] @^comb }) { |
given @weights.combinations($n).first({ 0 == [+] @^comb }) { |
||
when .so { "Length $n: ({.map: {%name{$_}}})" } |
|||
default { "Length $n: (none)" } |
|||
} |
} |
||
}</lang> |
}</lang> |
||
{{out}} |
{{out}} |
||
<pre>Length 1: (none) |
<pre>Length 1: (none) |
||
Length 2: archbishop gestapo |
Length 2: (archbishop gestapo) |
||
Length 3: centipede markham mycenae |
Length 3: (centipede markham mycenae) |
||
Length 4: alliance balm deploy mycenae |
Length 4: (alliance balm deploy mycenae) |
||
Length 5: alliance brute covariate deploy mincemeat |
Length 5: (alliance brute covariate deploy mincemeat) |
||
Length 6: alliance archbishop balm deploy gestapo mycenae |
Length 6: (alliance archbishop balm deploy gestapo mycenae) |
||
Length 7: alliance archbishop bonnet cobol departure exorcism moresby |
Length 7: (alliance archbishop bonnet cobol departure exorcism moresby) |
||
Length 8: alliance archbishop balm bonnet fiat flatworm isis lindholm |
Length 8: (alliance archbishop balm bonnet fiat flatworm isis lindholm) |
||
Length 9: alliance archbishop balm bonnet brute covariate eradicate mincemeat plugging |
Length 9: (alliance archbishop balm bonnet brute covariate eradicate mincemeat plugging) |
||
Length 10: alliance archbishop balm bonnet brute centipede cobol departure deploy mincemeat |
Length 10: (alliance archbishop balm bonnet brute centipede cobol departure deploy mincemeat) |
||
Length 11: alliance archbishop balm bonnet brute centipede cobol departure infra moresby speakeasy |
Length 11: (alliance archbishop balm bonnet brute centipede cobol departure infra moresby speakeasy) |
||
Length 12: alliance archbishop balm bonnet brute centipede cobol covariate diophantine efferent elysee infra |
Length 12: (alliance archbishop balm bonnet brute centipede cobol covariate diophantine efferent elysee infra) |
||
Length 13: alliance archbishop balm bonnet brute centipede cobol covariate departure efferent eradicate filmy isis |
Length 13: (alliance archbishop balm bonnet brute centipede cobol covariate departure efferent eradicate filmy isis) |
||
Length 14: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy elysee filmy markham speakeasy |
Length 14: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy elysee filmy markham speakeasy) |
||
Length 15: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy elysee exorcism flatworm infra mycenae |
Length 15: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy elysee exorcism flatworm infra mycenae) |
||
Length 16: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine elysee exorcism filmy gestapo infra |
Length 16: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine elysee exorcism filmy gestapo infra) |
||
Length 17: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine exorcism isis mincemeat mycenae plugging vein |
Length 17: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine exorcism isis mincemeat mycenae plugging vein) |
||
Length 18: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee exorcism filmy isis mycenae vein |
Length 18: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee exorcism filmy isis mycenae vein) |
||
Length 19: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee eradicate exorcism fiat infra isis smokescreen |
Length 19: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee eradicate exorcism fiat infra isis smokescreen) |
||
Length 20: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee eradicate exorcism gestapo infra isis smokescreen speakeasy |
Length 20: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee eradicate exorcism gestapo infra isis smokescreen speakeasy) |
||
Length 21: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee eradicate exorcism flatworm infra lindholm mincemeat plugging speakeasy |
Length 21: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee eradicate exorcism flatworm infra lindholm mincemeat plugging speakeasy) |
||
Length 22: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee eradicate escritoire exorcism fiat filmy flatworm mincemeat plugging speakeasy |
Length 22: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee eradicate escritoire exorcism fiat filmy flatworm mincemeat plugging speakeasy) |
||
Length 23: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee eradicate escritoire exorcism infra isis mincemeat moresby mycenae smokescreen speakeasy |
Length 23: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee eradicate escritoire exorcism infra isis mincemeat moresby mycenae smokescreen speakeasy) |
||
Length 24: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee exorcism filmy gestapo infra markham mincemeat moresby mycenae plugging smokescreen speakeasy |
Length 24: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine efferent elysee exorcism filmy gestapo infra markham mincemeat moresby mycenae plugging smokescreen speakeasy) |
||
Length 25: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine eradicate exorcism fiat filmy flatworm infra isis lindholm markham mincemeat moresby mycenae plugging speakeasy |
Length 25: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine eradicate exorcism fiat filmy flatworm infra isis lindholm markham mincemeat moresby mycenae plugging speakeasy) |
||
Length 26: alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine elysee eradicate escritoire exorcism fiat filmy gestapo infra isis markham mincemeat mycenae plugging speakeasy vein |
Length 26: (alliance archbishop balm bonnet brute centipede cobol covariate departure deploy diophantine elysee eradicate escritoire exorcism fiat filmy gestapo infra isis markham mincemeat mycenae plugging speakeasy vein) |
||
Length 27: alliance archbishop balm bonnet brute centipede covariate departure deploy efferent elysee eradicate escritoire exorcism fiat filmy flatworm infra isis lindholm markham mincemeat moresby mycenae plugging smokescreen speakeasy</pre> |
Length 27: (alliance archbishop balm bonnet brute centipede covariate departure deploy efferent elysee eradicate escritoire exorcism fiat filmy flatworm infra isis lindholm markham mincemeat moresby mycenae plugging smokescreen speakeasy)</pre> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |