Last active
May 25, 2020 11:55
-
-
Save grze2000/e33cfe69628729489ea7635b96dcc7b0 to your computer and use it in GitHub Desktop.
Matura Informatyka 2019 zadanie 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def readFile(path): | |
with open(path) as file: | |
return list(map(lambda x: x.strip().split('\t'), file.readlines()))[1:] | |
marki = readFile('marki.txt') | |
perfumy = readFile('perfumy.txt') | |
sklad = readFile('sklad.txt') | |
# 6.1 | |
id = [item[0] for item in sklad if item[1] == 'absolut jasminu'] | |
names = [item[1] for item in perfumy if item[0] in id] | |
print(names) | |
# 6.2 | |
families = dict() | |
for item in perfumy: | |
if item[3] in families: | |
if int(item[4]) < families[item[3]][0]: | |
families[item[3]] = [int(item[4]), item[1]] | |
else: | |
families[item[3]] = [int(item[4]), item[1]] | |
familiesSorted = sorted(families.items(), key=lambda x: x[0]) | |
familiesString = list(map(lambda x: x[0]+' '+' '.join(list(map(str, x[1]))), familiesSorted)) | |
print('\n', familiesString) | |
# 6.3 | |
id2 = [item[0] for item in sklad if re.search(r"paczula", item[1])] | |
id3 = {item[2] for item in perfumy if item[0] in id2} | |
names2 = sorted([item[1] for item in marki if not item[0] in id3]) | |
print('\n', names2) | |
# 6.4 | |
perfume = sorted([[item[1], round(int(item[4])*0.85, 2)] for item in perfumy if item[2] == 'm_1' and item[3] == 'orientalno-drzewna'], key=lambda x: x[1]) | |
print('\n', perfume) | |
# 6.5 | |
brands = dict() | |
for item in perfumy: | |
if item[2] in brands: | |
brands[item[2]].add(item[3]) | |
else: | |
brands[item[2]] = {item[3]} | |
names3 = [[item[0], list(item[1])[0]] for item in brands.items() if len(item[1]) == 1] | |
for i in names3: | |
for j in marki: | |
if i[0] == j[0]: | |
i[0] = j[1] | |
break | |
print('\n', names3) | |
with open('wyniki6.txt', 'w') as result: | |
result.write('6.1\n') | |
result.write('\n'.join(names)) | |
result.write('\n\n6.2\n') | |
result.write('\n'.join(familiesString)) | |
result.write('\n\n6.3\n') | |
result.write('\n'.join(names2)) | |
result.write('\n\n6.4\n') | |
result.write('\n'.join(list(map(lambda x: '\t'.join(list(map(str, x))), perfume)))) | |
result.write('\n\n6.5\n') | |
result.write('\n'.join(list(map(lambda x: '\t'.join(x), names3)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6.1 | |
Oyal Priather | |
Ologne D'oud | |
Uelques FleuE | |
6.2 | |
aromatyczna 124 Ibrary Ollec D'amore | |
cytrusowa 259 Sian Grad | |
cytrusowo-aromatyczna 178 Re Nostrum,ir | |
drzewna 123 Pperlee Bouquet | |
kwiatowa 110 Ose Deurmaline | |
kwiatowo-drzewna 104 Rougna | |
kwiatowo-orientalna 103 Arla : Vivace | |
kwiatowo-szyprowa 287 Etish Pothal | |
orientalna 113 Anille La Tosca | |
orientalna lagodna 122 Ndy Warhol S Rose | |
orientalno-drzewna 138 LackNight | |
owocowa 154 Ake Perfucturne | |
pudrowa 139 Ivm Cristal | |
skorzana 112 Ui Mare | |
szyprowa 226 Usk ti 1888 | |
szyprowo-skorzana 158 Uir OtPlace | |
wodna 146 Ilver Mounaya | |
zielona 406 EOman | |
6.3 | |
Aison Eranciro | |
Arthbey | |
Embert Lucas | |
Enmith | |
Nnick a Kieffo | |
6.4 | |
Ourn Boise 141.95 | |
Onou Back 222.7 | |
Pic An 230.35 | |
Nterl Bambola 292.4 | |
Ubilatio Champs 381.65 | |
Ibrary Ollec D'or 489.6 | |
Ate An 544.85 | |
Elov & Musc 660.45 | |
6.5 | |
Nnick a Kieffo orientalna | |
Ightce aromatyczna | |
X ICologne orientalno-drzewna | |
Enmith kwiatowo-orientalna | |
Issmkunstwerke orientalna |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment