All SolutionsAll Solutions

🌌

Interstellar

Week 32, 2026

Decode segments, decode characters | greenya | Odin Solutions

package main import "core:fmt" import "core:image" import "core:image/png" import "core:slice" import "core:strings" _ :: png main :: proc () { img, err := image.load_from_file("encoded.png") assert(err == nil) assert(img.width * img.height == len(img.pixels.buf) / 3) pixels := transmute ([][3] u8) img.pixels.buf[:len(img.pixels.buf)/3] Segment :: struct { width: int, color: [3] u8 } segments := make([dynamic] Segment) for x in 0..<img.width { last := slice.last_ptr(segments[:]) if last == nil || last.color != pixels[x] { append(&segments, Segment { width=1, color=pixels[x] }) } else { last.width += 1 } } sb := strings.builder_make() for s in segments { if s.width == 10 do continue strings.write_byte(&sb, u8(s.width)) } fmt.printfln("Decoded message ==|%s|==", strings.to_string(sb)) }