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] integer n

    Number of horizontal lines.

    Constraints: 0 <= n <= 100

  • [input] integer m

    Number of vertical lines.

    Constraints: 0 <= m <= 100

  • [output] an integer

    Number of rectangles.

Puzzles

Stats:

CreatedFeb 8, 2017
PublishedFeb 8, 2017
Warriors Trained821
Total Skips12
Total Code Submissions916
Total Times Completed338
JavaScript Completions121
C# Completions57
CoffeeScript Completions15
Python Completions182
Ruby Completions32
Total Stars12
% of votes with a positive feedback rating88% of 116
Total "Very Satisfied" Votes91
Total "Somewhat Satisfied" Votes21
Total "Not Satisfied" Votes4
Total Rank Assessments5
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • smile67 Avatar
  • elkirkmo Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • saudiGuy Avatar
Ad