-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdayone.cls
70 lines (48 loc) · 1.81 KB
/
dayone.cls
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
60
61
62
63
64
65
66
67
68
69
70
Class AOC2020.Day1 Extends %RegisteredObject
{
Property append As %String;
Property multiply As %String;
ClassMethod PartOne()
{
// set the variables that I will use to reference the list I am creating
set (number1,number2,number3,number4,number5,number6)=0
// build the list of numbers
set numberlist=$LISTBUILD("1721","979","366","299", "675", "1456")
set $LISTBUILD(number1,number2,number3,number4,number5,number6)=numberlist
//write !, numberlist
// A nested loop has been created and the first loop loops through and it
// appends the numbers together. The loop starts sequentially adding the
// numbers together and it then progresses and adds them in random ways
for i=1:1:1 {
set append1 = number1 + number2
write !, append1
set append2 = number3 + number4
write !, append2
set append3 = number5 + number6
write !, append3
set append4 = number1 + number3
write !, append4
set append5 = number1 + number4
write !, "correct answer=", append5
set result = ##class(AOC2020.Day1).%New()
set result.append = append5
write !, result.append
// a nested loop that multiplies the numbers together to get the overall result
for i=1:1:1 {
set multiple1 = number1 * number2
write !, multiple1
set multiple2 = number3 * number4
write !, multiple2
set multiple3 = number5 * number6
write !, multiple3
set multiple4 = number1 * number4
write !, "correct answer=", multiple4
set multiple5 = number4 * number5
write !, multiple5
set result = ##class(AOC2020.Day1).%New()
set result.multiply = multiple4
write !, result.multiply
}
}
}
}