Beauty of Mathematics

こちらのサイトにある、ふつくしいピラミッド的なものをRubyで再現してみました。
[Beauty of Mathematics, Interesting facts, Funny Math](https://www.easycalculation.com/funny/interesting-facts/math-beauty.php)

```text:出力結果
+------ Sequential Inputs of numbers with 8 -------+
|                                                  |
|                  1 * 8 + 1 = 9                   |
|                 12 * 8 + 2 = 98                  |
|                123 * 8 + 3 = 987                 |
|               1234 * 8 + 4 = 9876                |
|              12345 * 8 + 5 = 98765               |
|             123456 * 8 + 6 = 987654              |
|            1234567 * 8 + 7 = 9876543             |
|           12345678 * 8 + 8 = 98765432            |
|          123456789 * 8 + 9 = 987654321           |
|                                                  |
+--------------------------------------------------+

+------------- Sequential 1's with 9 --------------+
|                                                  |
|                 1 * 9 +  2 = 11                  |
|                12 * 9 +  3 = 111                 |
|               123 * 9 +  4 = 1111                |
|              1234 * 9 +  5 = 11111               |
|             12345 * 9 +  6 = 111111              |
|            123456 * 9 +  7 = 1111111             |
|           1234567 * 9 +  8 = 11111111            |
|          12345678 * 9 +  9 = 111111111           |
|         123456789 * 9 + 10 = 1111111111          |
|                                                  |
+--------------------------------------------------+

+------------- Sequential 8's with 9 --------------+
|                                                  |
|                  9 * 9 + 7 = 88                  |
|                 98 * 9 + 6 = 888                 |
|                987 * 9 + 5 = 8888                |
|               9876 * 9 + 4 = 88888               |
|              98765 * 9 + 3 = 888888              |
|             987654 * 9 + 2 = 8888888             |
|            9876543 * 9 + 1 = 88888888            |
|           98765432 * 9 + 0 = 888888888           |
|                                                  |
+--------------------------------------------------+

+---------- Numeric Palindrome with 1's -----------+
|                                                  |
|                    1 * 1 = 1                     |
|                  11 * 11 = 121                   |
|                111 * 111 = 12321                 |
|              1111 * 1111 = 1234321               |
|            11111 * 11111 = 123454321             |
|          111111 * 111111 = 12345654321           |
|        1111111 * 1111111 = 1234567654321         |
|      11111111 * 11111111 = 123456787654321       |
|    111111111 * 111111111 = 12345678987654321     |
|                                                  |
+--------------------------------------------------+

+------------------- Without 8 --------------------+
|                                                  |
|            12345679 *  9 = 111111111             |
|            12345679 * 18 = 222222222             |
|            12345679 * 27 = 333333333             |
|            12345679 * 36 = 444444444             |
|            12345679 * 45 = 555555555             |
|            12345679 * 54 = 666666666             |
|            12345679 * 63 = 777777777             |
|            12345679 * 72 = 888888888             |
|            12345679 * 81 = 999999999             |
|                                                  |
+--------------------------------------------------+

+------------- Sequential Inputs of 9 -------------+
|                                                  |
|                    9 * 9 = 81                    |
|                  99 * 99 = 9801                  |
|                999 * 999 = 998001                |
|              9999 * 9999 = 99980001              |
|            99999 * 99999 = 9999800001            |
|          999999 * 999999 = 999998000001          |
|        9999999 * 9999999 = 99999980000001        |
|      99999999 * 99999999 = 9999999800000001      |
|    999999999 * 999999999 = 999999998000000001    |
|                                                  |
+--------------------------------------------------+

+------------- Sequential Inputs of 6 -------------+
|                                                  |
|                    6 * 7 = 42                    |
|                  66 * 67 = 4422                  |
|                666 * 667 = 444222                |
|              6666 * 6667 = 44442222              |
|            66666 * 66667 = 4444422222            |
|          666666 * 666667 = 444444222222          |
|        6666666 * 6666667 = 44444442222222        |
|      66666666 * 66666667 = 4444444422222222      |
|    666666666 * 666666667 = 444444444222222222    |
|                                                  |
+--------------------------------------------------+
```


```rb:source.rb
width = 50

def wrap(o, s = ?|)
  s + o + s
end

{
  "Sequential Inputs of numbers with 8"=>
    (1..9).map{|n|"#{[*1..n] * ''} * 8 + #{n}"},
  
  "Sequential 1's with 9"=>
    (1..9).map{|n|"#{[*1..n] * ''} * 9 + %2d" % (n + 1)},
  
  "Sequential 8's with 9"=>
    9.downto(2).map{|n|"#{[*9.downto(n)] * ''} * 9 + #{n - 2}"},
  
  "Numeric Palindrome with 1's"=>
    (1..9).map{|n|[?1 * n] * 2 * " * "},
  
  "Without 8"=>
    (1..9).map{|n|"12345679 * %2d" % (9 * n)},
  
  "Sequential Inputs of 9"=>
    (1..9).map{|n|[?9 * n] * 2 * " * "},
  
  "Sequential Inputs of 6"=>
    (1..9).map{|n|"#{?6 * n} * #{?6 * (n - 1)}7"},
  
}.each do |title, formulas|
  
  formulas.map!{|s| wrap "#{s} = #{eval(s)}".center(width) }
  
  puts '', wrap(" #{title} ".center(width, ?-), ?+)
  puts wrap(" " * width), formulas, wrap(" " * width)
  puts wrap("".center(width, ?-), ?+)
end
```
見辛いのはわざとです。嘘です。