Compare commits
No commits in common. "03b6d66c5b96dce028c11dd87734c7ebbeb8998d" and "9c00dd61a4648124be5e61fede21fe1856c31156" have entirely different histories.
03b6d66c5b
...
9c00dd61a4
2 changed files with 15 additions and 53 deletions
|
|
@ -46,10 +46,12 @@ class Board:
|
||||||
), "Invalid buttons!"
|
), "Invalid buttons!"
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return "\n".join(self.rows) \
|
result = "\n".join(self.rows)
|
||||||
.replace("0", "⚪️") \
|
result = result\
|
||||||
.replace("1", "🟢️") \
|
.replace("0", "⚪️")\
|
||||||
|
.replace("1", "🟢️")\
|
||||||
.replace("x", "⚫️")
|
.replace("x", "⚫️")
|
||||||
|
return result
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def columns(self) -> tuple[str, ...]:
|
def columns(self) -> tuple[str, ...]:
|
||||||
|
|
|
||||||
|
|
@ -1,58 +1,18 @@
|
||||||
import pytest
|
|
||||||
|
|
||||||
from pigeon_magnet_solver.helpers import (_fix_exes, _rotate_r, _valid_rotate,
|
from pigeon_magnet_solver.helpers import (_fix_exes, _rotate_r, _valid_rotate,
|
||||||
rotate_r)
|
rotate_r)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("test_input,expected", [
|
def test_rotate_r():
|
||||||
# trivial cases
|
assert _rotate_r(list("1x01")) == list("11x0")
|
||||||
("1111", "1111"),
|
assert _rotate_r(list("11x0")) == list("011x")
|
||||||
("0000", "0000"),
|
assert _rotate_r(list("011x")) == list("x011")
|
||||||
("xxxx", "xxxx"),
|
assert _rotate_r(list("x011")) == list("1x01")
|
||||||
|
|
||||||
# interesting case "1x01"
|
assert _valid_rotate(list("1x01"), list("11x0")) is False
|
||||||
("1x01", "11x0"),
|
assert _valid_rotate(list("1x01"), list("011x")) is False
|
||||||
("11x0", "011x"),
|
assert _valid_rotate(list("1x01"), list("x011")) is True
|
||||||
("011x", "x011"),
|
assert _valid_rotate(list("1x01"), list("1x01")) is True
|
||||||
("x011", "1x01"),
|
|
||||||
])
|
|
||||||
def test__rotate_r(test_input: str, expected: str):
|
|
||||||
assert _rotate_r(list(test_input)) == list(expected)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("test_input,candidate,expected", [
|
|
||||||
# interesting case "1x01"
|
|
||||||
("1x01", "11x0", False),
|
|
||||||
("1x01", "011x", False),
|
|
||||||
("1x01", "x011", True),
|
|
||||||
("1x01", "1x01", True),
|
|
||||||
])
|
|
||||||
def test__valid_rotate(test_input: str, candidate: str, expected: bool):
|
|
||||||
assert _valid_rotate(list(test_input), list(candidate)) is expected
|
|
||||||
|
|
||||||
|
|
||||||
def test__fix_exes():
|
|
||||||
assert _fix_exes(list("1x01"), list("x011")) == list("0x11")
|
assert _fix_exes(list("1x01"), list("x011")) == list("0x11")
|
||||||
|
|
||||||
|
assert rotate_r(list("1x01")) == list("0x11")
|
||||||
@pytest.mark.parametrize("test_input,expected", [
|
|
||||||
# trivial cases
|
|
||||||
("1111", "1111"),
|
|
||||||
("0000", "0000"),
|
|
||||||
("xxxx", "xxxx"),
|
|
||||||
|
|
||||||
# fixpoints "1x10"
|
|
||||||
("1x10", "1x10"),
|
|
||||||
("101x", "101x"),
|
|
||||||
("1x1x", "1x1x"),
|
|
||||||
|
|
||||||
# alternating case "1010"
|
|
||||||
("1010", "0101"),
|
|
||||||
("0101", "1010"),
|
|
||||||
|
|
||||||
# interesting case "1x01"
|
|
||||||
("1x01", "0x11"),
|
|
||||||
("0x11", "1x01"),
|
|
||||||
])
|
|
||||||
def test_rotate_r(test_input: str, expected: str):
|
|
||||||
assert rotate_r(list(test_input)) == list(expected)
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue