## Who was the biggest "Weekend Update" host during that time period?

6

0

These are the hosts of the "Weekend Update" news segment on Saturday Night Live, with the years they hosted and their initials:

Chevy Chase         1975-1976  CC
Jane Curtain        1976-1980  JC
Dan Aykroyd         1977-1978  DA
Bill Murray         1978-1980  BM
Charles Rocket      1980-1981  CR
Gail Matthius       1981       GM
Brian Doyle-Murray  1981-1982  BD
Mary Gros           1981-1982  MG
Christine Ebersole  1982       CE
Brad Hall           1982-1984  BH
Christopher Guest   1984-1985  CG
Dennis Miller       1985-1991  DM
Kevin Nealon        1991-1994  KN
Norm MacDonald      1994-1997  NM
Colin Quinn         1998-2000  CQ
Jimmy Fallon        2000-2004  JF
Tina Fey            2000-2006  TF
Amy Poehler         2004-2008  AP
Seth Meyers         2006-2014  SM
Cecily Strong       2013-2014  CS
*Colin Jost         2014-pres  CJ
*Michael Che        2014-pres  MC

*At the time of this writing, present is 2017.


I got most of the years this website, but later ones I got from Wikipedia.

The task is simple. Given a range of years, output the initials of the person who was host during the most years in that time period. If there is a tie, output the initials of all the hosts that tied. Note that sometimes "Weekend Update" only has 1 host and sometimes it has 2.

For example, if the input is 1984-1985, output CG because he was the only person to host during both of those years.

# Specifics

• Input is flexible, but it will always consist of a start year and a later end year. Also you don't need to include the first two digits of the year: 95-05 is fine for 1995-2005.
• Assume all ranges are inclusive: 1982-1984 means 1982,1983,1984.
• For input, the earliest start year is 1975 and the latest end year is 2017

# Examples

• 1983-1987 => DM (he hosted '85,'86,'87)
• 1999-2001 => CQ JF TF [CQJFTF also ok] (all hosted during two of those years)
• 1975-2017 => SM (has 9 years!)
• 1990-2000 => KN NM (both have 4 years)
• 2013-2015 => SM CS CJ MC (all have 2 years)

1Hm, currently this challenge seems to be about who can encode the hosts + years the best. Have you considered having the hosts + years also as an input? – Stephen – 2017-07-18T21:18:19.097

@StepHen Yeah, but I'm interested in how people are creative with encoding, and tried to make the names as short as possible as such. – geokavel – 2017-07-18T21:20:41.077

I knew there was a tag for this, found it. I really thought there was also a tag for storing data like that efficiently, but I couldn't find it. – Stephen – 2017-07-18T21:27:29.083

@StepHen Are you thinking of Kolmogorov Complexity? – geokavel – 2017-07-18T21:29:50.803

I guess that is what I am thinking of, although it doesn't quite match this challenge. I was always under the assumption that KC was for constant output, but I just checked the tag wiki and that's not what it says. – Stephen – 2017-07-18T21:31:37.333

@JaneCurtain You're wrecking my compression scheme... O_o – Arnauld – 2017-07-18T22:00:49.297

2

# Python 2, 291 bytes

def f(b,e):
s=''.join('A AB BC BCD BD BDE EFGH GHJ J JK KL L L L L L LM M M MN N N N O O OPQ PQ PQ PQ PQR QR QRS RS RS S S S S ST STUV UV UV UV'.split()[b-1975:e-1974]);C=s.count;return''.join({'CJDBCGBMCBCDKNCJTASCCMCCAMRMDGEHGMNMQFFPMSJC'[ord(h)-65::22]for h in s if C(h)==max(map(C,s))})


Try it online!

1

# Python 2, 325 bytes

def f(x,y):a=sum([s.split(',')for s in('CC CC,JC JC,DA JC,DA,BM JC,BM JC,BM,CR CR,GM,BD,BD BD,MG,CE,BH BH BH,CG CG,'+'DM '*6+'DM,KN KN KN KN,'+'NM '*4+'CQ CQ CQ,'+'JF,TF '*4+'JF,TF,AP TF,AP TF,AP,SM AP,SM AP,'+'SM '*5+'SM,CS SM,CS,'+'CJ,MC '*4).split()[x-1975:y-1974]],[]);c=a.count;print{s for s in a if c(s)==max(map(c,a))}


Try it online!

### 284 bytes, but more boring:

def f(x,y):a=sum([s.split(',')for s in'eJx1z9sJwzAUBNFWtoBpwlrZCgrX+NV/LVEiHBxMYDjs79qyqVY1eeiS4j1O8SZvlCDllppR8Eh66BMuciGHbvGcdcYc+ua1R504Jv2RYdFF9tDV3/DexZVov26+ACfwONE='.decode('base64').decode('zip').split()[x-1975:y-1974]],[]);c=a.count;print{s for s in a if c(s)==max(map(c,a))}


Try it online!

There's at least one secret you haven't found yet that saves a couple (or more) bytes. – geokavel – 2017-07-18T22:54:21.947

@geokavel I can get down by 20 or so bytes I think. I'm trying to beat the "zip the text and decode it" approach but I haven't so far – musicman523 – 2017-07-18T23:08:44.960

@rosslh I don't think you saved your TIO link – musicman523 – 2017-07-19T00:02:57.600

Interestingly, using the % formatting is the same length as without the % formatting

– musicman523 – 2017-07-19T00:15:30.663

1

## JavaScript (ES6), 201200 199 bytes

Takes the year range in currying syntax (a)(b). Returns a string made of concatenated initials.

a=>b=>"MCCJCSSMAPTFJFCQNMKNDMCGBHCEMGBDGMCRBMDAJCCC".match(/../g).reduce((o,c,n)=>(s=(a<(x-='0017240243612010012111'[n])?x:a)-(b<(y=+'3318464233612011012141'[n]+x)?b:y))>m?o:s<m?(m=s,c):c+o,m=x=2014)


### Test cases

let f =

a=>b=>"MCCJCSSMAPTFJFCQNMKNDMCGBHCEMGBDGMCRBMDAJCCC".match(/../g).reduce((o,c,n)=>(s=(a<(x-='0017240243612010012111'[n])?x:a)-(b<(y=+'3318464233612011012141'[n]+x)?b:y))>m?o:s<m?(m=s,c):c+o,m=x=2014)

console.log(f(1983)(1987)) // => DM
console.log(f(1999)(2001)) // => CQ JF TF
console.log(f(1975)(2017)) // => SM
console.log(f(1990)(2000)) // => KN NM
console.log(f(2013)(2015)) // => SM CS CJ MC`