4
Note: all array references in this post are zero-indexed.
When playing the piano, two notes on the same key must be pressed with two different fingers. You could use the same finger, but it doesn't sound as good. At least, according to my piano teacher. I can't hear any difference.
The challenge is to take a space-separated list of 3 integers: Starting finger, ending finger, and length of repeating notes, and output the optimal sequence of finger numbers to match the input.
All piano jargon aside, output a string of numbers based on the input, where each number is +1
/-1
the one before it, all numbers are between 1 and 5, the sequence is args[2]
digits long, starting with args[0]
and ending with args[1]
, and is formatted as below.
The input can be command line arguments, values on the stack (for ><> users), STDIN, or any other conventional method.
Output will be a list of numbers, with these being valid outputs.
[1, 2, 3, 4, 5]
(1 2 3 4 5)
"12345"
12345
*1-2-3-4-5
**1 2 3 4 5
**
For each asterisk on the style above, compute the following to calculate your score:
final-score = code.length * (1.00 - (asterisks * 0.05));
You can assume the first two params will be between 1 and 5, but if it handles at least 0-9, multiply your code by 95%.
If the last digit is less than 2, or the input parameters are impossible, error however you like, or just exit.
Finger numbers on the piano work like this, however this is not integral to the challenge.
1 | Thumb
2 | Index finger
3 | Middle finger
4 | Ring finger
5 | Pinky (finger)
Sample input and output:
Input: 1 2 2
Output: 1 2
Input: 1 4 8
Output: 1 2 3 2 3 2 3 4
Input: 2 3 10
Output: 2 3 2 3 2 3 2 3 2 3
Input: 5 2 1
Output: Error
Input: 1 2 5
Output: Error
Input: 5 1 5
Output: 5 4 3 2 1
Input: 1 1 1
Output: 1
These do not have to be handled correctly.
Input: 1 6 6
Output: 1 2 3 4 5 6
Input: 0 9 8
Output: Error
I had the scoring wrong, everyone who's posted an answer please fix it. I'm really sorry D: – clap – 2015-09-03T03:59:49.573
You can just divide your score by 100 to get the new score, at least with no bonuses – clap – 2015-09-03T04:01:22.827
You may want to add an example where the end value is smaller than the start value (which seems legal based on the description). For example,
4 1 8
, with possible solution4 3 2 3 2 3 2 1
. – Reto Koradi – 2015-09-03T04:31:11.647yes, that's legal, I just forgot. thanks – clap – 2015-09-03T04:34:34.267