You've been staring at dashboards all day. Car after car rolls into the rental return line, each one flashing
two numbers. One is the big odometer that never resets, and the other is a smaller gas gauge that renters so
often forget to top off.
Your coworker leans over and grins. “Think we could make a game out of this? Look at this… Take those two
numbers, multiply them together, and keep a running total. Let's see how big it gets by the end of the shift!”
You agree… It sure beats sorting keychains.
Here's how the game works:
Each car provides two readings: the odometer and the gas remaining.
Multiply the odometer reading by the gas reading.
Add that product to your running total.
12345 678
For that car:
That number is added to the grand total.
Process every line in the file this way. After the last car has come through the line, what is the grand total you've built up?
That first game got out of hand… Literally! The totals ballooned into numbers that looked more like arcade high scores than anything meaningful. Then your coworker notices something… Every odometer is exactly five digits, and every gas reading is exactly three. That sparks an idea. “Let's treat the digits like cards! We can turn this into a kind of Pai Gow poker game!”
You both agree on a simple scoring system for each set of digits:
Here's how the game works for each car:
12129 123
Odometer: 1 2 1 2 9 → two pairs → 2 points
Gas: 1 2 3 → nothing → 0 points
Car score = 2 × 0 = 0
12119 677
Odometer: 1 2 1 1 9 → three of a kind → 3 points
Gas: 6 7 7 → one pair → 1 point
Car score = 3 × 1 = 3
44455 555
Odometer: 4 4 4 5 5 → full house → 4 points
Gas: 5 5 5 → three of a kind → 3 points
Car score = 4 × 3 = 12
Now the totals feel too small. “For each car, let's run the fuel all the way down… You know… Seinfeld style!” your coworker jokes. It makes sense in a forced and contrived manner, as their name is Kramer after all. This seems like a lot more work than even the first game, but you have all day.
Here's the twist… Instead of computing a single score for each car, you'll compute one score for every mile until the gas runs out! You'll never deal with leading zeros in the gas meter. If the tank shows 62, that means a two-digit hand. The odometer will always stay at five digits, no matter how much gas is left.
Example:
10006 4
This actually represents four separate cars, one for each mile driven until the gas is gone:
(10006, 4)
(10007, 3)
(10008, 2)
(10009, 1)
So for every line in the file:
Kramer's eyes light up. He's been waiting for this moment. “Alright, enough math for math's sake. Let's put some
money on it!” he declares. Turns out Kramer's a bit of a gambler, which naturally fits. His mother was a mudder
after all?
Anyway, so here's the wager:
If both the odometer and gas meter start on even numbers, the total points from that car (from its starting
reading until the gas runs out) go to Kramer
If both the odometer and gas meter start on odd numbers, the total points go to you
Any mix of odd/even means no points for either side
By now, you've realized that Pai Gow Odometer Poker wouldn't have the same ring to it even though it's more
accurate of a description of the game. But more importantly, you've realized your role in this game. You're
Odette Odessa Oddsen for goodness sakes! Better known from childhood as Oddy Oddsen. You know you got this!
Who's making fun now?!
For example:
12345 123 (Odd - Odd)
Sum all 123 scores and give those points to you
12346 124 (Even - Even)
Sum all 124 scores and give those points to Kramer
12345 124 (Odd - Even)
12344 125 (Even - Odd)
No points to either side.