Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Mareš
prm1
Commits
24b0db21
Commit
24b0db21
authored
Nov 15, 2019
by
Martin Mareš
Browse files
06: Řešení příkladů z cvičení
parent
5d1c058f
Changes
1
Hide whitespace changes
Inline
Side-by-side
07-compr/priklady.py
0 → 100644
View file @
24b0db21
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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment