# Up 12 at 4 it's [closed]

## Introduction

On BBC Radio 2, on Saturdays there's a show hosted by Tony Blackburn called Pick of the Pops. Here, Tony selects a random week from a random year (in the range 1960-1989), and plays the songs which were in the top 20 charts at the time.

## Challenge

Given a list of songs played on one Pick of the Pops episode, you must determine the year which Tony has chosen.

## Further Information

### Input

The input will be given as a string (either by STDIN or function arguments), with each list item separated by a comma.

The input will sorted with the number one single first, carrying on in order until the list ends with the number 20 single.

On the actual show, Blackburn plays the charts for two different years. This will not be the case for your input, only the chart for your one year will be supplied.

If song usually has a comma in its name, then the comma will be omitted.

### Output

Your output should simply be the year in the format YYYY (1989, 2365, 1901).

If for any reason, multiple years are found (say if the charts are form the first week of the year), then either select the first year or output both, comma separated.

### Rules

You can read from either a file or the internet.

If you use the internet, you must only use pages on the website officialcharts.com.

Note: if you read from a Wikipedia page, the page must have been created before the 23rd of August 2015.

The charts will be from the national UK charts, not international or of any other country.

Your output must be in the range of 1960 - 1989.

## Examples

### Input

Ticket to Ride,Here Comes the Night,The Minute You're Gone,Concrete and Clay,Little Things,Catch the Wind,For Your Love,King of the Road,The Last Time,Pop Go the Workers,Bring It On Home to Me,Stop in the Name of Love,Times They Are A-Changin',You're Breakin' My Heart,I Can't Explain,I'll Be There,Everybody's Gonna Be Happy,It's Not Usual,A World of Our Own,True Love Ways


### Output

1965


## Winning

The person with the shortest program in bytes wins.

## Note

At the moment, I'm still downloading all of the chart information, but you can use the following Python 2 code to retrieve the necessary information and create the file. (Requires the requests module)

import requests, re, datetime, time

date = datetime.date(1960,1,1)
prevyear=0
year = 1960

delay = # Set the delay yourself. So far 4 seconds still makes the download fail

while date.year != 1990:

response = requests.get("http://www.officialcharts.com/charts/singles-chart/%d%02d%02d"%(date.year, date.month, date.day)).text
time.sleep(delay)

tags = re.findall("<a href=\"/search/singles/.+\">.+</a>", response)[:20]
top20s = []

for i in tags[:]:
tag = re.sub("<a href=\"/search/singles/.+\">", "", i)
tag = re.sub("</a>","",tag)
top20s.append(tag)

top20s = list(map(lambda x:x.replace(",",""), top20s))

with open("songs.txt", "a") as f:
if year != prevyear:
string = str(year)+"\n"
else:
string = ""

chart = ",".join(top20s)

f.write(string+chart+"\n")

prevyear = year
date += datetime.timedelta(days=7)
year = date.year

• I'd suggest that you compile the information into one file, which would then be the only ressource everoyne can use. Aug 24, 2015 at 11:55
• What to do about songs with commas in the title? Such as Walk, Don't Run by the Ventures (1960). Aug 24, 2015 at 15:25
• @Geobits The comma will be removed Aug 24, 2015 at 15:26
• The grammar in the title is like sandpaper against my brain. Aug 24, 2015 at 17:00
• By the way, your username should be (for Greek accuracy) βήτα διάσπαση. Aug 9, 2016 at 16:27

## C# (277, 271, 223 compacted bytes)

After six years, this deserves an answer, so I'm going to make some assumptions:

• The data is stored in the file: C:\songs.txt.
• The songs for each week are stored on a new line in the following format:
• yyyy:song,song,song,...

var @in = Console.ReadLine();
foreach (var w in d.Split('\n')) {
var wd = w.Split(':');
if (wd[1].Split(',').Any(a => @in.Split(',').ToList().Any(i => i.Equals(a)))) {
Console.Write(wd[0]);
break;
}
}


Note: Compacted in this case means removing all line breaks and unnecessary whitespace. I'm retaining proper formatting for the sake of readability.

• TIO
– jdt
Sep 28, 2021 at 12:17