23
4
Several years back, Hot Wheels made a simple flash game called "Formula Fuelers Racers"*. To play the game, you select three ingredients from a fridge to put into your car, which is then raced against the computer's randomly-generated car. It turns out the mechanics of this game are pretty simple. First off, the actual race "time" of your car is randomly generated and has no bearing on whether or not you win the race. Secondly, the winner of the race is determined by a score which is calculated from the selected ingredients (duplicate ingredients are allowed, and the order matters). Each ingredient has an associated "value" and an associated "operation" as shown in the following table:
# ingredient val op
1 Hot Salsa 2 +
2 Root Beer 1 +
3 Milk 1 +
4 Pickle Juice 2 +
5 Mystery Lunch -3 *
6 BBQ Sauce 2 +
7 Egg 1 +
8 Ketchup 2 +
9 Mustard -1 *
10 Melon 1 +
11 Chocolate Milk 1 +
12 Mayonnaise -2 *
13 Baby Food 0 +
14 Pepper 1 +
15 Salt 2 +
16 Syrup -1 *
17 Salad Dressing 2 +
18 Orange Juice 1 +
19 Soy Sauce 2 +
For convenience, this challenge will be referring to ingredients by their number and not their name. Here are the steps to compute a score:
- First, initialize the score with the value of the first ingredient.
- Then, use the second ingredient's operation to combine the current score and the second ingredient's value to get an updated score.
- Finally, use the third ingredient's operation to combine the current score and the third ingredient's value to get the final score.
Higher scores are better and always beat lower scores.
For example, the ingredients 1 2 3
have a score of (2+1)+1 = 4
. The ingredients 7 5 6
have a score of (1*-3)+2 = -1
. Therefore, 1 2 3
beats 7 5 6
.
Challenge
In this challenge, you shall write a program which takes an ordered list of 3 integers and outputs the corresponding score.
Input
Your program may accept a list of three integers in the most convenient format. You are allowed to use either 1-indexing for the ingredient names (as above) or 0-indexing (subtract 1 from every index above).
Ouput
Your program must output a single integer indicating the score.
Test Cases
4 5 5 => 18 // max score
5 5 5 => -27 // min score
13 13 13 => 0
1 2 3 => 4
7 5 6 => -1
16 2 19 => 2
19 7 12 => -6
*This page is pretty outdated and doesn't work in some browsers, but you don't need to play the game for this challenge.
1So basically Salsa+Lunch+Mayo=Invincible? – Matthew Roh – 2017-04-09T23:02:26.290
3@SIGSEGV Duplicate ingredients are allowed. Salsa, Lunch, Lunch is allowed for a score of 18 that beats your 12. – Level River St – 2017-04-09T23:21:25.160
2
For reference, here is an archive of the game.
– Matthew Roh – 2017-04-10T08:00:09.9774Who keeps salt in the fridge? :) – Wossname – 2017-04-10T12:26:31.460
LUNCH LUNCH LUNCH
means your car explodes the second the wheels touch pavement then I s'pose. – Magic Octopus Urn – 2017-04-10T17:49:51.1033>
Can we take input ingredients in reverse order? (
[3,2,1]
instead of[1,2,3]
) – Arnauld – 2017-04-11T07:18:02.300@carusocomputing No, the score would then be 0, which is beaten by 18. – Erik the Outgolfer – 2017-04-11T11:36:58.693
@EriktheOutgolfer the score is -27 for L L L. I meant "explode" with a negative connotation. – Magic Octopus Urn – 2017-04-11T13:28:01.710
@Arnauld I'm leaning towards "no" mainly because that will probably affect the "golfiness" of the other existing answers. – PhiNotPi – 2017-04-12T13:07:51.357