Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submit assignment #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lviornery
Copy link

No description provided.

Copy link
Contributor

@alex-ozdemir alex-ozdemir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

I also noticed the file had a bunch of tabs in it. Rust opts for spaces, and there should be a way to tell your editor to use them.

else {
Ok(NextStep::Continue)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more idomatic to use match rather than if/elsewith an unwrap. Generally avoiding unwrap is good, because it makes it easier to very that code will execute without panicking.

}

/// Returns true if the game has been won!
fn done(&self) -> bool {
unimplemented!()
//We always start the game with a stack on the left peg, so check if two pegs (one of which is the left peg) are empty
self.get_tower(Peg::Left).is_empty() && (self.get_tower(Peg::Center).is_empty() || self.get_tower(Peg::Right).is_empty())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust convention is to enforce a 100 character limit on lines.

let mut starting_vector: Vec<Disk> = Vec::new();
for size in 0..disks {
starting_vector.push(Disk(disks-size))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can turn a range like 0..disks (or any iterator) into a vector using Iterator::collect. See the sample solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants