-
Notifications
You must be signed in to change notification settings - Fork 0
/
one.cs
59 lines (56 loc) · 1.42 KB
/
one.cs
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* Successful tests:
+++++[-] : 0
>>>>++ : 0002
>+++++++++[<++++++++>-]< : 720000000000
>>>>++<<+>>+ : 010300
/*
/* Whiteboarding
[0, 0, 0, 0, 0, 0, 0, ...]
^
[5, 0, 0, 0, 0, 0, 0, ...] Before the [ - ]
[0, 0, 0, 0, 0, 0, 0, ...] After the [ - ]
*/
/*string input = "++++++++[>++++++++<-]>++++++++.>++++++++[>++++++++++++<-]>+++++.+++++++..+++.>++++++++[>+++++<-]>++++.------------.<<<<+++++++++++++++.>>.+++.------.--------.>>+.";
List<int> output = [0];
int length = input.Length;
int olength = output.Count;
int memory = 0;
int index = 0;
int count = 0;
int right = 0;
int i = 0;
while (i < length) {
switch (input[i]) {
case '+':
output[memory]++;
break;
case '-':
output[memory]--;
break;
case '>':
output.Add(0);
memory++;
break;
case '<':
memory--;
break;
case '.':
char asc = (char)output[memory];
Console.Write(asc);
break;
case '[':
count++;
index = i;
if (input[i] == ']' && output[memory] == 0) i = right;
break;
case ']':
right = i;
if (output[memory] != 0) i = index;
break;
}
i++;
}
*/
//if (count == 0) output.RemoveAt(0);
/*Console.WriteLine();
Console.WriteLine($"Memory: {memory} Count: {length}");*/