Time waiting to buy my tickets
Imagine you are in a queue, every time you reach the first position you can buy just one ticket. Buyers have to wait through the line again if they want to buy more tickets. You are standing in line and has a number of tickets to purchase.
Given a list of buyers with the number of tickets they want to buy, determine how long it will take you to purchase your tickets if you are in the second position. Each transaction takes 1 unit of time. No time is spent moving to the back of the line.
//one liner solution, by japanfever (E3839EE383AAE382AAE9B3A9E38388E383ACE383AD)
let p_queue_time = t.reduce((a, x, i) => (x p), 0);
I’m happy to see you back japanfever, I missed you 😛 what have you been doing? Hey, we thought about going to Japan’s Cherry Blossoms but finally we’re going to Boston Dynamics and the MIT, if my gf lets me haha.
//one liner solution, by japanfever (E3839EE383AAE382AAE9B3A9E38388E383ACE383AD)
let p_queue_time = t.reduce((a, x, i) => (x p), 0);
//one liner solution, by japanfever (E3839EE383AAE382AAE9B3A9E38388E383ACE383AD)
let p_queue_time = t.reduce((a, x, i) => (x p), 0);
one liner solution, by japanfever (E3839EE383AAE382AAE9B3A9E38388E383ACE383AD)
https://jsfiddle.net/04z5n3qe/
Good point, I should have used a reduce for that, less code and it’s still easy to understand.
what the fuck is this site that does not let me write comments? wordpress fuck you
I see all your comments perfectly, maybe some cache issues on the browser, I don’t know but it’s true that sometimes WP sucks, at least they improved the interface (Dashboard) in the latest versions.