Programming Puzzle – Open Games Fest 👾
Many engineers here at HealthVerity are avid gamers. To celebrate their love for games (both electronic and tabletop) we are organizing a HealthVerity Open Games Fest, but we need your help planning it. There will be thousands of participants split into teams. Each team will attempt to complete a game circuit consisting of several types of games. Each circuit emphasizes different aspects of gaming, requiring hand to eye coordination (H), strategy (S) and creativity (R) in successful completion. Each gamer has these abilities in various amounts as well. How good a match they are for a circuit is determined by the dot product of the gamer’s and the circuit’s H, S, and R values. The higher the result, the better the match.
Each participant will be on exactly one team and there will be a distinct circuit for each team to attempt. Each participant will rank in order of preference their top X circuits. Since we would like the audiences to enjoy the games as much as possible, when assigning gamers to circuits we also want to consider how well their skills match up to the circuit. In fact we want to match gamers to circuits such that no gamer could switch to a circuit that they prefer more than the one they are assigned to and be a better fit for that circuit than one of the other gamers assigned to it.
To help us create the game circuit assignments write a program in either Python, Typescript, Rust, Java, C++, Go, Java, or Scala that takes as input a file of circuits and gamers and outputs a file of circuits and gamer assignments. The number of gamers assigned to a circuit should be the number of gamers divided by the number of circuits. Assume that the number of circuits and gamers will be such that each circuit will have the same number of gamers with no remainder.
Input file
One line per circuit or gamer. All circuits will come before any gamers. Circuit lines start with a C and gamer lines start with a G. Names of circuits and gamers will never have spaces. A skill and the rating for that skill are separated by a colon. Circuit lines have the circuit names followed by skills. gamer lines have the gamer names followed by skills, followed by circuits in order of preference, separated by commas.
Example:
C C0 H:7 E:7 R:10 C C1 H:2 E:1 R:1 C C2 H:7 E:6 R:4 G G0 H:3 E:9 R:2 C2,C0,C1 G G1 H:4 E:3 R:7 C0,C2,C1 G G2 H:4 E:0 R:10 C0,C2,C1 G G3 H:10 E:3 R:8 C2,C0,C1 G G4 H:6 E:10 R:1 C0,C2,C1 G G5 H:6 E:7 R:7 C0,C2,C1 G G6 H:8 E:6 R:9 C2,C1,C0 G G7 H:7 E:1 R:5 C2,C1,C0 G G8 H:8 E:2 R:3 C1,C0,C2 G G9 H:10 E:2 R:1 C1,C2,C0 G G10 H:6 E:4 R:5 C0,C2,C1 G G11 H:8 E:4 R:7 C0,C1,C2
Output file
One line per circuit assignment. Each line should contain the circuit name followed by the gamer name, followed by that gamer’s circuits in order of preference and the match score for that circuit. The line should include all gamers matched to the circuit. The example below is a valid assignment for the input file above.
C2 G6 C2:128 C1:31 C0:188, G3 C2:120 C0:171 C1:31, G10 C0:120 C2:86 C1:21, G0 C2:83 C0:104 C1:17 C1 G9 C1:23 C2:86 C0:94, G8 C1:21 C0:100 C2:80, G7 C2:75 C1:20 C0:106, G1 C0:119 C2:74 C1:18 C0 G5 C0:161 C2:112 C1:26, G11 C0:154 C1:27 C2:108, G2 C0:128 C2:68 C1:18, G4 C0:122 C2:106 C1:23
Run your program on this input file which contains 2000 circuits and 12000 gamers. Send us both your code and the output file to the following e-mail address: the sum of the names of the gamers (taking off the leading letter G) that are assigned to circuit C1970 @healthverity.com. So for example if the gamers assigned to circuit C1970 were G1,G2,G3,G4,G5 and G6 you would send your solution to 21@HealthVerity.com