remove aoc solutions

This commit is contained in:
2026-06-07 09:36:21 +02:00
parent a9bd4fe9f9
commit 802a6d8b53
31 changed files with 4 additions and 497 deletions

View File

@@ -0,0 +1,8 @@
func main[] : i64
sum := 0
for i in 0..266000
if i % 2 != 0
sum += i * i
io.println_i64(sum)

View File

@@ -0,0 +1,8 @@
func main[] : i64
sum := 0
for i in 0..1000
if i % 5 == 0 || i % 3 == 0
sum += i
io.println_i64(sum)

View File

@@ -0,0 +1,13 @@
func main[] : i64
sum := 0
a := 0
b := 1
while a < 4000000
if a % 2 == 0
sum += a
temp := b
b += a
a = temp
io.println_i64(sum)

View File

@@ -0,0 +1,11 @@
func main[] : i64
n := 600851475143
f := 2
while f * f <= n
if n % f == 0
n = n / f
else
f += 1
io.println_i64(n)

View File

@@ -0,0 +1,13 @@
func main[] : i64
out := 0
for a in 500..1000
for b in 500..1000
if a * b > out
s := (a * b)->to_str()
s_rev := s->reverse()
if s->equal(s_rev)
out = a * b
s->free()
s_rev->free()
io.println_i64(out)

View File

@@ -0,0 +1,6 @@
func main[] : i64
out := 1
for i in 1..21
out = math.lcm(out, i)
io.println_i64(out)

View File

@@ -0,0 +1,11 @@
func main[] : i64
sum_of_squares := 0
for i in 1..101
sum_of_squares += i * i
square_of_sum := 0
for i in 1..101
square_of_sum += i
square_of_sum = square_of_sum * square_of_sum
io.println_i64(square_of_sum - sum_of_squares)

View File

@@ -0,0 +1,11 @@
func main[] : i64
found := 0
i := 1
while true
if i->is_prime()
found += 1
if found == 10001
io.println_i64(i)
break
i += 1

View File

@@ -0,0 +1,14 @@
func main[] : i64
n := "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450"
out := 0
max := n->len() - 13
for i in 0..max
s := 1
j := 0
while j < 13
s = s * (n[i + j] - '0')
j += 1
if s > out
out = s
io.println_i64(out)

View File

@@ -0,0 +1,7 @@
func main[] : i64
for a in 1..1000
for b in 1..1000
c := 1000 - b - a
if a * a + b * b == c * c
io.println_i64(a * b * c)
return 0

View File

@@ -0,0 +1,7 @@
func main[] : i64
sum := 0
for i in 0..2000000
if i->is_prime()
sum += i
io.println_i64(sum)

View File

