mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 19:08:02 +00:00
Changed discussions of NULL to None to be more Pythonic.
This commit is contained in:
@@ -51,26 +51,26 @@
|
||||
"\n",
|
||||
"### Insert to Front\n",
|
||||
"\n",
|
||||
"* Insert a NULL\n",
|
||||
"* Insert a None\n",
|
||||
"* Insert in an empty list\n",
|
||||
"* Insert in a list with one element or more elements\n",
|
||||
"\n",
|
||||
"### Append\n",
|
||||
"\n",
|
||||
"* Append a NULL\n",
|
||||
"* Append a None\n",
|
||||
"* Append in an empty list\n",
|
||||
"* Insert in a list with one element or more elements\n",
|
||||
"\n",
|
||||
"### Find\n",
|
||||
"\n",
|
||||
"* Find a NULL\n",
|
||||
"* Find a None\n",
|
||||
"* Find in an empty list\n",
|
||||
"* Find in a list with one element or more matching elements\n",
|
||||
"* Find in a list with no matches\n",
|
||||
"\n",
|
||||
"### Delete\n",
|
||||
"\n",
|
||||
"* Delete a NULL\n",
|
||||
"* Delete a None\n",
|
||||
"* Delete in an empty list\n",
|
||||
"* Delete in a list with one element or more matching elements\n",
|
||||
"* Delete in a list with no matches\n",
|
||||
@@ -93,7 +93,7 @@
|
||||
"\n",
|
||||
"### Insert to Front\n",
|
||||
"\n",
|
||||
"* If the data we are inserting is NULL, return\n",
|
||||
"* If the data we are inserting is None, return\n",
|
||||
"* Create a node with the input data\n",
|
||||
"* If this is an empty list\n",
|
||||
" * Assign the head to the node\n",
|
||||
@@ -107,7 +107,7 @@
|
||||
"\n",
|
||||
"### Append\n",
|
||||
"\n",
|
||||
"* If the data we are inserting is NULL, return\n",
|
||||
"* If the data we are inserting is None, return\n",
|
||||
"* Create a node with the input data\n",
|
||||
"* If this is an empty list\n",
|
||||
" * Assign the head to the node\n",
|
||||
@@ -121,7 +121,7 @@
|
||||
"\n",
|
||||
"### Find\n",
|
||||
"\n",
|
||||
"* If data we are finding is NULL, return\n",
|
||||
"* If data we are finding is None, return\n",
|
||||
"* If the list is empty, return\n",
|
||||
"* For each node\n",
|
||||
" * If the value is a match, return it\n",
|
||||
@@ -133,7 +133,7 @@
|
||||
"\n",
|
||||
"### Delete\n",
|
||||
"\n",
|
||||
"* If data we are deleting is NULL, return\n",
|
||||
"* If data we are deleting is None, return\n",
|
||||
"* If the list is empty, return\n",
|
||||
"* For each node, keep track of previous and current node\n",
|
||||
" * If the value we are deleting is a match in the current node\n",
|
||||
@@ -323,7 +323,7 @@
|
||||
" linked_list.insert_to_front(10)\n",
|
||||
" assert_equal(linked_list.get_all_data(), [10])\n",
|
||||
"\n",
|
||||
" print('Test: insert_to_front on a NULL')\n",
|
||||
" print('Test: insert_to_front on a None')\n",
|
||||
" linked_list.insert_to_front(None)\n",
|
||||
" assert_equal(linked_list.get_all_data(), [10])\n",
|
||||
"\n",
|
||||
@@ -340,7 +340,7 @@
|
||||
" linked_list.append(10)\n",
|
||||
" assert_equal(linked_list.get_all_data(), [10])\n",
|
||||
"\n",
|
||||
" print('Test: append a NULL')\n",
|
||||
" print('Test: append a None')\n",
|
||||
" linked_list.append(None)\n",
|
||||
" assert_equal(linked_list.get_all_data(), [10])\n",
|
||||
"\n",
|
||||
@@ -357,7 +357,7 @@
|
||||
" node = linked_list.find('a')\n",
|
||||
" assert_equal(node, None)\n",
|
||||
"\n",
|
||||
" print('Test: find a NULL')\n",
|
||||
" print('Test: find a None')\n",
|
||||
" head = Node(10)\n",
|
||||
" linked_list = LinkedList(head)\n",
|
||||
" node = linked_list.find(None)\n",
|
||||
@@ -383,7 +383,7 @@
|
||||
" linked_list.delete('a')\n",
|
||||
" assert_equal(linked_list.get_all_data(), [])\n",
|
||||
"\n",
|
||||
" print('Test: delete a NULL')\n",
|
||||
" print('Test: delete a None')\n",
|
||||
" head = Node(10)\n",
|
||||
" linked_list = LinkedList(head)\n",
|
||||
" linked_list.delete(None)\n",
|
||||
@@ -441,23 +441,23 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Test: insert_to_front on an empty list\n",
|
||||
"Test: insert_to_front on a NULL\n",
|
||||
"Test: insert_to_front on a None\n",
|
||||
"Test: insert_to_front general case\n",
|
||||
"Success: test_insert_to_front\n",
|
||||
"\n",
|
||||
"Test: append on an empty list\n",
|
||||
"Test: append a NULL\n",
|
||||
"Test: append a None\n",
|
||||
"Test: append general case\n",
|
||||
"Success: test_append\n",
|
||||
"\n",
|
||||
"Test: find on an empty list\n",
|
||||
"Test: find a NULL\n",
|
||||
"Test: find a None\n",
|
||||
"Test: find general case with matches\n",
|
||||
"Test: find general case with no matches\n",
|
||||
"Success: test_find\n",
|
||||
"\n",
|
||||
"Test: delete on an empty list\n",
|
||||
"Test: delete a NULL\n",
|
||||
"Test: delete a None\n",
|
||||
"Test: delete general case with matches\n",
|
||||
"Test: delete general case with no matches\n",
|
||||
"Success: test_delete\n",
|
||||
|
||||
Reference in New Issue
Block a user