# How many goals has Steven Gerrard scored?

Steven Gerrard was born on 30th of May 1980. He is now 37 years old. Happy birthday, Steven!

To celebrate his anniversary, your goal is to remind him the number of goals he has scored each year in premiere league for Liverpool.

He doesn't want to remember the goals scored before or after playing for Liverpool. It is like scoring 0 goals.

Input

The starting year of football season.

Output

The number of goals scored by Steven during this season for Liverpool.

List of seasons and goals

1998–99     0
1999–2000   1
2000–01     7
2001–02     3
2002–03     5
2003–04     4
2004–05     7
2005–06     10
2006–07     7
2007–08     11
2008–09     16
2009–10     9
2010–11     4
2011–12     5
2012–13     9
2013–14     13
2014–15     9

Example

Input    Output
2002     5
2017     0
1990     0
2014     9

This is so the shortest submission in bytes in each language wins. Explanations are encouraged.

• Do we have to return 0 if the date is out of the range or can we throw an exception? Commented May 30, 2017 at 12:20
• @TheLethalCoder Steven Gerrard prefers to say that he has scored 0 goals. No exception Commented May 30, 2017 at 12:25

## JavaScript (ES6), 474342 39 bytes

y=>+'0723135148933694'[y-1999]+y%20%9|0

### How?

We compute an approximation x of the number of goals for a given year y with the formula:

x = y % 20 % 9

This is actually a very bad approximation, but it's always less than or equal to the expected value v and never less than v - 9, which allows to encode the difference with a single decimal digit.

y    | y % 20 | x = y % 20 % 9 | v  | v - x
-----+--------+----------------+----+------
1999 |     19 |              1 |  1 |     0
2000 |      0 |              0 |  7 |     7
2001 |      1 |              1 |  3 |     2
2002 |      2 |              2 |  5 |     3
2003 |      3 |              3 |  4 |     1
2004 |      4 |              4 |  7 |     3
2005 |      5 |              5 | 10 |     5
2006 |      6 |              6 |  7 |     1
2007 |      7 |              7 | 11 |     4
2008 |      8 |              8 | 16 |     8
2009 |      9 |              0 |  9 |     9
2010 |     10 |              1 |  4 |     3
2011 |     11 |              2 |  5 |     3
2012 |     12 |              3 |  9 |     6
2013 |     13 |              4 | 13 |     9
2014 |     14 |              5 |  9 |     4

### Demo

let f =

y=>+'0723135148933694'[y-1999]+y%20%9|0

for(y = 1997; y <= 2017; y++) {
console.log(y, f(y))
}

• Very nicely done. Commented May 30, 2017 at 18:11
• Wait. You're computing the number of goals from the input year, instead of indexing in a hard-coded database? Commented Jun 1, 2017 at 18:03
• @Blacksilver I need a first approximation to lower the range of stored values from 1-16 to 0-9. But there's still a hard-coded lookup table to store the differences with these computed values. Commented Jun 1, 2017 at 18:29

# 05AB1E, 25 24 bytes

•3ßÎó‚4Ëǝï•17в15ÝƵÊØ+Ikè

Try it online! or as a Test suite

Explanation

•3ßÎó‚4Ëǝï•                 # push the number 69255401071877657848
17в              # convert to list of base-17 digits
# produces the list [1,7,3,5,4,7,10,7,11,16,9,4,5,9,13,9,0]

15Ý           # push the range [0 ... 15]
ƵÊØ+       # add the 303rd prime (1999) to each
Ik     # get the index of the input in this list
# or -1 if outside the range
è    # get the element at that index in first list

# JavaScript, 44 Bytes

y=>parseInt("173547a7bg9459d9"[y-1999],17)|0
• Welcome to PPCG. Nice first answer :) Commented May 30, 2017 at 18:08

<?=intval(_173547a7bg9459d9[$argn-1998],17); Try it online! # PowerShell, 65 Bytes (($g=(1,7,3,5,4,7,10,7,11,16,9,4,5,9,13,9)["$args"-1999]),0)[!$g]

uses a ternary/array format to return 0 if the year isn't in the array.

This is so long because powershell doesn't have any else return 0 format, and the full array is required, if he scored 9 or less goals in each year we could shave a lot off this by indexing into a string instead.

# Bash, 97 93 Bytes

a=(1 7 3 5 4 7 10 7 11 16 9 4 5 9 13 9)
((2014<$1||$1<1999))&&(echo 0)||(echo $[a[$1-1999]])

# C#, 79 72 bytes

y=>new[]{0,1,7,3,5,4,7,10,7,11,16,9,4,5,9,13,9}[y>2014|y<1999?0:y-1998];

# Braingolf v0.6, 48 bytes

#ߎ-V173547#
792+82*945994+9&,0R!?1-[v>R]v_:0_|;

This is a weird one.

The character ߎ has the ordinal 1998, making the Braingolf literal for 1998, which is then subtracted from the input.

### Explanation:

#ߎ-V173547#
792+82*945994+9&,0R!?1-[v>R]v_:0_|;  Implicit input of n
#ߎ-                                  Subtract 1998 from n
V                                 Create a new stack and switch to it
173547                           Digit literals 1, 7, 3, 5, 4 and 7
#<newline>                 Integer literal 10
792                                  Digit literals 7, 9 and 2
+                                 Sum the last 2 items (9 and 2) to make 11
82*                              Digit literals 8 and 2 multiplied to make 16
9459                          Digit literals 9, 4, 5 and 9
94+                       Digit literals 9 and 4 summed to make 13
9                      Digit literal 9
&,                    Reverse stack
0                   Digit literal 0
!?                If n != 0
1-              Decrement n
[...]         Loop, repeat n+1 times
v>           Move to next stack and rotate to the right
v_       Move to next stack and output last item
:      Else
0_    Push zero and output
|   Endif
;  Suppress implicit output