Generate the Rummy Sequence Your task is to take an input n and output element n of the Rummy Sequence, a sequence which I made (looking on OEIS will not help you).

Definition

Each element of the Rummy Sequence is a set of truthy or falsey values. Ex.: [true, false].

The steps to producing a member of the Rummy Sequence are quite simple:


Start out with the first index, [] (this is element 0).
Set the leftmost falsey to truthy. If there are no falseys to change, then increase the length of the list by 1 and set all members of the new list to falsey.
Repeat step 2 until reaching element n.


Example

Let's define our function as rummy(int n) (stuff in {} is a step taken to get to the answer):

&gt;&gt;&gt; rummy(5)
{[]}
{[false]}
{[true]}
{[false, false]}
{[true, false]}
[true, true]


Rules


Standard loopholes apply.
Must work for inputs 0 through your language's upper numerical bound.
You may output in any way you see fit, provided that it is clear that the output is a set of truthy/falseys.


Trivia

I call this the "Rummy Sequence" because, starting at index 2, it defines the sets you would need to lay down in each round of Progressive Rummy, where falsey is a book and truthy is a run.

Test Cases

&gt;&gt;&gt; rummy(0)
[]

&gt;&gt;&gt; rummy(1)
[false]

&gt;&gt;&gt; rummy(6)
[false, false, false]

&gt;&gt;&gt; rummy(20)
[true, true, true, true, true]

&gt;&gt;&gt; rummy(1000)
[true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]
JavaScript ES6, 94 92 72 70 66 64 bytes

Saved 6 bytes thanks to Neil!

n=&gt;[...Array(a=Math.sqrt(8*n+1)-1&gt;&gt;1)].map((_,l)=&gt;l&lt;n-a*(a+1)/2)


I don't think this can be golfed more. At least with the equations.

Explanation

They are two main equations (n is input):

(Math.sqrt(8*n+1)-1)/2


This will give the total size the output array will need to be. In my program I used &gt;&gt;1 instead of (...)/2 these are the same as the first bit in binary has a value of 2. Shifting it will result in in floor(.../2)



n-a*(a+1)/2


This is the amount of trues there will be. a is the result of the previous expression.



This is what the syntax does:

[...Array(n)]


This code generates an array with range [0, n) in this answer n is the first equation.



.map((_,l)=&gt;l&lt;n) this will loop through the above range, l is the variable containing the current item in the range. If the item is less than the amount of trues they are (determined by second equation), then it will return true, else false.