Skip to content
Snippets Groups Projects
Commit e150ad45 authored by Thomas Bianco's avatar Thomas Bianco
Browse files

bug fix

parent 390067b0
Branches
No related tags found
No related merge requests found
{ {
"test_grid_2048.py": true, "test_grid_2048.py::test_grid_to_string": true,
"test_grid_2048.py::test_grid_to_string": true "test_grid_2048.py::test_move_row_right": true
} }
\ No newline at end of file
[ [
"test_grid_2048.py::test_create_grid" "test_grid_2048.py::test_move_row_left"
] ]
\ No newline at end of file
...@@ -87,8 +87,6 @@ def grid_to_string_with_size_and_theme(grid, theme,n): ...@@ -87,8 +87,6 @@ def grid_to_string_with_size_and_theme(grid, theme,n):
def long_value_with_theme(grid,theme): def long_value_with_theme(grid,theme):
return max(len(theme[v]) for v in get_all_tiles(grid)) return max(len(theme[v]) for v in get_all_tiles(grid))
<<<<<<< HEAD
#FONCTIONNALITE 4 #FONCTIONNALITE 4
...@@ -117,4 +115,9 @@ def move_row_left(row): ...@@ -117,4 +115,9 @@ def move_row_left(row):
return new_row + [0]*(n - len(new_row)) return new_row + [0]*(n - len(new_row))
def move_row_right(row): def move_row_right(row):
return move_row_left(row[-1:])[-1:] return move_row_left(row[::-1])[::-1]
# FONCTIONNALITE 5
def is_grid_full(grid):
return get_empty_tiles_positions(grid) == []
...@@ -80,6 +80,10 @@ def test_move_row_right(): ...@@ -80,6 +80,10 @@ def test_move_row_right():
assert move_row_right([2, 2, 2, 2]) == [0, 0, 4, 4] assert move_row_right([2, 2, 2, 2]) == [0, 0, 4, 4]
assert move_row_right([4, 2, 0, 2]) == [0, 0, 4, 4] assert move_row_right([4, 2, 0, 2]) == [0, 0, 4, 4]
assert move_row_right([2, 0, 0, 2]) == [0, 0, 0, 4] assert move_row_right([2, 0, 0, 2]) == [0, 0, 0, 4]
assert move_row_right[2, 4, 2, 2]) == [0, 2, 4, 4] assert move_row_right([2, 4, 2, 2]) == [0, 2, 4, 4]
assert move_row_right([2, 4, 4, 0]) == [0, 0, 2, 8] assert move_row_right([2, 4, 4, 0]) == [0, 0, 2, 8]
assert move_row_right([4, 8, 16, 32]) == [4, 8, 16, 32] assert move_row_right([4, 8, 16, 32]) == [4, 8, 16, 32]
def test_is_grid_full():
assert is_grid_full([[0, 16, 32, 0], [64, 0, 32, 2], [2, 2, 8, 4], [512, 8, 16, 0]]) == False
assert is_grid_full([[4, 16, 32, 4], [64, 8, 32, 2], [2, 2, 8, 4], [512, 8, 16, 1024]]) == True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment