[Question]
      [
A shape is [chiral](https://en.wikipedia.org/wiki/Chirality) if no amount of rotation can make it look like it's mirror image. In this puzzle we will be writing chiral computer programs.
For this puzzle we will think of a program as a rectangular matrix of characters. As such all solutions to this challenge must be rectangular (that is all lines must be of the same length). We can rotate these programs in quarter turn increments. For example the program
```
The quickish fish
    lept deftly
  rightwards
```
When rotated a quarter turn clockwise looks like
```
  T
  h
r e
i
glq
heu
tpi
wtc
a k
rdi
des
sfh
 t
 lf
 yi
  s
  h
```
We can also reflect these programs. Here is the same program reflected over a vertical axis:
```
hsif hsikciuq ehT
  yltfed tpel
    sdrawthgir
```
A chiral program is a program that when rotated any number of times will always output "`left`". However when reflected produces a program that outputs "`right`" no matter how many times it is rotated.
Your task is to write a chiral program in as few bytes as possible.
### Additional Rules
* Output is not-case sensitive but should be consistent. (e.g. You may output "`LEFT`" and "`rIgHt`" but this casing must be consistent under rotations)
* Lines are to be split either on a newline or a newline and a linefeed.
* Your program must be a rectangle, you can pad it with spaces or comments but each line must have the same length.
* You may optionally have a trailing newline (or newline and linefeed) on all of your programs if you wish.

[Answer]
# [Pascal (FPC)](https://www.freepascal.org/), ~~2161~~ ~~755~~ 349 bytes
```
///////bw(,,),(wb///////
///////er'''e''re///////
begin//girgtnflig//nigeb
write//itih'dteti//etirw
('le'//ne'' .''en//'ir'(
,'ft'//////////////'hg',
)end.////////////// 't',
,'t' //////////////.dne)
,'gh'//////////////'tf',
('ri'//ne''. ''en//'el'(
write//itetd'hiti//etirw
begin//gilfntgrig//nigeb
///////er''e'''re///////
///////bw(,),,(wb///////
```
[Try left](https://tio.run/##XVDLCsQgDLz7Fd7Ggqvf1Ee0AZHiBvr53cB2W7s5KGQyM8ls43seyytt83HEb027837wbp/Ohjl/agAIaPQDJspcY8zcstRUOMdYOdNk9saiUyy8YhESVrZw241DIeiUytigasoGNzjjkQTxUVgzvBmoLuEJWIgCXl/7BMJSaVAgr/9SkpTh0Pg0D/Y0p6Lm17okC1a@170OLKlKbveBXSSq1kXShTj4LsTj@AA "Pascal (FPC) – Try It Online")
[Try right](https://tio.run/##XVBJDsMgDLzzCm5DJApvymKIJYQiainPTx01zVIfQPIstmfp32NfXmkZty1@a1id77x363A0zPFTAwhAox8wUOYaY@aSquTGOcbKmQazNhZl6SMTZhZWtXBbjUNjKEt9glU7VYMKnPHIM@KjIAleAYF9AmGq1JmO6hSegFXurkjybzVnBRwKHcNtOIZz0@Hnujxj0p3Pdc8DW5aaynXgLZI9kyuSW4ia4hXitn0A "Pascal (FPC) – Try It Online")
@tsh motivated me to try again when I saw his program (in comment) and here it is!
---
Previous one with 755 bytes:
```
 begin write('left')end.//
/e .dne)'thgir'(etirw nigeb
/g                        e
.i                       .g
dn                       di
n                        nn
ew                       e
)r                       )w
'i                       'r
tt                       ti
fe                       ht
e(                       ge
l'                       i(
'r                       r'
(i                       'l
eg                       (e
th                       ef
it                       tt
r'                       i'
w)                       r)
 e                       we
nn                        n
id                       nd
g.                       i.
e                        g/
begin write('right')end. e/
 //.dne)'tfel'(etirw nigeb
```
[Try left](https://tio.run/##dZIxjkMhDET7OYU7Q7FwpiQYviWEImKJ4/9t0qQYt6/w83jej8/rMf/6@3Xf8rThS872sKTTemi21UqtgmpS2rKscQ3fmix8H1k@7Ik6hIyhOEFloC3CmoMhWQt22DpB3oTlA2UuuhFBWDi6EXYFLBE2DFMJ8wRlnluRqOeEsayTIS6WS4fT@wKbeipOZp4ZwnI5hsUfCG8MNYzCXArYOhkVP9XdPq5vd8UqpNZvd7vNn@rKff8D "Pascal (FPC) – Try It Online")
[Try right](https://tio.run/##dZIxjkMhDET7OYU7Q7FwpiQYviVkRSwSx/@7RZoU4/ZJ5nmY9@P39Zg//f26b6m1tLCsu9vUZNvXkfBhT8HThoec5duSLh/X1mzRiliFCZlRMQphXuCNsGiIYEsDwh48hpMJWxlLmYvCN2F7Y1@EWYcNwpIhOWE6oYt5Kib1TLDEsjZ0lsv1fwO9z6HUcyEzz3xgh@Ui4N8XaAw2R2EuZaCyrMVQTT7dvYavr/JCvso7rX@6W6vc9x8 "Pascal (FPC) – Try It Online")
If you saw my previous submission, just forget it :)
All rotations for both left and right programs are the same.
[Answer]
# [Klein (000)](https://github.com/Wheatwizard/Klein), ~~109~~ 87 bytes
```
."left"@\.
\"right"..
@"thgir">.
..@"tfel"\
\"left"@..
.>"right"@
.."thgir"\
.\@"tfel".
```
[Try it online!](https://tio.run/##Lcq7CcAwDAXAXmO8Pg9NYJw91PpHTArj/RVBXB7cM8t43YlZ6kY2imGN1jdIydi9jYVEIQO1TFiE/0ZgOjlHONmEdi7dXVX9uj8 "Klein – Try It Online")
Should be possible to get a shorter version of this answer so good luck!
This answer is inspired by spirals. In particular the idea is two interlocked spirals, one for left and one for right. It has two fold symmetry, So we can check the following programs to know it works:
## Quarter turn
```
...\.@\.
\.>"."""
@""l@trl
"tre"hie
thiftggf
fggtfiht
eih"ert"
lrt@l""@
""".">.\
.\@.\...
```
[Try it online!](https://tio.run/##DczBDcQwCATAP2XsPytXEHF98MU2CsrDon8uBcw86fF2kzSqUYw3CEAUSK2TgjqOHS61Y9ZaU@ZaNWOXeGz4KUie0gRUPkncNKHpN5LdPcbo6/cH "Klein – Try It Online")
## Mirrored
```
.\@.\...
""".">.\
lrt@l""@
eih"ert"
fggtfiht
thiftggf
"tre"hie
@""l@trl
\.>"."""
...\.@\.
```
[Try it online!](https://tio.run/##DczBDcQwCATAP2XsPytXEHF98MU2CsrDon8uBcw86fF205RGUgAQN03ylCag4rHhpyBzrZqxS2rHrLWmoI5jh4sCqXVSjPfnAfkuoxq7e4zR1@8P "Klein – Try It Online")
## Mirrored and Quarter turn
```
.\@"tfel".
.."thgir"\
.>"right"@
\"left"@..
..@"tfel"\
@"thgir">.
\"right"..
."left"@\.
```
[Try it online!](https://tio.run/##Lcq7DcAgDAXA3mO8Pk9MgMgebvkpVgrE/g4odFfcY7m/7tSEWbKBQmK22gdUGDF6bRNJFJbLAnc4VyWdGrnCX3c4V@nuIQS/7g8 "Klein – Try It Online")
[Answer]
# [Klein (000)](https://github.com/Wheatwizard/Klein), ~~27~~ 25 bytes
```
\(("right"@/
\(("left"@!\
```
[Try it online!](https://tio.run/##y85Jzcz7/z9GQ0OpKDM9o0TJQZ8LxMlJTQOyFWP@//9vYGDwX9cRAA "Klein – Try It Online") [Rotated once!](https://tio.run/##y85Jzcz7/z8mhktDA4SUlLhyirhSM7nS0rlKMriUSrgclLgUHbhi9P///29gYPBf1xEA) [Rotated twice!](https://tio.run/##y85Jzcz7/z9G0UGpJC01R0lDI4ZLH8jOSM8sAnH@//9vYGDwX9cRAA) [Rotated three times!](https://tio.run/##y85Jzcz7/18/hstBkUvJgatEiSujhCs9jSszlasoh0tJiUtDA4RiYv7//29gYPBf1xEA)
And flipped: [Try it online!](https://tio.run/##y85Jzcz7/1/fQakkIz2zSElDI4YrRhHIS0vNAXH@//9vYGDwX9cRAA) [Rotated once!](https://tio.run/##y85Jzcz7/z9Gn0vRgctBiUuphKskgystnSs1kyuniEtJiUtDA4RiYv7//29gYPBf1xEA) [Rotated twice!](https://tio.run/##y85Jzcz7/z9GQ0MpJzWtRMlBMYYLxCnKTM8A8vT///9vYGDwX9cRAA) [Rotated thrice!](https://tio.run/##y85Jzcz7/z8mhktDA4SUlLiKcrgyU7nS07gySrhKlLiUHLgcFLn0Y/7//29gYPBf1xEA)
The only one that gave me a bit of trouble was the flipped and rotated once, which looks like:
```
\/
!@
@"
"t
th
fg
ei
lr
""
((
((
\\
```
This is the only reason for the two sets of `((`.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~1481~~ ~~599~~ ~~505~~ ~~461~~ ~~341~~ ~~305~~ 271 bytes
```
/g+///g/g"c.c"g/
g=//////=rolol=g
"left"///inone/+
console//gsgsf//
.log(g)//ho(ot//
console//tlgl"//
"right"//"e)e//g
g=//////////////
//////////////=g
g//e)e"//"thgir"
//"lglt//elosnoc
//to(oh//)g(gol.
//fsgsg//elosnoc
+/enoni///"tfel"
g=lolor=//////=g
/g"c.c"g/g///+g/
```
## Mirrored
```
/g"c.c"g/g///+g/
g=lolor=//////=g
+/enoni///"tfel"
//fsgsg//elosnoc
//to(oh//)g(gol.
//"lglt//elosnoc
g//e)e"//"thgir"
//////////////=g
g=//////////////
"right"//"e)e//g
console//tlgl"//
.log(g)//ho(ot//
console//gsgsf//
"left"///inone/+
g=//////=rolol=g
/g+///g/g"c.c"g/
```
[Try it online!](https://tio.run/##lVLNbtwgEL7zFAjlYNcbJofeXOch2qPjxpZ3zLJiwQKyjdTm2beD7XUSJRslXAaG@X6GYd8du9B7PcZr67Z4OnaeD7ziv6LXVknf/WlPoAoAUKBEL3uhgKkKplV5Z5ypFBMGhygoo62zCAXrnQ3OIKGCCgMAk8apTOUAO5e5SIm1IhplCMqE12qXSATmCbiqnBd7fSRZBUC1CRJ3SntBFYLYiB6NC9b1lIiktwPISd0ZSYmBHKnnigKQPGtIJAMaQbLUk/PVqrL2TSgoFJxa6XE0XY8Z/L6z/@7sFaiNEHnJ2PBg@6id5QftvfNZyPlfxj3GB295eMbVBGwKgj1Wt48yjEbHNtEe0QfMcrl32rYtMT694PQudhEXzjQoQ4MKC5q15SpUSylNfdM08tCNWXa10Xl1a@bD/WafDvW@qXWTv5WcY2JL0vcRDyOpDCXtqSfaLp0NZA6@ncc4jXeqoPTL3PQsg/M8S4Y14W9KCj/4dwpFMbXymiMpEoa/YeGrm@Uh1toncgJfURE/JwYueEFlBcWoDxg2nL7C9dwgbsX7Lj7rFo@d@bBgiwbJgyqXTV9@0uSXDM4juezv4v179i5OgJ9/x3ox89JkaDSn/w "JavaScript (Node.js) – Try It Online")
### (Please see the TIO Link for all test cases, including mirrored version)
### Although further golfed, size `22x22 -> 21x21` on credit of @JoKing!
Size ~~38x38~~ ~~24x24~~ ~~22x22~~ ~~21x21~~ ~~18x18~~ ~~17x17~~ 16x16, 4-fold symmetry.
Here comes a question -- is it possible to have 15x15 or smaller for JS? It seems that what I need at least is the comment separator between two sub-blocks and at the edge, so at least 7+2+2+5=16 lines?
[Answer]
# [Klein (211)](https://github.com/Wheatwizard/Klein), 37 bytes
```
!\"left"@"thgir"\!
!/............../!
```
This has a different program for each rotation.
## Explanation
Note that each of these programs is padded to a square with no-ops before execution
### No change
```
!\"left"@"thgir"\!
!/............../!
```
[Try it online!](https://tio.run/##y85Jzcz7/18xRiknNa1EyUGpJCM9s0gpRpFLUV8PBegr/v//38jQ8L@uIwA "Klein – Try It Online")
`!` makes execution jump over the `\` and `"left"@` loads the string `"left"` into the stack and terminates the program printing the stack
### Quarter turn
```
!!...IP->
\/
".
r.
i.
g.
h.
t.
".
@.
".
t.
f.
e.
l.
".
\/
!!
^
|
P
I
```
[Try it online!](https://tio.run/##y85Jzcz7/19RkStGn0tJj6tIjytTjytdjytDj6tEDyTiACaB7DQ9rlQ9rhwwF6hYUfH///@6jv@NDA0B)
Execution runs off the top right corner of the square, continues in the bottom left corner and once again `!\"left"@` prints `"left`.
### Half turn
```
                ^
                |
                P
                I
!/............../!
!\"right"@"tfel"\!
..................
..................
..................
..................
..................
..................
..................
..................
..................
..................
..................
..................
................^.
................|.
IP->............P.
................I.
```
[Try it online!](https://tio.run/##y85Jzcz7/19RXw8F6CtyKcYoFWWmZ5QoOSiVpKXmKMUo/v//X9fxv5GhIQA)
Here, the execution path exits from the North side, re-enters through the West side, exits again from the East Before entering in the south. `\` bounces the path into `"left"@` to print it.
### Three-quarter turn
```
!!..IP->
/\
."
.l
.e
.f
.t
."
.@
."
.t
.h
.g
.i
.r
."
/\
!!
^
|
I
P
```
[Try it online](https://tio.run/##y85Jzcz7/19RkUs/hktPiUsvh0svlUsvjUuvBMx1AJNAdgaXXjqXXiaXXhFIBKhYUfH///@6jv@NDA0B)
Execution exits from the top right corner then re-enters in the bottom left. Once again the mirrors `/\` redirect the path into `"left"@` to print it.
### Reflection
```
!\"right"@"tfel"\!
!/............../!
```
This is essentialy the same as for left in all rotations.
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), ~~109~~ ~~89~~ 71 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
```
（tfel⁸（（
（h（right
⁸g   q（f
li    re
er    il
f（    g⁸
thgir（h（
（（⁸left（
```
[Try it here](https://dzaima.github.io/Canvas/?u=JXVGRjA4dGZlbCV1MjA3OCV1RkYwOCV1RkYwOCUwQSV1RkYwOGgldUZGMDhyaWdodCUwQSV1MjA3OGclMjAlMjAlMjBxJXVGRjA4ZiUwQWxpJTIwJTIwJTIwJTIwcmUlMEFlciUyMCUyMCUyMCUyMGlsJTBBZiV1RkYwOCUyMCUyMCUyMCUyMGcldTIwNzglMEF0aGdpciV1RkYwOGgldUZGMDglMEEldUZGMDgldUZGMDgldTIwNzhsZWZ0JXVGRjA4,v=8) | [Try reversed!](https://dzaima.github.io/Canvas/?u=JXVGRjA4JXVGRjA4JXUyMDc4bGVmdCV1RkYwOCUwQXRoZ2lyJXVGRjA4aCV1RkYwOCUwQWYldUZGMDglMjAlMjAlMjAlMjBnJXUyMDc4JTBBZXIlMjAlMjAlMjAlMjBpbCUwQWxpJTIwJTIwJTIwJTIwcmUlMEEldTIwNzhnJTIwJTIwJTIwJTIwJXVGRjA4ZiUwQSV1RkYwOGgldUZGMDhyaWdodCUwQSV1RkYwOHRmZWwldTIwNzgldUZGMDgldUZGMDg_,v=8) Those are the only two possible programs, as the program is rotationally symmetric.
Made in [this](https://dzaima.github.io/Canvas/?u=JXVGRjM3SSV1RkYwMyV1RkYxOCV1RkYxOCUyMCV1MjU0QiV1RkYxQSV1RkYxMyV1MjdGMyV1RkY0RSV1RkYxQSV1RkYxMiV1MjdGMyV1RkY0RXJlc3VsdC52YWx1ZSUzRHAucCV1RkYwMyV1RkY1RA__,i=JTIwJTBBJTBBJTBBJTBBJTBBJTBBJTIwJTIwJXVGRjA4cmlnaHQlMEEldUZGMDh0ZmVsJXUyMDc4JXVGRjA4,v=8).
[Answer]
# [Gol><>](https://github.com/Sp3000/Golfish), 23 bytes
```
\"thgir"H /
\"tfel"H.9\
```
[Try it online!](https://tio.run/##S8/PScsszvj/P0apJCM9s0jJQ0GfC8hOS81R8tCzjPn/HwA "Gol><> – Try It Online")
This is the same format as [my Klein answer](https://codegolf.stackexchange.com/a/172024/76162), but 2 bytes shorter. Maybe there's another 2D language out there that can golf those last 2 bytes off... But for now, this is as short as it gets.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 131 bytes
```
#######:$:#
:right#l>r#
$><<###e<i#
:left##f<g#
####   t#h#
#t##   ##t#
#h#t   ####
#g<f##tfel:
#i<e###<<>$
#r>l#thgir:
#:$:#######
```
[Try it online!](https://tio.run/##JY1LCgAhDEP3PYUQTyHFwwz4A1els5jTO1Gz6esjEHufby3cpJggyUbrjpkNErMqfdFBP0t1oGqD7HIIwdHJfhi8wt8Pg9y0UtYyk2BooVPNUWB5wnsbRr8Xb9b6AQ "Ruby – Try It Online")
[Answer]
# [Hexagony](https://github.com/m-ender/hexagony), 98 bytes
```
\[[email protected]](/cdn-cgi/l/email-protection);./r.
.)@.;...;.
ll..)gt.;$
;.i<;;;i);
e;@.)@e;.l
.;e;d.g|.|
rt/;t.;)g\
@f.#l.;..r
\.;\.;i\.i
```
[Try it online!](https://tio.run/##FYwxCsQgFAX7f41sYzM5wNvCg9gE4hpBNiAWCXh3Y2CmG@aI15bO/z1GwNPEWjGcRzC1UsClhj4m8ldSdrIoP5soiqGondTpVtuqWboUzP9YyvuoFtAkB/IYDw "Hexagony – Try It Online") | [Rotated 90°](https://tio.run/##DckxCkIxEEXRfrahzTT3L@BZzEKmEYwxEBRCCoW/95j2nFf53uvn/VsrY1DUSeM5Jbpj4ijRiLC8bLoBRp8Pl2vuhVBF1qRaNPcmfqrBYVDBpWFt5Nl1hbX@ "Hexagony – Try It Online") | [Rotated 180°](https://tio.run/##FYwxCsQgFAX7f41sYzM5wNvCg9gE4hpBNiAWCXh3Y2DKmTnitaXzf4@RCVmEiVUQZeHnLSQnmtZWrdMTu6KwgqJ3eEWTy5K@GdlnmslBKTb79zEdo66o4QljPA "Hexagony – Try It Online") | [Rotated 270°](https://tio.run/##DckxCkIxEEXRfrahzTT3L@BZzEKmEYwxEBRCCoW/95j2nFf53uvn/VsLrupnjmZDcqhgBzSdThpMlSo1E1UByKZc/pidvdyQLmkRtCjHXrxvmk8s6SqMyLX@ "Hexagony – Try It Online")
[Reversed](https://tio.run/##FYsxCsQgFAX7f41sYzM5wNvCg9gE4hpBNiAWCXh3Y@BNNfOOeG3p/N9jUFfU8ARDMPEO@4iWHJRiclnSNyMrKE7rFa3TE7uisJDcrLW2avX9l4Wft0zIIsyN8QA "Hexagony – Try It Online") | [Rotated 90° & Reversed](https://tio.run/##FckxCgIxEIbRfq6hTZpvD/BbzEGmEYzZQHAhpFhh7x5j@96ez2c5Pt85g6ZM9zBSQxpvzJ3qeUMGPBbewoaS0ms0TBT5iv8O5SJV26DqSoR1KUGBtXe1K3qd8wc "Hexagony – Try It Online") | [Rotated 180° & Reversed](https://tio.run/##FYsxCsQgFAX7f41sYzM5wNvCg9gE4hpBNiAWCXh3Y@BNNfOOeG3p/N9jBDSXA9n8j6UgqFbbqoZcCoaidlKnW5TH@SiKifyVlJ2sFHBp1h@b9v1PLOBpYq2M8QA "Hexagony – Try It Online") | [Rotated 270° & Reversed](https://tio.run/##HckxCgIxEIbRfq6hzTTfHuC3mINMIxizgaAQUijs3eNi@95ePvf6fn3XaiOPrisYVHBpWOKHGmzWpFo0zxUQqsjo8@FyTcuLxI3/biUaEcZzntgdyxgUdXKtHw "Hexagony – Try It Online")
Hexagony was kind of fun for this challenge, because a rotation or a reversal can drastically change the actual program. Each Rotation/Reversal is its own unique program. Some of the program execution paths are much more interesting than others.
I will admit that coming up with this took longer than it probably should have. I am pretty sure a shorter answer can be done in Hexagony, so good luck!
[Answer]
# [APL (dzaima/APL)](https://github.com/dzaima/APL), 181 bytes
The program has rotational symmetry so only two cases need to be checked
---
## Left
```
⍝⍝⍝⍝⍝⍝⍝  t⎕t⍝
t←'lef'⍝ ←←←⍝
⎕←t,     't'⍝
t←'righ'⍝r,l⍝
   ⍝     i e⍝
 ⍝ '     g f⍝
⍝' h     h '⍝
⍝f g     t ⍝
⍝e i     ⍝
⍝l,r⍝'hgir'←t
⍝'t'     ,t←⎕
⍝←←← ⍝'fel'←t
⍝t⎕t  ⍝⍝⍝⍝⍝⍝⍝
```
[Try it online!](https://tio.run/##ZY87DgIxDER7TuHOTThUJPKTjIQiVxyAbhEN5V4uFwkes0qzlgvneTyaxIdcb8/Y7nHOse3nJtLx/qpNFx2vD0vKDGzz0bYxhU0aCMXKS91bqXj1IGC2dUurRskJ3uykUHavbWeqTirxQbJtUep6kGQOtPxAJHTc1tI6I4076d87II2lBFvJccs5yVL7T93y3HP@AA "APL (dzaima/APL) – Try It Online")
## Right
```
⍝t⎕t  ⍝⍝⍝⍝⍝⍝⍝
⍝←←← ⍝'fel'←t
⍝'t'     ,t←⎕
⍝l,r⍝'hgir'←t
⍝e i     ⍝
⍝f g     t ⍝
⍝' h     h '⍝
 ⍝ '     g f⍝
   ⍝     i e⍝
t←'righ'⍝r,l⍝
⎕←t,     't'⍝
t←'lef'⍝ ←←←⍝
⍝⍝⍝⍝⍝⍝⍝  t⎕t⍝
```
[Try it online!](https://tio.run/##ZZA5DgMhDEX7nMKdG3IopLBJRIqQqzlAuqA0lLncXIT4ezQ0gywwz98L@Fe9PzZfnn7O/fOTvQ8hUu9qNxzv72GQcAyV1RdEWJiwnEDQB1h1DZGcSlu6QMV06uoOEikZEWNWi7KRTIy@xo/qiaKRM5@0WgBBV24lZWQ0V23ePtDVmU7nW7oaIi60XnO@7mI6FX5EvTn/ "APL (dzaima/APL) – Try It Online")
## Explanation
This is my first APL program so it is pretty simple. It only uses one trick that I think is interesting.
If we start by stripping away all the comments we get the following programs
**Left**
```
t←'lef'
⎕←t,     't'
t←'righ'
```
**Right**
```
t←'righ'
⎕←t,     't'
t←'lef'
```
Starting from the left program we do three things.
1. Assign `'lef'` to the variable `t`
2. Print the variable `t` and the letter `'t'`
3. Assign `'righ'` to the variable `t`
Now because it is the mirror the right program does these three steps but in the opposite order. This means that we print `'left'` for the left program and `'right'` for the right program.
The one trick here is that the `'t'` actually comes from a rotated copy of the code. If you look at the third colum of our code you will see that it is `'t'`. We reuse this `'t'` in the rotated versions to append the `t` that is needed.
[Answer]
# [Alice](https://github.com/m-ender/alice), 25 bytes
```
}/"regttoo {
{/"lifh""@@{
```
Left: [Normal](https://tio.run/##S8zJTE79/79WX6koNb2kJD9foZqrWl8pJzMtQ0nJwaH6/38A "Alice – Try It Online"), [1/4 turn clockwise](https://tio.run/##S8zJTE79/7@6lktfn0tJiSuniCszlSstnSujhEsJiPK5HIBIgau6@v9/AA "Alice – Try It Online"), [1/2 turn](https://tio.run/##S8zJTE79/7/awUFJKSMtM0dJv5qrWiE/v6QkPbVISb/2/38A "Alice – Try It Online"), [1/4 turn counterclockwise](https://tio.run/##S8zJTE79/79WX6koNb2kJD9foZqrWl8pJzMtQ0nJwaH6/38A "Alice – Try It Online")
Right: reflect across [horizontal axis](https://tio.run/##S8zJTE79/79aIT@/pCQ9tUhJv5ar2sFBSSkjLTNHSb/6/38A "Alice – Try It Online"), [down-right diagonal](https://tio.run/##S8zJTE79/7@2mktfn0tJiasohys1kys9jaskg6tEiSsfiBy4FBy4qqv//wcA "Alice – Try It Online"), [vertical axis](https://tio.run/##S8zJTE79/79aXyknMy1DScnBoZqrVl@pKDW9pCQ/X6H6/38A "Alice – Try It Online"), [up-right diagonal](https://tio.run/##S8zJTE79/7@6mstBgcshn0sJiEq4Mkq40tK5MlO5coq4lJS49PW5qmv//wcA "Alice – Try It Online")
## Explanation
This program has three parts. The first part is the three `{`s and one `}` on the corners. The `{` turn the IP left until it reaches the `}`, at which point it turns right. In the reflected version, the IP goes along the top row in the original program. In the original version, turning right will immediately hit the adjacent `{`, pointing the IP along the bottom row in the original program.
Next are the two slashes in the second column. If the program is horizontally oriented, either type of slash would simply change to ordinal mode, sending the IP in the same left/right direction it was already going. If the program is vertically oriented, the IP bounces around quite a bit more, but making them both forward slashes gives the same end result. (Two backslashes would give the opposite result, and one of each would create an infinite loop.)
The rest of the program is straightforward. The IP in ordinal mode bounces diagonally, so either `"left"o@` or `"right"o@` will be run depending on how this section was entered.
[Answer]
# [Haskell](https://www.haskell.org/), ~~461~~ 379 bytes
*82 bytes saved by [Ørjan Johansen](https://codegolf.stackexchange.com/users/66041/%c3%98rjan-johansen)*
```
--_----------mppr--
-- ----------a  l--
rl=p  p--   niam= _
p m="left"-- n==p--
p a="right"++ "" --
main  =putStr rl --
--n +r       =iep--
-- -+t       pgf---
-- -"S       uht---
-- "tt       tt" --
---thu       S"- --
---fgp       t+- --
--pei=       r+ n--
-- lr rtStup=  niam
-- "" ++"thgir"=a p
--p==n --"tfel"=m p
_ =main   --p  p=lr
--l  a---------- --
--rppm----------_--
```
[Try it online!](https://tio.run/##RdDLrcQgDAXQfaq48hZRgqtIARELkqAxyOI59Wc8A/Pi5cH4d6a/Vxa57xi3@B9Vtce4xIjHEiBuXVgB9SeglVQZ26KoTJJ3I@fG7K9uiamX4zQKAUReaampNID1stU6uuDboyF0jOCSdfYNNk2PPU6jddp12jSyX54ZjXrRzmvaSnHafugvL0zTXHhaD2ijnvhcPt2lPNb79iCEQHYepRMn6Ocvc/MqZHsW4uq2gcd6zp8DsXTPEyA9Jxx9u2p9zK9@328 "Haskell – Try It Online")
Since this one has 4-fold symmetry you only need to test the mirror:
```
--rppm----------_--
--l  a---------- --
_ =main   --p  p=lr
--p==n --"tfel"=m p
-- "" ++"thgir"=a p
-- lr rtStup=  niam
--pei=       r+ n--
---fgp       t+- --
---thu       S"- --
-- "tt       tt" --
-- -"S       uht---
-- -+t       pgf---
--n +r       =iep--
main  =putStr rl --
p a="right"++ "" --
p m="left"-- n==p--
rl=p  p--   niam= _
-- ----------a  l--
--_----------mppr--
```
[Try it online!](https://tio.run/##RdBBrsQgCAbg/ZziD1vDEThFD9C4sK0ZNcRHz99HrTPDji8g4BH/3qmU62LuqpW/sTK/mAsQfwa3FVJjboAnCqiU7nUq0hzItlRIKtQNRAiB7NhzJ4mPlY5ui50qQMux3r0pezKiB7Qxl7ddp1kYc93sOKctNA1k9qkzmsa0TDsP42nhU6f79lhD6NMkJ3V7DhM9fUPfs9zvKaJQz/thFMJ90rAqVNJm5C83kbu3F7m/w@E5TLCOud@IQBlz159V1c58Xf8 "Haskell – Try It Online")
This is a start. It is far from ideal, but there are a few interesting things going on here. Haskell is a certainly an interesting language for this challenge. I look forward to an answer that beats this be it mine or someone else's.
[Answer]
# [Python 2](https://docs.python.org/2/), 209 bytes (14 x 14)
Normal (left):
```
##########sps#
s="left"##=r=#
print s###"i"#
s="right"#rnl#
####      ite#
###"      g f#
#"#t      hst#
#tsh      t#"#
#f g      "###
#eti      ####
#lnr#"thgir"=s
#"i"###s tnirp
#=r=##"tfel"=s
#sps##########
```
[Try it online!](https://tio.run/##PY5LCkQxCAT3niLoDWaf4@QjBCeomzl9xmfg9a4opXv/fH7lcw69sW0EVnG17khUtRJsZfFiYZExrfKYoVUWwfNVMuwtES@O0gOR/OI0D3SbFz0MUI@rTHQFNueLlLhECX0OVqwG2R4LiwvrhtwWureV9ln@5pw/ "Python 2 – Try It Online")
Reflected (right):
```
#sps##########
#=r=##"tfel"=s
#"i"###s tnirp
#lnr#"thgir"=s
#eti      ####
#f g      "###
#tsh      t#"#
#"#t      hst#
###"      g f#
####      ite#
s="right"#rnl#
print s###"i"#
s="left"##=r=#
##########sps#
```
[Try it online!](https://tio.run/##Rc9LDgQhCATQvacw1A1673H8kBjHAJs5vaOS9LB7VAzl/Fr7jGct6FS8E5AkAWQld0oaQEx7rdEGywzoQ3bYKstNs3G8429LrE66NG1OA20SzNnUNvcVZ43lEk62jKCJhGszgoyOMIWHxdPz9Dlpz2WHt2341z9/WesH "Python 2 – Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 55 bytes
```
####‛‛#
‛⟑ǒ#¬⟑#
‛¬ẋ#ẋǒ#
#######
#ǒẋ#ẋ¬‛
#⟑¬#ǒ⟑‛
#‛‛####
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%23%23%23%23%E2%80%9B%E2%80%9B%23%0A%E2%80%9B%E2%9F%91%C7%92%23%C2%AC%E2%9F%91%23%0A%E2%80%9B%C2%AC%E1%BA%8B%23%E1%BA%8B%C7%92%23%0A%23%23%23%23%23%23%23%0A%23%C7%92%E1%BA%8B%23%E1%BA%8B%C2%AC%E2%80%9B%0A%23%E2%9F%91%C2%AC%23%C7%92%E2%9F%91%E2%80%9B%0A%23%E2%80%9B%E2%80%9B%23%23%23%23&inputs=&header=&footer=) | [Try it flipped](https://lyxal.pythonanywhere.com?flags=&code=%23%E2%80%9B%E2%80%9B%23%23%23%23%0A%23%E2%9F%91%C2%AC%23%C7%92%E2%9F%91%E2%80%9B%0A%23%C7%92%E1%BA%8B%23%E1%BA%8B%C2%AC%E2%80%9B%0A%23%23%23%23%23%23%23%0A%E2%80%9B%C2%AC%E1%BA%8B%23%E1%BA%8B%C7%92%23%0A%E2%80%9B%E2%9F%91%C7%92%23%C2%AC%E2%9F%91%23%0A%23%23%23%23%E2%80%9B%E2%80%9B%23&inputs=&header=&footer=)
The code is rotationally symetrical.
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), ~~649~~ 188 bytes
### Unflipped, Unrotated
```
:-%    l :%r     %-:
write(%e%-(i %(etirw
left).%f.weg%.)right
%      t)rth.      %
%      )tiit)      %
%      .htr)t      %
right).%gew.f%.)left
write(% i(-%e%(etirw
:-%     r%: l    %-:
```
[Try it online!](https://tio.run/##XY5LCgUhDAT3niKbgFmYA3ifqAFhHnkBj@84HzeTVdOQrvrZ0Y@a/kPnzAlhXYeMdgXAlMMwdYkomKICRnG1EboUJ8bCQyoymdbm4X4GcDJv/GTcJbmq06fk5ka@y3tkjVYZXNboxdh00JiWwkt/PcEwL9nHc84T "Prolog (SWI) – Try It Online")
### Unflipped, Rotated
```
:wr%%%lw:
-ri   er-
%ig   fi%
 th   tt
 et   )e
 ()   .(
 %.   %%
  %.)tfel
right).%
%(etirw-:
:-write(%
 %.)thgir
left).%
 %%   .%
 (.   )(
 e)   re
 tl   it
%ie   gi%
-rf   hr-
:wt%%%tw:
```
[Try it online!](https://tio.run/##Hc4xCkQxCATQ3lOkEZIi/wC5j0mEwC6u4PGz4@8eIjPztc/5rP4LvXeEMfOJQd20lCLWiXVBU5mKb8i9UBGHmkC1QU@F@IGYIbD5lEOma3t7cOMqrhZ90Ohh6lKZ3re91OjIfN8yhTMvU2rmtUyW7LBs8wMpFrAKtLCq24Q2lo5wrPcY9/4B "Prolog (SWI) – Try It Online")
### Flipped, Unrotated
```
:-%     r%: l    %-:
write(% i(-%e%(etirw
right).%gew.f%.)left
%      .htr)t      %
%      )tiit)      %
%      t)rth.      %
left).%f.weg%.)right
write(%e%-(i %(etirw
:-%    l :%r     %-:
```
[Try it online!](https://tio.run/##XY5BCsUgDET3niKbgFmYA3ifqAGhJT/g8f21rZtmNTzIvDnt6EdNv6Fz5oSwzjBDXwFTDsPUJSJoTCgYxdVGMK3NibHK4IJMXYqH5xm4uZE/GTckV3X6QCfzxhuujquy8JB6Vd6KbRdMUWHb350dMhq8O@f8Aw "Prolog (SWI) – Try It Online")
## Flipped, Rotated
```
:wl%%%rw:
-re   ir-
%if   gi%
 tt   ht
 e)   te
 (.   )(
 %%   .%
left).%
 %.)thgir
:-write(%
%(etirw-:
right).%
  %.)tfel
 %.   %%
 ()   .(
 er   )e
 ti   lt
%ig   ei%
-rh   fr-
:wt%%%tw:
```
[Try it online!](https://tio.run/##Hc5BCkUhCAXQuatwItSgFtB@rITgPfxCy@/f3uwg6r2vP@sZ5bftnLaXiPhuVFyZ2byQWIeGCXEENIOJNUOhUKpQTpAIVIVpaY8M3FnNMYc5tbLdQpOQJA3zXRq5jfktEn@LXde9wBe5s3Qz6v2sfjNuWhi00EBsQIpWxSfU0bTtQPvY7Zw/ "Prolog (SWI) – Try It Online")
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), ~~239~~ ~~223~~ ~~209~~ 181 bytes
```
%%%%%%%  l:r%
right).% e-i%
:-write(%fwg%
left).%  trh%
  %      )it%
 %(      .t)%
%.e%     %e.%
%)t.      (%
%ti)      %
%hrt  %.)tfel
%gwf%(etirw-:
%i-e %.)thgir
%r:l  %%%%%%%
```
[Try it online!](https://tio.run/##JYpBCgQhDATveYWXBnPQB/ifqAFhlmzA57vZsS7povKxZz2jfLeeg0tKqxnIdEzniiRFQa1sU5eMvgdoSX9TcpuglGL9YfUw5GvVGYQqN0JqGHu9MYe48pXY0zxuZe@yCGN3ZHG1XRpBi7xpDjWCtRWfl3PODw "Prolog (SWI) – Try It Online")
Since the program has 4 fold symmetry you only need to check the mirror:
```
%r:l  %%%%%%%
%i-e %.)thgir
%gwf%(etirw-:
%hrt  %.)tfel
%ti)      %
%)t.      (%
%.e%     %e.%
 %(      .t)%
  %      )it%
left).%  trh%
:-write(%fwg%
right).% e-i%
%%%%%%%  l:r%
```
[Try it online!](https://tio.run/##JY5BCgQhDATveUUuDXrQB/ifqAFhhmzA57syqVt1Xfq1Zz2j/LaeA2uLGQFBizBq9jnUCGN3JHG1XRphmvMXuyyCa@YPMBOy17CEa1UQSSqIkSJVz9c4Emd10JLuud7FbYJa2aYuCX0PkOmYX5Si91nAvJrhnD8 "Prolog (SWI) – Try It Online")
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), ~~1331~~ 1055 bytes
*-276 bytes thanks to [Ørjan Johansen](https://codegolf.stackexchange.com/users/66041/%C3%98rjan-johansen)*
```
// ////////////;/;/////////// //
// ////////////S/S/////////// //
  module m////mtmt////m eludom
//o///////////=a=a///////////o//
//d///////////"r"r///////////d//
//u///////////tttt///////////u//
//l///////////f#h#///////////l//
//e///////////emgm///////////e//
// ///////////loio/////////// //
//m///////////"drd///////////m//
//////////////=u"u//////////////
//////////////ml=l//////////////
//////////////#eme//////////////
////////////// =#=//////////////
;Start#module= 0   #m="left"=m//
//m="thgir"=m#   0=eludom#tratS;
;Start#module=0   #m="right"=m//
//m="tfel"=m#   0 =eludom#tratS;
//////////////=#= //////////////
//////////////eme#//////////////
//////////////l=lm//////////////
//////////////u"u=//////////////
//m///////////drd"///////////m//
// ///////////oiol/////////// //
//e///////////mgme///////////e//
//l///////////#h#f///////////l//
//u///////////tttt///////////u//
//d///////////r"r"///////////d//
//o///////////a=a=///////////o//
  module m////tmtm////m eludom
// ///////////S/S//////////// //
// ///////////;/;//////////// //
```
[Try "left" online!](https://tio.run/##hVNNa8MwDL3nVwj73Kb3osEYhR32cegPGG7jNAErLq4N@/eZmlKq2FsmH2LJT4otvXcwl24cjybCE9C6P7rKfp99iPDytnv@@Hr9fN9h7c@xPjprhuqxrQ/9wDuCFV1gNUSgal2btU9xHOsaamFbXg/joyoD7HnNAQDkm@Qs0DVCkeL0BetS4wmAK3iRggaNcP30i0ZEVFBBuM0ESCIS2YSbJoATkVZ3WrhuAlgRsXQi6RbPdL73RR9kimqCvDNNAGmYVJpHMgA5dIsAbckuAgA1ZoDtPpoQ9W0gCBsA0ITK2TYqvF2S3did@sC@5uMN3uakYzBxv80q3AuE/tTNKrTW3QtAViHrg0ZYfAW/Ui8CuE@0COBOYwGQKTwrVQxL3oqn7Ypxy@YzX2xBGJnCjGsLyv1LWkkhZr0qaC9JyLrBTDhz6bHyqJAe/KndX9Q9V//16Ac "Bash – Try It Online")
[Try "right" online!](https://tio.run/##hVPBasMwDL3nK0R8bt178WCMwg7ddugHDLdxmoAVF1eG/X2mpbSVY8jkQyz5WZGl94722o3jyRK8AK77k6/czyVEgrf97vXz@/3rY2d0uJA@eWeH6rnVx37gHcIKr7AaCLBaa7sOicZRa9BP2/ISxkdVDjjwmgEAMDTJO8C/CCFNXwTnUxMQgDMEccUaa4Qbpl80IhLrWAu3mQBJRIhNuGkCeBFRnWqF6yeAExE8o3Rd8czQB1/0AWVVsZFF4gSQlupk8sgM4I3HRYBDpxYBRhkoAGhqap2vDSoA2IC5jUFRtHTYVtsD2UjqNjGzYYjiG7E/d8RXHhm6cx/vKRYzwD2Fd@0jQ8YQrnLxFcplsygByJ1a7gP3uuyDcGueVjEs2TrP8y7GnTGEGVMQRlbVMucKyv1LWlkVsz4WtJdVsW7sTDi59Fh5VEgvY0iu3lLdM/3z0S8 "Bash – Try It Online")
This was difficult for many reasons:
* Clean *requires* a file header `module <filename>` be present at the start, *and only the start* of the file. Unfortunately, this means that for the rotations of the mirrored program to be valid it also has to appear at the bottom of the file. To make this worse, `module ..` is invalid for global, `let .. in`, `where ..` and `with ..` definitions; and the token `module` appearing if it hasn't been defined causes an error.
* Both block comments and line comments nest: `/* /* */` leaves one level of comment open, and so does `/* // */` (as well as commenting the rest of the line out).
* The same function can be defined multiple times, but only directly after itself.
Fortunately, we *can* define `module` as something in a `#..` (let-before) expression, which is all we need. Because Clean doesn't type-check alternatives that are never used (and a variety of other equally unused things), the requisite second definition of `Start` can be complete garbage. This allows us to use the second `Start` to consume the module header at the bottom of the file because Clean treats `m module m` as calling the function `m` on `module` and `m` (which since we've defined `module` and `m`, doesn't cause an error). It doesn't matter that `m` is a string and not a function, because the `Start` alternative never gets type-checked.
This is easier to see if you look at it through the compiler's eyes:
```
module m;
Start#module=0#m="left"=m;
Start#module=0#m="right"=m module m
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 341 bytes
```
Ẹw"thgir"∧"left"wẸ
w"              "w
"                "
t                t
f                h
e                g
l                i
"                r
∧                "
"                ∧
r                "
i                l
g                e
h                f
t                t
"                "
w"              "w
Ẹw"tfel"∧"right"wẸ
```
[Try it online!](https://tio.run/##bdDBCcMwDAXQ@5@iaIRu1ARbMggKwmCyQTbpCiHbtIs4pj5Fto6Pjy39xV6rbPrmZ63f8yiUhZPRb/@QhpipNEShx22owEkzZE8Z0ZMgeGKopzQ@b2grjX8OuZaCjbnkScGeAsRTnB01OX1SUC8zBv13aYmll1nrBQ "Brachylog – Try It Online")
[!enilno ti yrT](https://tio.run/##jdDBCcMwDAXQ@5@iaIRs1BRbMggKwmCyQTbJCiHbtIs4pjlV9iECXx7G1v@zPV@y6JunWj/HXijHoPRdN7LEkqk0RKHH31CBk2bInjLEUwR7CkieFNY/3/3YlkQ7N24a1FNC8MSInmQUahB9UNBVpnCyX5sa4lVmrSc)
Takes advantage of Brachylog taking the main predicate to be the one on the first line and not much caring about the other lines beyond requiring that they can compile. Unreflected, it prints an empty string followed by "left" on the same line, and reflected it prints an empty string followed by "right" on the same line. I'm tempted to think there might be a way to make a (usefully) non-square version using `ṇ`, but that might be plenty tricky without trying to make it work differently under reflection.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 181 bytes
```
#########tpt#
t=:left##=u=#
puts t###:t:#
t=:right#rsl#
####     i e#
###t     gtf#
#t#h     h#t#
#ftg     t###
#e i     ####
#lsr#thgir:=t
#:t:###t stup
#=u=##tfel:=t
#tpt#########
```
[Try it online!](https://tio.run/##NY5LCgAhDEP3PYWQWwheZsAfuJAaF3N6xxYmqz5C0uh@3nPwi5MQpjhyIZB2gszNFS4gMrqnvTZC14BYJJh6yE50qiyXiObU7iUorE7WJMg3YYLTWAq22jUmiv@xpsU9xTeAJQ/3bN@vcz4 "Ruby – Try It Online")
This is a port of Curtis Bechtel's Python answer to Ruby, golfed a little more.
Actually, his Python program is a polyglot and runs on Ruby too, so my first answer was a copy-paste of it, but it seemed unfair. So I wrote a script that generates a new answer starting from a base script. You can try it here:
[Build your own](https://tio.run/##dY/NDsIgDIDvPMWSLbJJhibOixlPYjygQTeDkxT2qz77BEVjNPYApd/XpkC97ceO5TmnWsnSBNFsDF@BDFtJsTc2U7XRgfE1KA@FCUeOUM86euIqnqx2BQedUAO80uqshS8fz2WV@BxEI0CLBA22yz@@Ucv6fwhJFsdzShePeZcrv3ZrviG9PW7EgewNWgdw4AI7gWReWXwqZLkhg@u2sx//k88Lp2mKkWi4DOQ0miEETL6WehrwI4IVxzs)
[Answer]
# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~89~~ 55 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
'…¸q©ƒ'
ƒ     …
©     ¸
q     q
¸     ©
…     ƒ
'ƒ©q¸…'
```
Very basic approach. Outputs in full lowercase.
[Try it online](https://tio.run/##MzBNTDJM/f9f/VHDskM7Cg@tPDZJnevYJAUQAApxHVoJZh7awVUIZhRyHdoBEVnJBZQHM49N4lI/NunQysJDO4BC6v//AwA) or [try it online reflected](https://tio.run/##MzBNTDJM/f9f/dikQysLD@141LBMnQtIKIDAsUlch3aAWYdWchWCGYVch1ZCRHZwHZsEZgFVc6kDiUM7Cg@tPDZJ/f9/AA) (each rotation is the same).
**Explanation:**
```
'…¸   '# Push the dictionary string "left" to the stack
   q   # Stop the program (and output the top of the stack implicitly)
       # Everything else after it is ignored
```
Reversed:
```
'ƒ©   '# Push the dictionary string "right" to the stack
   q   # Stop the program (and output the top of the stack implicitly)
       # Everything else after it is ignored
```
[See this 05AB1E tip of mine (section *How to use the dictionary?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `'…¸` is `"left"` and `'ƒ©` is `"right"`.
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 131 bytes
```
 .Cq"tfel"
""`KT?`qC".
lC       `C
eq       Kq
f`       T"
t?       ?t
"T       `f
qK       qe
C`       Cl
."Cq`?TK`""
 "left"qC.
```
[Run and debug it](https://staxlang.xyz/#c=+.Cq%22tfel%22+%0A%22%22%60KT%3F%60qC%22.%0AlC+++++++%60C%0Aeq+++++++Kq%0Af%60+++++++T%22%0At%3F+++++++%3Ft%0A%22T+++++++%60f%0AqK+++++++qe%0AC%60+++++++Cl%0A.%22Cq%60%3FTK%60%22%22%0A+%22left%22qC.+&i=&a=1)
This is the "right" variant.
[Answer]
## Batch, ~~438~~ 321 bytes
```
:::::::::::::@@@:
@echo left&: eee:
@exit/b&:    cxc:
@echo right&:hih:
:  :         oto:
:: &          / :
:& t         rbl:
:t h         i&e:
:f:g         g:f:
:e&i         h t:
:lbr         t &:
: /          & ::
:oto         :  :
:hih:&thgir ohce@
:cxc    :&b/tixe@
:eee :&tfel ohce@
:@@@:::::::::::::
```
Explanation: A `:` is used to indicate a label, which is as good as a comment, so as the program has rotational symmetry the only difference between the two versions is which of the `@` lines is first, in which case either `left` or `right` is output before the script exits.
I did try creatively overlapping the rotated lines with each other but my attempt actually ended up with a larger grid.
Edit: Saved 117 bytes thanks to @ØrjanJohansen.
[Answer]
# [Runic Enchantments](https://github.com/Draco18s/RunicEnchantments/tree/Console), 116 bytes
```
> \ !U\L
 ...@..
 \.R"""
 @""trl
 "lrhie
 teiggf
 ffgiht
 ethrt"
 l"t""@
 " "R.\
 .\@.@.
DR\!!/R
     !!
```
[Try it online!](https://tio.run/##Fcw9CsUwDAPgPaewdQC/G5QMHTsFunkr@YPQIbjnz3M0fQih@b39WesgJb71CiQiUYQCqSQAjgjYHA6M2Xp2WO61FkcptTdzZGvT9njAgLjHhCTqEI3@SOFMyvxL3uww01p/ "Runic Enchantments – Try It Online")
[And reversed](https://tio.run/##Jcw7CkMxDETR3quQZgHKDoKKlK8ypFMX/AOTwuit35HJVKe4zLq/47P3ZW8mo2ciIRURSgQgiwXmckADZfQ1EaitjeIB76PVemJf3UtAAccMmGTQiUVF7RzmB7PlVyJm@m/vHw "Runic Enchantments – Try It Online")
Not exactly a port, but utilized [Post Left Garf Hunter's Klein 000 answer](https://codegolf.stackexchange.com/a/172011/47990) as a starting point, given the typical near-compatibility of the two languages (most commands are the same and the edge wrapping in Runic is identical to Klein 000). The only issue was that Klein IPs always start from the top left and Runic's do not. As such the `.` are all part of the original code and still treated as NOP by Runic, while the  are NOPs I had to add as part of controlling the flow.
Prints `"left"` in all 4 rotations and `"right"` when mirrored (and in all four rotations thereof). Two middle columns were completely unused after my modifications, so I was able to remove them.
In theory a rotation with lots of trailing whitespace could be used for a lower byte count (eg. [this variant](https://tio.run/##PYu5DYAwDAB7TxF7ALMBckFJZYnOHconRRRRmN@kiLj27vr71Nv9BGNqMQ0SY0W4mHrNZRDLhoBCo@TaSRkhsC4nOK@1BbNpbIYpNmKFPfwc7h8 "Runic Enchantments – Try It Online")), however the spaces are needed to correctly rotate the structure using external tools and so I included them.
Below variants contain the unused chunks that were removed, but are otherwise identical:
[All four lefts](https://tio.run/##TZE9jsQgDIV7n8J2P84NRhSTVFQodO5W@UGKtkDs@bOGRUuoDMbPz5/zz3f6um@PjwMqfG17YacSCKJwTsdZWNxEQI7LeaTMQQjBizhel9mz2o2U/bys7EQiAkrohY6qZhdF1ZpT09m3iyUgvEfvD8Lr9bIXRfIU1dtXERWTtCrzw8LMFjpm70q@LOQrz3ymzcKypWU9jt3CfT/WJZ3Fwq2cPOdSyy4uzjO7WoamFaS7aT0QPkEpEk3mqjsi@rNk1v7PGzAMRtWYYh9HFPDByHLxwchyg5HNRg9GQJOTXigRKAxGCs/9@D8/ZqzvC8NE5lrDx0Zpk@ighYMWN1ql0iqN1llp7Y3WUWltjVaqtK5GKw9aPGhh7VEX4jXalmxX7/v@BQ "Runic Enchantments – Try It Online"). Outputs `leftleftleftleft` (the fact that all four can be run like this is coincidence).
[Right 1](https://tio.run/##Jc0rDgMxDARQnlPYPoB7g8qguygo2mVmVX5SVBC5508dddAjMzO/n/5eK@qNEUHhGYBBWJkZAhARU2J1jmkSicSZe6NjDnKWWq@zZ3Na6@dVS9k1mwc1y04himI0nMrJ12DXeD@I7ov0QLxR0ysAIvyz1g8 "Runic Enchantments – Try It Online"), [Right 2](https://tio.run/##TY07CsMwEET7PcVqDjC5QdgidqVK2N12wR@BSSGU8ysyGJzphse8Kd9Pfremf4kSEt1Q1@UAXcLDiLpvuYCzaGBCydteYaE3RxzGCUZG0Zk0TOMQ4Seza5aoou56KbtTE3Esa3f4yV73@7O1Hw "Runic Enchantments – Try It Online"), [Right 3](https://tio.run/##Jc07DsMwDAPQPaeQeAD1BoWGJpMnI9m0Ff4BQQfDPb@rpJzeQrJ/P@09J/3DTMsrGh/Mj0gLiamYqDhBEEQx54mhAVBnGhVrH3DmXPat1eEcqW17KfmqnX1FbcmpQNDRT6dJ9DVcNZH7wS@eZMSBDwtz/gA "Runic Enchantments – Try It Online"), [Right 4](https://tio.run/##TYw7CsMwEET7PcVqDjC5QdgidqVK2N12wR@BSSGU8ysyDiGvGx7zyvuVn63d9cdDRemGui4HmFScxLGsFep@uoSSt73CgkpwxGGcYOSsEknDNA4Rfrre2LdckNjXzO@Ndgu9eSXNmYJE/aO1Dw "Runic Enchantments – Try It Online")
[Answer]
# [Gol><>](https://github.com/Sp3000/Golfish), 342 bytes
```
 8A_          _A8
9       ""       9
A       LR       A
_       EI       _
        FG
        TH
        "T
         "
 "TFEL" HH"RIGHT"
 "THGIR"HH "LEFT"
        "
        T"
        HT
        GF
_       IE       _
A       RL       A
9       ""       9
 8A_          _A8
```
Wow! That took longer than I expected, halfway through I realized the reflection was *vertically*, not horizontally like I had been coding for! I'm pretty sure that this works, but if I made a mistake please let me know. This can most likely be golfed a ridiculous amount more, I just took an extreme brute force method to do so. The shape itself is actually a square, it is technically symmetric, except on across the x-axis, so when it flips, it returns "RIGHT" instead!!!
The character that made this program possible is the 'A', which allows for teleportation to the beginning of a certain line!
[Try it online!](https://tio.run/##bZA7CsQwDER7n0LMKZLShW0ZXBn36fKBQIrcHweCpV1Wq2r0YCRmtutcj3vvnSa/kM7iJ3LzWIAhZueHKnUI78QVsnidXIlJlKLGBqEZRPggtBgKiBk1J254EadcwUwoIb7o1/f1EQax/ZiiIgmUgwaS2LVo7D/l2Aqp9wc "Gol><> – Try It Online")
]


[Question]
      [
## Introduction:
I think everyone knows what a Lava Lamp is, but in case they do not:
[![enter image description here](https://i.stack.imgur.com/dILgU.gif)](https://i.stack.imgur.com/dILgU.gif)
[(Image source)](http://api.ning.com/files/qrbliHRnvdw1Rjlr3hjMBmZV8cArQzQHkjqIHMFYV8KWdSCn2lBsAOS6i8s6TltTPjR1JKi9OOFVeYuHqDer7HzWmrvpdteJ/1614584823.gif?xgip=108%3A0%3A324%3A324%3B%3B&width=48&height=48&crop=1%3A1)
They're basically glass tubes that contain wax in a translucent liquid. The bottom part is heated when the lamp is turned on, causing a change in density and thus the wax floats to the top. When it cools down, it falls down again, causing the effect we see above.
It usually takes about 45-60 minutes for the base of the lamp to rise in temperature high enough to change the solid wax to liquid wax (if the lamp is located in an area at room temperature).
[More information on Wikipedia, which is also used as source for some of the text above.](https://en.wikipedia.org/wiki/Lava_lamp)
## Challenge:
Given a positive integer `n` indicating the amount of minutes that have passed since we've turned the Lava Lamp on, output a random state of the Lava Lamp based on integers on five levels.
For this challenge we'll say the Lava Lamp contains 1000 units of wax in total, and we have five levels where the wax can be at.
1) If `n` is below 45, the Lava Lamp is still heating up, so the output will be four empty lines with `1000` at the bottom:
```
1000
```
2) If `n` is in the range `[45, 60)` the Lava Lamp has increased in temperature enough for wax to move around, but no very high yet. The wax can reach up to and including the third level.
3) If `n` is `60` or higher, the wax can be at any of the five levels.
So given the positive integer `n` as input, we'll output a [random](https://codegolf.meta.stackexchange.com/a/1325/52210) state with the three rules above in mind.
**Here are some example outputs:**
Possible outputs for any `n` that is `>= 45`:
```
523
106
371
```
```
913
87
```
Possible outputs for any `n` that is `>= 60`:
```
73
113
312
5
497
```
```
284
55
637
24
```
Constant output for `n` that is `<= 44` (and possible output for any `n`):
```
1000
```
## Challenge rules:
* There can be empty lines, even though the level above it is not empty.
* Just `0` isn't allowed on any line. Should be empty instead.
* Output is somewhat flexible. You are allowed to output a list/array of strings/objects instead of a new-line delimited result as above. The reason I say strings/objects is due to the rule above. An empty line should be `""`, `null`, `[]`, etc., but cannot be `0` or a negative integer (nor can it be `false`) (I.e. `["", "", 913, "", 87]` for `n >= 45`). You are also allowed to reverse the output (I.e. `1000\n\n\n\n` instead of `\n\n\n\n1000` or `[87, null, 913, null, null]` instead of `[null, null, 913, null, 87]`).
* The numbers should all be integers. The can be decimals with `0` as decimal value, but none of the numbers should have any decimal digits, and the integers should always sum to exactly `1000`.
* All possible [random](https://codegolf.meta.stackexchange.com/a/1325/52210) outputs based on `n` should have a non-zero chance of occurring.
* A trailing new-line (so there are six lines of output) is allowed.
## General rules:
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
* [Standard rules apply](https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet/2422#2422) for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
* [Default Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* If possible, please add a link with a test for your code.
* Also, adding an explanation for your answer is highly recommended.

[Answer]
# [Python 2](https://docs.python.org/2/), ~~117~~ ~~113~~ ~~108~~ ~~107~~ ~~106~~ 105 bytes
```
from random import*
def f(n):a=['']*5;exec"i=randint(0,(n>44)+(n>59)<<1);a[i]=(a[i]or 0)+1;"*1000;print a
```
[Try it online!](https://tio.run/##RYyxDoMgFEV3v4K4yNMOiEq1aH/EOJAqkUEwhKH9evpkcTn35eS@e/7C7iyPUXt3EK/simGO0/lQZuumiaYWXmqai2IpO7l9t09upqtnbKDsQe27baHC6AYYxxqkms0y0YvOEwZVLfOyZozJ0@MLUVFTBpmmDTIpvHHiYpfY3x43kSL1Bb@94LwZ@vYJ8Q8 "Python 2 – Try It Online")
Returns a reversed list (bottom first)
---
Version inspired by the stackoverflow [answer](https://stackoverflow.com/a/8064754/1682559) in the comments (edgecases are more likely):
# [Python 2](https://docs.python.org/2/), 129 bytes
```
from random import*
def f(n):a=sorted([1000]*5+sample(range(1001)*5,(n>44)+(n>59)<<1));print[y-x or''for x,y in zip([0]+a,a)[:5]]
```
[Try it online!](https://tio.run/##RYxBDoIwEEX3nKI7ZwCTUigCohchLJpAtYm0TWEBXh5HNmzen7zM/35b3s6KfdfBTSwoO1CYybuwxNEwaqbBYqMeM4lxgC7jnPexTGY1@c8IVHiNQDLDWKZgn0WBCYWssW0zxLsPxi7ddl2ZC5eLdoGt6caMZV/joeN9olKFXSP7ftfAMdKQE48W3bT2pzxYnZ7mieXxX4rTl0LkdVXccP8B "Python 2 – Try It Online")
[Answer]
# JavaScript (ES6), 78 bytes
Returns a reversed array where empty levels are filled with a space.
```
t=>(a=[...'     '],g=k=>k?g(k-1,a[Math.random()*(t>59?5:t<45||3)|0]++):a)(1e3)
```
[Try it online!](https://tio.run/##ZcxNDoIwEEDhvadwx4xAA6E1Qmw5gScgLCb8KtgaaFz17lWXpm/5Ld6D3rR32/1lU236wY/SW6mAZMMYi46/ojaZ5CLVUk@wpHlCzY3szDbSvXkCnsAqUdaislcunCvQZW0cY0UI@VCg74zezTqw1UwwQoZ4@BfOQxIBiTKgc/i6fMl/AA "JavaScript (Node.js) – Try It Online")
### Commented
```
t => (                      // t = input
  a = [...'     '],         // a[] = output array, initially filled with 5 spaces
  g = k =>                  // g = recursive function taking an iteration counter k
    k ?                     //   if k is not equal to zero:
      g(                    //     do a recursive call:
        k - 1,              //       decrement k
        a[                  //       update a[]:
          Math.random() * ( //         pick a random slot:
            t > 59 ? 5 :    //           among all 5 slots if t > 59
            t < 45          //           force the 1st slot if t < 45
            || 3            //           among the 3 first slots otherwise
          ) | 0             //         round the above result to an integer
        ]++                 //       increment the wax amount on this slot
      )                     //     end of recursive call
    :                       //   else:
      a                     //     stop recursion and return a[]
)(1e3)                      // initial call to g() with k = 1000
```
[Answer]
# [R](https://www.r-project.org/), ~~85~~ 84 bytes
```
function(n)write(ifelse(t<-table(cut(runif(1e3,2*(n<60)+3*(n<45),5),0:5)),t,""),1,1)
```
-1 byte thanks to @Giuseppe
[Try it online!](https://tio.run/##JYpBCsMwDATvfUZOUquA3TQ5FH8mCRIIglpcmT7ftRtYhh12c5U0Vim2u74MDL9ZnUGFjw@Dp9HX7WDYi0MupgKRJ7pfwdIS8Db18piRWsJzRiSnYUCKFLG@s5pDwIt0nNa@TTtPX/5zY/0B "R – Try It Online")
Explanation (ungolfed):
```
function(n){
      # Generate 1000 random uniform numbers in [5,5] (if n<45),
      # in [2,5] (if 45<=n<60) and in [0,5] (if n>=60).
    x = runif(1e3,2*(n<60)+3*(n<45),5)
      # Code each by the number of the interval it falls in (0,1],(1,2]...(4,5]
    cx = cut(x,0:5)
      # Tabulate the intervals. Because cut() returns a factor,
      # zero counts are included
    t = table(cx)
      # Vector-wise replace zero elements with "" and cat out, 1 per line.
    t1 = ifelse(t,t,"")
    write(t1,1,1)
}
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~131~~, ~~116~~, ~~90~~, ~~89~~, 87 bytes
```
L(l,a,v,A){for(A=5,v=1e3;A--;v-=a)printf("%d\n"+!a*2,a=l>59|A<3&l>44?rand()%-~v:!A*v);}
```
[Try it online!](https://tio.run/##VY7NUoMwFIX3PMVtHZwEEodacGxDcNi3T6AuYvhpahocoHFR8dGN0OqiuzPfPd@dI2ktpbtRRupjUULa9YVq7naZd4W0ertmvTqUI3EbpIkgluT4VDUtynlCLF@US5ZTyizlAn@0yvQVmvvFi5mHMxHcE8F1lqy@8nR5q7M4fmqFKRD26bddz/LAYja40YGDUAZNQbS1JHInWgiCMVsMJw@gO2tSN/IdYcxGMi2Y@opHDMJQpZPILm2A6bLnom8Ump48q9ezBPC/cKvMsS/BL9bjUgL7v/MGXdLgDc4tEhfHLk5csnIPkXuMfmSlRd05@vkL "C (gcc) – Try It Online")
**Update**: Fixed a bug in the original. Fused in the helper function, reducing an additional 15 bytes.
**Update 2**: -25 bytes thanks to ErikF.
**Update 3**: -1 byte thanks to ceilingcat.
## Degolf
```
L(l,a,v,A){
    for(A=5,v=1e3;A--;v-=a)
        printf("%d\n"+!a*2, // No clue how this works anymore, but it'll advance the pointer
                            // to the string constant when a number shouldn't be printed.
        a=l>59|A<3&l>44?rand()%-~v // Random integer to print in [0, v]
        :!A*v); // If bottom layer, return remaining volume
}
```
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf), ~~21~~ 20 bytes
```
5º*♪{k[K∞╟(]m<Σ∞wΦ}σ
```
[Try it online!](https://tio.run/##y00syUjPz0n7/9/00C6tRzNXVWdHez/qmPdo6nyN2Fybc4uB7PJzy2rPN///b8BlYsJlYsplasllZsBlaGAAAA "MathGolf – Try It Online")
This is my first answer in my new language. I based my solution on Emigna's 05AB1E solution, but used some neat features of MathGolf to make it a tiny bit shorter.
## Explanation
```
5º*                   push 5, [0], multiply (yielding [0,0,0,0,0]
   ♪                  push 1000
    {                 start block
     k                push input as integer
      K∞              push 22 and double it, yielding 44
        ╟(            push 60 and decrease, yielding 59
          α           wrap last two elements in array, yielding [44,59]
           m<         map is less than, giving [0,0], [1,0] or [1,1]
             Σ        sum array, giving 0, 1 or 2
              ∞       double, giving 0, 2 or 4
               w      push random integer in range
                Φ     increase array element
                 }    execute for loop (loops 1000 times)
                  σ   convert to string and remove leading zeroes (implicit map)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~27~~ ~~26~~ 25 bytes
Saved a byte thanks to *Adnan*.
Saved another byte thanks to *Kevin Cruijssen*.
```
5Å0₄FD„,;ÇI‹O·ÝΩ©è>®ǝ]ε0Û
```
[Try it online!](https://tio.run/##ATYAyf9vc2FiaWX//zXDhTDigoRGROKAniw7w4dJ4oC5T8K3w53OqcKpw6g@wq7HnV3OtTDDm///NTk "05AB1E – Try It Online")
**Explanation**
```
5Å0                         # initialize with a list of 5 zeroes
   ₄F                       # 1000 times do:
     D                      # duplicate the list
      „,;ÇI‹                # check if the input is larger than 44 and/or 59
            O·              # sum and double, yielding (0,2 or 4)
             ÝΩ             # pick a random number between and 0 and the number above
               ©è           # get the count in that level
                 >          # increment it
                  ®ǝ        # insert it at the same position
                     ]      # end loop
                      ε0Û   # remove leading zeroes on each level
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~87~~ 86 bytes
```
f=(n,w=1e3,s=5,r=n<45|n<60&s<4|s<2?w:Math.random()*w|0)=>s?`${r||""}
`+f(n,w-r,s-1):""
```
[Try it online!](https://tio.run/##hc7fCsIgHIbh812GRGjp2EoHLW1X0D1Mttkfloa/kQfZtRsdFsFOPx4@3qt@aOj85T4x6/ohJaOwpUGVw5aCEtQrK7mIVlbFEiSPIDdNqI96Oude297dMFmFWBB1gKZdPH2MCL2ydm0@L8xTYCWpEUr7rHMW3DjkozthgwtCvifyKzifJ2KWiN0sqf60pDc "JavaScript (Node.js) – Try It Online")
The 83-byte solution (`(n/15-2|0)*s<4`) is reserved first because I need to check for larger `n`.
UPDATE: Yeah, `(n/15-2|0)*s<4` didn't work because for larger `n` because `n` large enough makes the sum fail to reach 1000.
[Answer]
# PHP, 92 bytes
```
$i=5;for($n=1e3;$i--;$n-=$x)echo($x=rand($i?0:$n,$i<($argn<60?$argn<45?:3:5)?$n:0))?:"","
";
```
Run as pipe with `-R` or [try it online](http://sandbox.onlinephpfunctions.com/code/218896eb2ea7e4780ca690544349f6ead123293c).
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), 215 bytes
```
import StdEnv,Math.Random,Text
? ::!Int->Int
?_=code{ccall time "I:I"
}
$n#l=take(max(2*min(n/15-2)2)0+1)(genRandReal(?0))
#l=map toInt[1E3*e/sum l\\e<-l]
|sum l==1000=map(\v|v>0=v<+"\n"="\n")(l++repeat 0)%(0,4)= $n
```
[Try it online!](https://tio.run/##JY/BS8MwGMXv@StinZCsrUurXsqyXtyhoCCbNyvykWazmHwpXVYmzn/d2Orl8X7w3oOnjAYM1jVHo6mFFkNrO9d7uvXNGofkEfz79QawcTZ51idPSloUFxX6dDUKKd@kco3@UgqMob61mkZVUUXkm8zw0kgPH5pZOLF8bltkuMju0pznXMQZZ3uN0/JGg2Gl4JyMBQsd9W6cfsnWN3O9OBwtNXWtl6l5Jec/kjITQkxJVg/nYSXksIyjGiM5CWcmjnvdafBU8Csmklsu6QzD1sN4a7R0qocftTOwP4S0egj3nwi2Vf/wZMDvXG9/AQ "Clean – Try It Online")
So I've finally found a shorter way to get a random seed than importing `System._Unsafe`, `System.Time` and using `toInt(accUnsafe time)`...
And boy is it truly in the spirit of codegolf - embedding a call to C, ignoring the world state type normally used to ensure the evaluation order of such things.
[Answer]
# [Java (JDK 10)](http://jdk.java.net/), ~~121~~ ~~117~~ ~~113~~ 111 bytes
```
m->{for(int w=1000,j,i=5;i-->0;w-=j=i>0?j*=Math.random():w,System.out.println(j<1?"":j))j=m>59|m>44&i<3?w+1:0;}
```
[Try it online!](https://tio.run/##bVA9T8MwEN3zK04ZUEIbyxWtBE2cDIiBgalsiMGkSXsmtiP70oBKf3twq4qJJ52edF/v3Sl5kJnafk51J72H18YTHKMIoB8@OqzBk6RAB4tb0BJNsiGHZvf2DtLtfAq0d3b08PRVNz2hNWEYAlRYywbCjrWDqc8F9miNH3TjimdDza5xJbQgYNJZeWytS9AQjGLBOZ@rOYpVjllW8nzMhBJY8krdihdJe@ak2VqdpOtxvvn21GhmB2J9MEWdSVSxqOJ4rdJUCV2uHn50uVzeYHFXjbPFmuenKY8uBoMkXDQxmOB5oALuLzwTsEqvZwD8oxFaIIbsD3GaX5tbJuvzHxK8pk7ROU7TLw "Java (JDK 10) – Try It Online")
It's biased towards putting more wax near the top, but it's theoretically possible for any legal arrangement of wax to appear.
edit: 4 bytes were saved by [@KevinCruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)
# In Human-readable Java:
```
(int minutes /* golfed variable m */) -> {
  int waxRemaining = 1000; // golfed variable w
  // golfed version goes from index 4 to 0 in a bit of a roundabout way
  // starting at 5 but decrementing right away
  for (int level = 4 /* golfed variable i */; level <= 0; level--) {
    // golfed variable j
    // the golfed version initializes this to (waxRemaining + 1)
    // in order to juice out some extra bytes during the Math.random() call
    int waxAtLevel = 0;
    // the golfed version does all of these ifs as ternary operations
    // and avoids using 2-character operators wherever possible
    // so e.g. "a == 0" becomes "a<1" and "a && b" becomes "a&b"
    // since here we are certain things can't be negative,
    // and took a good look at the Java operator precedence cheat-sheet
    // to make sure "&" and "|" would work properly to give a truthy value
    if (level == 0) {
      // if we are at the bottom level, just put the rest of the wax there
      waxAtLevel = waxRemaining;
    } else if (minutes >= 60 || (minutes >= 45 && level < 3)) {
      // otherwise if we are at a legal level put a random portion of the remaining wax there
      // note: the random portion can be between 0 and waxRemaining inclusive
      waxAtLevel = (int) (Math.random() * (waxRemaining + 1));
    }
    if (waxAtLevel > 0) {
      // only print the amount of way at this level if its greater than 0
      System.out.print(waxAtLevel);
    }
    System.out.println();
    waxRemaining -= waxAtLevel;
  }
}
```
[Answer]
# [Powershell](https://docs.microsoft.com/en-us/powershell/), 188 162 bytes
```
param($m);$t=0;$a=,0*5;$s=if($m-lt45){4}elseif($m-lt60){2}else{0};$s..4|%{$t+=$a[$_]=if($_-eq4){1e3-$t}elseif($t-ne1e3){Random(1000-$t)}}$a|%{if($_){$_}else{''}}
```
[Try it online!](https://tio.run/##PYzLCsIwEEX3fsdIO2rKVNO6KPkJtyIl4IhC@rANuBjz7TFUdHvuPWccXjzNd3YuxtFOtsuhwwa8oQas2dGmamA2j1vCynldoejAbuYfqQllvxChkK5Fod9rAb81YM/QXha1VfzUKCUfFPi/7lXPCaGcbH8durwkorRjCCuwKbKYKNB@81kWQoyxPn4A)
-2 bytes by @Kevin Cruijssen
-4 bytes by removing optional Get- verb
-20 bytes by shortning loop and removing spaces
[Answer]
# [Pascal (FPC)](https://www.freepascal.org/), ~~192~~ 190 bytes
```
var n,a:word;z:array[0..4]of word;begin read(n);if n>44then a:=a+3;if n>59then a:=a+2;Randomize;for n:=0to 999do inc(z[random(a)]);for n:=0to 4do if z[n]>0then writeln(z[n])else writeln end.
```
[Try it online!](https://tio.run/##TcxBDoIwEEDRq8yyjUqIlkXbwCHcEhYjbbUJTkkhEnv5Khij25efP@LU43BwY5/zAyPQHtUSotFJYYz4bMuiEF1wsOHFXj1BtGgYce0dUCPEfLMEqGrcnT5UyR8d9RnJhLtPVrvw/qu6nANIKU0ATz1LbdwChrzj/4lYAweppa4pt@ES/WwHYitxO0z2K2DJFDmLqnoB "Pascal (FPC) – Try It Online")
Using [packing into bins method by TFeld](https://codegolf.stackexchange.com/a/171985/60517). Prints bottom row first with a trailing newline.
It seems that FPC doesn't have problems with `random(0)`, so I have some unusual adding there.
---
My original submission, golfed down to 209 bytes:
```
var n,i,a,r:int32;begin read(n);if n>44then a:=a-2;if n>59then a:=a-2;r:=1000;Randomize;for i:=-3to-0do begin if i>a then begin n:=random(r+1);if n>0then write(n);r:=r-n;end;writeln;end;if r>0then write(r)end.
```
[Try it online!](https://tio.run/##VY5LDsIwDAWvkmURDUp/CxKlh@AGpknBUnEqE4HE5UtIWMDOGr959gr3CRY5r9O2PYAF1VhDzRopdq05@wuSYA@uop3BWdDY9/HqSYC2INuChuMvYm0bpZQ5Ablww5c3c2CB2souBqlcEKU1qTiCyGohpC1nqeJ98z2n8v7JGP3nhVTOkownZzJbypyi/BflXcKHbeuH4Q0 "Pascal (FPC) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 28 bytes
```
>“,;‘SḤ‘µȷŻṗS⁼¥ƇȷX;0ẋ5¤ḣ5Yḟ0
```
A full program printing the result (upside down, as has been allowed).
**[Try it online!](https://tio.run/##AUEAvv9qZWxsef//PuKAnCw74oCYU@G4pOKAmMK1N8W74bmXU@KBvMKlxoc3WDsw4bqLNcKk4bij4bmaWeG4nzD///81OQ "Jelly – Try It Online")** - this is altered to use `7` rather than `ȷ` (1000) because the implementation is golf-tastically slow! (...for \$n>59\$ a list of \$10^{15}\$ 5-tuples is built and then filtered, from which to choose)
### How?
```
>“,;‘SḤ‘µȷŻṗS⁼¥ƇȷX;0ẋ5¤ḣ5Yḟ0 - Main Link: integer, n
 “,;‘                        - list of code-page indices = [44,59]
>                            - greater than? (vectorises)
     S                       - sum (i.e. 0, 1 or 2)
      Ḥ                      - double (i.e 0, 2 or 4)
       ‘                     - increment (i.e. 1, 3 or 5)
        µ                    - start a new monadic link, call that x (i.e. f(x))
         ȷ                   - literal 1000
          Ż                  - zero-range = [0,1,2,...,1000]
           ṗ                 - Cartesian power (all tuples of length x using those numbers)
               Ƈ             - filter keep if:
              ¥              -   last two links as a dyad:
            S                -     sum
             ⁼  ȷ            -     equals 1000? (i.e. only valid tuples)
                 X           - random choice (get one of these tuples)
                      ¤      - nilad followed by link(s) as a nilad:
                   0         -   zero
                    ẋ5       -   repeat five times = [0,0,0,0,0]
                  ;          - concatenate     (e.g. [354,388,258,0,0,0,0,0])
                       ḣ5    - head to index 5 (e.g. [354,388,258,0,0])
                         Y   - join with newlines
                          ḟ0 - filter out zeros
                             - implicit print
```
[Answer]
# [Twig](https://twig.symfony.com/), 126 bytes
This was an actually fun challenge!
This code creates a macro that has to be imported.
```
{%macro a(s,z=1000)%}{%for _ in 4..1%}{%set t=s>59or(s>44and _<3)?random(z):''%}{%set z=z-t%}{{t}}
{%endfor%}{{z}}{%endmacro%}
```
To import it, just do this:
```
{%- import 'macro.twig' as a -%}
{{- a.a(50) -}}
```
This should do the trick.
You can try it on <https://twigfiddle.com/t4dfgy>
**Notice**: Due to the page removing whitespaces, I was forced to add an `-` at the end of the line, to prove that it is outputting the correct number of lines.
On a regular installation, you would just see the newlines without issues.
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 62 bytes
```
{($!=1e3)||@,|((+$!-($!-=$!.rand+|0)||@)xx($_/15+|0)*2-4)[^4]}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwv1pDRdHWMNVYs6bGQadGQ0NbRVEXKKRrq6KoV5SYl6JdYwCS0qyo0FCJ1zc0BfG1jHRNNKPjTGJr/6flFykY6Bga6JgAkamOqYGOmYGOuYFCNZeCQnFipYJKvIKtnYIe0C6uWq7/AA "Perl 6 – Try It Online")
An anonymous code block that takes a string and returns a list of integers, with `Nil` or an empty list (`[]`) in place of `0`s.
### Explanation:
```
{($!=1e3)||@,|((+$!-($!-=$!.rand+|0)||@)xx($_/15+|0)*2-4)[^4]}
{                                                            }  # Anonymous code block
 ($!=1e3)  # Initialise $! to 1000
                +$!-($!-=$!.rand+|0)     # Pick a random value from 0 to $!
                                    ||@  # Or an empty array if it is zero
            ,  (                       )xx  # Repeat this
                                          ($_/15+|0)*2-4  # The given value mapped to 0,2,4
             |(                                         )[^4] # Get the first four values
 ($!    )||@  # Where the first value is the leftover number in $! or an empty array
```
[Answer]
# [PHP](https://php.net/), ~~113~~ ~~108~~ ~~99~~ ~~97~~ 93 bytes
```
<?php $i=$argv[1];while($a++<1e3){${r.rand(1,$i<60?$i<45?:3:5)}++;}echo"$r5
$r4
$r3
$r2
$r1";
```
[Try it online!](https://tio.run/##K8go@P/fxr4go0BBJdNWJbEovSzaMNa6PCMzJ1VDJVFb28Yw1VizWqW6SK8oMS9Fw1BHJdPGzMAeSJqY2lsZW5lq1mprW9emJmfkK6kUmXKpFJkAsTEQGwGxoZL1////TQ0MAA)
-11 bytes thanks to @titus
-9 bytes because everything is a string
[Answer]
# [J](http://jsoftware.com/), ~~56~~ ~~55~~ ~~54~~ ~~48~~ ~~43~~ 40 bytes
```
5{.1e3(2<@-/\[,0,~[:\:~?@$~)2*1#.>&44 59
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/Tav1DFONNYxsHHT1Y6J1DHTqoq1irOrsHVTqNI20DJX17NRMTBRMLf9rcnEVpRaWZhalKqjnleamFmUmq3MVJeal5OdmVqWqq3NxpSZn5CukKRjAGCYmcJYpjGUGlzU0MOD6DwA "J – Try It Online")
*-3 bytes thanks to FrownyFrog*
---
Another conceptually nice method that's a bit longer but guarantees perfectly uniform distribution over all possibilities, per [the method here](https://math.stackexchange.com/a/1276225/20688):
### [J](http://jsoftware.com/), 53 bytes
```
5$!.a:[:<@(+/);._1 0:,(1e3#1)({~#?#)@,0$~2*1#.>&44 59
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/TVUU9RKtoq1sHDS09TWt9eINFQysdDQMU42VDTU1quuU7ZU1HXQMVOqMtAyV9ezUTEwUTC3/a3JxFaUWlmYWpSqo55XmphZlJqtzFSXmpeTnZlalqqtzcaUmZ@QrpCkYwBgmppgsM7ispSXXfwA "J – Try It Online")
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~115~~ ~~105~~ 98 bytes
-17 bytes thanks to mazzy
```
$a=,0*5
45,60-ge"$args"|%{$i+=2}
$i..4|%{$t+=$a[$_]=random(1001-$t)}
$a[4]+=1e3-$t
$a|%{"$_"*!!$_}
```
[Try it online!](https://tio.run/##Lcq7CoMwGEDhPU@h4W9tvRHbqCBk6tK5SwcRDRgvELVEoYP12dP0Mp6P85ieQs2dkFJDw1YNnPnEjRGN/YQErcDAVTvj126F3mOnDUEfhvSTi8eA51AWTPGxnoZDREgUwHI0D89p4bFInE2bMjuGEru2DeWmN@Rcul7KzEF7aCxKEcLVeOdqyPBPkq/cRG1dp@WPaarf "PowerShell – Try It Online")
A golf of [Edwin's lovely answer](https://codegolf.stackexchange.com/a/172142/78849). If you like this, upvote him.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~37~~ 36 bytes
```
Ｆ²Ｆ²⊞υ∧‹³⁺ι÷Ｉθ¹⁵‽⊕⁻φ↨υ¹⊞υ⁻φΣυＥυ⎇ιＩιω
```
[Try it online!](https://tio.run/##TY3LCsIwEEX3fsUsJxCh9bEQVz42BQtF/YHQjDTQTjWPil8fm0rB2dzFnHtP3Shb96qN8dFbwJWAOavgGgwSDqzxQs7hWkLVBodGQsH@bAajCU/KeXwJCflWiDGuinXfYcG1pY7Yk8bS8NjKsyyTcFSO0mguptsvZss/dAsdht/XGvZYqmdC7mRZ2U/yT1Yz6t4Ji3Gzi8uh/QI "Charcoal – Try It Online") Link is to verbose version of code. Edit: Saved 1 byte by converting the empty list from base 1 instead of trying to sum it. Explanation:
```
Ｆ²Ｆ²
```
Loop twice, twice. Alternatively I could have integer divided the loop index by 2 for the same byte count.
```
‹³⁺ι÷Ｉθ¹⁵
```
If the outer index plus a fifteenth of the temperature is greater than three...
```
⊞υ∧...‽⊕⁻φΣ∨υω
```
... then push a random integer up to and including 1000 - the sum so far. Unfortunately Charcoal can't calculate the sum of an empty list so I have to convert from base 1 instead.
```
⊞υ⁻φΣυ
```
Push the leftover amount to the list. (The sum is safe here because the list is no longer empty.)
```
Ｅυ⎇ιＩιω
```
Convert the list to string, but use the empty string instead of zero.
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~62~~ 55 bytes
```
->n{w=1000;[4,4,3,3].map{|r|r*15>n||w-=q=rand(w);q}<<w}
```
[Try it online!](https://tio.run/##Nco7CoAgAADQvVM0VmgofkBKLyIORrglJYREdnYjtOktL5zLlZ3MUPk7SowQmjQFFBBAzLjZ/U4hhQEz5VOKUB4yWL92sZ@OZ57jk/fWaWSaD1KltMqK7FcUeX0cF4Uw@QU "Ruby – Try It Online")
Tests are limited to 0-99 degrees, because lava lamps could be [dangerous](https://www.youtube.com/watch?v=_rjkvQo_FDQ) at higher temperatures:
]


[Question]
      [
**Challenge**
Giving a valid arithmetic sum with some missing numbers, output the full expression.
Example:
```
    1#3                 123
+   45#     =>     +    456
--------            --------
    579                 579
```
**Input**
* Expression format can be an array `["1#3", "45#", "579"]`, a string `"1#3+45#=579"`, or 3 inputs `f("1#3","45#","579")`
**Output**
* Same as input
* You don't need to output the result
**Notes**
* The missing numbers are going to be represented using `#` or any other constant non-numeric character you want
* Assume result wont have a missing number
* Assume Input/Output consist in 2 terms and a final result
* Assume both term > 0 and result >= 2
* There might be multiple solutions. You can output anyone as long as the sum result match
**Test Cases with possibly outputs (pretty format)**
```
    #79                     879
+   44#         =>      +   444
--------                --------
    1323                   1323
    5#5                     555
+   3#3         =>      +   343
--------                --------
    898                     898
      #                       1
+     #         =>      +     1
--------                --------
      2                       2
    ###                     998
+   ###         =>      +     1     PD: there are a lot of possible outputs for this one
--------                --------
    999                     999
    123                     123
+     #         =>      +     1
--------                --------
    124                     124
      9                       9
+    #6         =>      +    46
--------                --------
     55                      55
    #123651                     1123651
+      #98#         =>      +      7981
------------                -----------
    1131632                     1131632
```
---
Standard [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") rules apply

[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), ~~22~~ 16 bytes
```
{Ṣ∧Ị∋|}ᵐ²ịᵐ.k+~t
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r/v/rhzkWPOpY/3N31qKO7pvbh1gmHNj3c3Q2k9bK160r@/49WMlQwVtJRUDIxVQBRpuaWSrH/owA "Brachylog – Try It Online")
-6 bytes thanks to @Fatelize
## Explanation
```
{Ṣ∧Ị∋|}ᵐ²ịᵐ.k+~t
{     }ᵐ²                   #   for each letter in each string
 Ṣ∧Ị∋                       #       if " " return a digit; else input
     |                      #
         ịᵐ                 #   cast each string to number
            k+              #   the sum of all but the last one
              ~t            #       is equal to the last one
           .                #   output that list
```
[Answer]
# JavaScript (ES6), ~~74~~ 57 bytes
Takes input as `(a)(b)(result)`, where ***a*** and ***b*** are strings with `.` for unknown digits and ***result*** is an integer. Returns an array of 2 integers.
```
a=>b=>F=(c,n)=>`${r=[c,n]}`.match(`^`+[a,b])?r:F(c-1,-~n)
```
[Try it online!](https://tio.run/##bY7NDoIwEITvPgbx0EbYpBSQmhRvvATBtFTwJ9gaIF6MvnotjSfxsrPJfjOzV/mQoxou9ynS5tjajlvJi4YXJUcq1JgXYv0ceOX2@iXgJid1RuIgNpUMmxrvh12JVETC6K2xVUaPpm@hNyfUoQC2LMAoSBJwQmhMMV79ICmkM0KBOslZviQAZvdXGGNLgsTUE3NJnCzv/gnI3EzSP/nOnqXEMyz3IYSSjMYY2w8 "JavaScript (Node.js) – Try It Online")
### Commented
```
a => b =>                // a, b = term patterns (e.g. a = ".79", b = "44.")
  F = (c,                // c = expected result (e.g. 1323)
          n) =>          // n = guessed value of b, initially undefined
    `${r = [c, n]}`      // we coerce r = [c, n] to a string (e.g. "879,444")
                         // if n is still undefined, this gives just c followed by a comma
    .match(`^` + [a, b]) // we coerce [a, b] to a string, prefixed with "^" (e.g. "^.79,44.")
    ?                    // this is implicitly turned into a regular expression; if matching:
      r                  //   return r
    :                    // else:
      F(c - 1, -~n)      //   decrement c, increment n and do a recursive call
```
[Answer]
## Matlab, 143 134 132 119 115 bytes
```
function[m]=f(x,y,r),p=@(v)str2num(strrep(v,'#',char(randi([48,57]))));m=[1,1];while sum(m)-r,m=[p(x),p(y)];end;end
```
-4 bytes thanks to @Luismendo
[Try it Online](https://tio.run/##FYzBCoMwEER/RfCQXdgebBVbJND/kBxCjCg0UVZN9evT7cAw8GDe4nabfM7jEd0@L7EPRo9w0kWMtOo3JNx2vscjgCz7FRKpUpGbLAPbOMzQ109qWoOSLui@osp032n@@GKTV8Abk@AVThHChabzcfg3j6Cq8qGoUHUjyqJpX5h/)
---
Pretty big and pretty stupid. It simply replaces all `#` with random digits until it finds the correct ones.
[Answer]
# [R](https://www.r-project.org/), ~~67~~ 51 bytes
Rock simple and scales horribly, just grep all the sum combinations. Use "." for unknown digits. It won't find the same answer as test case number 4, but it will give **a** possible answer, which follows the letter of the rules as given.
-16 bytes by grepping after forming the output and replacing `paste` with the `?` operator.
```
function(x,y,z,`?`=paste)grep(x?y,1:z?z:1-1,v=T)[1]
```
[Try it online!](https://tio.run/##PYzBCoMwDIbve4rRk4VYSGOdkUlfYrcxcAwdu6g4N9SX72oru/w/@fIlo2vPqWs/3WN69V0ywwIr1Lauhvt7auRzbIZktgtgudq1xBThW13kFW@uTYQ6sQCRZconkiYhD54aZQQcBSnaquAiYrVNIfQOVEShmDlA1PT3UGfR5IDyLY3Zj72YGwwLLqKOhDn55@4H "R – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 32 bytes
```
Ｆ²⊞υ0Ｗ⁻ζΣＩυ≔Ｅ⟦θη⟧⭆κ⎇⁼μ#‽χμυ←Ｅυ⮌ι
```
[Try it online!](https://tio.run/##FY7BCoJAEIbvPsWglxE2sESwPEV0SxDrFh0WW90lXXPXNerlt3FOw/D93/yN5KYZee99OxrAXQyVsxIdgzAJ4yL4SNULwFJpZ/HH4OoGPHE7o4tp4Git6jSW/I33iYF8EDEbpbv18mJwE0Zz88Xz5HhvcSBtFMYMaq6f44DbhPaBRAwcPasoOePhItqZwWqgGrVYhLECFVGF91mUBWmUBvk@95ul/wM "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｆ²⊞υ0
```
Push two string `0`s to the predefined empty list `u` to get the while loop going.
```
Ｗ⁻ζΣＩυ
```
Repeat while the sum of casting the values in `u` to integer is not equal to the desired result.
```
≔Ｅ⟦θη⟧
```
Create an array of the two inputs and map over it.
```
⭆κ⎇⁼μ#‽χμυ
```
Replace each `#` with a random digit and assign the result back to `u`.
```
←Ｅυ⮌ι
```
Print the result right justified. (Left justified would be just `υ` for a 4-byte saving.)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 20 bytes
```
ØDṛċ¡V€)ŒpḌð€ŒpS⁼¥ƇḢ
```
[Try it online!](https://tio.run/##y0rNyan8///wDJeHO2cf6T60MOxR0xrNo5MKHu7oObwByAYygx817jm09Fj7wx2L/v//H62ubGhkbGZqqK6joK5saaGsHvvf0NDY0MzYCAA "Jelly – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands) (legacy), ~~23~~ 20 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
[²³«εð9ÝΩ:}²gôJDO¹Q#
```
-3 bytes thanks to *@Emigna*.
Unknown digits are spaces (). Input order should be: expected result; longest string; shortest string.
[Try it online](https://tio.run/##ATwAw/8wNWFiMWX//1vCssKzwqvOtcOwOcOdzqk6fcKyZ8O0SkRPwrlRI///MTEzMTYzMgogMTIzNjUxCiA5OCA).
**Explanation:**
```
[                 # Start an infinite loop
 ²³«              #  Take the second and third inputs, and merge them together
               #   i.e. " 79" and " 4 " → " 79 4 "
    ε     }    #  Map each character to:
     ð   :     #   Replace a space with:
      9ÝΩ      #   A random digit in the range [0,9]
               #    i.e. " 79 4 " → ['3','7','9','2','4','3']
               #    i.e. " 79 4 " → ['5','7','9','7','4','4']
²g             #  Get the length of the second input
               #   i.e. " 79" → 3
  ô            #  And split it into two numbers again
               #   i.e. ['3','7','9','2','4','3'] and 3 → [['3','7','9'],['2','4','3']]
               #   i.e. ['5','7','9','7','4','4'] and 3 → [['5','7','9'],['7','4','4']]
   J           #  Join each list together to a single number
               #   i.e. [['3','7','9'],['2','4','3']] → [379,243]
               #   i.e. [['5','7','9'],['7','4','4']] → [579,744]
    D          #  Duplicate this list
     O         #  Sum the list
               #   i.e. [379,243] → 622
               #   i.e. [579,744] → 1323
      ¹Q#      #  If it's equal to the first input: stop the infinite loop
               #  (and output the duplicate list implicitly)
               #   i.e. 1323 and 622 → 0 (falsey) → continue the loop
               #   i.e. 1323 and 1323 → 1 (truthy) → stop the loop and output [579,744]
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~81~~ 74 bytes
*-7 bytes thanks to nwellnhof!*
```
{first {try S/\=/==/.EVAL},map {$^a;S:g[\#]=$a[$++]},[X] ^10 xx.comb('#')}
```
[Try it online!](https://tio.run/##JcfLCoJAFIDh/TzFwSOpjGhH0zKZRYt27YQIvMAUGYGSjAWK@OzT7Vv9f3dVTazbERY1CNBTfVf9E6anGiHzC@EL4Xv74@4wu63sYDIrmWbbW15gKUyZm5yXs5ufSqhoCcPgXR7t2bbQcmbdyxFqu29eqnNS9j@DAuSrCEW0TgxHwwdSEMYRMQ4/mGyQCfZNopDiMHgD "Perl 6 – Try It Online")
Anonymous code block that takes input as a string containing an arithmetical expression e.g. "12#+45#=579". Substitutes each `#` with possible permutations of digits, substitutes the`=` with `==` and finds the first valid result.
### Explanation:
```
{  # Anonymous code block                                                      }
 first   # Find the first of:
                                                               ^10  # The range of 0 to 9
                                                                   xx.comb('#') # Multiplied by the number #s in the code
                                                          ,[X]  # The cross-product of these lists
                          map   # Map each crossproduct to:
                              {$^a;.trans: "#"=>{$a[$++]}}  # The given string with each # translated to each element in the list
      {try S/\=/==/.EVAL}, # Find which of these is true when = are changed to == and it is eval'd
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 22 bytes
```
{'#'⎕R{⍕?10}t}⍣{⍎⍺}t∘←
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///v1pdWf1R39Sg6ke9U@0NDWpLah/1LgZy@h717qotedQx41HbhP//gSo8/YEsA640IEmMHq40BXVTc0tbQ2VjbRNTZXUQ39DQ2NDM2MhW2dDI2MzUUFvZ0gIiYWlpaausrKwNxGA@UAmIow4A "APL (Dyalog Unicode) – Try It Online")
[Answer]
# Java 10, ~~203~~ ~~198~~ 193 bytes
```
(a,b,c)->{int A=0,B=0,l=a.length();for(a+=b,b="";A+B!=c;A=c.valueOf(b.substring(0,l)),B=c.valueOf(b.substring(l)),b="")for(var t:a.getBytes())b+=t<36?(t*=Math.random())%10:t-48;return A+"+"+B;}
```
[Try it online.](https://tio.run/##fZJBT4NAEIXv/opxicmubEkppRZxNe3Ng3rwaDws221F6dbA0MSY/vY6i3ggGkPYLPnmvckM71Xv9eh19XY0lW4auNOl@zwBKB3aeq2NhXv/CfCIdek2YHh/0bK/FPKWaje2BiNyKj2c0NGgxtLAPThQcORaFtKI0fUn2cJCjeWS3krpqLJugy9c5OtdzXWoClkoxvJFuDxVJl8oE@111dqHNS@ipi2ariUnrRDk8Tf1zLsI77nXNeCljjYWlx9oGy5EESq8SmY3HM/VncaXqNZutdsSOYvHlziazvPaYls7WISMnmV@OOZ@qPe2qGiofrb9rlzBltbVb@TpGbT43hX1Qc6Ci4xJNp0GTMbJJOmWM2TBnywNUmJJkDA5z@ZDWRB4mT@zLBugeJJ4RH6T6QB0jWZMpunQigSzNPYwm3tZnMSzZDKsIRqPiWW//mw3fVf1Xx766Hw0aLfRrsXonUqwctxFpg9FyCghLPzJzuH4BQ)
**Explanation:**
```
(a,b,c)->{           // Method with 2 Strings & integer parameters and String return-type
  int A=0,B=0,       //  Result-integers, starting both at 0
      l=a.length();  //  Length of the first String-input
  for(a+=b,          //  Concat the second String-input to the first
      b="";          //  Reuse `b`, and start it as an empty String
      A+B!=c         //  Loop as long as `A+B` isn't equal to the integer-input
      ;              //    After every iteration:
       A=c.valueOf(b.substring(0,l)),
                     //     Set `A` to the first String-part as integer
       B=c.valueOf(n.substring(l)),
                     //     Set `B` to the second String-part as integer
       b="")         //     Reset `b` to an empty String
    for(var t:a.getBytes())
                     //   Inner loop over the characters of the concatted String inputs
      b+=t<36?       //    If the current character is a '#':
          (t*=Math.random())%10
                     //     Append a random digit to `b`
         :           //    Else (it already is a digit):
          t-48;      //     Append this digit to `b`
  return A+"+"+B;}   //  After the loop, return `A` and `B` as result
```
[Answer]
# C# .NET, ~~225~~ ~~220~~ 196 bytes
```
(a,b,c)=>{int A=0,B=0,l=a.Length;for(a+=b,b="";A+B!=c;A=int.Parse(b.Substring(0,l)),B=int.Parse(b.Substring(l)),b="")foreach(var t in a)b+=(t<36?new System.Random().Next(10):t-48)+"";return(A,B);}
```
Port of [my Java 10 answer](https://codegolf.stackexchange.com/a/171486/52210).
(I'm very rusty in C# .NET golfing, so can defintely be golfed..)
-3 bytes implicitly thanks to *@user82593* and [this new C# tip he added](https://codegolf.stackexchange.com/a/171513/52210).
-29 bytes thanks to *@hvd*.
[Try it online.](https://tio.run/##bZFRb8IgEMff/RQ3@gIpNtbazq7iokv25BYzl@yZImoTpQmg22L87A60ZnHzgYPwu///uEOYtqi1PIo1Nwamul5qvtm3AIzlthIw@zZWbqLnrRIDY3WllhQue6UsBeyjW2QIC2BHzGlJBWHDvbuDEevQsVtrxqOJVEu7Kha1xjxkJS0ZQsUoHN8xUYyYy46mXBuJy2i2Lc8lsFMS4hxuU8@8C3GekosV3nEN1j0LOClDhu0gyR6V/Lw08cbVvN5gEr3KL4vjDnmw7V6fhO4dWtqtVnhEx6Q4HAGK1u8IdnU1hxdeKUz8YADepbEYBfc5oqjXCxCNk25Cin8suMnSIHUsCRJE@3n/WhYEXuZjnudXKO4mHjm/bu8KnApliKbptZUTZGnsYd73sjiJs6R7yjn8be4kOQ8VOG0Opf9VEE3PzQifamXqtYw@dGXlpFISL5ofDxEwQKFoKhyOPw)
**Explanation:**
```
(a,b,c)=>{        // Method with 2 string & int parameters and int-tuple return-type
  int A=0,B=0,    //  Result-integers, starting both at 0
      l=a.Length; //  Length of the first string-input
  for(a+=b,       //  Concat the second string-input to the first
      b="";       //  Reuse `b`, and start it as an empty string
      A+B!=c      //  Loop as long as `A+B` isn't equal to the integer-input
      ;           //    After every iteration:
       A=int.Parse(b.Substring(0,l)),
                  //     Set `A` to the first string-part as integer
       B=int.Parse(b.Substring(l)),
                  //     Set `B` to the second string-part as integer
       b="")      //     Reset `b` to an empty string
    foreach(var t in a)
                  //   Inner loop over the characters of the concatted string inputs
      b+=(t<36?   //    If the current character is a '#':
           new System.Random().Next(10)
                  //     Use a random digit
          :       //    Else (it already is a digit):
           t-48)  //     Use this digit as is
         +"";     //    And convert it to a string so it can be appended to the string
  return(A,B);}   //  After the loop, return `A` and `B` in a tuple as result
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~121~~ ~~155~~  ~~152~~  149 bytes
```
import re
def f(i,k=0,S=re.sub):s=S('#','%s',i)%(*list('%0*d'%(i.count('#'),k)),);print(s)if eval(S('=','==',S('\\b0*([1-9])','\\1',s)))else f(i,k+1)
```
[Try it online!](https://tio.run/##JY3dboMwDIXv@xSRIpSYZBUhoEEnP0V3N3bRn6BFpQXhdNKenhlqyZb1nXPs6S/9jA@/LPE@jXMSc9hdQy96He0NC3vEOezpeYYD4VErqazKSNkImc6HSEmrrMivKtNxfxmfj7RawN4ALHxMc2RAEHsRfk@D5jxyHnnw2nXnItdf7q39BqZd55QlAAgDhdd742CR4jNQEpcTBdr1fP29NVUl0fnSKxBSNBuoNrAaalkbLz02bcM6G@qaQeVRMBHbCSOxXLVXSW5nuJGXcvkH "Python 3 – Try It Online")
*+34 New solution with regex to circumvent the fact that python doesn't support numbers with leading zeroes.*
*-3 thanks to @Jonathan Frech*
---
**The old solution doesn't work if # is the first character in any number (because eval doesn't accept leading zeroes) and is therefore invalid :(**
```
def f(i,k=0):
 s=i.replace('#','%s')%(*list('%0*d'%(i.count('#'),k)),)
 print(s)if eval(s.replace('=','=='))else f(i,k+1)
```
[Try it online!](https://tio.run/##RY3LCoMwEADvfkUghN3VINonLezHiCZ0MWgwaaFfn1p66HUYZuI7P9blWMrkvPIoduaO7pVKLO3mYhhGh6DBgklABusgKSOYrp7AoLTj@lzyVyA7E1mqVNxkJ4nEK/caAqZ/hvcMMxC5kNxv1vRUPEJ/0M1JX/h8vQGVDw "Python 3 – Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~228~~ ~~213~~ ~~203~~ ~~172~~ 170 bytes
**-15** Bytes thanks to *@ceilingcat*. I've never used `index` before.
**-10** Bytes thanks to *@Logem*. Preprocessor magic
refactored call to `exit(0)` with puts as parameter.
```
char*c,*p[9],k;main(i,v)int**v;{for(i=X[1],35))||X[2],35))?p[k++]=c,main(*c=57,v):k;!c*i--;)47==--*p[i]?*p[i]=57:Y[1])+Y[2])^Y[3])?main(i,v):exit(puts(v[2],puts(v[1])));}
```
[Try it online!](https://tio.run/##PY3LbsIwFES/BWXj69gLx4RHLCubfkQiy5Wiy@sqECJILaTSX8d1KWIzOouZMyj3iDHiobtwFHx0ay96c@poYCQC0DBxHsz37nxhZBunvNAlwP3euOIf69H1ee4tiueIoy2XaVj1ZoacpDQwX1orZVKTr5@ZGlWbVJC3yQKfrdMe6vdntb3RxMav6crC38uLUh/A/MQYM1XoRalitl5lUSmtFrp44O7Y7a9RfrS2m87EQsLGMrQ0bLY3Fn4B "C (gcc) – Try It Online")
[Answer]
# PHP, 112 bytes
lame brute force solution
```
for(;$s=$argn;eval(strtr($s,['='=>'==','#'=>0]).'&&die($s);'))for($k=$n++;$k;$k=$k/10|0)$s[strpos($s,35)]=$k%10;
```
takes string as input, stops at first solution. Run as pipe with `-nR` or [try it online](http://sandbox.onlinephpfunctions.com/code/b89fdcd901365dc04bf9c90ad46ef25a7aa6553b).
[Answer]
# Powershell, 91 byte
The script finds all solutions. The total number of iterations is 10 power the number of characters `#`. The recursion depth is equal to the number of characters `#`.
```
filter f{$h,$t=$_-split'#',2
if($t){0..9|%{"$h$_$t"}|f}elseif($h-replace'=','-eq'|iex){$h}}
```
Test script:
```
filter f{$h,$t=$_-split'#',2
if($t){0..9|%{"$h$_$t"}|f}elseif($h-replace'=','-eq'|iex){$h}}
@(
    ,('1#3+45#=579','123+456=579')
    ,('#79+44#=1323','879+444=1323')
    ,('5#5+3#3=898','505+393=898 515+383=898 525+373=898 535+363=898 545+353=898 555+343=898 565+333=898 575+323=898 585+313=898 595+303=898')
    ,('#+#=2','0+2=2 1+1=2 2+0=2')
    ,('9+#6=55','9+46=55')
    ,('123+##=124','123+01=124')
    ,('#123651+#98#=1131632','1123651+7981=1131632')
    ,('##+##=2','00+02=2 01+01=2 02+00=2')
    ,('##+##=99','00+99=99 01+98=99 02+97=99 03+96=99 04+95=99 05+94=99 06+93=99 07+92=99 08+91=99 09+90=99 10+89=99 11+88=99 12+87=99 13+86=99 14+85=99 15+84=99 16+83=99 17+82=99 18+81=99 19+80=99 20+79=99 21+78=99 22+77=99 23+76=99 24+75=99 25+74=99 26+73=99 27+72=99 28+71=99 29+70=99 30+69=99 31+68=99 32+67=99 33+66=99 34+65=99 35+64=99 36+63=99 37+62=99 38+61=99 39+60=99 40+59=99 41+58=99 42+57=99 43+56=99 44+55=99 45+54=99 46+53=99 47+52=99 48+51=99 49+50=99 50+49=99 51+48=99 52+47=99 53+46=99 54+45=99 55+44=99 56+43=99 57+42=99 58+41=99 59+40=99 60+39=99 61+38=99 62+37=99 63+36=99 64+35=99 65+34=99 66+33=99 67+32=99 68+31=99 69+30=99 70+29=99 71+28=99 72+27=99 73+26=99 74+25=99 75+24=99 76+23=99 77+22=99 78+21=99 79+20=99 80+19=99 81+18=99 82+17=99 83+16=99 84+15=99 85+14=99 86+13=99 87+12=99 88+11=99 89+10=99 90+09=99 91+08=99 92+07=99 93+06=99 94+05=99 95+04=99 96+03=99 97+02=99 98+01=99 99+00=99')
) | % {
    $s,$e = $_
    $r = $s|f
    "$($e-eq$r): $r"
}
```
## Powershell, 'Assume both term > 0' is mandatory, 110 bytes
```
filter f{$h,$t=$_-split'#',2
if($t){0..9|%{"$h$_$t"}|f}else{$a,$b,$c=$_-split'\D'
$_|?{+$a*+$b*!(+$a+$b-$c)}}}
```
]