A common visual explanation of the Pythagorean theorem is as such:
The squares are meant to represent the side length's squared, and the areas of a + b = c
, just like the Pythagorean theorem says.
This part is what you have to show.
Your task
- You will get two integers as input, meant to represent sides
a
andb
of a right triangle (ex.3, 4
). - You will then make squares out of the lengths
a
,b
, andc
out of the#
character. For example here is 3:
###
###
###
- You will then format these into a math equation that explains the particular Pythagorean triplet:
#####
#### #####
### #### #####
### #### #####
### + #### = #####
- Notice how the
=
and+
signs have spaces on both sides and how everything is on the bottom. - You will never get values for
a
andb
that makec
non-integral. - This is code-golf so shortest code in bytes wins!
Test Cases
(more coming once I have time, these are really hard to make by hand)
3, 4
#####
#### #####
### #### #####
### #### #####
### + #### = #####
6, 8
##########
##########
######## ##########
######## ##########
###### ######## ##########
###### ######## ##########
###### ######## ##########
###### ######## ##########
###### ######## ##########
###### + ######## = ##########
4, 3
#####
#### #####
#### ### #####
#### ### #####
#### + ### = #####
5, 12
#############
############ #############
############ #############
############ #############
############ #############
############ #############
############ #############
############ #############
##### ############ #############
##### ############ #############
##### ############ #############
##### ############ #############
##### + ############ = #############
a+b=c
\$\endgroup\$