From 5c2f9513f056f9074966f181683ef6b2c6e10791 Mon Sep 17 00:00:00 2001 From: nea Date: Tue, 5 Jul 2022 12:24:19 +0200 Subject: Remove stuff --- shunting.py | 49 ---------------------- .../notenoughupdates/util/Calculator.java | 1 - 2 files changed, 50 deletions(-) delete mode 100644 shunting.py diff --git a/shunting.py b/shunting.py deleted file mode 100644 index 22d79f11..00000000 --- a/shunting.py +++ /dev/null @@ -1,49 +0,0 @@ -precedence = { - '-': 0, - '+': 0, - '*': 1, - '/': 1, -} - - -def shunting(inss: [str]): - op = [] - out = [] - for ins in inss: - if str.isnumeric(ins): - list.append(out, ins) - elif len(ins) == 1 and ins in "+-*/": - p = precedence[ins] - while op: - l = op[len(op) - 1] - if l == "(": - break - pl = precedence[l] - if pl > p: - out.append(op.pop()) - else: - break - op.append(ins) - elif len(ins) == 1 and ins in "mkbt": - out.append(ins) - elif ins == "(": - op.append(ins) - elif ins == ")": - while True: - if not op: - raise "ILLEGAL PARENTHESIS" - l = op.pop() - if l == "(": - break - out.append(l) - else: - raise f"UNKNOWN OP {ins}" - while op: - l = op.pop() - if l == "(": - raise "ILLEGAL PARENTHESIS" - out.append(l) - return out - - -print(shunting("1 + 22 k * ( 3 + 4 ) k".split())) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java index eb1ba425..89befec7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java @@ -154,7 +154,6 @@ public class Calculator { public static List shuntingYard(List toShunt) throws CalculatorException { // IT'S SHUNTING TIME // This is an implementation of the shunting yard algorithm - // Dear god, just thinking about dijkstra makes me wet and hard, such a fucking good mathematician Deque op = new ArrayDeque<>(); List out = new ArrayList<>(); -- cgit