[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:
]