16
\$\begingroup\$

Given an input date, your entry will output the full list of supported versions of the Ubuntu Linux distro on that date.

The full list of all releases is as follows:

Version    Code name         Release date  Supported until

4.10       Warty Warthog     2004-10-20    2006-04-30
5.04       Hoary Hedgehog    2005-04-08    2006-10-31
5.10       Breezy Badger     2005-10-13    2007-04-13
6.06 LTS   Dapper Drake      2006-06-01    2009-07-14  2011-06-01 (Server)
6.10       Edgy Eft          2006-10-26    2008-04-25
7.04       Feisty Fawn       2007-04-19    2008-10-19
7.10       Gutsy Gibbon      2007-10-18    2009-04-18
8.04 LTS   Hardy Heron       2008-04-24    2011-05-12  2013-05-09 (Server)
8.10       Intrepid Ibex     2008-10-30    2010-04-30
9.04       Jaunty Jackalope  2009-04-23    2010-10-23
9.10       Karmic Koala      2009-10-29    2011-04-30
10.04 LTS  Lucid Lynx        2010-04-29    2013-05-09  2015-04-30 (Server)
10.10      Maverick Meerkat  2010-10-10    2012-04-10
11.04      Natty Narwhal     2011-04-28    2012-10-28
11.10      Oneiric Ocelot    2011-10-13    2013-05-09
12.04 LTS  Precise Pangolin  2012-04-26    2017-04-26
12.10      Quantal Quetzal   2012-10-18    2014-05-16
13.04      Raring Ringtail   2013-04-25    2014-01-27
13.10      Saucy Salamander  2013-10-17    2014-07-17
14.04 LTS  Trusty Tahr       2014-04-17    2019-04
14.10      Utopic Unicorn    2014-10-23    2015-07-23
15.04      Vivid Vervet      2015-04-23    2016-01
15.10      Wily Werewolf     2015-10-22    2016-07
16.04 LTS  Xenial Xerus      2016-04-21    2021-04

Rules

  • For each supported version, the exact version string will be output, e.g. 4.10
  • For LTS (long-term support) versions, LTS will be appended to the version
  • The three oldest LTS versions come in two flavours - desktop and server. If both of these LTS versions are supported on the given date, the output will simply be the version string as above. However if only the server version is supported, then you must append -server to the end of the version string
  • At the time of writing, 4 of the recent versions only have YYYY-MM in their supported-until dates. You must treat these dates as if they are the last day of the given month. e.g. 2019-04 must be treated as 2019-04-30
  • There will be no output for dates outside of the full date range captured in the table
  • Input date formats are flexible, but must contain some enumeration of Year, Month and Day. Number of days or seconds (or other units) from an epoch are not valid input formats.
  • Output lists may be given in whatever format is convenient for your language
  • You may use datetime functions from your language
  • You may assume all inputs are valid

Examples:

Input:        Output:

2000-01-01    
2004-10-20    4.10
2005-05-05    4.10, 5.04
2006-06-06    5.04, 5.10, 6.06LTS
2010-10-10    6.06LTS-server, 8.04LTS, 9.04, 9.10, 10.04LTS, 10.10
2021-04-30    16.04LTS
2021-05-01    
\$\endgroup\$
8
  • 4
    \$\begingroup\$ Breezy Badger...? \$\endgroup\$
    – Alex A.
    Commented Nov 5, 2015 at 22:32
  • \$\begingroup\$ Some of your examples are incorrect. 2010-10-10 should return 6.06LTS-server, 8.04LTS, 9.04, 9.10LTS, 10.04LTS, 10.10 \$\endgroup\$
    – Mwr247
    Commented Feb 3, 2016 at 16:39
  • \$\begingroup\$ @Mwr247 Thanks - I fixed that one. Do you see any other errors? \$\endgroup\$ Commented Feb 3, 2016 at 17:26
  • \$\begingroup\$ @Mwr247 Ah - I forgot to quote the date string when passing to a function. \$\endgroup\$ Commented Feb 3, 2016 at 17:44
  • 1
    \$\begingroup\$ @DigitalTrauma Whoops! I had removed a grouping in there to save two characters, but didn't realize the effect it had on that aspect of the condition. It's fixed now. \$\endgroup\$
    – Mwr247
    Commented Feb 3, 2016 at 18:33

1 Answer 1

5
\$\begingroup\$

JavaScript (ES6), 552 bytes

d=>(d=d.replace(/^20|-/g,'')*1,[for(r of'41020,60430;50408,61031;51013,70413;-60601,90714,110601;61026,80425;70419,81019;71018,90418;-80424,110512,130509;81030,100430;90423,101023;-91029,110430;-100429,130509,150430;101010,120410;110428,121028;111013,130509;-120426,170426;121018,140516;130425,140127;131017,140717;-140417,190430;141023,150723;150423,160131;151022,160731;-160421,210430'.split`;`.map(a=>a.split`,`))if(d>=(a=Math.abs(f=r[0]))&&((m=d<=r[1])||r[2]&&d<=r[2]))((a+'').slice(-6,-2)/100).toFixed(2)+'LTS'.slice(f)+(m?'':'-server')].join`, `)

Building the data array takes up ~68% of the total size. The rest is input formatting, array lookup, and output string construction.

The data string is split into an array of arrays of either 2 (normal) or 3 (server) length. The dates are reduced to numeric format, with the intial "20" stripped (along with any leading zeroes after that). LTS is denoted by a negative start date. Version numbers can be conveniently derived from all but the last two digits of the positive start date, divided by 100.

\$\endgroup\$
3
  • \$\begingroup\$ Woohoo - first answer! Sorry - I'm JS novice - can I test ES6 in a browser somehow? Or what is the easiest way to verify? \$\endgroup\$ Commented Feb 3, 2016 at 17:30
  • \$\begingroup\$ @DigitalTrauma Yes, just assign the function to a variable (add F= before the code above) and then just call the function through it (F("2010-10-10")). You can run it in any modern browser developer console (f12 key). \$\endgroup\$
    – Mwr247
    Commented Feb 3, 2016 at 17:39
  • \$\begingroup\$ +1 - Looks good now! (not sure why I put my previous comments against my own question and not your answer - oh well - you got the point :)) \$\endgroup\$ Commented Feb 3, 2016 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.