INDAPlus21 / INDAPlus21/eliased-task-2
Pass
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
**Very well done Elias!**
Notiser:
_Your code_:
```rust
let shouldipushrow: i32;
let shouldipushcolumn: i32;
if row < halfn {
shouldipushrow = row + 1;
} else {
shouldipushrow = firstn - row;
}
if column < halfsecondn {
shouldipushcolumn = column + 1;
} else {
shouldipushcolumn = secondn - column;
}
let minimum : i32 = cmp::min(shouldipushrow, shouldipushcolumn);
if minimum > 9 {
print!(".");
} else {
print!("{}", minimum);
}
```
_Formatting suggestion_:
```rust
print!("{}",
match cmp::min(
if row < halfn {
row + 1
} else {
firstn - row
},
if column < halfsecondn {
scolumn + 1
} else {
secondn - column
}
) {
_minimum if _minimum > 9 => ".",
_minimum => _minimum
}
);
```
_Your code_:
```rust
while numsummed < halfn {
let mut templargest : i32 = 0;
for i in x.clone() {
if i > templargest
{
templargest = i;
}
}
let index = x.iter().position(|z| *z == templargest).unwrap();
x.remove(index);
numsummed += 1;
sum += templargest;
}
```
Cloning is expensive. Instead of filtering out the highest numbers, it would be better to sort and sum a subset of the sorted numbers.
_Suggestion_:
```rust
while numsummed < halfn {
let mut templargest : i32 = 0;
for _i in numsummed..x.len() {
if x[_i] > templargest {
templargest = x[_i];
x[_i] = x[numsummed];
x[numsummed] = templargest;
break;
}
}
numsummed += 1;
sum += templargest;
}
```
_Or_:
```rust
x.sort();
x[halfn..x.len()].iter().sum();
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue contains Rust code and optimization suggestions but names no file, test, or entry point. First determine whether this review feedback represents an active task; no acceptance criteria or definition of done is provided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 10/100