#!/usr/bin/env julia # jloptima v0.1 - Core War optima number calculator in Julia by John Metcalf # using the bomb-free space method - 28/09/2025 # Usage: $ julia optima.jl coresize [modulo] coresize = parse(Int, get(ARGS, 1, "8000")) modulo = parse(Int, get(ARGS, 2, "1")) scores = [ ( let score = coresize - 1 high = low = pos = step while (pos = (pos + step) % coresize) != 0 high = max(high, pos) low = min(low, pos) score += coresize - high + low - 1 end score, step end ) for step = 1:div(coresize, 2) if gcd(step, coresize) == modulo ] println("step, score") for (score, step) in sort(scores)[1:20] println("$step, $score") end