We just need to cycle the pattern roygbv. Rust has good iterators so let's use that:

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut args = std::env::args().skip(1);
    let program = args.next().ok_or("program")?.into_bytes();
    let mut pos @ mut dist = 0;
    for p in program {
        pos += 1;
        let d = b"roygbv".iter().cycle().skip(pos).position(|x| *x == p).ok_or("out of bounds")?;
        dist += 1 + d;
        pos += d;
    }
    println!("{dist}");
    Ok(())
}
We could make it significantly faster by calculating deltas instead of .iter().cycle() but it already runs in ~4 milliseconds with my input. Who cares?

Let's look at part 2 instead... oh it's about maximizing distances. How convenient.

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut args = std::env::args().skip(1);
    let program = args.next().ok_or("program")?.into_bytes();
    let mut counts = [0; 6];
    for p in program {
        counts[b"roygbv".iter().position(|x| *x == p).ok_or("invalid char")?] += 1;
    }
    let mut program = counts.iter().zip(*b"roygbv")
        .flat_map(|(n, c)| std::iter::repeat(c).take(*n))
        .collect::<Vec<u8>>();
    let mut pos @ mut dist = 0;
    for p in program {
        pos += 1;
        let d = b"roygbv".iter().cycle().skip(pos).position(|x| *x == p).ok_or("out of bounds")?;
        dist += 1 + d;
        pos += d;
    }
    println!("{dist}");
    Ok(())
}
Just run it, submit the result and... beep. Wait what? Oh right, r to o is just 1 unit, r to v is 5. We just need to work backwards from r, so rvbgyo should do it:
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut args = std::env::args().skip(1);
    let program = args.next().ok_or("program")?.into_bytes();
    let mut counts = [0; 6];
    let perm = b"rvbgyo";
    for p in program {
        counts[perm.iter().position(|x| *x == p).ok_or("invalid char")?] += 1;
    }
    let mut program = counts.iter().zip(*perm)
        .flat_map(|(n, c)| std::iter::repeat(c).take(*n))
        .collect::<Vec<u8>>();
    let mut pos @ mut dist = 0;
    for p in program {
        pos += 1;
        let d = b"roygbv".iter().cycle().skip(pos).position(|x| *x == p).ok_or("out of bounds")?;
        dist += 1 + d;
        pos += d;
    }
    println!("{dist}");
    Ok(())
}
Tests with example inputs seem OK... let's submit result with input. And we're done.