Skip to content

Commit 2b2a856

Browse files
committed
整数判定において、先頭が0だったり、文字数が20以上だったらFalseにするように
1 parent 8b6ef3d commit 2b2a856

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

atcodertools/fmtprediction/predict_types.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ def is_float(text):
4848

4949

5050
def is_int(text):
51-
return re.match(r"-?\d+$", text) is not None
51+
if text == "0":
52+
return True
53+
if re.match(r"-?\d+$", text) is None:
54+
return False
55+
if text[0] == "0":
56+
return False
57+
if len(text) > 19 or (text[0] == '-' and len(text) > 20):
58+
return False
59+
return True
5260

5361

5462
def _convert_to_proper_type(value: str) -> Any:

0 commit comments

Comments
 (0)