-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAoC10a.asv
39 lines (35 loc) · 1.05 KB
/
AoC10a.asv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
clear; clc; close all;
file = 'inputAoC10test';
data = readmatrix(file, ...
Delimiter = '', ...
OutputType = 'string');
for i = 1:length(data) %provede pro všechny řádky
l = data{i} %vezme celý řádek
while true %bude dělat dokuď budou dostupné dvojice závorek
l_prev = l
l = strrep(strrep(strrep(strrep(l, '()', ''), '[]', ''), '{}', ''), '<>', '');
if strcmp(l_prev, l) %ukončí while pokuď l a l_prev je stejný
break;
end
end
data{i} = l; %vrátí zbytek závorek do své celly
end
score = 0;
for i = 1:length(data) %pro každý řádek
for j = data{i} %pro každý znak
switch j
case ")"
score = score + 3; data(i) = "";
break;
case "]"
score = score + 57; data(i) = "";
break
case "}"
score = score + 1197; data(i) = "";
break
case ">"
score = score + 25137; data(i) = "";
break
end
end
end