7 kyu
Simple Fun #105: Rectangles
182 of 338myjinxin2015
Description:
Task
Imagine n
horizontal lines and m
vertical lines.
Some of these lines intersect, creating rectangles.
How many rectangles are there?
Examples
For n=2, m=2,
the result should be 1
.
there is only one 1x1 rectangle.
For n=2, m=3
, the result should be 3
.
there are two 1x1 rectangles and one 1x2 rectangle. So 2 + 1 = 3
.
For n=3, m=3, the result should be 9
.
there are four 1x1 rectangles, two 1x2 rectangles, two 2x1 rectangles and one 2x2 rectangle. So 4 + 2 + 2 + 1 = 9
.
Input & Output
[input]
integern
Number of horizontal lines.
Constraints:
0 <= n <= 100
[input]
integerm
Number of vertical lines.
Constraints:
0 <= m <= 100
[output]
an integerNumber of rectangles.
Puzzles
Similar Kata:
Stats:
Created | Feb 8, 2017 |
Published | Feb 8, 2017 |
Warriors Trained | 821 |
Total Skips | 12 |
Total Code Submissions | 916 |
Total Times Completed | 338 |
JavaScript Completions | 121 |
C# Completions | 57 |
CoffeeScript Completions | 15 |
Python Completions | 182 |
Ruby Completions | 32 |
Total Stars | 12 |
% of votes with a positive feedback rating | 88% of 116 |
Total "Very Satisfied" Votes | 91 |
Total "Somewhat Satisfied" Votes | 21 |
Total "Not Satisfied" Votes | 4 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |