Introduction
Yes my parents spend a lot time at home during the cold December holidays as many others.
So I also want my cake.
But I have a problem: I just sent the invitations today so I'm not sure how many friends will come. Also I don't want to order a big cake because I have been on a diet since last year and don't want to keep temptation leftovers in the fridge.
Challenge
Write a full program to output the cake design so my baker prepares just enough cake for everyone.
Input Integer 1 <= n <= 999
. Worst case I eat my cake alone.
- Each slice will have a unique label number
1 .. n
sequenced left to right, then top to bottom. - Write in the middle line and align center the best way you can.
- Slice size is a square of 3x3 (this is why upper limit is 999).
*
indicate where to cut each slice.
Output
n = 1 => Side = RoundUP(sqrt(1)) = 1
*****
* *
* 1 *
* *
*****
n = 3 => Side = RoundUP(sqrt(3)) = 2
*********
* * *
* 1 * 2 *
* * *
*********
* *
* 3 *
* *
*****
n = 5 => Side = RoundUP(sqrt(5)) = 3
*************
* * * *
* 1 * 2 * 3 *
* * * *
*************
* * *
* 4 * 5 *
* * *
*********
n = 10 => Side = RoundUP(sqrt(10)) = 4
*****************
* * * * *
* 1 * 2 * 3 * 4 *
* * * * *
*****************
* * * * *
* 5 * 6 * 7 * 8 *
* * * * *
*****************
* * *
* 9 * 10*
* * *
*********
Winning
Shortest code in bytes wins.
Worst case I eat my cake alone.
- I consider this the best case scenario. \$\endgroup\$