All SolutionsAll Solutions
ðŸ§
The Ultimate Answer
Week 42, 2026
Calculate score of each word, track the top | greenya | Odin Solutions
package main
import "core:fmt"
import "core:strings"
WORDS_STRICT := #load("words-strict.txt", string)
main :: proc () {
fmt.println("The answer to the ultimate question of life, the universe, and everything is...")
top: struct { score: int, word: string }
for word in strings.split_lines_iterator(&WORDS_STRICT) {
score := word_score(word)
if score == 42 do fmt.println(word)
if score > top.score do top = { score, word }
}
fmt.printfln("The highest scoring word is %s which scores %i points", top.word, top.score)
}
word_score :: proc (word: string) -> int {
s: int
for i:=1; i<len(word); i+=1 do s += abs(int(word[i]) - int(word[i-1]))
return s
}