PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'''
Challenge from The Rab-bit (see COMMENTS)
-----
Calculate the square of a number using only:
- "while" or "for"
- The operators "+" and "-"
Constraints
* Do not use modules or libraries that give the value squared
* You can use the language you want
-----
'''
'''
NOTE
This solution takes advantage of the following info about squares:
1st move
A = 1 A = 1×1
2nd move
AB = 1 A + 3 Bs = 2×2
BB
3rd move
ABC = 1 A + 3 Bs + 5 Cs = 3×3
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run