Odin SolutionsOdin Solutions
🔗
URL Shortener
Week 11, 2026
All SolutionsGeneral solution for any alphabet, step and len | greenya | Odin Solutions
package main
import "core:fmt"
import "core:strings"
import "core:slice"
main :: proc () {
SEQ_ABC :: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
SEQ_STEP :: 2611
SEQ_LEN :: 3
b: strings.Builder
next_k: for k in 0 ..< SEQ_STEP {
for n := k ;; n += SEQ_STEP {
s := int_to_base(n, &b, SEQ_ABC, SEQ_LEN)
if len(s) == SEQ_LEN {
fmt.printfln("%d: %s", n, s)
} else {
continue next_k
}
}
}
}
int_to_base :: proc (n: int, b: ^strings.Builder, abc: string, min_len: int) -> string {
base := len(abc)
assert(base >= 2)
assert(min_len >= 1)
strings.builder_reset(b)
if n > 0 {
for r := n; r > 0; r /= base {
i := r % base
strings.write_byte(b, abc[i])
}
} else {
strings.write_byte(b, abc[0])
}
for len(b.buf) < min_len {
strings.write_byte(b, abc[0])
}
slice.reverse(b.buf[:])
return strings.to_string(b^)
}