Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 805d8b9

Browse files
propagate Greg Eakin's suggestions, corrections and improvements over to the Spanish language tree
1 parent cf99d17 commit 805d8b9

File tree

6 files changed

+23
-16
lines changed

6 files changed

+23
-16
lines changed

‎es/ch07/caballos.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_3x4(self):
9696
anchura = 4
9797
altura = 3
9898
# 1,0 2,0 3,0
99-
# 0,2 1,2 2,0
99+
# 0,2 1,2 2,2
100100
# 2 C C C .
101101
# 1 . . . .
102102
# 0 . C C C
@@ -114,8 +114,8 @@ def test_10x10(self):
114114
self.encontrarCaballoPosiciones(anchura, altura, 22)
115115

116116
def test_12x12(self):
117-
anchura = 13
118-
altura = 13
117+
anchura = 12
118+
altura = 12
119119
self.encontrarCaballoPosiciones(anchura, altura, 28)
120120

121121
def test_13x13(self):

‎es/ch09/mochila.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,12 @@ def __init__(self, pesoTotal, volumenTotal, valorTotal):
261261
self.ValorTotal = valorTotal
262262

263263
def __gt__(self, otro):
264-
return self.ValorTotal > otro.ValorTotal
264+
if self.ValorTotal != otro.ValorTotal:
265+
return self.ValorTotal > otro.ValorTotal
266+
if self.PesoTotal != otro.PesoTotal:
267+
return self.PesoTotal < otro.PesoTotal
268+
return self.VolumenTotal < otro.VolumenTotal
269+
265270

266271
def __str__(self):
267272
return "peso: {:0.2f} vol: {:0.2f} valor: {}".format(

‎es/ch13/pi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def fnMudar(genes):
9191
aptitudÓptima, geneSet, fnMostrar,
9292
fnMudar, edadMáxima=250,
9393
segundosMáximos=segundosMáximos)
94-
return mejor.Aptitud>=aptitudÓptima
94+
return aptitudÓptima<=mejor.Aptitud
9595

9696
def test_optimize(self):
9797
geneSet = [i for i in range(1, 512 + 1)]

‎es/ch15/pruebas.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def fnMudar(niño):
245245
edadMáxima=None, tamañoDePiscina=10,
246246
intercambiar=intercambiar)
247247

248-
self.assertTrue(not mejor.Aptitud > aptitudÓptima)
248+
self.assertTrue(not aptitudÓptima > mejor.Aptitud)
249249

250250

251251
class Corta:
@@ -379,14 +379,14 @@ def __init__(self, genes):
379379
len(funcs[func_id].Instrucciones) == 0:
380380
del func.Instrucciones[índice]
381381

382-
for índice in reversed(range(len(temp))):
383-
if type(temp[índice]) is Llama:
384-
func_id = temp[índice].FuncId
385-
if func_id is None:
386-
continue
387-
if func_id >= len(funcs) or \
388-
len(funcs[func_id].Instrucciones) == 0:
389-
del temp[índice]
382+
for índice in reversed(range(len(temp))):
383+
if type(temp[índice]) is Llama:
384+
func_id = temp[índice].FuncId
385+
if func_id is None:
386+
continue
387+
if func_id >= len(funcs) or \
388+
len(funcs[func_id].Instrucciones) == 0:
389+
del temp[índice]
390390
self.Principal = temp
391391
self.Funcs = funcs
392392

‎es/ch17/regex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def __gt__(self, otro):
364364
conjunto = (self._totalDeseado -
365365
self.NúmeroDeDeseadosQueCoincidieron) + \
366366
self.NúmeroDeNoDeseadosQueCoincidieron
367-
otroConjunto = (self._totalDeseado -
367+
otroConjunto = (otro._totalDeseado -
368368
otro.NúmeroDeDeseadosQueCoincidieron) + \
369369
otro.NúmeroDeNoDeseadosQueCoincidieron
370370
if conjunto != otroConjunto:
@@ -379,7 +379,7 @@ def __gt__(self, otro):
379379
return self.Longitud < otro.Longitud
380380

381381
def __str__(self):
382-
return "coincide con {} deseadas y {} no deseadas, lon {}".format(
382+
return "coincide con: {} deseadas y, {} no deseadas, lon {}".format(
383383
"todas" if self._totalDeseado ==
384384
self.NúmeroDeDeseadosQueCoincidieron else
385385
self.NúmeroDeDeseadosQueCoincidieron,

‎es/ch18/ticTacToe.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ def mudar_mover(genes):
200200
aMover = genes[principio:fin]
201201
genes[principio:fin] = []
202202
índice = random.choice(range(len(genes)))
203+
if índice >= principio:
204+
índice += 1
203205
genes[índice:índice] = aMover
204206
return True
205207

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /