Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
tap1012
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
tap1012
Commits
56804e18
Commit
56804e18
authored
Jan 29, 2019
by
Aldo Eduardo Niebla Cruz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ejercicios realizados
parent
79a57786
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
276 additions
and
56 deletions
+276
-56
02-Comprehension&Documentation.ipynb
02-Comprehension&Documentation.ipynb
+276
-56
No files found.
02-Comprehension&Documentation.ipynb
View file @
56804e18
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
31
,
"execution_count":
253
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
"[2, 2, 4, 6, 8]"
"[2, 2, 4, 6, 8]"
]
]
},
},
"execution_count":
31
,
"execution_count":
253
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
40
,
"execution_count":
256
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
"[2, 2, 4, 6, 8]"
"[2, 2, 4, 6, 8]"
]
]
},
},
"execution_count":
40
,
"execution_count":
256
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -63,7 +63,7 @@
...
@@ -63,7 +63,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
3
8,
"execution_count":
18
8,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -81,7 +81,7 @@
...
@@ -81,7 +81,7 @@
" 9: 387420489}"
" 9: 387420489}"
]
]
},
},
"execution_count":
3
8,
"execution_count":
18
8,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -93,7 +93,7 @@
...
@@ -93,7 +93,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 3
7
,
"execution_count": 3
48
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -102,14 +102,15 @@
...
@@ -102,14 +102,15 @@
"[[1, 0, 0], [0, 1, 0], [0, 0, 1]]"
"[[1, 0, 0], [0, 1, 0], [0, 0, 1]]"
]
]
},
},
"execution_count": 3
7
,
"execution_count": 3
48
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"# Comprensión anidada\n",
"# Comprensión anidada\n",
"[ [ 1 if item_idx == row_idx else 0 for item_idx in range(0, 3) ] for row_idx in range(0, 3) ]"
"k = [ [ 1 if item_idx == row_idx else 0 for item_idx in range(0, 3) ] for row_idx in range(0, 3) ]\n",
"k"
]
]
},
},
{
{
...
@@ -151,7 +152,7 @@
...
@@ -151,7 +152,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
77
,
"execution_count":
38
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -160,7 +161,7 @@
...
@@ -160,7 +161,7 @@
"function"
"function"
]
]
},
},
"execution_count":
77
,
"execution_count":
38
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -192,29 +193,25 @@
...
@@ -192,29 +193,25 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
47
,
"execution_count":
186
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"name": "stdout",
"text/plain": [
"output_type": "stream",
"[(13, -3), (4, 1), (1, 2), (9, 10)]"
"text": [
"[(13, -3), (4, 1), (1, 2), (9, 10)]\n"
]
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"a = [(1, 2), (4, 1), (9, 10), (13, -3)]\n",
"a = [(1, 2), (4, 1), (9, 10), (13, -3)]\n",
"a.sort(key=lambda x: x[1])\n",
"a.sort(key=lambda x: x[1])"
"a"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
51
,
"execution_count":
69
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -241,14 +238,20 @@
...
@@ -241,14 +238,20 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
55
,
"execution_count":
161
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"499999500000\n"
"0\n",
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"15\n"
]
]
}
}
],
],
...
@@ -257,9 +260,10 @@
...
@@ -257,9 +260,10 @@
" num = 0\n",
" num = 0\n",
" while num
<
n:
\
n
",
" while num
<
n:
\
n
",
"
yield
num
\
n
",
"
yield
num
\
n
",
"
print
(
num
)\
n
",
"
num
+=
1
\
n
",
"
num
+=
1
\
n
",
"\
n
",
"\
n
",
"
sum_of_first_n =
sum(firstn(
1000000
))\n",
"
sum_of_first_n =
sum(firstn(
6
))\n",
"
print
(
sum_of_first_n
)"
"
print
(
sum_of_first_n
)"
]
]
},
},
...
@@ -272,7 +276,7 @@
...
@@ -272,7 +276,7 @@
},
},
{
{
"
cell_type
"
:
"
code
",
"
cell_type
"
:
"
code
",
"
execution_count
"
:
66
,
"
execution_count
"
:
110
,
"
metadata
"
:
{},
"
metadata
"
:
{},
"
outputs
"
:
[
"
outputs
"
:
[
{
{
...
@@ -303,16 +307,38 @@
...
@@ -303,16 +307,38 @@
"
source
"
:
[
"
source
"
:
[
"##
2
.
4
Ejercicios
\
n
",
"##
2
.
4
Ejercicios
\
n
",
"###
2
.
4
.
1
\
n
",
"###
2
.
4
.
1
\
n
",
"
Dada
una
lista
de
enteros
**
a
**,
utili
s
ando
una
comprensi
ó
n
,
Imprimir
una
nueva
lista
que
contenga
\"
par
\"
o
\"
impar
\"
en
cada
uno
de
sus
elementos
,
dependiendo
del
valor
del
elemento
en
la
lista
orginal
."
"
Dada
una
lista
de
enteros
**
a
**,
utili
z
ando
una
comprensi
ó
n
,
Imprimir
una
nueva
lista
que
contenga
\"
par
\"
o
\"
impar
\"
en
cada
uno
de
sus
elementos
,
dependiendo
del
valor
del
elemento
en
la
lista
orginal
."
]
]
},
},
{
{
"
cell_type
"
:
"
code
",
"
cell_type
"
:
"
code
",
"
execution_count
"
:
67
,
"
execution_count
"
:
374
,
"
metadata
"
:
{},
"
metadata
"
:
{},
"
outputs
"
:
[],
"
outputs
"
:
[
{
"
data
"
:
{
"
text
/
plain
"
:
[
"[(
0
,
'
par
'),\
n
",
"
(
1
,
'
impar
'),\
n
",
"
(
2
,
'
par
'),\
n
",
"
(
3
,
'
impar
'),\
n
",
"
(
4
,
'
par
'),\
n
",
"
(
5
,
'
impar
'),\
n
",
"
(
6
,
'
par
'),\
n
",
"
(
7
,
'
impar
'),\
n
",
"
(
8
,
'
par
'),\
n
",
"
(
9
,
'
impar
')]"
]
},
"
execution_count
"
:
374
,
"
metadata
"
:
{},
"
output_type
"
:
"
execute_result
"
}
],
"
source
"
:
[
"
source
"
:
[
"
a =
[0,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
]"
"
a =
[0,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
]\
n
",
"\
n
",
"[
(
x
,
'
par
')
if
x
%
2=
=0
else
(
x
,
'
impar
')
for
x
in
a
]"
]
]
},
},
{
{
...
@@ -325,11 +351,24 @@
...
@@ -325,11 +351,24 @@
},
},
{
{
"
cell_type
"
:
"
code
",
"
cell_type
"
:
"
code
",
"
execution_count
"
:
69
,
"
execution_count
"
:
342
,
"
metadata
"
:
{},
"
metadata
"
:
{},
"
outputs
"
:
[],
"
outputs
"
:
[
{
"
data
"
:
{
"
text
/
plain
"
:
[
"[(
0
,
'
apple
'),
(
1
,
'
banana
'),
(
2
,
'
grapes
'),
(
3
,
'
pear
')]"
]
},
"
execution_count
"
:
342
,
"
metadata
"
:
{},
"
output_type
"
:
"
execute_result
"
}
],
"
source
"
:
[
"
source
"
:
[
"
my_list =
['apple',
'
banana
',
'
grapes
',
'
pear
']\
n
"
"
my_list =
['apple',
'
banana
',
'
grapes
',
'
pear
']\
n
",
"\
n
",
"[
(
k
,
my_list
[
k
])
for
k
in
range
(
len
(
my_list
))
]\
n
"
]
]
},
},
{
{
...
@@ -342,12 +381,66 @@
...
@@ -342,12 +381,66 @@
},
},
{
{
"
cell_type
"
:
"
code
",
"
cell_type
"
:
"
code
",
"
execution_count
"
:
72
,
"
execution_count
"
:
349
,
"
metadata
"
:
{},
"
metadata
"
:
{},
"
outputs
"
:
[],
"
outputs
"
:
[
{
"
data
"
:
{
"
text
/
plain
"
:
[
"[(
0
,
'
a
'),\
n
",
"
(
0
,
'
b
'),\
n
",
"
(
0
,
'
c
'),\
n
",
"
(
0
,
'
d
'),\
n
",
"
(
0
,
'
e
'),\
n
",
"
(
0
,
'
f
'),\
n
",
"
(
1
,
'
a
'),\
n
",
"
(
1
,
'
b
'),\
n
",
"
(
1
,
'
c
'),\
n
",
"
(
1
,
'
d
'),\
n
",
"
(
1
,
'
e
'),\
n
",
"
(
1
,
'
f
'),\
n
",
"
(
2
,
'
a
'),\
n
",
"
(
2
,
'
b
'),\
n
",
"
(
2
,
'
c
'),\
n
",
"
(
2
,
'
d
'),\
n
",
"
(
2
,
'
e
'),\
n
",
"
(
2
,
'
f
'),\
n
",
"
(
3
,
'
a
'),\
n
",
"
(
3
,
'
b
'),\
n
",
"
(
3
,
'
c
'),\
n
",
"
(
3
,
'
d
'),\
n
",
"
(
3
,
'
e
'),\
n
",
"
(
3
,
'
f
'),\
n
",
"
(
4
,
'
a
'),\
n
",
"
(
4
,
'
b
'),\
n
",
"
(
4
,
'
c
'),\
n
",
"
(
4
,
'
d
'),\
n
",
"
(
4
,
'
e
'),\
n
",
"
(
4
,
'
f
'),\
n
",
"
(
5
,
'
a
'),\
n
",
"
(
5
,
'
b
'),\
n
",
"
(
5
,
'
c
'),\
n
",
"
(
5
,
'
d
'),\
n
",
"
(
5
,
'
e
'),\
n
",
"
(
5
,
'
f
'),\
n
",
"
(
6
,
'
a
'),\
n
",
"
(
6
,
'
b
'),\
n
",
"
(
6
,
'
c
'),\
n
",
"
(
6
,
'
d
'),\
n
",
"
(
6
,
'
e
'),\
n
",
"
(
6
,
'
f
')]"
]
},
"
execution_count
"
:
349
,
"
metadata
"
:
{},
"
output_type
"
:
"
execute_result
"
}
],
"
source
"
:
[
"
source
"
:
[
"
a =
[0,1,2,3,4,5,6]\n",
"
a =
[0,1,2,3,4,5,6]\n",
"
b =
[\"a\",\"b\",\"c\",\"d\",\"e\",\"f\"]"
"
b =
[\"a\",\"b\",\"c\",\"d\",\"e\",\"f\"]\n",
"\
n
",
"[
(
num
,
char
)
for
num
in
a
for
char
in
b
]"
]
]
},
},
{
{
...
@@ -360,11 +453,25 @@
...
@@ -360,11 +453,25 @@
},
},
{
{
"
cell_type
"
:
"
code
",
"
cell_type
"
:
"
code
",
"
execution_count
"
:
7
4
,
"
execution_count
"
:
35
4
,
"
metadata
"
:
{},
"
metadata
"
:
{},
"
outputs
"
:
[],
"
outputs
"
:
[
{
"
data
"
:
{
"
text
/
plain
"
:
[
"[
5
,
7
,
97
,
77
,
23
,
73
,
61
]"
]
},
"
execution_count
"
:
354
,
"
metadata
"
:
{},
"
output_type
"
:
"
execute_result
"
}
],
"
source
"
:
[
"
source
"
:
[
"
a=
[5,
7
,
22
,
97
,
54
,
62
,
77
,
23
,
73
,
61
]"
"
a=
[5,
7
,
22
,
97
,
54
,
62
,
77
,
23
,
73
,
61
]\
n
",
"\
n
",
"
b =
filter(lambda
y:
y
%
2=
=1,
a
)\
n
",
"
list
(
b
)"
]
]
},
},
{
{
...
@@ -377,11 +484,26 @@
...
@@ -377,11 +484,26 @@
},
},
{
{
"
cell_type
"
:
"
code
",
"
cell_type
"
:
"
code
",
"
execution_count
"
:
76
,
"
execution_count
"
:
3
76
,
"
metadata
"
:
{},
"
metadata
"
:
{},
"
outputs
"
:
[],
"
outputs
"
:
[
{
"
data
"
:
{
"
text
/
plain
"
:
[
"
193
"
]
},
"
execution_count
"
:
376
,
"
metadata
"
:
{},
"
output_type
"
:
"
execute_result
"
}
],
"
source
"
:
[
"
source
"
:
[
"
a =
[5,
8
,
10
,
20
,
50
,
100
]
"
"
from
functools
import
reduce
\
n
",
"\
n
",
"
a =
[5,
8
,
10
,
20
,
50
,
100
]\
n
",
"\
n
",
"
reduce
(
lambda
n
,
m:
n
+
m
,
a
)"
]
]
},
},
{
{
...
@@ -394,13 +516,27 @@
...
@@ -394,13 +516,27 @@
},
},
{
{
"
cell_type
"
:
"
code
",
"
cell_type
"
:
"
code
",
"
execution_count
"
:
78
,
"
execution_count
"
:
103
,
"
metadata
"
:
{},
"
metadata
"
:
{},
"
outputs
"
:
[],
"
outputs
"
:
[
{
"
data
"
:
{
"
text
/
plain
"
:
[
"[
35
,
45
,
55
,
65
]"
]
},
"
execution_count
"
:
103
,
"
metadata
"
:
{},
"
output_type
"
:
"
execute_result
"
}
],
"
source
"
:
[
"
source
"
:
[
"
a =
[5,
10
,
15
,
20
]\
n
",
"
a =
[5,
10
,
15
,
20
]\
n
",
"
\
n
",
"
\
n
",
"
b =
[30,
35
,
40
,
45
]"
"
b =
[30,
35
,
40
,
45
]\
n
",
"\
n
",
"
c =
map(
(
lambda
x
,
y:
x
+
y
),
a
,
b
)\
n
",
"
list
(
c
)"
]
]
},
},
{
{
...
@@ -413,6 +549,39 @@
...
@@ -413,6 +549,39 @@
"[
Wikipedia
](
https:
//
es
.
wikipedia
.
org
/
wiki
/
Terna_pitag
%
C3
%
B3rica
)
:
Una
terna
pitag
ó
rica
es
un
conjunto
ordenado
de
tres
n
ú
meros
enteros
positivos
a
,
b
,
c
,
y
son
soluci
ó
n
de
la
ecuaci
ó
n
diofantina
cuadr
á
tica
$
a
^{
2
}+
b
^{
2
}=
c
^{
2
}$.\
n
"
"[
Wikipedia
](
https:
//
es
.
wikipedia
.
org
/
wiki
/
Terna_pitag
%
C3
%
B3rica
)
:
Una
terna
pitag
ó
rica
es
un
conjunto
ordenado
de
tres
n
ú
meros
enteros
positivos
a
,
b
,
c
,
y
son
soluci
ó
n
de
la
ecuaci
ó
n
diofantina
cuadr
á
tica
$
a
^{
2
}+
b
^{
2
}=
c
^{
2
}$.\
n
"
]
]
},
},
{
"
cell_type
"
:
"
code
",
"
execution_count
"
:
14
,
"
metadata
"
:
{},
"
outputs
"
:
[
{
"
data
"
:
{
"
text
/
plain
"
:
[
"[[(
3
,
4
,
5
),\
n
",
"
(
5
,
12
,
13
),\
n
",
"
(
6
,
8
,
10
),\
n
",
"
(
7
,
24
,
25
),\
n
",
"
(
8
,
15
,
17
),\
n
",
"
(
9
,
12
,
15
),\
n
",
"
(
9
,
40
,
41
),\
n
",
"
(
10
,
24
,
26
),\
n
",
"
(
12
,
16
,
20
),\
n
",
"
(
12
,
35
,
37
)]]"
]
},
"
execution_count
"
:
14
,
"
metadata
"
:
{},
"
output_type
"
:
"
execute_result
"
}
],
"
source
"
:
[
"
def
Terna
(
n
)
:
\
n
",
"
TP =
[(a,
b
,
c
)
for
a
in
range
(
1
,
50
)
for
b
in
range
(
a
+
1
,
50
)
for
c
in
range
(
b
+
1
,
50
)
if
a
**
2
+
b
**
2 =
=
c
**
2
]\
n
",
"
yield
TP
[
0:n
]\
n
",
"
\
n
",
"
list
(
Terna
(
10
))"
]
},
{
{
"
cell_type
"
:
"
markdown
",
"
cell_type
"
:
"
markdown
",
"
metadata
"
:
{},
"
metadata
"
:
{},
...
@@ -423,11 +592,54 @@
...
@@ -423,11 +592,54 @@
},
},
{
{
"
cell_type
"
:
"
code
",
"
cell_type
"
:
"
code
",
"
execution_count
"
:
80
,
"
execution_count
"
:
27
,
"
metadata
"
:
{},
"
outputs
"
:
[
{
"
data
"
:
{
"
text
/
plain
"
:
[
"[['
a
',
'
b
',
'
c
'],\
n
",
"
['
a
',
'
c
',
'
b
'],\
n
",
"
['
b
',
'
a
',
'
c
'],\
n
",
"
['
b
',
'
c
',
'
a
'],\
n
",
"
['
c
',
'
a
',
'
b
'],\
n
",
"
['
c
',
'
b
',
'
a
']]"
]
},
"
execution_count
"
:
27
,
"
metadata
"
:
{},
"
output_type
"
:
"
execute_result
"
}
],
"
source
"
:
[
"
a =
[\"a\",
\"
b
\",
\"
c
\"]\
n
",
"\
n
",
"
def
Permuta
(
string
,
prefix=
\"\"):\n",
"
if
len
(
string
)
==
1:
\
n
",
"
yield
prefix
+
string
\
n
",
"
else:
\
n
",
"
for
i
in
range
(
len
(
string
))
:
\
n
",
"
yield
from
getPermutations
(
string
[
:i
]+
string
[
i
+
1:
],
prefix
+
string
[
i
])\
n
",
"\
n
",
"[
list
(
perm
)
for
perm
in
Permuta
(''.
join
(
a
))]"
]
},
{
"
cell_type
"
:
"
code
",
"
execution_count
"
:
24
,
"
metadata
"
:
{},
"
metadata
"
:
{},
"
outputs
"
:
[],
"
outputs
"
:
[],
"
source
"
:
[
"
source
"
:
[
"
a =
[\"a\",
\"
b
\",
\"
c
\"]"
"'''
no
tomar
en
cuenta
,
es
una
prueba
,
el
ejercicio
final
esta
arriba
'''
\
n
",
"
def
permuta
(
vec
,
k
,
storage
)
:
\
n
",
"
if
k
<
len
(
vec
)
:
\
n
",
"
for
i
in
range
(
k
,
len
(
vec
))
:
\
n
",
"
vec
[
k
],
vec
[
i
]
=
vec
[
i
],
vec
[
k
]\
n
",
"
permuta
(
vec
,
k
+
1
,
storage
)\
n
",
"
vec
[
k
],
vec
[
i
]
=
vec
[
i
],
vec
[
k
]\
n
",
"
else:
\
n
",
"
storage
.
append
(
vec
)\
n
",
"
print
(
vec
)\
n
"
]
]
},
},
{
{
...
@@ -447,20 +659,28 @@
...
@@ -447,20 +659,28 @@
},
},
{
{
"
cell_type
"
:
"
code
",
"
cell_type
"
:
"
code
",
"
execution_count
"
:
1
,
"
execution_count
"
:
87
,
"
metadata
"
:
{},
"
metadata
"
:
{},
"
outputs
"
:
[
"
outputs
"
:
[
{
{
"
name
"
:
"
stdout
",
"
data
"
:
{
"
output_type
"
:
"
stream
",
"
text
/
plain
"
:
[
"
text
"
:
[
"[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
]"
"
hello
\
n
"
]
]
},
"
execution_count
"
:
87
,
"
metadata
"
:
{},
"
output_type
"
:
"
execute_result
"
}
}
],
],
"
source
"
:
[
"
source
"
:
[
"
from
miModulo
import
helloWorld
\
n
",
"#
from
miModulo
import
helloWorld
\
n
",
"
helloWorld
.
hello
()"
"#
helloWorld
.
hello
()\
n
",
"\
n
",
"
lista=
[]\n",
"
for
i
in
range
(
20
)
:
\
n
",
"
lista
.
append
(
i
)\
n
",
"
lista
"
]
]
},
},
{
{
...
...
Write
Preview
Markdown
is supported
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