Given a standard combination lock like the one in the picture. The way to unlock it is to align the 4 numbers in the code on the combination line. After years of loyal service you have been fired from the lock factory and have decided to exact revenge by not jumbling up the locks before you send them off, thus leaving every lock with the combination to unlock it on the combination line.
You also know that by looking at the order of the numbers in the other lines it is possible to work out what numbers must be on the combination line (and therefore the combination to unlock it is).
If every line on the lock is given a number starting from line 0 for the combination line (the line which unlocks the lock) to line 9. For example, if the numbers on line 4 are 5336
, then the combination to unlock it would be 1992
.
Unfortunately the locks have already been packaged and your view of each lock is obscured, so you can only see numbers on different lines of the lock.
The Challenge
Given 4 pairs of digits, where the first digit of the integer represents the line number and the second digit represents the the number which appears on that line, work out the combination to the lock. For example if you input:
57 23 99 45
Then it should output:
2101
Or
25 78 63 15
and
3174
Assume the input will always be 4 positive integers in the form `25 64 72 18.
This is code-golf, so the shortest programs in number of bytes wins.
Also this is my first question, so any feedback is appreciated.
57 23 99 45
. That's not four pairs of integers: it's four integers. And some answers are assuming they get that as a string, whereas others are assuming that it comes ready-parsed as 4 ints. \$\endgroup\$0
s). \$\endgroup\$