Skip to content

Instantly share code, notes, and snippets.

@MasterAlish
Created August 22, 2013 19:06
Show Gist options
  • Save MasterAlish/6311422 to your computer and use it in GitHub Desktop.
Save MasterAlish/6311422 to your computer and use it in GitHub Desktop.
Solution for "sunloverz / gist:6309925" on ruby
class RectangularGrid
def countRectangles(n,m)
sum = 0
for i_n in 1..n
for i_m in 1..m
if i_m != i_n
sum = sum + (m-i_m+1)*(n-i_n+1)
end
end
end
return sum
end
end
r = Rect.new
puts r.countRectangles(3,3)
puts r.countRectangles(2,5)
puts r.countRectangles(592,964)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment