As a magician-to-be, Elyse needs to practice some basics. She has a stack of cards that she wants to manipulate.
To make things a bit easier she only uses the cards 1 to 10.
The stack of cards is represented by a queue, with the bottom of the stack at the front of the queue, and the top of the stack at the back.
Implement the function insert_top that returns a copy of the stack with the new card provided added to the top of the stack.
insert_top(queue.from_list([5, 9, 7, 1]), 8)
// -> queue.from_list([5, 9, 7, 1, 8])Implement the function remove_top_card that returns a copy of the stack having had its top card removed. If the given stack is empty, the original stack should be returned, unchanged.
remove_top_card(queue.from_list([3, 2, 6, 4, 8]))
// -> queue.from_list([3, 2, 6, 4])Implement the function insert_bottom that returns a copy of the stack with the new card provided added to the bottom of the stack.
insert_bottom(queue.from_list([5, 9, 7, 1]), 8)
// -> queue.from_list([8, 5, 9, 7, 1])Implement the function remove_bottom_card that returns a copy of the stack having had its bottom card removed. If the given stack is empty, the original stack should be returned, unchanged.
remove_bottom_card(queue.from_list([8, 5, 9, 7, 1]))
// -> queue.from_list([5, 9, 7, 1])Implement the function check_size_of_stack that checks whether the size of the stack is equal to a given stack_size or not.
check_size_of_stack(queue.from_list([3, 2, 6, 4, 8]), 4)
// -> FalseAs a magician-to-be, Elyse needs to practice some basics. She has a stack of cards that she wants to manipulate.
To make things a bit easier she only uses the cards 1 to 10.
The stack of cards is represented by a queue, with the bottom of the stack at the front of the queue, and the top of the stack at the back.
Implement the function insert_top that returns a copy of the stack with the new card provided added to the top of the stack.
insert_top(queue.from_list([5, 9, 7, 1]), 8)
// -> queue.from_list([5, 9, 7, 1, 8])Implement the function remove_top_card that returns a copy of the stack having had its top card removed. If the given stack is empty, the original stack should be returned, unchanged.
remove_top_card(queue.from_list([3, 2, 6, 4, 8]))
// -> queue.from_list([3, 2, 6, 4])Implement the function insert_bottom that returns a copy of the stack with the new card provided added to the bottom of the stack.
insert_bottom(queue.from_list([5, 9, 7, 1]), 8)
// -> queue.from_list([8, 5, 9, 7, 1])Implement the function remove_bottom_card that returns a copy of the stack having had its bottom card removed. If the given stack is empty, the original stack should be returned, unchanged.
remove_bottom_card(queue.from_list([8, 5, 9, 7, 1]))
// -> queue.from_list([5, 9, 7, 1])Implement the function check_size_of_stack that checks whether the size of the stack is equal to a given stack_size or not.
check_size_of_stack(queue.from_list([3, 2, 6, 4, 8]), 4)
// -> False