feat: Initial commit
This commit is contained in:
3
Laboratorio11/bad_words.txt
Normal file
3
Laboratorio11/bad_words.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
sesso
|
||||
droga
|
||||
C++
|
||||
27
Laboratorio11/censore.py
Normal file
27
Laboratorio11/censore.py
Normal file
@@ -0,0 +1,27 @@
|
||||
def readBadWords(filename: str):
|
||||
fio = open(filename, "r")
|
||||
bad_words = set()
|
||||
|
||||
for line in fio:
|
||||
bad_words.add(line.strip())
|
||||
|
||||
fio.close()
|
||||
return bad_words
|
||||
|
||||
|
||||
def main():
|
||||
bad_words = readBadWords("bad_words.txt")
|
||||
|
||||
fio = open("input.txt", "r")
|
||||
fout = open("output.txt", "w")
|
||||
|
||||
for line in fio:
|
||||
for wrd in bad_words:
|
||||
line = line.replace(wrd, "*"*len(wrd))
|
||||
|
||||
fout.write(line)
|
||||
|
||||
fio.close()
|
||||
fout.close()
|
||||
|
||||
main()
|
||||
32
Laboratorio11/cmqStrings.py
Normal file
32
Laboratorio11/cmqStrings.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from string import printable
|
||||
|
||||
def main():
|
||||
a = list(input("Prima stringa: "))
|
||||
b = list(input("Seconda stringa: "))
|
||||
|
||||
both = set()
|
||||
ina = set()
|
||||
inb = set()
|
||||
nowhere = set()
|
||||
|
||||
for char in printable:
|
||||
ia = char in a
|
||||
iab = char in b
|
||||
|
||||
if ia and iab:
|
||||
both.add(char)
|
||||
elif ia:
|
||||
ina.add(char)
|
||||
elif iab:
|
||||
inb.add(char)
|
||||
else:
|
||||
nowhere.add(char)
|
||||
|
||||
print(both)
|
||||
print(ina)
|
||||
print(inb)
|
||||
print(nowhere)
|
||||
|
||||
|
||||
|
||||
main()
|
||||
40
Laboratorio11/countWords.py
Normal file
40
Laboratorio11/countWords.py
Normal file
@@ -0,0 +1,40 @@
|
||||
def clean(word: str):
|
||||
a = len(word)
|
||||
|
||||
while True:
|
||||
word = word.strip("()[]{}!?.,<>:;-_`’‘")
|
||||
if a == len(word):
|
||||
break
|
||||
|
||||
a = len(word)
|
||||
|
||||
return word
|
||||
|
||||
def main():
|
||||
filename = input("Inserisci il nome del file: ")
|
||||
fio = open(filename, "r")
|
||||
|
||||
words = {}
|
||||
|
||||
for line in fio:
|
||||
for word in line.split():
|
||||
word = clean(word)
|
||||
if word not in words:
|
||||
words[word] = 1
|
||||
else:
|
||||
words[word] += 1
|
||||
|
||||
fio.close()
|
||||
|
||||
vals = sorted(words.values(), reverse=True)
|
||||
|
||||
for i in range(0, 100):
|
||||
for word in words:
|
||||
if words[word] == vals[i]:
|
||||
print(word, end=" ")
|
||||
words.pop(word)
|
||||
break
|
||||
|
||||
print()
|
||||
|
||||
main()
|
||||
229
Laboratorio11/export.csv
Normal file
229
Laboratorio11/export.csv
Normal file
@@ -0,0 +1,229 @@
|
||||
name,slug,value,date_of_information,ranking,region
|
||||
"Liechtenstein","liechtenstein","$139,100","2009 est.","1","Europe"
|
||||
"Monaco","monaco","$115,700","2015 est.","2","Europe"
|
||||
"Luxembourg","luxembourg","$110,300","2020 est.","3","Europe"
|
||||
"Singapore","singapore","$93,400","2020 est.","4","East Asia/Southeast Asia"
|
||||
"Ireland","ireland","$89,700","2020 est.","5","Europe"
|
||||
"Qatar","qatar","$85,300","2020 est.","6","Middle East"
|
||||
"Isle of Man","isle-of-man","$84,600","2014 est.","7","Europe"
|
||||
"Bermuda","bermuda","$81,800","2019 est.","8","North America"
|
||||
"Cayman Islands","cayman-islands","$73,600","2019 est.","9","Central America"
|
||||
"Falkland Islands (Islas Malvinas)","falkland-islands-islas-malvinas","$70,800","2015 est.","10","South America"
|
||||
"Switzerland","switzerland","$68,400","2020 est.","11","Europe"
|
||||
"United Arab Emirates","united-arab-emirates","$67,100","2019 est.","12","Middle East"
|
||||
"Norway","norway","$63,600","2020 est.","13","Europe"
|
||||
"Brunei","brunei","$62,200","2020 est.","14","East Asia/Southeast Asia"
|
||||
"Gibraltar","gibraltar","$61,700","2014 est.","15","Europe"
|
||||
"San Marino","san-marino","$60,800","2019 est.","16","Europe"
|
||||
"United States","united-states","$60,200","2020 est.","17","North America"
|
||||
"Jersey","jersey","$56,600","2016 est.","18","Europe"
|
||||
"Hong Kong","hong-kong","$56,200","2020 est.","19","East Asia/Southeast Asia"
|
||||
"Denmark","denmark","$55,900","2020 est.","20","Europe"
|
||||
"Macau","macau","$54,800","2020 est.","21","East Asia/Southeast Asia"
|
||||
"Netherlands","netherlands","$54,200","2020 est.","22","Europe"
|
||||
"Guernsey","guernsey","$52,500","2014 est.","23","Europe"
|
||||
"Iceland","iceland","$52,300","2020 est.","24","Europe"
|
||||
"Austria","austria","$51,900","2020 est.","25","Europe"
|
||||
"Germany","germany","$50,900","2020 est.","26","Europe"
|
||||
"Sweden","sweden","$50,700","2020 est.","27","Europe"
|
||||
"Andorra","andorra","$49,900","2015 est.","28","Europe"
|
||||
"Kuwait","kuwait","$49,900","2019 est.","29","Middle East"
|
||||
"Australia","australia","$48,700","2020 est.","30","Australia - Oceania"
|
||||
"Belgium","belgium","$48,200","2020 est.","31","Europe"
|
||||
"Finland","finland","$47,300","2020 est.","32","Europe"
|
||||
"Saint Pierre and Miquelon","saint-pierre-and-miquelon-2","$46,200","2006 est.","33","North America"
|
||||
"Canada","canada","$45,900","2020 est.","34","North America"
|
||||
"Saudi Arabia","saudi-arabia","$44,300","2020 est.","35","Middle East"
|
||||
"New Zealand","new-zealand","$42,400","2020 est.","36","Australia - Oceania"
|
||||
"Korea, South","korea-south","$42,300","2020 est.","37","East Asia/Southeast Asia"
|
||||
"France","france","$42,000","2020 est.","38","Europe"
|
||||
"Greenland","greenland","$41,800","2015 est.","39","North America"
|
||||
"United Kingdom","united-kingdom","$41,600","2020 est.","40","Europe"
|
||||
"Japan","japan","$41,400","2019 est.","41","East Asia/Southeast Asia"
|
||||
"Bahrain","bahrain","$40,900","2020 est.","42","Middle East"
|
||||
"Faroe Islands","faroe-islands","$40,000","2014 est.","43","Europe"
|
||||
"Malta","malta","$39,200","2020 est.","44","Europe"
|
||||
"Italy","italy","$39,000","2020 est.","45","Europe"
|
||||
"Czechia","czechia","$38,300","2020 est.","46","Europe"
|
||||
"Israel","israel","$38,300","2020 est.","47","Middle East"
|
||||
"Cyprus","cyprus","$37,700","2020 est.","48","Europe"
|
||||
"Aruba","aruba","$37,500","2017 est.","49","Central America"
|
||||
"Virgin Islands","virgin-islands","$37,000","2016 est.","50","Central America"
|
||||
"Lithuania","lithuania","$36,700","2020 est.","51","Europe"
|
||||
"Slovenia","slovenia","$36,500","2020 est.","52","Europe"
|
||||
"Spain","spain","$36,200","2020 est.","53","Europe"
|
||||
"Estonia","estonia","$35,600","2020 est.","54","Europe"
|
||||
"Guam","guam","$35,600","2016 est.","55","Australia - Oceania"
|
||||
"Sint Maarten","sint-maarten","$35,300","2018 est.","56","Central America"
|
||||
"British Virgin Islands","british-virgin-islands","$34,200","2017 est.","57","Central America"
|
||||
"Montserrat","montserrat","$34,000","2011 est.","58","Central America"
|
||||
"Puerto Rico","puerto-rico","$33,400","2020 est.","59","Central America"
|
||||
"Poland","poland","$32,200","2020 est.","60","Europe"
|
||||
"Portugal","portugal","$32,200","2020 est.","61","Europe"
|
||||
"New Caledonia","new-caledonia","$31,100","2015 est.","62","Australia - Oceania"
|
||||
"Hungary","hungary","$31,000","2020 est.","63","Europe"
|
||||
"Bahamas, The","bahamas-the","$30,800","2020 est.","64","Central America"
|
||||
"Slovakia","slovakia","$30,300","2020 est.","65","Europe"
|
||||
"Latvia","latvia","$29,900","2020 est.","66","Europe"
|
||||
"Romania","romania","$28,800","2020 est.","67","Europe"
|
||||
"Turkey","turkey","$28,400","2020 est.","68","Middle East"
|
||||
"Greece","greece","$27,300","2020 est.","69","Europe"
|
||||
"Oman","oman","$27,300","2019 est.","70","Middle East"
|
||||
"Croatia","croatia","$26,500","2020 est.","71","Europe"
|
||||
"Russia","russia","$26,500","2020 est.","72","Central Asia"
|
||||
"Malaysia","malaysia","$26,400","2020 est.","73","East Asia/Southeast Asia"
|
||||
"Panama","panama","$25,400","2020 est.","74","Central America"
|
||||
"Kazakhstan","kazakhstan","$25,300","2020 est.","75","Central Asia"
|
||||
"Taiwan","taiwan","$24,502","2018 est.","76","East Asia/Southeast Asia"
|
||||
"Curacao","curacao","$24,500","2019 est.","77","Central America"
|
||||
"Northern Mariana Islands","northern-mariana-islands","$24,500","2016 est.","78","Australia - Oceania"
|
||||
"Seychelles","seychelles","$24,400","2020 est.","79","Africa"
|
||||
"Trinidad and Tobago","trinidad-and-tobago","$23,700","2020 est.","80","Central America"
|
||||
"Chile","chile","$23,300","2020 est.","81","South America"
|
||||
"Saint Kitts and Nevis","saint-kitts-and-nevis","$23,300","2020 est.","82","Central America"
|
||||
"Bulgaria","bulgaria","$22,400","2020 est.","83","Europe"
|
||||
"Uruguay","uruguay","$21,600","2020 est.","84","South America"
|
||||
"Turks and Caicos Islands","turks-and-caicos-islands","$21,100","2020 est.","85","Central America"
|
||||
"Argentina","argentina","$19,700","2020 est.","86","South America"
|
||||
"Costa Rica","costa-rica","$19,700","2020 est.","87","Central America"
|
||||
"Mauritius","mauritius","$19,500","2020 est.","88","Africa"
|
||||
"Saint Martin","saint-martin","$19,300","2005 est.","89","Central America"
|
||||
"Belarus","belarus","$19,100","2020 est.","90","Europe"
|
||||
"Guyana","guyana","$18,700","2020 est.","91","South America"
|
||||
"Montenegro","montenegro","$18,300","2020 est.","92","Europe"
|
||||
"Serbia","serbia","$18,200","2020 est.","93","Europe"
|
||||
"Antigua and Barbuda","antigua-and-barbuda","$18,000","2020 est.","94","Central America"
|
||||
"Mexico","mexico","$17,900","2020 est.","95","North America"
|
||||
"Palau","palau","$17,600","2019 est.","96","Australia - Oceania"
|
||||
"Thailand","thailand","$17,300","2020 est.","97","East Asia/Southeast Asia"
|
||||
"Dominican Republic","dominican-republic","$17,000","2020 est.","98","Central America"
|
||||
"Equatorial Guinea","equatorial-guinea","$17,000","2020 est.","99","Africa"
|
||||
"French Polynesia","french-polynesia","$17,000","2015 est.","100","Australia - Oceania"
|
||||
"Cook Islands","cook-islands","$16,700","2016 est.","101","Australia - Oceania"
|
||||
"China","china","$16,400","2020 est.","102","East Asia/Southeast Asia"
|
||||
"Suriname","suriname","$16,100","2020 est.","103","South America"
|
||||
"Botswana","botswana","$16,000","2020 est.","104","Africa"
|
||||
"Turkmenistan","turkmenistan","$15,500","2019 est.","106","Central Asia"
|
||||
"Grenada","grenada","$15,100","2020 est.","107","Central America"
|
||||
"Gabon","gabon","$14,400","2020 est.","108","Africa"
|
||||
"Bosnia and Herzegovina","bosnia-and-herzegovina","$14,300","2020 est.","109","Europe"
|
||||
"Brazil","brazil","$14,100","2020 est.","110","South America"
|
||||
"Georgia","georgia","$14,100","2020 est.","111","Middle East"
|
||||
"Azerbaijan","azerbaijan","$13,700","2020 est.","112","Middle East"
|
||||
"Nauru","nauru","$13,500","2019 est.","113","Australia - Oceania"
|
||||
"Colombia","colombia","$13,400","2020 est.","114","South America"
|
||||
"Albania","albania","$13,300","2020 est.","115","Europe"
|
||||
"Maldives","maldives","$13,000","2020 est.","116","South Asia"
|
||||
"Barbados","barbados","$12,900","2020 est.","117","Central America"
|
||||
"Armenia","armenia","$12,600","2020 est.","118","Middle East"
|
||||
"Sri Lanka","sri-lanka","$12,500","2020 est.","119","South Asia"
|
||||
"Iran","iran","$12,400","2020 est.","120","Middle East"
|
||||
"Ukraine","ukraine","$12,400","2020 est.","121","Europe"
|
||||
"Cuba","cuba","$12,300","2016 est.","122","Central America"
|
||||
"Moldova","moldova","$12,300","2020 est.","123","Europe"
|
||||
"Paraguay","paraguay","$12,300","2020 est.","124","South America"
|
||||
"Saint Lucia","saint-lucia","$12,300","2020 est.","125","Central America"
|
||||
"Anguilla","anguilla","$12,200","2008 est.","126","Central America"
|
||||
"Saint Vincent and the Grenadines","saint-vincent-and-the-grenadines","$12,100","2020 est.","127","Central America"
|
||||
"Egypt","egypt","$12,000","2020 est.","128","Africa"
|
||||
"Lebanon","lebanon","$11,600","2020 est.","129","Middle East"
|
||||
"Mongolia","mongolia","$11,500","2020 est.","130","East Asia/Southeast Asia"
|
||||
"South Africa","south-africa","$11,500","2020 est.","131","Africa"
|
||||
"Indonesia","indonesia","$11,400","2020 est.","132","East Asia/Southeast Asia"
|
||||
"Peru","peru","$11,300","2020 est.","133","South America"
|
||||
"American Samoa","american-samoa","$11,200","2016 est.","134","Australia - Oceania"
|
||||
"Fiji","fiji","$11,000","2020 est.","135","Australia - Oceania"
|
||||
"Bhutan","bhutan","$10,900","2020 est.","136","South Asia"
|
||||
"Kosovo","kosovo","$10,800","2020 est.","137","Europe"
|
||||
"Algeria","algeria","$10,700","2020 est.","138","Africa"
|
||||
"Ecuador","ecuador","$10,300","2020 est.","139","South America"
|
||||
"Libya","libya","$10,300","2020 est.","140","Africa"
|
||||
"Dominica","dominica","$9,900","2020 est.","141","Central America"
|
||||
"Jordan","jordan","$9,800","2020 est.","142","Middle East"
|
||||
"Tunisia","tunisia","$9,700","2020 est.","143","Africa"
|
||||
"Iraq","iraq","$9,300","2020 est.","144","Middle East"
|
||||
"Namibia","namibia","$8,900","2020 est.","145","Africa"
|
||||
"Jamaica","jamaica","$8,700","2020 est.","146","Central America"
|
||||
"Eswatini","eswatini","$8,400","2020 est.","147","Africa"
|
||||
"Guatemala","guatemala","$8,400","2020 est.","148","Central America"
|
||||
"Vietnam","vietnam","$8,200","2020 est.","149","East Asia/Southeast Asia"
|
||||
"El Salvador","el-salvador","$8,100","2020 est.","150","Central America"
|
||||
"Philippines","philippines","$8,000","2020 est.","151","East Asia/Southeast Asia"
|
||||
"Bolivia","bolivia","$7,900","2020 est.","152","South America"
|
||||
"Laos","laos","$7,800","2020 est.","153","East Asia/Southeast Asia"
|
||||
"Saint Helena, Ascension, and Tristan da Cunha","saint-helena-ascension-and-tristan-da-cunha","$7,800","FY09/10 est.","154","Africa"
|
||||
"Venezuela","venezuela","$7,704","2018 est.","155","South America"
|
||||
"Uzbekistan","uzbekistan","$7,000","2020 est.","156","Central Asia"
|
||||
"Morocco","morocco","$6,900","2020 est.","157","Africa"
|
||||
"Tonga","tonga","$6,400","2019 est.","158","Australia - Oceania"
|
||||
"Samoa","samoa","$6,300","2020 est.","159","Australia - Oceania"
|
||||
"Gaza Strip","gaza-strip","$6,220","2019 est.","160","Middle East"
|
||||
"Angola","angola","$6,200","2020 est.","161","Africa"
|
||||
"Belize","belize","$6,100","2020 est.","162","Central America"
|
||||
"India","india","$6,100","2020 est.","163","South Asia"
|
||||
"Tokelau","tokelau","$6,004","2017 est.","164","Australia - Oceania"
|
||||
"Cabo Verde","cabo-verde","$6,000","2020 est.","165","Africa"
|
||||
"Niue","niue","$5,800","2003 est.","166","Australia - Oceania"
|
||||
"Djibouti","djibouti","$5,500","2020 est.","167","Africa"
|
||||
"West Bank","west-bank","$5,400","2020 est.","168","Middle East"
|
||||
"Ghana","ghana","$5,300","2020 est.","169","Africa"
|
||||
"Nicaragua","nicaragua","$5,300","2020 est.","170","Central America"
|
||||
"Cote d'Ivoire","cote-divoire","$5,200","2020 est.","171","Africa"
|
||||
"Honduras","honduras","$5,100","2020 est.","172","Central America"
|
||||
"Mauritania","mauritania","$5,000","2020 est.","173","Africa"
|
||||
"Nigeria","nigeria","$4,900","2020 est.","174","Africa"
|
||||
"Bangladesh","bangladesh","$4,800","2020 est.","175","South Asia"
|
||||
"Kyrgyzstan","kyrgyzstan","$4,700","2020 est.","176","Central Asia"
|
||||
"Pakistan","pakistan","$4,600","2020 est.","177","South Asia"
|
||||
"Burma","burma","$4,500","2020 est.","178","East Asia/Southeast Asia"
|
||||
"Tuvalu","tuvalu","$4,400","2020 est.","179","Australia - Oceania"
|
||||
"Cambodia","cambodia","$4,200","2020 est.","180","East Asia/Southeast Asia"
|
||||
"Kenya","kenya","$4,200","2020 est.","181","Africa"
|
||||
"Papua New Guinea","papua-new-guinea","$4,100","2020 est.","182","East Asia/Southeast Asia"
|
||||
"Sao Tome and Principe","sao-tome-and-principe","$4,100","2020 est.","183","Africa"
|
||||
"Marshall Islands","marshall-islands","$4,000","2019 est.","184","Australia - Oceania"
|
||||
"Sudan","sudan","$4,000","2020 est.","185","Africa"
|
||||
"Nepal","nepal","$3,800","2020 est.","186","South Asia"
|
||||
"Wallis and Futuna","wallis-and-futuna","$3,800","2004 est.","187","Australia - Oceania"
|
||||
"Tajikistan","tajikistan","$3,700","2020 est.","188","Central Asia"
|
||||
"Cameroon","cameroon","$3,600","2020 est.","189","Africa"
|
||||
"Micronesia, Federated States of","micronesia-federated-states-of","$3,500","2019 est.","190","Australia - Oceania"
|
||||
"Congo, Republic of the","congo-republic-of-the","$3,400","2020 est.","191","Africa"
|
||||
"Benin","benin","$3,300","2020 est.","192","Africa"
|
||||
"Senegal","senegal","$3,300","2020 est.","193","Africa"
|
||||
"Zambia","zambia","$3,300","2020 est.","194","Africa"
|
||||
"Timor-Leste","timor-leste","$3,200","2020 est.","195","East Asia/Southeast Asia"
|
||||
"Comoros","comoros","$3,100","2020 est.","196","Africa"
|
||||
"Syria","syria","$2,900","2015 est.","197","Middle East"
|
||||
"Haiti","haiti","$2,800","2020 est.","198","Central America"
|
||||
"Vanuatu","vanuatu","$2,800","2020 est.","199","Australia - Oceania"
|
||||
"Guinea","guinea","$2,700","2020 est.","200","Africa"
|
||||
"Zimbabwe","zimbabwe","$2,700","2020 est.","201","Africa"
|
||||
"Tanzania","tanzania","$2,600","2020 est.","202","Africa"
|
||||
"Solomon Islands","solomon-islands","$2,500","2020 est.","203","Australia - Oceania"
|
||||
"Yemen","yemen","$2,500","2017 est.","204","Middle East"
|
||||
"Ethiopia","ethiopia","$2,300","2020 est.","205","Africa"
|
||||
"Kiribati","kiribati","$2,300","2020 est.","206","Australia - Oceania"
|
||||
"Lesotho","lesotho","$2,300","2020 est.","207","Africa"
|
||||
"Burkina Faso","burkina-faso","$2,200","2020 est.","208","Africa"
|
||||
"Gambia, The","gambia-the","$2,200","2020 est.","209","Africa"
|
||||
"Mali","mali","$2,200","2020 est.","210","Africa"
|
||||
"Uganda","uganda","$2,200","2020 est.","211","Africa"
|
||||
"Rwanda","rwanda","$2,100","2020 est.","212","Africa"
|
||||
"Togo","togo","$2,100","2020 est.","213","Africa"
|
||||
"Afghanistan","afghanistan","$2,000","2020 est.","214","South Asia"
|
||||
"Guinea-Bissau","guinea-bissau","$1,800","2020 est.","215","Africa"
|
||||
"Korea, North","korea-north","$1,700","2015 est.","216","East Asia/Southeast Asia"
|
||||
"Eritrea","eritrea","$1,600","2017 est.","217","Africa"
|
||||
"Sierra Leone","sierra-leone","$1,600","2020 est.","218","Africa"
|
||||
"South Sudan","south-sudan","$1,600","2017 est.","219","Africa"
|
||||
"Chad","chad","$1,500","2020 est.","220","Africa"
|
||||
"Madagascar","madagascar","$1,500","2020 est.","221","Africa"
|
||||
"Malawi","malawi","$1,500","2020 est.","222","Africa"
|
||||
"Liberia","liberia","$1,400","2020 est.","223","Africa"
|
||||
"Mozambique","mozambique","$1,200","2020 est.","224","Africa"
|
||||
"Niger","niger","$1,200","2020 est.","225","Africa"
|
||||
"Congo, Democratic Republic of the","congo-democratic-republic-of-the","$1,100","2020 est.","226","Africa"
|
||||
"Central African Republic","central-african-republic","$900","2020 est.","227","Africa"
|
||||
"Somalia","somalia","$800","2020 est.","228","Africa"
|
||||
"Burundi","burundi","$700","2020 est.","229","Africa"
|
||||
|
1
Laboratorio11/input.txt
Normal file
1
Laboratorio11/input.txt
Normal file
@@ -0,0 +1 @@
|
||||
Faccio sesso e mi drogo tutto il giorno codando in C++
|
||||
95
Laboratorio11/maze.py
Normal file
95
Laboratorio11/maze.py
Normal file
@@ -0,0 +1,95 @@
|
||||
fio = open("maze.txt", "r")
|
||||
|
||||
maze_raw = fio.readlines()
|
||||
|
||||
fio.close()
|
||||
|
||||
xmax = len(maze_raw) - 1
|
||||
ymax = len(maze_raw[0].strip()) - 1
|
||||
|
||||
maze = {}
|
||||
sol = {}
|
||||
for x in range(len(maze_raw)):
|
||||
for y in range(len(maze_raw[x].strip())):
|
||||
paths = set()
|
||||
|
||||
if x > 0:
|
||||
if maze_raw[x - 1][y] == " ":
|
||||
paths.add((x - 1, y))
|
||||
|
||||
if y > 0:
|
||||
if maze_raw[x][y - 1] == " ":
|
||||
paths.add((x, y - 1))
|
||||
|
||||
if maze_raw[x][y] == " ":
|
||||
paths.add((x, y))
|
||||
|
||||
if y < ymax:
|
||||
if maze_raw[x][y + 1] == " ":
|
||||
paths.add((x, y + 1))
|
||||
|
||||
if x < xmax:
|
||||
if maze_raw[x + 1][y] == " ":
|
||||
paths.add((x + 1, y))
|
||||
|
||||
if len(paths) != 0:
|
||||
maze[(x,y)] = paths
|
||||
|
||||
if maze_raw[x][y] == "*":
|
||||
sol[(x,y)] = "*"
|
||||
else:
|
||||
sol[(x,y)] = "?"
|
||||
|
||||
for key in maze:
|
||||
if key[0] == 0:
|
||||
if maze_raw[key[0]][key[1]] == " ":
|
||||
sol[key] = "N"
|
||||
|
||||
if key[0] == xmax:
|
||||
if maze_raw[key[0]][key[1]] == " ":
|
||||
sol[key] = "S"
|
||||
|
||||
if key[1] == 0:
|
||||
if maze_raw[key[0]][key[1]] == " ":
|
||||
sol[key] = "W"
|
||||
|
||||
if key[1] == ymax:
|
||||
if maze_raw[key[0]][key[1]] == " ":
|
||||
sol[key] = "E"
|
||||
|
||||
cont = True
|
||||
|
||||
def check(xi, yi):
|
||||
global sol
|
||||
return (xi, yi) in sol and sol[xi, yi] != "?" and sol[xi, yi] != "*"
|
||||
|
||||
while cont:
|
||||
cont = False
|
||||
for key in maze:
|
||||
if sol[key] == "?":
|
||||
if check(key[0] - 1, key[1]):
|
||||
sol[key] = "N"
|
||||
cont = True
|
||||
continue
|
||||
|
||||
if check(key[0] + 1, key[1]):
|
||||
sol[key] = "S"
|
||||
cont = True
|
||||
continue
|
||||
|
||||
if check(key[0], key[1] - 1):
|
||||
sol[key] = "W"
|
||||
cont = True
|
||||
continue
|
||||
|
||||
if check(key[0], key[1] + 1):
|
||||
sol[key] = "E"
|
||||
cont = True
|
||||
continue
|
||||
|
||||
|
||||
for x in range(xmax+1):
|
||||
for y in range(ymax+1):
|
||||
print(sol[(x,y)],end="")
|
||||
|
||||
print()
|
||||
9
Laboratorio11/maze.txt
Normal file
9
Laboratorio11/maze.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
* *******
|
||||
* * * *
|
||||
* ***** *
|
||||
* * * *
|
||||
* * *** *
|
||||
* * *
|
||||
***** * *
|
||||
* * *
|
||||
******* *
|
||||
22
Laboratorio11/nazioniPIL.py
Normal file
22
Laboratorio11/nazioniPIL.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import csv
|
||||
|
||||
with open("export.csv") as csv_file:
|
||||
csv_reader = csv.reader(csv_file)
|
||||
|
||||
line_count = 0
|
||||
|
||||
nations = {}
|
||||
|
||||
for row in csv_reader:
|
||||
if line_count == 0:
|
||||
print(f'Column names are {", ".join(row)}')
|
||||
line_count += 1
|
||||
else:
|
||||
nations[row[0]] = row[2]
|
||||
|
||||
while True:
|
||||
uinput = input("Inserisci il nome della nazione o quit: ")
|
||||
if uinput == "quit":
|
||||
break
|
||||
|
||||
print(nations[uinput])
|
||||
1
Laboratorio11/output.txt
Normal file
1
Laboratorio11/output.txt
Normal file
@@ -0,0 +1 @@
|
||||
Faccio ***** e mi drogo tutto il giorno codando in ***
|
||||
33
Laboratorio11/sparseSum.py
Normal file
33
Laboratorio11/sparseSum.py
Normal file
@@ -0,0 +1,33 @@
|
||||
def sparseArraySum(a: dict, b: dict):
|
||||
vsum = {}
|
||||
|
||||
ka = a.keys()
|
||||
kb = b.keys()
|
||||
|
||||
sas = set()
|
||||
|
||||
for i in ka:
|
||||
sas.add(i)
|
||||
|
||||
for i in kb:
|
||||
sas.add(i)
|
||||
|
||||
for k in sas:
|
||||
d = 0
|
||||
e = 0
|
||||
|
||||
if k in a:
|
||||
d = a[k]
|
||||
|
||||
if k in b:
|
||||
e = b[k]
|
||||
|
||||
vsum[k] = d + e
|
||||
|
||||
return vsum
|
||||
|
||||
|
||||
da = {5:4, 9:2, 10:9}
|
||||
db = {5:4, 9:2, 2:3}
|
||||
|
||||
print(sparseArraySum(da, db))
|
||||
16449
Laboratorio11/test
Normal file
16449
Laboratorio11/test
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user