Skip to content

Commit

Permalink
pass test case 2
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Jan 12, 2025
1 parent e09cc26 commit 710c23f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 18 additions & 1 deletion rust/pascals-triangle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@ pub struct PascalsTriangle{

impl PascalsTriangle {
pub fn new(row_count: u32) -> Self {
let rows = generate_rows(row_count);
PascalsTriangle{
rows: vec!()
rows: rows
}
}

pub fn rows(&self) -> Vec<Vec<u32>> {
return self.rows.clone()
}
}

fn generate_rows(row_count: u32) -> Vec<Vec<u32>> {
let mut rows = vec!();
for i in 1..=row_count {
let row = generate_row(i);
rows.push(row)
}
rows
}

fn generate_row(row_index: u32) -> Vec<u32> {
if row_index == 1 {
return vec!(1)
}
vec!()
}
1 change: 0 additions & 1 deletion rust/pascals-triangle/tests/pascals-triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ fn zero_rows() {
}

#[test]
#[ignore]
fn single_row() {
let pt = PascalsTriangle::new(1);
let expected: Vec<Vec<u32>> = vec![vec![1]];
Expand Down

0 comments on commit 710c23f

Please sign in to comment.