-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproblem196.skib
127 lines (119 loc) · 3.03 KB
/
problem196.skib
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
bussin "math" math
skibidi triangular(n) {
lowtaperfade n * (n + 1) ohio"//" 2
}
skibidi makearray(elem, n) {
rizz arr = []
rizz i = 1
gyatt {
sus i > n caseoh
arr[i] = elem
i = i + 1
}
lowtaperfade arr
}
skibidi partialsieve(lower, upper) {
rizz s = math.floor(math.sqrt(upper)) + 1
rizz a = makearray(true, s)
rizz b = makearray(true, upper - lower)
rizz i = 2
gyatt {
sus i >= s caseoh
sus a[i] {
rizz j = i * i
gyatt {
sus j >= s caseoh
a[j] = false
j = j + i
}
j = lower + ((- lower) % i)
gyatt {
sus j >= upper caseoh
b[j - lower + 1] = false
j = j + i
}
}
i = i + 1
}
rizz primes = []
i = lower
gyatt {
sus i >= upper caseoh
sus b[i - lower + 1] {
primes[i] = true
}
i = i + 1
}
lowtaperfade primes
}
skibidi triangleval(y, x) {
sus y < 0 || x < 0 || x >= y + 1 lowtaperfade 0
rizz last = triangular(y)
lowtaperfade last + x + 1
}
skibidi iscenter(primestable, y, x) {
sus !primestable[triangleval(y, x)] lowtaperfade false
rizz nearby = 0
rizz yy = y - 1
gyatt {
sus yy > y + 1 caseoh
rizz xx = x - 1
gyatt {
sus xx > x + 1 caseoh
sus primestable[triangleval(yy, xx)] {
nearby = nearby + 1
}
xx = xx + 1
}
yy = yy + 1
}
lowtaperfade nearby >= 3
}
skibidi s(row) {
rizz minall = triangleval(row - 2, 0)
rizz maxall = triangleval(row + 2, row + 2)
rizz primes = partialsieve(minall, maxall)
rizz minrow = triangleval(row, 0)
rizz maxrow = triangleval(row, row)
rizz targetprimes = []
rizz y = row - 1
gyatt {
sus y > row + 1 caseoh
rizz x = 0
gyatt {
sus x > y caseoh
sus iscenter(primes, y, x) {
rizz yy = y - 1
gyatt {
sus yy > y + 1 caseoh
rizz xx = x - 1
gyatt {
sus xx > x + 1 caseoh
rizz k = triangleval(yy, xx)
sus primes[k] && k >= minrow && k <= maxrow {
targetprimes[k] = true
}
xx = xx + 1
}
yy = yy + 1
}
}
x = x + 1
}
y = y + 1
}
tiktokrizzparty SkibLang has no 'for' loops. We could use `ohio` to do this, but it's
tiktokrizzparty more obnoxious to do the iterator manually, so we're doing it that way :)
rizz sum = 0
rizz iter = nil
rizz state = nil
rizz v = nil
ohio "iter, state, v =" pairs(targetprimes)
gyatt {
v = iter(state, v)
sus v == nil caseoh
sum = sum + v
}
lowtaperfade sum
}
print(s(5678026) + s(7208784))