Open violaso opened 2 years ago
Well done Daniel!
I'm only missing one additional solution to a Kattis problem. Did you miss a git push?
git push
Assignment instructions:
Solve at least two of the following problems: Summera tal Avstånd till kanten 🗹 Cyber-Clara och anmälningslistorna A Different Problem
Solve at least two of the following problems:
Some tips on your code.
Your solution has som unnecessary branching.
Your solution:
fn check_num(row_nr: u32, rows: u32, column_nr: u32, columns: u32) -> String{ let row_distance: u32; let column_distance: u32; if (rows - row_nr) < row_nr { row_distance = rows - row_nr; } else { row_distance = row_nr; } if (columns - column_nr) > column_nr { column_distance = column_nr; } else { column_distance = columns - column_nr; } if cmp::min(column_distance, row_distance) >= 9 { return ".".to_string(); } else { return (cmp::min(column_distance, row_distance)+1).to_string(); } }
Optimised solution:
fn check_num(row_nr: u32, rows: u32, column_nr: u32, columns: u32) -> String{ let row_distance = cmp::min(rows - row_nr, row_nr); let column_distance = cmp::min(columns - column_nr, column_nr); match cmp::min(column_distance, row_distance) { _x if _x >= 9 => ".".to_string(), _x => (_x + 1).to_string() } }
Keep up the good work!
Klar förresten(glömde skriva, sorry)
Well done Daniel!
I'm only missing one additional solution to a Kattis problem. Did you miss a
git push
?Assignment instructions:
Tips
Some tips on your code.
Avstånd till kanten
Your solution has som unnecessary branching.
Your solution:
Optimised solution:
Keep up the good work!