Simple Fun #190: Folding Paper
Description:
Task
John was in math class and got bored, so he decided to fold some origami from a rectangular a × b
sheet of paper (a > b
). His first step is to make a square piece of paper from the initial rectangular piece of paper by folding the sheet along the bisector of the right angle and cutting off the excess part.
After moving the square piece of paper aside, John wanted to make even more squares! He took the remaining (a-b) × b
strip of paper and went on with the process until he was left with a square piece of paper.
Your task is to determine how many square pieces of paper John can make.
Example:
For: a = 2, b = 1
, the output should be 2
.
Given a = 2
and b = 1
, John can fold a 1 × 1
then another 1 × 1
.
So the answer is 2
.
For: a = 10, b = 7
, the output should be 6
.
We are given a = 10
and b = 7
. The following is the order of squares John folds: 7 × 7, 3 × 3, 3 × 3, 1 × 1, 1 × 1, and 1 × 1
.
Here are pictures for the example cases.
Input/Output
[input]
integera
2 ≤ a ≤ 1000
[input]
integerb
1 ≤ b < a ≤ 1000
[output]
an integer
The maximum number of squares.
Similar Kata:
Stats:
Created | Mar 8, 2017 |
Published | Mar 8, 2017 |
Warriors Trained | 2019 |
Total Skips | 39 |
Total Code Submissions | 2353 |
Total Times Completed | 941 |
JavaScript Completions | 290 |
C# Completions | 111 |
Python Completions | 499 |
Ruby Completions | 67 |
Crystal Completions | 11 |
Haskell Completions | 40 |
C Completions | 10 |
Total Stars | 29 |
% of votes with a positive feedback rating | 92% of 183 |
Total "Very Satisfied" Votes | 158 |
Total "Somewhat Satisfied" Votes | 20 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |