Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
func patience(deck) {
|
||||
var stacks = [];
|
||||
deck.each { |card|
|
||||
given (stacks.first { card < .last }) { |stack|
|
||||
case (defined stack) {
|
||||
stack << card
|
||||
}
|
||||
default {
|
||||
stacks << [card]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gather {
|
||||
while (stacks) {
|
||||
take stacks.min_by { .last }.pop
|
||||
stacks.grep!{ !.is_empty }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var a = [4, 65, 2, -31, 0, 99, 83, 782, 1]
|
||||
say patience(a)
|
||||
Loading…
Add table
Add a link
Reference in a new issue