summaryrefslogtreecommitdiff
path: root/2015/rust/day25/src/main.rs
blob: 655c13203fc50953f63f00cdad8735539a955a0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn main() {
    let start:u128 = 20151125;
    let factor:u128 = 252533;
    let div:u128 = 33554393;

    let mut val:u128 = start;

    let mut x = 1;
    let mut y = 2;
    loop {
        val = val * factor % div;
        if y == 2947 && x == 3029 { break; }
        x += 1;
        y -= 1;
        if y == 0 {
            y = x;
            x = 1;
        }
    }
    println!("Row: {} Column: {} Code: {}", y, x, val);
}