Casting out nines: Difference between revisions

Content added Content deleted
Line 2,102: Line 2,102:


fn cast_out(base int, start int, end int) []int {
fn cast_out(base int, start int, end int) []int {
mut b := base - 1
mut b := []int{len: base - 1, init: index}
mut x, mut k := start / b, 0
mut result := []int{}
mut ran, mut result := []int{}, []int{}
mut x, mut k := start / (base - 1), 0
mut ran := b.filter(it % b.len == (it * it) % b.len)
for idx in 0..b {
if idx % b == (idx * idx) % b {ran << idx}
}
for {
for {
for n in ran {
for n in ran {
k = b * x + n
k = b.len * x + n
if k < start {continue}
if k < start {continue}
if k > end {return result}
if k > end {return result}
Line 2,118: Line 2,116:
}
}
return result
return result
}
}
</syntaxhighlight>
</syntaxhighlight>