This file contains hidden or 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
| // artisanal, handcrafted code written by a human, not by a statistical model ;) | |
| // solution to leetcode #67 | |
| // this approach is very flexible and can be adapted to solve any leetcode problem | |
| "use strict"; // this not needed in typescript but im leaving it in | |
| const EMPTY = " " as const; | |
| const START = "<" as const; | |
| type Cell = typeof EMPTY | typeof START | string; |
This file contains hidden or 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
| const EMPTY = " " as const; | |
| const START = "<" as const; | |
| type Cell = typeof EMPTY | typeof START | string; | |
| type Direction = "L" | "R"; | |
| class Tape { | |
| private symbols: Map<number, Cell>; | |
| private position: number; |
This file contains hidden or 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 dataclasses import dataclass | |
| from typing import Literal | |
| type LeftParen = Literal["("] | |
| type RightParen = Literal[")"] | |
| type Number = int | |
| type Token = LeftParen | RightParen | NumberLiteral | Identifier | Def | Eof | If | StringLiteral | LogicLiteral | |
| @dataclass |
This file contains hidden or 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
| // Lucas Wolschick (C) 2022 | |
| // You should probably not use this as this has not been tested | |
| // Usage: brainfuck [file] | |
| // | |
| // Try it with this code (available at en.wikipedia.org/wiki/Brainfuck, not mine!) | |
| // ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++. | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <stdint.h> |
This file contains hidden or 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
| use std::io::Write; | |
| #[derive(Debug, Copy, Clone, Eq, PartialEq)] | |
| enum Tile { | |
| X, | |
| O, | |
| Empty, | |
| } | |
| impl Tile { |