Skip to content
39 changes: 19 additions & 20 deletions exercises/08-hours_and_minutes/README.es.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
# `08` Horas y minutos

## 📝 Instrucciones:

Dado el número entero `N` - el número de segundos que pasan desde la medianoche:

1. ¿cuántas horas y minutos completos han pasado desde la medianoche?

El programa debe imprimir dos números: el número de horas (entre 0 y 23) y el número de minutos (entre 0 y 1339).
En este ejercicio vamos a suponer que es medianoche, queremos que con la función `hours_minutes` que hemos provisto para tí nos digas cuánto tiempo han pasado desde entonces con los segundos que se introduzcan como parámetro.

Por ejemplo:
## 📝 Instrucciones:

* Si N = 3900 --> han pasado 3900 segundos desde la medianoche ,es decir, ahora es la 1:05 am.

El programa debe imprimir 1 65 --> 1 hora completa ha pasado desde la medianoche, 65 minutos completos han pasado desde la medianoche.
1. Completa la función para que retorne el resultado esperado.

2. Realiza dos calculos con los segundos que se pasan por parámetro en la función para que uno calcule la hora segun segundos que han pasado y el otro para saber los minutos `(hora , minutos)`

### Ejemplo de entrada:
## Ejemplo de entrada:
```py
3900 # 1

+ 3900
60 # 2
```
## Ejemplo de salida:
```py
(1, 5) # 1

### Ejemplo de salida:
(0, 1) # 2
```
## 💡 Pista:

+ (1, 65)
+ Recuerda cuantos segundos hay en una hora (3600) y cuantos segundos en un minuto (60).

## 💡 Pista:
+ Si no sabes cómo empezar la solución a esta asignación, por favor, revisa la teoría en esta lección: https://snakify.org/lessons/print_input_numbers/

+ Si no sabes cómo empezar la solución a esta asignación, por favor, revisa la teoría en esta lección:
https://snakify.org/lessons/print_input_numbers/
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/print_input_numbers/steps/1/

+ También puedes intentar paso a paso con trozos de la teoría:
https://snakify.org/lessons/print_input_numbers/steps/1/
[comment]: <Solution: (secs//3600, secs//60)>
34 changes: 19 additions & 15 deletions exercises/08-hours_and_minutes/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
# `08` Hours and Minutes

In this exercise we are going to suppose that it is midnight, we want that with the function `hours_minutes` that we have provided for you tell us how much time has passed since then with the seconds that are introduced as parameter.

## 📝 Instructions:

Given the integer N - the number of seconds that is passed since midnight -
1. Complete the function to return the expected result.

1. How many full hours and full minutes are passed since midnight?
2. Perform two calculations with the seconds that are passed by parameter in the function so that one calculates the time according to the seconds that have passed and the other to know the minutes `(hour , minutes)`.

The program should print two numbers: the number of hours (between 0 and 23) and the number of minutes (between 0 and 1339).
## Example input:

For example:
```py
3900 # 1

* If N = 3900 --> then 3900 seconds have passed since midnight - i.e. now it's 1:05am.
60 # 2
```

So the program should print 1 65 --> 1 full hour is passed since midnight, 65 full minutes passed since midnight.
## Example output:

### Example input:
```py
(1, 5) # 1

+ 3900
(0, 1) # 2
```
## 💡 Hint:

### Example output:
+ Remember how many seconds there are in an hour (3600) and how many seconds in a minute (60).

+ (1, 65)
+ If you don't know how to start solving this assignment, please, review a theory for this lesson: https://snakify.org/lessons/print_input_numbers/

## 💡 Hint:
+ You may also try step-by-step theory chunks: https://snakify.org/lessons/print_input_numbers/steps/1/

+ If you don't know how to start solving this assignment, please, review a theory for this lesson:
https://snakify.org/lessons/print_input_numbers/

+ You may also try step-by-step theory chunks:
https://snakify.org/lessons/print_input_numbers/steps/1/
[comment]: <Solution: (secs//3600, secs//60)>
3 changes: 0 additions & 3 deletions exercises/08-hours_and_minutes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@ def hours_minutes(secs):

return None




#Invoke the funtion and pass any interger as its argument.
print(hours_minutes(3900))
3 changes: 3 additions & 0 deletions exercises/08-hours_and_minutes/solution.hide.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def hours_minutes(secs):
mins = secs // 60
return (secs//3600, mins%60)
20 changes: 18 additions & 2 deletions exercises/08-hours_and_minutes/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,26 @@
@pytest.mark.it('The function hours_minutes must exist')
def test_for_functon_existence(capsys, app):
assert callable(app.hours_minutes)

@pytest.mark.it('The function hours_minutes must return the correct output for 60 secs')
def test_for_file_output(capsys, app):
assert app.hours_minutes(60) == (0, 1)

@pytest.mark.it('The function hours_minutes must return the correct output')
@pytest.mark.it('The function hours_minutes must return the correct output for 3900 secs')
def test_for_file_output(capsys, app):
assert app.hours_minutes(4004) == (4004//3600, 4004//60)
assert app.hours_minutes(3900) == (1, 5)


@pytest.mark.it('The function hours_minutes must return the correct output for 4500 secs')
def test_for_file_output(capsys, app):
assert app.hours_minutes(4500) == (1, 15)


@pytest.mark.it('The function hours_minutes must return the correct output for 7320 secs')
def test_for_file_output(capsys, app):
assert app.hours_minutes(7320) == (2, 2)





Expand Down
3 changes: 3 additions & 0 deletions exercises/29-remove-duplicate-words/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
s = input()
words = [word for word in s.split(" ")]
print (" ".join(sorted(list(set(words)))))
4 changes: 2 additions & 2 deletions exercises/29-remove-duplicate-words/solution.hide.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
s = raw_input()
s = input()
words = [word for word in s.split(" ")]
print " ".join(sorted(list(set(words))))
print (" ".join(sorted(list(set(words)))))
9 changes: 9 additions & 0 deletions exercises/29-remove-duplicate-words/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest, io, sys, json, mock, re, os

@pytest.mark.it('Your solution should work as expected')
def test_expected_output(capsys, app):
fake_input=['Hola como Hola']
with mock.patch('builtins.input', lambda x: fake_input.pop()):
app()
captured = capsys.readouterr()
assert captured.out == " como \n"
2 changes: 1 addition & 1 deletion exercises/38-sort-tuples-ascending/solution.hide.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
break
l.append(tuple(s.split(",")))

print sorted(l, key=itemgetter(0,1,2))
print (sorted(l, key=itemgetter(0,1,2)))
11 changes: 11 additions & 0 deletions exercises/38-sort-tuples-ascending/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest, io, sys, json, mock, re, os
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'

@pytest.mark.it('The solution should return the expected output')
def test_convert_inputs(capsys, app):

fake_input = ["Tom,19,80 John,20,90 Jony,17,91 Jony,17,93 Json,21,85"] #fake input
with mock.patch('builtins.input', lambda x: fake_input.pop()):
app()
captured = capsys.readouterr()
assert captured.out == "[('John', '20', '90'), ('Jony', '17', '91'), ('Jony', '17', '93'), ('Json', '21', '85'), ('Tom', '19', '80')]\n"