Do you know Icy Tower ? Here is a gameplay example of what i'm talking about
The game concept is simple : you play as Harold the Homeboy, and your goal is to jump from floors to floors to go as high as possible without falling and getting off-screen ( the camera goes higher following you or at a speed that gets faster over time, and does not go down ).
If you get off-screen ( fell or camera was too fast for you to keep up ), it's game over, and then you get a score.
Your task is to write a program/function/whatever that calculates the score based on a input.
How to calculate the score :
The formula is simple : \$Score = 10 * LastFloor + Sum(ValidComboList.TotalFloorJumped^2)\$
What is a valid combo ?
You have to jump from floors to floors to go as high as possible. Sometimes, you will the to the floor \$F+1\$
But sometimes, if you go fast enough ( faster = higher jumps ), you will do a multi-floor jump, and skip some floors between. A combo is a sequence of multi-floors jump. To be considered as a multi-floor jump, you need to skip at least 1 floor, meaning you need to get to the floor \$F+x\$ where \$x >= 2\$
See that you always jump to \$x >= 2\$, jumps to lower floors with floors skipped between are not considered valid
A combo ends when :
- You jump to the floor \$F+x\$ where \$(x < 0) | (x == 1)\$
- You wait more than about 3 seconds on the same floor ( in the gameplay video, you can see on the left a "timing bar", and the combo ends if it gets empty )
- You get off-screen ( falling or not jumping fast enough )
In this challenge, to simplify a bit, we will consider that, when the input indicates a "jump to the same floor \$F+0\$" means that the 3 second timeout is passed, so the two rules will be simplified in one :
"You jump to the floor \$F+x\$ where \$x<2\$
A valid combo ( a combo that will be used for the score calculation ) :
- The number of multi-floor jumps \$N >= 2\$
- The combo MUST NOT end with going off-screen. If you go off-screen, the combo is invalid and won't included in the score. Said in another way : The combo must be followed by a jump to another floor or by waiting about 3 seconds.
In this challenge, since we consider that jumping to the same floor is waiting 3 seconds, the rules to make a valid combo is "You must jump to another floor"
Since you need at least 2 multi-floor jumps to make a combo, the number of total floor jumped is higher than 4
The input
The input will be a "list" of integers ( or STDIN input ) which represents the sequence of floor jumped on. For example, the start to the video linked previously in the post will look like :
[5 4 5 10 12 15 17 18 19 20 23 24 25 28 29 30 31 34 35 36 37 34 35 36 37 38 39 40 43 48 45 46 50 55 54]
for the first floors. The start floor is ommited. This input end on floor 54 meaning he went off-screen just after that, without getting to another floor, so there's the game over ( this was not the case in the video since he went to the floor 232, so the array accurately representing the sequence would end with 232 at the end )
Here, with this input, you must output \$829\$, because :
\$Score = 10 * 54 + 12^2 + 8^2 + 9^2\$ Because the last floor Harold was on is the floor number 54, and he made 3 valid combos :
- First combo of 4 multi-floor jumps with a total of 12 floors jumped in that combo
- Second combo of 2 multi-floor jumps with a total of 8 floors jumped in that combo
- The last combo of 2 multi-floor jumps with a total of 9 floors jumped in that combo
Test cases :
[] => Undefined Behavior
[5]
=> \$50\$
[4 0 5 6 8 10 10]
=> \$10*10 + 4^2 = 116\$ Correction applied
[4 0 5 6 6 6 6 8 10 10]
=> \$10*10 + 4^2 = 116\$ ( Here, Harold just waited 9 seconds. No combo to validate, but still a legitimate input ) Correction applied
[5 7 10 10 11 9 14 17 15 16]
=> \$10*16 + 10^2 + 8^2 = 324\$
[5 4 5 10 12 15 17 18 19 20 23 24 25 28 29 30 31 34 35 36 37 34 35 36 37 38 39 40 43 48 45 46 50 55 54]
=> \$10 * 54 + 12^2 + 8^2 + 9^2 = 829\$
[5 4 5 10 12 15 17 18 19 20 23 24 25 28 29 30 31 34 35 36 37 34 35 36 37 38 39 40 43 48 45 46 50 55 56]
=> \$10 * 54 + 12^2 + 8^2 + 9^2 = 849\$
[5 4 5 10 12 15 17 18 19 20 23 24 25 28 29 30 31 34 35 36 37 34 35 36 37 38 39 40 43 48 45 46 50 55 55]
=> \$10 * 55 + 12^2 + 8^2 + 9^2 = 839\$ ( harold waited 3 seconds to validate the combo )
[5 4 5 10 12 15 17 18 19 20 23 24 25 28 29 30 31 34 35 36 37 34 35 36 37 38 39 40 43 48 45 46 50 55]
=> \$10 * 55 + 12^2 + 8^2 = 758\$ ( because harold went off-screen without confirming the combo)
If you want, you can condsider that the input always starts with zero ( since the game start at floor 0 ), if this is the case, say it in your answer
Rules :
- Input and output in any convenient way
- Full program, or function, or lambda, or macro are acceptable
- Standard Loopholes are forbidden
- This is code-golf, so lower number of bytes are better
Edit : Correction applied on some test cases