Permalink
Browse files

Add rectangle puzzle

  • Loading branch information...
1 parent c34be8e commit b9268c899938f9df82096543b21723e73c369614 @benlangfeld committed Nov 8, 2011
Showing with 22 additions and 0 deletions.
  1. +21 −0 about_rectangles.rb
  2. +1 −0 path_to_enlightenment.rb
View
@@ -0,0 +1,21 @@
+require File.expand_path(File.dirname(__FILE__) + '/edgecase')
+
+class Rectangle
+ def initialize(*corners)
+ @corners = corners
+ end
+
+ def all_unit_points
+ # Hint: Array#permutation
+ end
+end
+
+def rectangle(*corners)
+ Rectangle.new(corners).all_unit_points
+end
+
+class AboutRectangles < EdgeCase::Koan
+ def test_all_unit_points_are_included
+ assert_equal [[0,0], [0,1], [0,2], [0,3], [1,0], [1,1], [1,2], [1,3], [2,0], [2,1], [2,2], [2,3], [3,0], [3,1], [3,2], [3,3]], rectangle([0,0], [0,3], [3,0], [3,3])
+ end
+end
View
@@ -36,3 +36,4 @@
require 'about_java_interop'
end
require 'about_extra_credit'
+require 'about_rectangles'

0 comments on commit b9268c8

Please sign in to comment.