INDAPlus21 / INDAPlus21/eliased-task-2

Pass

Open
#1 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.