-
Notifications
You must be signed in to change notification settings - Fork 44
Space - Jessica #34
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
base: master
Are you sure you want to change the base?
Space - Jessica #34
Conversation
CheezItMan
left a comment
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 work Jessica. You hit all the learning goals here. Take a look at my comments and let me know what questions you have.
| case remove | ||
| when '[' | ||
| return false if array[i] != ']' | ||
| when ']' | ||
| return false if array[i] != '[' | ||
| when '{' | ||
| return false if array[i] != '}' | ||
| when '}' | ||
| return false if array[i] != '{' | ||
| when '(' | ||
| return false if array[i] != ')' | ||
| when ')' | ||
| return false if array[i] != '(' |
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.
Just a note that you can dry this up with a hash where they keys are the close braces and the values are the corresponding open braces.
return false if brace_hash[remove] != array.pop
| if (@front == 0 && @rear == (@max_size - 1)) || | ||
| (@rear == ((@front - 1) % (@max_size - 1))) |
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.
| if (@front == 0 && @rear == (@max_size - 1)) || | |
| (@rear == ((@front - 1) % (@max_size - 1))) | |
| if (@front != -1 && @front == (@rear + 1) % @max_size |
| elsif @front == -1 # Queue is empty | ||
| # initialize front and rear | ||
| @front += 1 | ||
| @rear += 1 | ||
| elsif (@rear == (@max_size - 1) && @front != 0) # rear needs to wrap around | ||
| @rear = 0 | ||
| else | ||
| @rear += 1 | ||
| end |
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.
This can be dried up with something like
| elsif @front == -1 # Queue is empty | |
| # initialize front and rear | |
| @front += 1 | |
| @rear += 1 | |
| elsif (@rear == (@max_size - 1) && @front != 0) # rear needs to wrap around | |
| @rear = 0 | |
| else | |
| @rear += 1 | |
| end | |
| else | |
| @rear = (@rear + 1) % @max_size | |
| end |
| @store[@rear] = element | ||
| end | ||
|
|
||
| def dequeue |
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.
👍
| return dequeue | ||
| end | ||
|
|
||
| def front |
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.
👍
| end | ||
|
|
||
| # get how many elements are in the array | ||
| def size |
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.
👍 , Nicely done
| end | ||
| end | ||
|
|
||
| def empty? |
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.
👍
| @@ -1,19 +1,18 @@ | |||
| class Stack | |||
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.
👍
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation