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
// Lessons learned - use Clojure | |
const fs = require('fs') | |
function parseInstruction(instruction) { | |
const regex = /([a-z]+) ([a-z]+) ([-]*[0-9]+) if ([a-z]+) ([><=!]+) ([-]*[0-9]+)/g | |
return regex.exec(instruction) | |
} | |
function parseInput(filePath) { | |
const input = fs.readFileSync(filePath, 'utf8').trim().split("\n"); |
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
(require '[clojure.string :as str]) | |
(import [java.time Month LocalDateTime YearMonth]) | |
(defn left-pad [desired-width s] | |
(let [padding (apply str (repeat (- desired-width | |
(count (str s))) | |
" "))] | |
(str padding s))) | |
(defn right-pad [desired-width s] |