mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-07 01:48:02 +00:00
Fixed #21: Partitioning linked list problem: Does not work if item greater than partition value is to the left.
This commit is contained in:
@@ -151,19 +151,20 @@
|
||||
"\n",
|
||||
" print('Test: General case')\n",
|
||||
" # Partition = 10\n",
|
||||
" # Input: 4, 3, 7, 8, 10, 1, 10, 12\n",
|
||||
" # Output: 4, 3, 7, 8, 1, 10, 10, 12\n",
|
||||
" # Input: 4, 3, 13, 8, 10, 1, 14, 10, 12\n",
|
||||
" # Output: 4, 3, 8, 1, 10, 10, 13, 14, 12\n",
|
||||
" linked_list = MyLinkedList(Node(12))\n",
|
||||
" linked_list.insert_to_front(10)\n",
|
||||
" linked_list.insert_to_front(14)\n",
|
||||
" linked_list.insert_to_front(1)\n",
|
||||
" linked_list.insert_to_front(10)\n",
|
||||
" linked_list.insert_to_front(8)\n",
|
||||
" linked_list.insert_to_front(7)\n",
|
||||
" linked_list.insert_to_front(13)\n",
|
||||
" linked_list.insert_to_front(3)\n",
|
||||
" linked_list.insert_to_front(4)\n",
|
||||
" partitioned_list = linked_list.partition(10)\n",
|
||||
" assert_equal(partitioned_list.get_all_data(),\n",
|
||||
" [4, 3, 7, 8, 1, 10, 10, 12])\n",
|
||||
" [4, 3, 8, 1, 10, 10, 13, 14, 12])\n",
|
||||
"\n",
|
||||
" print('Success: test_partition')\n",
|
||||
"\n",
|
||||
|
||||
Reference in New Issue
Block a user