Skip to content

Commit 9c565b6

Browse files
authored
Solución Reto mouredev#44 [lenguaje]" (Ej: Solución Reto #0 Python)
1 parent 97fed81 commit 9c565b6

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed
Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
package com.mouredev.weeklychallenge2022
1+
#* Enunciado: Crea una función que retorne el número total de bumeranes de
2+
#* un array de números enteros e imprima cada uno de ellos.
3+
#* - Un bumerán (búmeran, boomerang) es una secuencia formada por 3 números
4+
#* seguidos, en el que el primero y el último son iguales, y el segundo
5+
#* es diferente. Por ejemplo [2, 1, 2].
6+
#* - En el array [2, 1, 2, 3, 3, 4, 2, 4] hay 2 bumeranes ([2, 1, 2]
7+
#* y [4, 2, 4]).
28

3-
/*
4-
* Reto #44
5-
* BUMERANES
6-
* Fecha publicación enunciado: 02/10/22
7-
* Fecha publicación resolución: 07/11/22
8-
* Dificultad: FÁCIL
9-
*
10-
* Enunciado: Crea una función que retorne el número total de bumeranes de un array de números
11-
* enteros e imprima cada uno de ellos.
12-
* - Un bumerán (búmeran, boomerang) es una secuencia formada por 3 números seguidos, en el que el
13-
* primero y el último son iguales, y el segundo es diferente. Por ejemplo [2, 1, 2].
14-
* - En el array [2, 1, 2, 3, 3, 4, 2, 4] hay 2 bumeranes ([2, 1, 2] y [4, 2, 4]).
15-
*
16-
* Información adicional:
17-
* - Usa el canal de nuestro Discord (https://mouredev.com/discord) "🔁reto-semanal"
18-
* para preguntas, dudas o prestar ayuda a la comunidad.
19-
* - Tienes toda la información sobre los retos semanales en
20-
* https://retosdeprogramacion.com/semanales2022.
21-
*
22-
*/
9+
def sequence(initList):
10+
init = 0
11+
for i, num in enumerate(initList):
12+
if i == init:
13+
try:
14+
if initList[init] != initList[init+1] and initList[init] == initList[init+2]:
15+
boomerangList.append(initList[init:init+3])
16+
init = i+3
17+
else:
18+
init+=1
19+
except:
20+
pass
21+
return(len(boomerangList))
22+
23+
initList = [2, 1, 2, 3, 3, 4, 2, 4]
24+
boomerangList = []
25+
print(f'En el array {initList} hay {sequence(initList)} bumeranes ({boomerangList})')

0 commit comments

Comments
 (0)