Skip to content

Instantly share code, notes, and snippets.

@andriiburka
Created March 24, 2020 10:42
Show Gist options
  • Save andriiburka/20f2c200fc2528038669ddeafbda8b8e to your computer and use it in GitHub Desktop.
Save andriiburka/20f2c200fc2528038669ddeafbda8b8e to your computer and use it in GitHub Desktop.
Concert.py 90/100
'''
/\\\\\\\\\ /\\\
/\\////////\\\ \/\\\
/\\\ \/\\\ \/\\\ /\\\ /\\\
\/\\\ \/\\\ /\\/\\\\\\ \/\\\ /\\/\\\\\\\ \/// \///
\/\\\\\\\\\\\\\\\ \/\\\////\\\ /\\\\\\\\\ \/\\\/////\\\ /\\\ /\\\
\/\\\/////////\\\ \/\\\ \//\\\ /\\\////\\\ \/\\\ \/// \/\\\ \/\\\
\/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\
\/\\\ \/\\\ \/\\\ \/\\\ \//\\\\\\\/\\ \/\\\ \/\\\ \/\\\
\/// \/// \/// \/// \///////\// \/// \/// \///
/\\\\\\\\\\\\\
\/\\\/////////\\\ /\\\
\/\\\ \/\\\ \/\\\
\/\\\\\\\\\\\\\\ /\\\ /\\\ /\\/\\\\\\\ \/\\\\\\\\ /\\\\\\\\\
\/\\\/////////\\\ \/\\\ \/\\\ \/\\\/////\\\ \/\\\////\\\ \////////\\\
\/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/// \/\\\\\\\\/ /\\\\\\\\\\
\/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\///\\\ /\\\/////\\\
\/\\\\\\\\\\\\\/ \//\\\\\\\\\ \/\\\ \/\\\_\///\\\ \//\\\\\\\\/\\
\///////////// \///////// \/// \/// \/// \////////\// '''
import re
concert_dict = {}
bands_time = {}
popular_band_stars = ''
while True:
command = re.split("; ", input())
if "start of concert" in command:
popular_band_stars = input()
break
elif "Add" in command:
cmd_add = command[0]
band_add = command[1]
stars_add = re.split(", ", command[2])
if band_add not in concert_dict:
concert_dict[band_add] = stars_add
else:
[concert_dict[band_add].append(name) for name in stars_add if name not in concert_dict[band_add]]
elif "Play" in command:
cmd_play = command[0]
band_play = command[1]
time_play = int(command[2])
if band_play not in bands_time:
bands_time[band_play] = time_play
else:
bands_time[band_play] += time_play
print(f"Total time: {sum([time for band, time in bands_time.items()])}")
[print(f"{band} -> {time}") for band, time in sorted(bands_time.items(), key=lambda item: -item[1])]
if popular_band_stars in concert_dict:
print(popular_band_stars)
[print(f"=> {star}") for star in concert_dict[popular_band_stars]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment