| debug = helper.debug | debug = helper.debug | ||||
| load_input = helper.load_input | load_input = helper.load_input | ||||
| def is_digit(n): | |||||
| try: | |||||
| m = int(n) | |||||
| except ValueError: | |||||
| return False | |||||
| return True | |||||
| class InputNumber: | class InputNumber: | ||||
| def __init__(self, number, start_pos, end_pos, line): | def __init__(self, number, start_pos, end_pos, line): | ||||
| self.line = line | self.line = line | ||||
| def _is_symbol(self, char): | def _is_symbol(self, char): | ||||
| return (char != "." and not is_digit(char)) | |||||
| return (char != "." and not char.isdigit()) | |||||
| def _check_up(self, input): | def _check_up(self, input): | ||||
| if self.line == 0: | if self.line == 0: | ||||
| for j, line in enumerate(lines): | for j, line in enumerate(lines): | ||||
| i = 0 | i = 0 | ||||
| while i < max_len: | while i < max_len: | ||||
| if is_digit(line[i]): | |||||
| if line[i].isdigit(): | |||||
| current_number = "" | current_number = "" | ||||
| start_pos = i | start_pos = i | ||||
| while i < max_len and is_digit(line[i]): | |||||
| while i < max_len and line[i].isdigit(): | |||||
| current_number += f"{line[i]}" | current_number += f"{line[i]}" | ||||
| i += 1 | i += 1 | ||||
| end_pos = i | end_pos = i |