///Compares the solution word to the guess word. Requires a valid solution word to run and check
///the guess against.
//maybe implement caching later
//there was subtle bug where I didn't quite replicate the right behavior
//when there are multiple of the same character not in the right place but I think I fixed it now
Compares the solution word to the guess word. Requires a valid solution word to run and check
the guess against.
maybe implement caching later
there was subtle bug where I didn't quite replicate the right behavior
when there are multiple of the same character not in the right place but I think I fixed it now
Compares the solution word to the guess word . Requires a valid solution word to run and check the guess against . maybe implement caching later there was subtle bug where I didn ' t quite replicate the right behavior when there are multiple of the same character not in the right place but I think I fixed it now
fn solution_compare(guess: WordId, solution: WordId, gbank: WordBank, sbank: WordBank) -> Grade {
    //check if yellow
    let mut r = [Mark::Grey, Mark::Grey, Mark::Grey, Mark::Grey, Mark::Grey];
    let g = gbank[guess];
    let s = sbank[solution];
    for (i, (a, b)) in s.chars().zip(g.chars()).enumerate() {
        if a == b {
            r[i] = Mark::Green;
        }
    }
    for (i, c) in s.chars().enumerate() {
        if r[i] == Mark::Green {
            continue;
        }
        for (j, b) in g.chars().enumerate() {
            if r[j] == Mark::Grey && c == b {
                r[j] = Mark::Yellow;
                break;
            }
        }
    }
    Grade { marks: r }
}
fn solution_compare ( guess : WordId , solution : WordId , gbank : WordBank , sbank : WordBank ) -> Grade { //check if yellow let mut r = [ Mark :: Grey , Mark :: Grey , Mark :: Grey , Mark :: Grey , Mark :: Grey ] ; let g = gbank [ guess ] ; let s = sbank [ solution ] ; for ( i , ( a , b ) ) in s . chars ( ) . zip ( g . chars ( ) ) . enumerate ( ) { if a == b { r [ i ] = Mark :: Green ; } } for ( i , c ) in s . chars ( ) . enumerate ( ) { if r [ i ] == Mark :: Green { continue ; } for ( j , b ) in g . chars ( ) . enumerate ( ) { if r [ j ] == Mark :: Grey && c == b { r [ j ] = Mark :: Yellow ; break ; } } } Grade { marks : r } }
Compares the solution word to the guess word.
Compares the solution word to the guess word .
guess
WordId
solution
WordId
gbank
WordBank
sbank
WordBank