@@ -0,0 +1,36 @@
func main[] : i64
N := 20
grid := []
grid->push([8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8])
grid->push([49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 4, 56, 62, 0])
grid->push([81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 3, 49, 13, 36, 65])
grid->push([52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91])
grid->push([22, 31, 16, 71, 51, 67, 63, 89, 41, 92, 36, 54, 22, 40, 40, 28, 66, 33, 13, 80])
grid->push([24, 47, 32, 60, 99, 3, 45, 2, 44, 75, 33, 53, 78, 36, 84, 20, 35, 17, 12, 50])
grid->push([32, 98, 81, 28, 64, 23, 67, 10, 26, 38, 40, 67, 59, 54, 70, 66, 18, 38, 64, 70])
grid->push([67, 26, 20, 68, 2, 62, 12, 20, 95, 63, 94, 39, 63, 8, 40, 91, 66, 49, 94, 21])
grid->push([24, 55, 58, 5, 66, 73, 99, 26, 97, 17, 78, 78, 96, 83, 14, 88, 34, 89, 63, 72])
grid->push([21, 36, 23, 9, 75, 0, 76, 44, 20, 45, 35, 14, 0, 61, 33, 97, 34, 31, 33, 95])
grid->push([78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 3, 80, 4, 62, 16, 14, 9, 53, 56, 92])
grid->push([16, 39, 5, 42, 96, 35, 31, 47, 55, 58, 88, 24, 0, 17, 54, 24, 36, 29, 85, 57])
grid->push([86, 56, 0, 48, 35, 71, 89, 7, 5, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58])
grid->push([19, 80, 81, 68, 5, 94, 47, 69, 28, 73, 92, 13, 86, 52, 17, 77, 4, 89, 55, 40])
grid->push([4, 52, 8, 83, 97, 35, 99, 16, 7, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66])
grid->push([88, 36, 68, 87, 57, 62, 20, 72, 3, 46, 33, 67, 46, 55, 12, 32, 63, 93, 53, 69])
grid->push([4, 42, 16, 73, 38, 25, 39, 11, 24, 94, 72, 18, 8, 46, 29, 32, 40, 62, 76, 36])
grid->push([20, 69, 36, 41, 72, 30, 23, 88, 34, 62, 99, 69, 82, 67, 59, 85, 74, 4, 36, 16])
grid->push([20, 73, 35, 29, 78, 31, 90, 1, 74, 31, 49, 71, 48, 86, 81, 16, 23, 57, 5, 54])
grid->push([1, 70, 54, 71, 83, 51, 54, 69, 16, 92, 33, 48, 61, 43, 52, 1, 89, 19, 67, 48])
out := 0
for i in 0..N-3
for j in 0..N-3
h : i64 = (grid->nth(i) as Array)->nth(j) * (grid->nth(i) as Array)->nth(j+1) * (grid->nth(i) as Array)->nth(j+2) * (grid->nth(i) as Array)->nth(j+3)
v : i64 = (grid->nth(j) as Array)->nth(i) * (grid->nth(j+1) as Array)->nth(i) * (grid->nth(j+2) as Array)->nth(i) * (grid->nth(j+3) as Array)->nth(i)
d1 : i64 = (grid->nth(i) as Array)->nth(j) * (grid->nth(i+1) as Array)->nth(j+1) * (grid->nth(i+2) as Array)->nth(j+2) * (grid->nth(i+3) as Array)->nth(j+3)
d2 : i64 = (grid->nth(i) as Array)->nth(N-j-1) * (grid->nth(i+1) as Array)->nth(N-j-2) * (grid->nth(i+2) as Array)->nth(N-j-3) * (grid->nth(i+3) as Array)->nth(N-j-4)
out = math.max(out, math.max(h, math.max(v, math.max(d1, d2))))
io.println_i64(out)

View File

@@ -0,0 +1,21 @@
func num_divisors[n: i64] : i64
end := n->isqrt()
out := 0
for i in 1..end+1
if n % i == 0
out += 2
if end * end == n
out -= 1
return out
func main[] : i64
n := 0
i := 1
while true
n += i
if num_divisors(n) > 500
io.println_i64(n)
break
i += 1

View File

@@ -0,0 +1,3 @@
func main[] : i64
n := 37107287533 + 46376937677 + 74324986199 + 91942213363 + 23067588207 + 89261670696 + 28112879812 + 44274228917 + 47451445736 + 70386486105 + 62176457141 + 64906352462 + 92575867718 + 58203565325 + 80181199384 + 35398664372 + 86515506006 + 71693888707 + 54370070576 + 53282654108 + 36123272525 + 45876576172 + 17423706905 + 81142660418 + 51934325451 + 62467221648 + 15732444386 + 55037687525 + 18336384825 + 80386287592 + 78182833757 + 16726320100 + 48403098129 + 87086987551 + 59959406895 + 69793950679 + 41052684708 + 65378607361 + 35829035317 + 94953759765 + 88902802571 + 25267680276 + 36270218540 + 24074486908 + 91430288197 + 34413065578 + 23053081172 + 11487696932 + 63783299490 + 67720186971 + 95548255300 + 76085327132 + 37774242535 + 23701913275 + 29798860272 + 18495701454 + 38298203783 + 34829543829 + 40957953066 + 29746152185 + 41698116222 + 62467957194 + 23189706772 + 86188088225 + 11306739708 + 82959174767 + 97623331044 + 42846280183 + 55121603546 + 32238195734 + 75506164965 + 62177842752 + 32924185707 + 99518671430 + 73267460800 + 76841822524 + 97142617910 + 87783646182 + 10848802521 + 71329612474 + 62184073572 + 66627891981 + 60661826293 + 85786944089 + 66024396409 + 64913982680 + 16730939319 + 94809377245 + 78639167021 + 15368713711 + 40789923115 + 44889911501 + 41503128880 + 81234880673 + 82616570773 + 22918802058 + 77158542502 + 72107838435 + 20849603980 + 53503534226
io.println(n->to_str()->substr(0, 10))

View File

