Keg, -rR
, 15 13 bytes
1&÷{!;|":'½≤⑾
Try it online!
-2 bytes thanks to @a'_'
Answer History
15 Bytes
1&÷^{!;|":'2*≥⑾
Try it online!
I'm quite happy with this answer, and I'm quite happy with the explanation.
Explained
1&
First, we store the number 1 in the register. This will end up being the means by which the result is shown.
÷^
We then item split the input list and reverse it, so that things are in descending order.
{!;|
Now, we start a while loop that will run while the length of the stack - 1 is not zero.
":'
This bit of the algorithm took me a while to visualise and write... I had to resort to move playing cards around my living room floor to understand which stack shifting mechanics to use.
Lets say the input stack (after item splitting and reversal) is [4, 2, 1]
. Right shifting the stack ("
) gives [1, 4, 2]
, duplicating the top gives [1, 4, 2, 2]
and then left shifting the stack ('
) gives [4, 2, 2, 1]
.
We do this so that we can compare the top of the stack with the next item and preserve that second item (in other words, circumnavigate the side effects of operators consuming stack items).
2*≥
We then multiply the top item by two and see if the result is greater than or equal to the next item in the series.
⑾
The result is then augmented multiplied into the register and the while loop continues.
-rR
prints the value of the register at the end of execution as an integer.