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

Adam Dunlap Submission #3

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

AdamCDunlap
Copy link

Type "a" to make the first move on a shortest path to a victory.

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.

Really nice work 😄!

@@ -1,6 +1,6 @@
[package]
name = "wk0-starter"
version = "0.1.0"
authors = ["Alex Ozdemir <aozdemir@hmc.edu>"]
authors = ["Adam Dulnap <adunlap@hmc.edu>"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! You found the Cargo.toml!

Also, I want to meet this Adam Dulnap kid -- seems pretty cool!

@@ -1,11 +1,12 @@
// Alex Ozdemir <aozdemir@hmc.edu> // <- Your name should replace this line!
// Adam Dunlap <adunlap@hmc.edU>
// Starter code for HMC's MemorySafe, week 0
Copy link
Contributor

Choose a reason for hiding this comment

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

O.o

@@ -45,11 +47,14 @@ enum Peg {
enum Action {
/// Do this move
Move(Move),
/// Make an automatic move
Auto,
Copy link
Contributor

Choose a reason for hiding this comment

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

😀

/// Quit the game
Quit,
}

/// The next step the game should take. Produced after a user instruction is processed.
/// The next step the game should take. Produced after a user instruction is
/// processed.
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 99 character lines (not 80, or 100 for that matter).

'c' => Peg::Center,
'r' => Peg::Right,
_ => return Err(HanoiError::UnknownCommand),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably could remove this duplication. A function?

}

impl State {

/// Creates a Towers of Hanoi game with `disks` disks in a single tower
fn new(disks: u8) -> State {
unimplemented!()
State{left: (1..disks+1).rev().map(|n| Disk(n)).collect(),
center: Vec::new(), right: Vec::new()}
Copy link
Contributor

Choose a reason for hiding this comment

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

😄

Point-free would be even cooler!

// disk is on, or right peg if not). Next, find the largest disk n that
// is not on the destination peg. If we can move it, do so. Otherwise,
// recurse trying to move the n-1 disk to the peg that is neither the
// destination peg nor n's peg.
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation!

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