Skip to content
Snippets Groups Projects
Commit 24b0db21 authored by Martin Mareš's avatar Martin Mareš
Browse files

06: Řešení příkladů z cvičení

parent 5d1c058f
No related branches found
No related tags found
No related merge requests found
def skalarni_soucin(x, y):
return sum([i*j for i, j in zip(x, y)])
def nasobilka(n):
return [[i*j for i in range(1, n+1)] for j in range(1, n+1)]
def prunik_seznamu(x, y):
return [a for a in x if a in y]
def palindromy(radek):
return [slovo for slovo in radek.split() if slovo == slovo[::-1]]
def transpozice(x):
return [[a[i] for a in x] for i in range(len(x[0]))]
def nasobeni_matic(x, y):
yt = transpozice(y)
return [[skalarni_soucin(rx, ryt) for ryt in yt] for rx in x]
def slova_podle_delky(radek):
dvojice = [ (len(slovo), slovo) for slovo in radek.split() ]
for _, slovo in sorted(dvojice):
print(slovo)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment