Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const getGets = (arr) => {
- let index = 0;
- return () => {
- const toReturn = arr[index];
- index += 1;
- return toReturn;
- };
- };
- // this is the test
- const test = [
- "4",
- "5",
- "1",
- "3",
- "5"
- ];
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- let targets = gets(); // N
- let Gs = gets();
- let Gl = gets();
- let Ps = gets();
- let Pl = gets();
- let Gtotal = 0;
- let Ptotal = 0;
- Gtotal = (Number(targets) * Number(Gs)) + Number(Gl) + Number(Gl);
- Ptotal = (Number(targets) * Number(Ps)) + Number(Pl) + Number(Pl);
- if (+Gtotal < +Ptotal) print("George");
- if (+Ptotal < +Gtotal) print("Peter");
- if (+Gtotal == +Ptotal) print("Draw");
- /*
- George and Peter shoot at different speeds and accuracy,
- so for example George will hit a target roughly once every Gs seconds, while Peter will need roughy Ps seconds.
- So for example, the server sends the targets to George, which takes Gl seconds,
- Gosho shoots all targets with his shooting speed, and then the response back to the server take another Gl seconds.
- write a program which will determine if George or Peter will win the current round, or there will be a draw.
- Input
- On the first line - the number N - the number of targets.
- On the second line - Gs - George's speed.
- On the third line - Gl - George's latency.
- On the fourth line - Ps - Peter's speed
- On the fifth line Pl - Peter's latency.
- Output
- There is one line of output:
- George - if George wins
- Peter - if Peter wins
- Draw - if the amount it takes is the same for both of them
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement