-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day25.cs
46 lines (38 loc) · 1.01 KB
/
Day25.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
using System;
using System.Collections.Generic;
using System.Numerics;
class Day25 {
public static int Solution1() {
DroidController controller = new DroidController() {
InQueue = new Queue<BigInteger>(),
OutQueue = new Queue<BigInteger>()
};
Intcode droid = new Intcode("input25.txt");
droid.SetInput(controller);
droid.SetOutput(controller);
droid.Run();
return 0;
}
class DroidController : IIntcode {
public IIntcode Input { get; set; }
public IIntcode Output { get; set; }
public Queue<BigInteger> InQueue { get; set; }
public Queue<BigInteger> OutQueue { get; set; }
public void RequestInput() {
PrintQueue();
EnqueueString(Console.ReadLine());
OutQueue.Enqueue('\n');
}
void EnqueueString(string toQueue) {
foreach (char c in toQueue) {
OutQueue.Enqueue(c);
}
}
public void Continue() => PrintQueue();
void PrintQueue() {
while (InQueue.Count > 0) {
Console.Write((char)InQueue.Dequeue());
}
}
}
}