@@ -0,0 +1,22 @@
func collatz_num[n: i64] : i64
if n % 2 == 0
return n / 2
return n * 3 + 1
func collatz_seq[n: i64]: i64
i := 1
while n != 1
n = collatz_num(n)
i += 1
return i
func main[] : i64
max := 0
max_index := 0
for i in 1..1000000
seq := collatz_seq(i)
if seq > max
max = seq
max_index = i
io.println_i64(max_index)

View File

@@ -0,0 +1,9 @@
func main[] : i64
n := 40
r := 20
out := 1
for i in 1..r+1
out = out * (n - (r - i)) / i
io.println_i64(out)

View File

@@ -0,0 +1,18 @@
func main[] : i64
n := [1]
for j in 0..1000
carry := 0
for i in 0..n->size
tmp : i64 = n->nth(i) * 2 + carry
n->set(i, tmp % 10)
carry = tmp / 10
while carry > 0
n->push(carry % 10)
carry = carry / 10
sum := 0
for i in 0..n->size
sum += n->nth(i)
io.println_i64(sum)

View File

@@ -0,0 +1,26 @@
func main[] : i64
s1 := [0, 3, 3, 5, 4, 4, 3, 5, 5, 4]
s2 := [3, 6, 6, 8, 8, 7, 7, 9, 8, 8]
s3 := [0, 0, 6, 6, 5, 5, 5, 7, 6, 6]
sum := 0
for i in 1..10
sum += s1->nth(i)
for i in 0..10
sum += s2->nth(i)
for i in 20..100
sum += s3->nth(i / 10) + s1->nth(i % 10)
for i in 1..10
sum += s1->nth(i) + 7
for j in 1..10
sum += s1->nth(i) + 7 + 3 + s1->nth(j)
for j in 0..10
sum += s1->nth(i) + 7 + 3 + s2->nth(j)
for j in 20..100
sum += s1->nth(i) + 7 + 3 + s3->nth(j / 10) + s1->nth(j % 10)
sum += s1->nth(1) + 8
io.println_i64(sum)

View File

@@ -0,0 +1,28 @@
func findmax[triangle: Array, row: i64, col: i64] : i64
if row == 14
return (triangle->nth(row) as Array)->nth(col)
left := findmax(triangle, row + 1, col)
right := findmax(triangle, row + 1, col + 1)
return (triangle->nth(row) as Array)->nth(col) + math.max(left, right)
func main[] : i64
triangle := []
triangle->push([75])
triangle->push([95, 64])
triangle->push([17, 47, 82])
triangle->push([18, 35, 87, 10])
triangle->push([20, 4, 82, 47, 65])
triangle->push([19, 1, 23, 75, 3, 34])
triangle->push([88, 2, 77, 73, 7, 63, 67])
triangle->push([99, 65, 4, 28, 6, 16, 70, 92])
triangle->push([41, 41, 26, 56, 83, 40, 80, 70, 33])
triangle->push([41, 48, 72, 33, 47, 32, 37, 16, 94, 29])
triangle->push([53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14])
triangle->push([70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57])
triangle->push([91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48])
triangle->push([63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31])
triangle->push([4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23])
io.println_i64(findmax(triangle, 0, 0))

View File

@@ -0,0 +1,22 @@
func days[y: i64, m: i64] : i64
if m == 2
if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0))
return 29
else
return 28
else if (m == 4) || (m == 6) || (m == 9) || (m == 11)
return 30
else
return 31
func main[] : i64
wday := 0
sun := 0
for year in 1901..2001
for mon in 1..13
if wday == 5
sun += 1
wday = (wday + days(year, mon)) % 7
io.println_i64(sun)

View File

@@ -0,0 +1,21 @@
func multiply[n: Array, x: i64] : void
carry := 0
for i in 0..n->size
prod : i64 = n->nth(i) * x + carry
n->set(i, prod % 10)
carry = prod / 10
while carry > 0
n->push(carry % 10)
carry = carry / 10
func main[] : i64
n := [1]
for i in 2..101
multiply(n, i)
sum := 0
for i in 0..n->size
sum += n->nth(i)
io.println_i64(sum)

View File

@@ -0,0 +1,21 @@
func divisors_sum[n: i64] : i64
k := n
sum := 1
for i in 2..k+1
p := 1
while k % i == 0
p = p * i
k = k / i
sum = sum * (p * i - 1) / (i - 1)
return sum - n
func main[] : i64
sum := 0
for i in 2..10000
d := divisors_sum(i)
if i < d && i == divisors_sum(d)
sum += i + d
io.println_i64(sum)