summaryrefslogtreecommitdiff
path: root/captcha.py
diff options
context:
space:
mode:
Diffstat (limited to 'captcha.py')
-rw-r--r--captcha.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/captcha.py b/captcha.py
index e5fe28c..4011bbd 100644
--- a/captcha.py
+++ b/captcha.py
@@ -24,6 +24,22 @@ def adj(grid, x: int, y: int, orth=False, center=False) -> list[int]:
return [v for v in base if v is not None]
+def across(grid, x: int, y: int) -> bool:
+ side_length = int(len(grid) ** 0.5)
+ cell = value(grid, x, y)
+ for nx in range(0, side_length):
+ if value(grid, nx, y) != cell:
+ break
+ else:
+ return True
+ for ny in range(0, side_length):
+ if value(grid, x, ny) != cell:
+ break
+ else:
+ return True
+ return False
+
+
class Shape:
def __init__(self, grid, x: int, y: int) -> None:
self.value = value(grid, x, y)
@@ -130,6 +146,9 @@ class Captcha:
near = adj(answer, x, y, True, False)
if len(near) != len(set(near)):
return False
+ case "l":
+ if not across(answer, x, y):
+ return False
case "m":
shape = Shape(answer, x, y)
if shape_match_m: