This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by ChatGPT's o1-preview model Sep 2024 | |
# Prompt: """Write a Python function that takes a mathematical expression as a | |
# string evaluates it. The function should handle basic arithmetic operators and | |
# precedence but does not need to handle parentheses. The function must not use | |
# Python’s eval function.""" | |
# WARNING: this code contains at least one bug, see associated post for info: | |
# https://seeinglogic.com/posts/checking-on-chatgpt/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Tuple, List | |
# x, y | |
Pos = Tuple[int, int] | |
dir_deltas = [ | |
(-1, -1), | |
(-1, 0), | |
(-1, 1), | |
(0, -1), |