Statement

## Goal

In baseball, a player's batting average is defined as his total number of hits (singles, doubles, triples, and home runs => S+D+T+HR) divided by at-bats (plate appearances, not including walks, hit-by-pitch, and sacrifices => PA-W-HBP-SAC), rounded to three decimal places and without a leading 0 (e.g. .238).

Calculate the batting averages for each player and print them highest to lowest.
Input
Line 1: The number of batters N.
Line 2: Name,PA,S,D,T,HR,W,HBP,SAC (name, plate appearances, singles, doubles, triples, home runs, walks, hit-by-pitch, sacrifices)
Output
N lines: Name and batting average (no two are the same), sorted highest to lowest.
Constraints
3 ≤ N ≤ 16
PA ≤ 1000
Example
Input
```3
MadKnight 100 5 4 3 2 7 3 3
eulerscheZahl 100 12 4 3 2 7 3 3
Robin_Hood 100 14 4 3 2 7 3 3```
Output
```Robin_Hood .264
eulerscheZahl .241

Game modes
FastestShortest

Test cases
Test 1 Test
Input
3 MadKnight 100 5 4 3 2 7 3 3 eulerscheZahl 100 12 4 3 2 7 3 3 Robin_Hood 100 14 4 3 2 7 3 3
Output
Robin_Hood .264 eulerscheZahl .241 MadKnight .161

Validator 1 Validator
Input
3 jrke 591 141 74 16 25 60 6 3 VizGhar 568 65 5 7 32 7 24 16 jacek 425 129 43 19 41 70 12 28
Output
jacek .737 jrke .490 VizGhar .209

Test 2 Test
Input
5 Robin_Hood 441 128 51 2 46 73 8 24 jacek 482 77 30 7 14 84 12 28 jrke 484 59 31 8 43 83 19 21 Astrobytes 461 160 79 12 39 46 4 18 JBM 470 68 33 17 37 57 17 5
Output
Astrobytes .738 Robin_Hood .676 JBM .396 jrke .391 jacek .358

Validator 2 Validator
Input
5 Westicles 505 189 24 4 20 16 4 17 MSmits 502 51 18 9 29 31 11 0 MadKnight 487 16 19 16 19 60 28 10 struct 590 154 1 4 43 39 3 7 jrke 515 153 49 11 37 89 6 17
Output
jrke .620 Westicles .506 struct .373 MSmits .233 MadKnight .180

Test 3 Test
Input
10 jacek 520 57 78 3 45 91 24 15 struct 417 161 24 0 3 33 0 4 JBM 521 198 31 11 1 94 4 0 Konstant 533 144 37 19 25 48 27 17 Astrobytes 532 127 50 15 35 91 15 6 jrke 471 145 68 1 28 35 19 3 PaarthThePro 446 22 27 4 2 43 5 11 TBali 526 90 68 7 30 36 3 8 MSmits 490 192 12 7 23 21 21 8 MadKnight 400 7 11 6 32 10 6 7
Output
jrke .585 JBM .570 Astrobytes .540 MSmits .532 Konstant .510 struct .495 jacek .469 TBali .407 MadKnight .149 PaarthThePro .142

Validator 3 Validator
Input
10 struct 494 89 54 12 49 55 14 25 AntiSquid 503 13 73 13 17 42 28 8 jacek 563 115 38 16 43 62 0 21 TBali 466 191 47 6 42 81 3 19 Robin_Hood 496 94 59 14 5 45 17 19 jrke 448 181 62 15 13 60 24 15 MSmits 554 80 1 15 10 19 8 16 Velcoro 597 140 32 17 32 86 9 3 VizGhar 532 191 72 15 18 95 10 0 eulerscheZahl 452 36 28 4 17 36 16 18
Output
TBali .788 jrke .777 VizGhar .693 struct .510 Velcoro .443 jacek .442 Robin_Hood .414 AntiSquid .273 eulerscheZahl .223 MSmits .207

Test 4 Test
Input
16 Konstant 479 112 14 13 26 28 20 3 JBM 495 172 78 3 0 13 6 5 jacek 419 196 51 9 47 29 15 6 MadKnight 532 163 1 11 24 45 3 4 jrke 529 167 60 16 40 27 29 23 VizGhar 421 180 38 4 32 99 27 4 AntiSquid 425 149 13 12 43 6 24 15 Westicles 456 22 12 18 23 48 12 5 Velcoro 420 25 25 5 39 77 19 10 PaarthThePro 487 135 8 8 2 68 19 18 eulerscheZahl 534 144 40 2 3 30 14 9 TBali 454 83 78 10 3 72 0 5 struct 473 191 71 19 33 53 3 22 Astrobytes 478 80 48 15 14 33 23 4 MSmits 595 3 79 7 34 15 10 2 Robin_Hood 500 155 9 15 32 97 21 28
Output
VizGhar .873 jacek .821 struct .795 jrke .629 Robin_Hood .596 AntiSquid .571 JBM .537 TBali .462 MadKnight .415 PaarthThePro .401 eulerscheZahl .393 Konstant .386 Astrobytes .376 Velcoro .299 MSmits .217 Westicles .192

Validator 4 Validator
Input
16 MSmits 565 106 11 8 22 34 16 8 jacek 472 2 40 17 21 41 7 15 MadKnight 451 79 19 19 48 29 17 20 Velcoro 493 167 8 14 28 44 0 14 Westicles 432 30 1 4 44 41 5 25 Astrobytes 582 167 40 3 41 33 21 4 JBM 412 172 20 3 9 68 21 12 jrke 562 128 67 17 41 80 25 25 VizGhar 588 63 32 3 30 76 1 11 eulerscheZahl 412 69 0 11 12 84 29 5 Konstant 559 23 77 10 48 19 26 11 struct 494 170 22 16 48 79 26 13 AntiSquid 523 105 13 11 36 51 2 16 TBali 508 34 34 7 41 4 15 5 Robin_Hood 445 7 24 10 27 12 6 3 PaarthThePro 434 147 17 6 6 22 27 15
Output
struct .681 JBM .656 jrke .586 Velcoro .499 Astrobytes .479 PaarthThePro .476 MadKnight .429 AntiSquid .363 Konstant .314 eulerscheZahl .313 MSmits .290 VizGhar .256 TBali .240 Westicles .219 jacek .196 Robin_Hood .160

Solution language

Solution

Stub generator input
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
Online Participants