INDAPlus21 / INDAPlus21/dpeilitz-task-2

Pass

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

**Very well done David!**

Tips följer:

_Your code_:
```rust
let mut output = String::with_capacity((rows) * (columns + 1));

for x in 1..=rows {
for y in 1..=columns {
//skriv avstånd upp ned sida och sida och genom let ...
let dist_top = x;
let dist_left = y;
let dist_bot = (rows+1) - dist_top; //add one to measure the distance OUTSIDE of the box
let dist_right = (columns+1) - dist_left;
//find out the shortest distance
let min = dist_left.min(dist_right).min(dist_top).min(dist_bot);
if min < 10 {

//convert to char by getting the asci value, converting to u8 then to char
output.push(char::from_digit(min as u32, 10).unwrap());
}
else{
output.push('.');
}
}
output.push_str("\n")
}

println!("{}", output);
```

_Optimised version_:
```rust
for _row in 1..=rows {
for _col in 1..=columns {
let dist_top = _row;
let dist_left = _col;
let dist_bottom = (rows + 1) - dist_top;
let dist_right = (columns + 1) - dist_left;

print!("{}",
match dist_left.min(dist_right).min(dist_top).min(dist_bot) {
_min if _min < 10 =>
char::from_digit(_min, 10).unwrap(),
_ => '.'
}
);
}
println!();
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue contains Rust snippets for generating a grid and an attempted optimized version, but it names no files, tests, or requested change. First locate where this output is implemented and verify whether the optimized snippet compiles; the issue provides no clear completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.