xxxxxxxxxx
38
let currFloor = 0
let input
let currIndex = 0
function preload() {
input = loadStrings("input.txt")
}
function setup() {
createCanvas(400, 400);
rectMode(CENTER)
textAlign(CENTER, CENTER)
input = input[0]
}
function draw() {
for (let i = 0; i < 10; i++) {
background(240, 99, 164);
noStroke()
for (let y = 0, c = 1; y < height; y += height / 3, c--) {
fill(236, 1, 90)
rect(width / 2, y + height / 6, width - 20, height / 3 - 20)
textSize(40)
fill(252, 238, 33)
text(currFloor + c, width / 2, y + height / 6)
}
fill(0)
textSize(14)
text(currIndex, 30, 10)
// Part One
if (currIndex == input.length) return noLoop()
// Part Two
// if (currFloor == -1) return noLoop()
if (input[currIndex] == "(") currFloor++
else currFloor--
currIndex++
}
}