"Sander Land" <sander.land / gmail.com> writes: > Good idea, here are the tests i'm using. It also includes the irb > session as well as a number of other tests. > It assumes the result of any calculation with FWI's and integers is a FWI. > I'm using a different syntax for the FWI's, but it should be easy > enough to convert this to whatever you're using. I like this syntax though better than the one in the quiz and may adopt it. Actually, it shouldn't be too hard to support both syntaxes... I do take issue with one of your tests, though: > def test_power > uint3 = UnsignedFWI(3) > assert_equal(2, 2 ** uint3.new(1)) > assert_equal(0, 2 ** uint3.new(3)) > assert_equal(0, 2 ** uint3.new(67)) > assert_equal(1, 3 ** uint3.new(2)) > assert_equal(3, uint3.new(3) ** uint3.new(-1)) # 3**7 mod 8 > end That just feels wrong. (except for the last one) I would write: def test_power uint3 = UnsignedFWI(3) assert_equal(2, uint3.new(2) ** 1) assert_equal(0, uint3.new(2) ** 3) assert_equal(0, uint3.new(2) ** 67) assert_equal(1, uint3.new(3) ** 2) assert_equal(3, uint3.new(3) ** uint3.new(-1)) # 3**7 mod 8 end And maybe: def test_power_fwi_exponent uint3 = UnsignedFWI(3) assert_equal(2, 2 ** uint3.new(1)) assert_equal(8, 2 ** uint3.new(3)) assert_equal(8, 2 ** uint3.new(67)) end I really think that you want to keep exponentiation looking like repeated multiplication of the first argument. Of course, it would be nice if our kind quiz host would respond with a few rulings for the edge cases I outlined before. At least then we'd know when we were ignoring the rules of the quiz.