mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Polish n stacks solution
This commit is contained in:
parent
9c441e9f18
commit
76da9ec98d
|
@ -119,7 +119,6 @@
|
|||
" def push(self, stack_index, data):\n",
|
||||
" if self.stack_pointers[stack_index] == self.stack_size - 1:\n",
|
||||
" raise Exception('Stack is full')\n",
|
||||
" else:\n",
|
||||
" self.stack_pointers[stack_index] += 1\n",
|
||||
" array_index = self.abs_index(stack_index)\n",
|
||||
" self.stack_array[array_index] = data\n",
|
||||
|
@ -127,7 +126,6 @@
|
|||
" def pop(self, stack_index):\n",
|
||||
" if self.stack_pointers[stack_index] == -1:\n",
|
||||
" raise Exception('Stack is empty')\n",
|
||||
" else:\n",
|
||||
" array_index = self.abs_index(stack_index)\n",
|
||||
" data = self.stack_array[array_index]\n",
|
||||
" self.stack_array[array_index] = None\n",
|
||||
|
@ -237,21 +235,21 @@
|
|||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 2",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python2"
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.10"
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.4.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
Loading…
Reference in New Issue
Block a user