Create a program that, given an integer N, outputs the number of years we have to get to N A.D. or how many years it has been since N A.D, as a string or int. For example, given 2014, the program should output 5 as it has been that many years since 2014. Input of the year in which you run the program should result in 0.
Treat the input "0" however you like: as its own year, as 1 A.D. or as 1 B.C. This means that you can pretend there IS a year zero and have all BC years be off by one.
Negative integers (integers with - in front of them) are treated as years B.C. For example inputting -2 would result in the program telling how many years it has been since 2 B.C.
Treat improper inputs (inputs that don't only use numbers and the dash as characters (abcd), or use the dash by itself or use it wrongly (e.g. 6-)) however you want, error or exit or something else.
The winning program is the program with the shortest code that does all of this. Have fun.
-1
should result in an output of2019
this year? \$\endgroup\$ – Neil Jun 13 '19 at 14:252009
?.. \$\endgroup\$ – Jonathan Allan Jun 13 '19 at 14:28