### Re^2: Golf: Buying with exact change

by dragonchild (Archbishop)
 on Feb 22, 2005 at 14:44 UTC ( #433346=note: print w/ replies, xml ) Need Help??

```Without //= patch:
@x=@_;my%c;\$e=sub{my\$v=pop;exists\$c{\$v}?\$c{\$v}:\$c{\$v}=\$v<0?0:\$v==0||gr
+ep&\$e(\$v-\$_),@x};\$t=\$s=0;{&\$e(++\$t)?\$t-\$s>=\$x[0]&&last:(\$s=\$t);redo}\$
+s

With //= patch:
@x=@_;my%c;\$e=sub{my\$v=pop;\$c{\$v}//=\$v<0?0:\$v==0||grep&\$e(\$v-\$_),@x};\$
+t=\$s=0;{&\$e(++\$t)?\$t-\$s>=\$x[0]&&last:(\$s=\$t);redo}\$s
```
```@x=@_;my%c;\$e=sub{my\$v=pop;\$c{\$v}//=\$v==0||\$v>0&&grep&\$e(\$v-\$_),@x};\$t
+=\$s=0;{&\$e(++\$t)?\$t-\$s>=\$x[0]&&last:(\$s=\$t);redo}\$s
```
```@x=@_;my%c;\$e=sub{my\$v=pop;\$c{\$v}//=!\$v||\$v>0&&grep&\$e(\$v-\$_),@x};for(
+\$t=\$s=0;\$t-\$s<\$x[0];&\$e(++\$t)or\$s=\$t){}\$s
```

Create A New User
Node Status?
node history
Node Type: note [id://433346]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (15)
As of 2015-11-25 20:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?