Skip to content

Commit

Permalink
62: Re-submit
Browse files Browse the repository at this point in the history
  • Loading branch information
sankichi92 committed Dec 30, 2023
1 parent e171bdf commit 40a6aa0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion 62-domino-and-tromino-tiling/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const MODULO: i64 = 1_000_000_007;

pub fn num_tilings(n: i32) -> i32 {
let n = n as usize;

Expand All @@ -7,7 +9,7 @@ pub fn num_tilings(n: i32) -> i32 {
tilings.push(5);

for i in 3..n {
tilings.push(2 * tilings[i - 1] + tilings[i - 3]);
tilings.push(((2 * tilings[i - 1] as i64 + tilings[i - 3] as i64) % MODULO) as i32);
}

tilings[n - 1]
Expand Down Expand Up @@ -36,4 +38,9 @@ mod tests {
fn failed_case2() {
assert_eq!(num_tilings(5), 24);
}

#[test]
fn failed_case3() {
assert_eq!(num_tilings(30), 312342182);
}
}

0 comments on commit 40a6aa0

Please sign in to comment.