Skip to content

Instantly share code, notes, and snippets.

View nbgoodall's full-sized avatar
🎨

Nick Goodall nbgoodall

🎨
View GitHub Profile

Keybase proof

I hereby claim:

  • I am nbgoodall on github.
  • I am nbgoodall (https://keybase.io/nbgoodall) on keybase.
  • I have a public key ASDPpW2vo6a0QBY8H-vLFOBdtWNXIVWKV_5sHbs36Iarkwo

To claim this, I am signing this object:

def missing_ints(arr)
(arr.min..arr.max).to_a - arr
end
missing_ints([1, 3, 3, 5, 6])
# => [2, 4]
missing_ints([1, 2, 3, 4, 4, 7, 7])
# => [5, 6]
#
# <Node tree=Array.new([value, left, right]) parent=Node node_index=(1|2)>
#
class Node < Struct.new(:tree, :parent, :node_index)
def value
@value ||= tree[0]
end
def leaf(index)
tree[index] ? Node.new(Array(tree[index]), self, index) : nil
@nbgoodall
nbgoodall / Level 1
Last active August 29, 2015 14:05
Ruby Warrior – Beginner
class Player
def play_turn(warrior)
warrior.walk!
end
end