import chess import chess.svg def is_valid_chess_notation(moves): """ Checks if the given list of chess moves is valid. Requires: pip install python-chess Maybe one person will find this interesting? Parameters: moves (list): A list of strings where each string is a move in standard algebraic notation. Returns: bool: True if the moves are valid, False otherwise. """ board = chess.Board() try: for move in moves: chess_move = board.parse_san(move) board.push(chess_move) #print(board) #print("--------------") except ValueError: return False return True # Example usage: moves = ["e4", "e5", "Nf3", "Nc6", "Bb5", "a6", "Ba4", "Nf6", "O-O", "Be7", "Re1", "b5", "Bb3", "d6", "c3", "O-O", "h3"] print(is_valid_chess_notation(moves)) # Output: True moves_invalid = ["e4", "e4"] print(is_valid_chess_notation(moves_invalid)) # Output: False