# APL, 10-3 = 7 Inspired* by [this answer][1] where the arguments are replicated and then used in a multiplication table: ⊖∘.×⍨(/⍨⎕) `⎕` Issues a prompt (`⎕:`) and evaluates any expression entered then. (For security reasons, this doesn't work on [TryAPL][2] but it does work on [NGN/APL][3].)<br> `/⍨` Replicates its argument itself times (`/⍨4 3` ⇔ `3 3 3 4 4 4 4`)<br> `∘.×⍨` Creates a multiplication table.<br> `⊖` Flips upside down. This happens to work on any length input (input is indented 6 spaces, output is at left margin): ⊖∘.×⍨(/⍨⎕) ⎕: ⍬ ⍝ Empty list (the square of nothing) ⊖∘.×⍨(/⍨⎕) ⎕: 0 ⍝ 0² = 0 ⊖∘.×⍨(/⍨⎕) ⎕: 0 1 ⍝ (0+1)² = 1² 1 ⊖∘.×⍨(/⍨⎕) ⎕: 2 3 ⍝ (2+3)² = 2² + 3² 6 6 9 9 9 6 6 9 9 9 6 6 9 9 9 4 4 6 6 6 4 4 6 6 6 ⊖∘.×⍨(/⍨⎕) ⎕: 1 2 3 ⍝ (1+2+3)² = 1² + 2(1×2) + 2(1×3) + 2² + 2(2×3) + 3² 3 6 6 9 9 9 3 6 6 9 9 9 3 6 6 9 9 9 2 4 4 6 6 6 2 4 4 6 6 6 1 2 2 3 3 3 ⊖∘.×⍨(/⍨⎕) ⎕: ⍳4 ⍝ Integers 1 through 4 4 8 8 12 12 12 16 16 16 16 4 8 8 12 12 12 16 16 16 16 4 8 8 12 12 12 16 16 16 16 4 8 8 12 12 12 16 16 16 16 3 6 6 9 9 9 12 12 12 12 3 6 6 9 9 9 12 12 12 12 3 6 6 9 9 9 12 12 12 12 2 4 4 6 6 6 8 8 8 8 2 4 4 6 6 6 8 8 8 8 1 2 2 3 3 3 4 4 4 4 --- *Originally, I had a different solution in mind: Each rectangle is created separately by creating a multiplication table for each combination of the two arguments. Then the four squares are mended together vertically and horizontally. It looks like this: ,/⍪⌿⊖∘.(,⍴×)⍨⎕ `⎕` Prompt, as above.<br> `,⍴×<` Combine (`,`) the args and use that to shape (`⍴`) a rectangle filled with their product (`×`).<br> `∘.(`…`)⍨` Create a table where each cell is whatever is specified in `(`…`)`<br> `⊖` Flip vertically.<br> `⍪/` Combine cells vertically.<br> `,/` Combine cells horizontally. [1]: http://codegolf.stackexchange.com/a/61221/43319 [2]: http://tryapl.org/ [3]: http://ngn.github.io/apl/web/