注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
Zoox今年的新题, roller coaster
Roller Coaster Simulator
You’re working on a new video game in which players build roller coasters for a simulated theme park. You need to create a system to produce an overall score for each submitted coaster so they may be ranked in an online leaderboard.
Input
You can assume the input will be provided as a list of strings describing the roller coaster type followed by the stats for each coaster. All stats are numbers except LiftType, which is a string that can take one of the following values: “Cable”, “Chain”, “Launched”. The input format is as follows:
RollerCoasterType MaxSpeed BumpsPerSecond LiftType
Per-type Coaster Scoring Functions
For this problem we will consider only the three coaster types described below, but your solution should be able to scale to 10-20 different roller coaster types and be able to process many roller coasters efficiently. The score function is broken down into two parts, the “Comfort” score, and the “Overall” score, defined below. Your tool should print out “Overall” score, for use in the leaderboard rankings.
Comfort
The comfort of a roller coaster can be an arbitrary function of MaxSpeed, BumpsPerSecond, and LiftType. Unless otherwise stated, the comfort score is computed as follows:
Comfort: min(1.0, 1.0 / BumpsPerSecond, 1.0 / MaxSpeed)
Overall
The overall score of a roller coaster is computed as follows, where ScaleFactor is a constant scaling factor that differs by roller coaster type:
Overall: ScaleFactor * Comfort * MaxSpeed
Roller Coaster Types
The roller coaster types you will need to consider are as follows:
1. Wooden
- ScaleFactor: 1.0
2. Steel
- ScaleFactor: 2.0
- Comfort: min(1.0, 1.0 / BumpsPerSecond, 5 / MaxSpeed)
3. Suspended
- ScaleFactor: 0.5
- A LiftType of "Cable" adds an additional 0.5 to Comfort
Example
Input
Wooden 4 1.0 Chain
Steel 20 2.0 Cable
Suspended 2 1.5 Cable
Suspended 2 1.5 Chain
Output
Overall: 1.0
Overall: 10.0
Overall: 1.0
Overall: 0.5
Explanation of Output
Comfort = min(1.0, 1.0/1.0, 1/4); Overall = 4.0*0.25=1.0
Comfort = min(1.0, 1.0/2.0, 5/20); Overall = 2*20*0.25=10.0
Comfort = min(1.0, 1.0/1.5, 1/2) + 0.5; Overall = 0.5*2.0*1.0=1.0
Comfort = min(1.0, 1.0/1.5, 1/2); Overall = 0.5*2.0*0.5=0.5
求大米看面经~ |