Count the coins/0-1: Difference between revisions

m
Replaced "collect" with "toSeq" (equivalent but maybe more elegant.
m (Replaced "collect" with "toSeq" (equivalent but maybe more elegant.)
Line 357:
 
Using a solver object rather than global variables.
<lang Nim>import math, strutilssequtils, sugarstrutils
 
type Solver = object
Line 383:
echo "Sum $# from coins $#".format(want, coins.join(" "))
var solver = Solver(want: want, width: width)
var rindices = collecttoSeq(for i in 0..coins.high: i)
solver.count(0, newSeq[int](), @coins, newSeq[int](), rindices)
if solver.count1 > 10:
Anonymous user