-
Notifications
You must be signed in to change notification settings - Fork 12
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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>"] |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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), | ||
}; |
There was a problem hiding this comment.
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()} |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation!
Type "a" to make the first move on a shortest path to a victory.