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 5f582c3

Browse files
Merge pull request #78 from kiddopro/15.2-Parking_lot_check
15.2-Parking_lot_check
2 parents e0f78e2 + 247325f commit 5f582c3

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed
2.58 KB
Binary file not shown.

‎exercises/15.2-Parking_lot_check/app.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@
55
]
66

77
#Your code go here:
8-
9-
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
parking_state = [
2+
[1,1,1],
3+
[0,0,0],
4+
[1,1,2]
5+
]
6+
7+
#Your code go here:
8+
def get_parking_lot(matrix):
9+
state = {'total_slots': 0, 'available_slots': 0, 'occupied_slots': 0}
10+
for i in range(len(matrix)):
11+
for j in range(len(matrix[i])):
12+
if matrix[i][j] == 1:
13+
state["occupied_slots"] += 1
14+
state["total_slots"] += 1
15+
elif matrix[i][j] == 2:
16+
state["available_slots"] += 1
17+
state["total_slots"] += 1
18+
return state
19+
20+
get_parking_lot(parking_state)

‎exercises/15.2-Parking_lot_check/test.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,18 @@ def test_variable_exists(app):
99
raise AttributeError("The function get_parking_lot should exist on app.py")
1010

1111
@pytest.mark.it('The function get_parking_lot should return an object with correct values')
12-
def test_variable_exists(app):
12+
def test_correct_output(app):
1313
value1 = [[1,1,1], [0,0,0], [1,1,2]]
14-
result1 = {'total_slots': 9, 'available_slots': 1, 'occupied_slots': 5}
14+
result1 = {'total_slots': 6, 'available_slots': 1, 'occupied_slots': 5}
15+
try:
16+
assert app.get_parking_lot(value1) == result1
17+
except AttributeError:
18+
raise AttributeError("The function get_parking_lot should exist on app.py")
19+
20+
@pytest.mark.it('The function get_parking_lot should return an object with correct values')
21+
def test_different_values(app):
22+
value1 = [[1,2,1,0], [0,1,0,2], [1,0,1,1]]
23+
result1 = {'total_slots': 8, 'available_slots': 2, 'occupied_slots': 6}
1524
try:
1625
assert app.get_parking_lot(value1) == result1
1726
except AttributeError:

0 commit comments

Comments
(0)

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