fn top_left(tiles: &[Tile]) -> Vec<Tile> {
    let mut top_left = Vec::new();
    for original in tiles.iter() {
        'options: for t in original.options() {
            let mut is_above = false;
            let mut is_left = false;
            for orig_u in tiles.iter() {
                if t.num == orig_u.num {
                    continue;
                }
                for u in orig_u.options() {
                    if t.left(&u) {
                        is_left = true;
                    }
                    if t.above(&u) {
                        is_above = true;
                    }
                    if t.right(&u) || t.below(&u) {
                        // t in this orientation cannot be top-left
                        continue 'options;
                    }
                }
            }
            if is_above && is_left {
                top_left.push(t.clone());
                break;
            }
        }
    }
    top_left
}
// Find the top left tile - it should match on the right and the bottom only
// This actually finds all four corners. I don't know why it works!
// It's late, I'll understand it tomorrow.
Find the top left tile - it should match on the right and the bottom only
This actually finds all four corners. I don't know why it works.
It's late, I'll understand it tomorrow.
Find the top left tile - it should match on the right and the bottom only This actually finds all four corners . I don ' t know why it works . It ' s late I ' ll understand it tomorrow .
fn top_left(tiles: &[Tile]) -> Vec<Tile> {
    let mut top_left = Vec::new();
    for original in tiles.iter() {
        'options: for t in original.options() {
            let mut is_above = false;
            let mut is_left = false;
            for orig_u in tiles.iter() {
                if t.num == orig_u.num {
                    continue;
                }
                for u in orig_u.options() {
                    if t.left(&u) {
                        is_left = true;
                    }
                    if t.above(&u) {
                        is_above = true;
                    }
                    if t.right(&u) || t.below(&u) {
                        // t in this orientation cannot be top-left
                        continue 'options;
                    }
                }
            }
            if is_above && is_left {
                top_left.push(t.clone());
                break;
            }
        }
    }
    top_left
}
fn top_left ( tiles : & [ Tile ] ) -> Vec < Tile > { let mut top_left = Vec :: new ( ) ; for original in tiles . iter ( ) { ' options : for t in original . options ( ) { let mut is_above = false ; let mut is_left = false ; for orig_u in tiles . iter ( ) { if t . num == orig_u . num { continue ; } for u in orig_u . options ( ) { if t . left ( & u ) { is_left = true ; } if t . above ( & u ) { is_above = true ; } if t . right ( & u ) || t . below ( & u ) { // t in this orientation cannot be top-left continue ' options ; } } } if is_above && is_left { top_left . push ( t . clone ( ) ) ; break ; } } } top_left }
Find the top left tile - it should match on the right and the bottom only
This actually finds all four corners.
Find the top left tile - it should match on the right and the bottom only This actually finds all four corners .
tiles
&[Tile]