Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,12 @@
|
|||
combos = (arr, k) ->
|
||||
return [ [] ] if k == 0
|
||||
return [] if arr.length == 0
|
||||
|
||||
combos_with_head = ([arr[0]].concat combo for combo in combos arr, k-1)
|
||||
combos_sans_head = combos arr[1...], k
|
||||
combos_with_head.concat combos_sans_head
|
||||
|
||||
arr = ['iced', 'jam', 'plain']
|
||||
console.log "valid pairs from #{arr.join ','}:"
|
||||
console.log combos arr, 2
|
||||
console.log "#{combos([1..10], 3).length} ways to order 3 donuts given 10 types"
|
||||
Loading…
Add table
Add a link
Reference in a new issue