INDAPlus21 / INDAPlus21/ogronman-task-15

Pass

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

Description

**Very well done Oscar!**

Here are some notes:

#### Guess that data structure!
Let me show you how to structure this better.

_Your code_:
```rs
fn main() {

let input = io::stdin();


let mut number_of_cmds: u16 = 0;

let mut is_stack = true;
let mut is_priority = true;
let mut is_queue = true;

let mut stack:Vec = vec![];
let mut priority:Vec = vec![];
let mut queue: VecDeque = VecDeque::with_capacity(1);

for _line in input.lock().lines().map(|_line| _line.unwrap()) {

if !_line.contains(" "){

number_of_cmds = _line.parse::().unwrap();

queue = VecDeque::with_capacity(number_of_cmds as usize);
stack = vec![];
priority = vec![];

}else {

let commands:Vec = _line.split_whitespace()
.map(|_c| _c.trim())
.filter(|_c| !_c.is_empty()) // Kanske ta bort
.map(|_c| _c.parse::().unwrap())
.collect();

if commands[0] == 1 {
//...
number_of_cmds = number_of_cmds - 1;
}else{
//...
number_of_cmds = number_of_cmds - 1;
}

if number_of_cmds == 0 {
//...

is_stack = true;
is_priority = true;
is_queue = true;

}

}
}

}
```
_Refactored (untested) code:_
```rs
fn main() {
let lines: Vec = input
.lock()
.lines()
.map(|_line| _line.unwrap()
.collect();

let mut is_stack = true;
let mut is_priority = true;
let mut is_queue = true;

let mut stack: Vec;
let mut priority: Vec;
let mut queue: VecDeque;

while lines.has_next() {

let number_of_cmds: usize = lines.next().unwrap().parse().unwrap();

stack = Vec::with_capacity(number_of_commands);
priority = Vec::with_capacity(number_of_commands);
queue = VecDeque::with_capacity(number_of_commands);

is_stack = true;
is_priority = true;
is_queue = true;

for _ in 0..number_of_cmds {

let (command_type, command_value): (u16, u16) = {
let line = lines
.next().unwrap()
.split_whitespace()
.map(|_num| _num.parse().unwrap());
(line.next().unwrap(), line.next().unwrap())
};

match command_type {
1 => {/*...*/},
_ /*2*/ => {/*...*/}
}

if !is_queue && !is_stack && !is_priority {
break;
}
}

println!("{}",
match (is_queue, is_stack, is_priority) {/*...*/}
);
}
}
```

Nice tree with tests! Java whaaa..! Could use some inline documentation to ease future reference.

Keep it up!

Contributor guide

No contributing guide indexed for this repository

Research direction

This is review feedback marked “Pass” rather than an actionable task, and it names no source file or specific test to change. The repository's Java implementation and the mentioned tests are the only available starting points; no concrete completion criterion is provided beyond the suggestion to add inline documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, rust
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.