Update queue from stacks challenge (#111)

Update test cases and __init__ method.
This commit is contained in:
Donne Martin 2016-10-29 09:13:02 -04:00 committed by GitHub
parent 12b58ccf9b
commit 2d651a6eca
2 changed files with 6 additions and 2 deletions

View File

@ -43,6 +43,8 @@
"* Does popping from an empty stack result in an exception?\n", "* Does popping from an empty stack result in an exception?\n",
" * Yes\n", " * Yes\n",
"* Can we assume the user passed in stack index is valid?\n", "* Can we assume the user passed in stack index is valid?\n",
" * Yes\n",
"* Can we assume this fits memory?\n",
" * Yes" " * Yes"
] ]
}, },

View File

@ -42,6 +42,8 @@
"* Does popping from an empty stack result in an exception?\n", "* Does popping from an empty stack result in an exception?\n",
" * Yes\n", " * Yes\n",
"* Can we assume the user passed in stack index is valid?\n", "* Can we assume the user passed in stack index is valid?\n",
" * Yes\n",
"* Can we assume this fits memory?\n",
" * Yes" " * Yes"
] ]
}, },
@ -118,8 +120,8 @@
" def __init__(self, num_stacks, stack_size):\n", " def __init__(self, num_stacks, stack_size):\n",
" self.num_stacks = num_stacks\n", " self.num_stacks = num_stacks\n",
" self.stack_size = stack_size\n", " self.stack_size = stack_size\n",
" self.stack_pointers = [-1] * num_stacks\n", " self.stack_pointers = [-1] * self.num_stacks\n",
" self.stack_array = [None] * num_stacks * stack_size\n", " self.stack_array = [None] * self.num_stacks * self.stack_size\n",
"\n", "\n",
" def abs_index(self, stack_index):\n", " def abs_index(self, stack_index):\n",
" return stack_index * self.stack_size + self.stack_pointers[stack_index]\n", " return stack_index * self.stack_size + self.stack_pointers[stack_index]\n",