From: Phrogz Date: 2007-12-15T07:15:08+09:00 Subject: Re: Programmer Ping-Pong (#150) On Dec 14, 2:12 pm, Michal Suchanek wrote: > On 14/12/2007, Eric I. wrote: > > > > > avl_tree.rb > > __BEGIN__ > > #!/usr/bin/env ruby -wKU > > class AVLTree > > def initialize > > @contents = [] > > end > > > def empty? > > @contents.empty? > > end > > > def include?(obj) > > @contents.include?(obj) > > end > > > def <<(obj) > > @contents << obj > > end > > > def height > > (Math.log(@contents.size + 1) / Math.log(2)).round > > end > > Now I think this one is misleading. Here you choose to lie about the > tree height. There is no way one can detect this by a test, a list > passes for a binary tree at any time. It is just somewhat unbalanced - > the real height is @contents.length So...write a failing test case :)