22 lines
397 B
QBasic
22 lines
397 B
QBasic
OPEN 1, "../data/2015/1/input.txt", "r"
|
|
LINE INPUT #1 file$
|
|
|
|
f=0
|
|
for a=1 to len(file$)
|
|
c$ = mid$(file$, a, 1)
|
|
if (c$ == "(") f = f + 1
|
|
if (c$ == ")") f = f - 1
|
|
next a
|
|
|
|
print "Part 1: ", f
|
|
|
|
f = 0
|
|
steps = 0
|
|
for a=1 to len(file$)
|
|
c$ = mid$(file$, a, 1)
|
|
if (c$ == "(") f = f + 1
|
|
if (c$ == ")") f = f - 1
|
|
steps = steps + 1
|
|
if (f < 0) break
|
|
next a
|
|
print "Part 2: ", steps |