try ranges.append(.{ item, item + alm.seeds.items[i + 1] });
}
for (0..7) |map_id| {
RANGES: while (ranges.popOrNull()) |range| {
// std.debug.print("{any}\n", .{range});
for (alm.maps[map_id].items) |m_item| {
const offset: isize = @as(isize, @intCast(m_item.destination)) - m_item.from;
// std.debug.print("map: {} {} => {}\n", .{ m_item.from, m_item.to, offset });
if (range[1] <= m_item.from) {
// range is before the map start
} else if (m_item.to <= range[0]) {
// range is after the map end
} else if (m_item.from <= range[0] and m_item.to >= range[1]) {
// range fully contained in the map
try next.append(.{ @intCast(range[0] + offset), @intCast(range[1] + offset) });
continue :RANGES;
} else if (m_item.from >= range[0] and m_item.to < range[1]) {
// map fully contained int the range
try next.append(.{ m_item.destination, m_item.destination + m_item.range });
if (m_item.from != range[0]) try ranges.append(.{ range[0], m_item.from });
try ranges.append(.{ m_item.to, range[1] });
continue :RANGES;
} else if (m_item.from <= range[0] and m_item.to <= range[1]) {
// map - range - map - range
try next.append(.{ @intCast(range[0] + offset), @intCast(m_item.to + offset) });
try ranges.append(.{ m_item.to, range[1] });
continue :RANGES;
} else if (range[0] <= m_item.from and range[1] <= m_item.to) {
// range - map - range - map
try next.append(.{ @intCast(m_item.from + offset), @intCast(range[1] + offset) });
try ranges.append(.{ range[0], m_item.from });
continue :RANGES;
} else {
unreachable;
}