Compare commits

...

725 commits
2 ... master

Author SHA1 Message Date
go outside labs helper
c1935a5723
Update links 2023-11-28 12:06:06 -08:00
YnQzZ2w
f51e2f289a
🦖 2023-08-13 09:01:14 -07:00
bt3gl
454f989928
Update README.md 2023-08-08 20:35:51 -07:00
bt3gl
7a42c72a71
Update README.md 2023-08-08 20:32:18 -07:00
bt3gl
8e2ee50f0e
Update README.md 2023-08-08 20:30:00 -07:00
bt3gl
4b58e7b308
Update README.md 2023-08-08 20:29:33 -07:00
bt3gl
20771919fb
Update README.md 2023-08-08 20:25:09 -07:00
bt3gl
2178f880ee
Update README.md 2023-08-08 20:20:44 -07:00
bt3gl
ed6bc75d3e
Update README.md 2023-08-08 20:17:28 -07:00
bt3gl
93a3d07928
Update README.md 2023-08-08 20:12:39 -07:00
bt3gl
faa7b70a00
Update bst_is_valid.py 2023-08-08 20:11:05 -07:00
bt3gl
5108f546c6
Update bs_sucessor_and_precessor.py 2023-08-08 20:00:05 -07:00
bt3gl
0264d26b7e
Update README.md 2023-08-08 19:59:55 -07:00
bt3gl
fcd4eb423b
Update bt_construct_inorder_preorder.py 2023-08-08 19:56:03 -07:00
bt3gl
14404c47c8
Update bt_construct_inorder_postorder.py 2023-08-08 19:55:27 -07:00
bt3gl
bbdd47ffd3
Update bt_construct_inorder_postorder.py 2023-08-08 19:51:19 -07:00
bt3gl
b9318bf6ea
Update bt_inorder_iterator.py 2023-08-08 19:27:15 -07:00
bt3gl
bc8ff138e3
Update README.md 2023-08-08 17:49:23 -07:00
bt3gl
86b7f9ce18
Update README.md 2023-08-08 17:47:37 -07:00
bt3gl
2ef7451aba
Update README.md 2023-08-08 17:47:09 -07:00
bt3gl
3d8e44eef9
Update README.md 2023-08-08 17:46:27 -07:00
bt3gl
802c4c9d5a
Update README.md 2023-08-08 17:45:16 -07:00
bt3gl
39a321a8e0
Update README.md 2023-08-08 17:43:53 -07:00
bt3gl
039bc676f7
Update README.md 2023-08-08 17:42:57 -07:00
bt3gl
eea51a4809
Update README.md 2023-08-08 17:41:16 -07:00
bt3gl
65da6b0c55
Update README.md 2023-08-08 17:39:52 -07:00
bt3gl
7341955f63
Update README.md 2023-08-08 17:39:01 -07:00
bt3gl
ef51d31441
Update README.md 2023-08-08 17:38:12 -07:00
bt3gl
74b313da96
Update README.md 2023-08-08 17:37:07 -07:00
bt3gl
0225dba9ab
Update README.md 2023-08-08 17:33:45 -07:00
bt3gl
215115e76b
Update README.md 2023-08-08 17:33:22 -07:00
bt3gl
3d2fda8696
Update README.md 2023-08-08 17:31:48 -07:00
bt3gl
567efaaa42
Update README.md 2023-08-08 17:26:50 -07:00
bt3gl
a684d7989e
Update README.md 2023-08-08 17:17:16 -07:00
bt3gl
7b32dbb0d7
Update README.md 2023-08-08 17:11:56 -07:00
bt3gl
ac1f70506a
Update README.md 2023-08-08 17:10:49 -07:00
bt3gl
ba0780c240
Delete map_sum.py 2023-08-08 17:03:31 -07:00
bt3gl
044afb8d21
Update README.md 2023-08-08 17:03:08 -07:00
bt3gl
a0d31643e4
Update README.md 2023-08-08 17:02:16 -07:00
bt3gl
4e895726bd
Update trie_preorder.py 2023-08-08 17:02:11 -07:00
bt3gl
728b441734
Update trie_postorder.py 2023-08-08 17:01:53 -07:00
bt3gl
a97c06f579
Update trie_find_height.py 2023-08-08 16:59:52 -07:00
bt3gl
761e86705f
Update trie_bfs.py 2023-08-08 16:57:11 -07:00
bt3gl
bd2fb7fb45
Update README.md 2023-08-08 16:51:52 -07:00
bt3gl
544f5e8f4b
Delete largest_k_matrix.py 2023-08-08 16:51:48 -07:00
bt3gl
f02da2c80e
Update k_smallest_matrix.py 2023-08-08 16:51:10 -07:00
bt3gl
66cf6cc427
Update and rename k_element_stream.py to kth_largest_stream.py 2023-08-08 16:45:59 -07:00
bt3gl
f75b102b78
Delete median_from_stream.py 2023-08-08 16:44:19 -07:00
bt3gl
bf35809bb2
Update and rename top_k_frequent_heap.py to top_k_frequent.py 2023-08-08 16:44:03 -07:00
bt3gl
e7d19505dc
Update and rename free_rooms.py to non_overlapping_invervals.py 2023-08-08 16:42:03 -07:00
bt3gl
9077029939
Update and rename compare_2_tops.py to compare_two_tops.py 2023-08-08 16:37:55 -07:00
bt3gl
e8c7b716af
Update heapify.py 2023-08-08 16:34:19 -07:00
bt3gl
3d8b77bf80
Update heap_sort.py 2023-08-08 16:33:04 -07:00
bt3gl
4002609137
Update README.md 2023-08-08 16:21:55 -07:00
bt3gl
09b98e3740
Update README.md 2023-08-08 16:21:29 -07:00
bt3gl
fde384b038
Update matrix_dfs_and_bfs.py 2023-08-08 16:21:22 -07:00
bt3gl
0f85ea546c
Update README.md 2023-08-08 16:18:57 -07:00
bt3gl
d574e9627d
Update matrix_bfs.py 2023-08-08 16:18:48 -07:00
bt3gl
93a6452f57
Update README.md 2023-08-08 16:16:05 -07:00
bt3gl
cc05ef2ea8
Update dfs.py 2023-08-08 16:15:56 -07:00
bt3gl
c8fad05719
Update bfs.py 2023-08-08 16:14:09 -07:00
bt3gl
f117ec52e5
Update README.md 2023-08-08 16:12:42 -07:00
bt3gl
1b5c749a50
Update README.md 2023-08-08 16:10:02 -07:00
bt3gl
92a74485ec
Update README.md 2023-08-08 16:09:42 -07:00
bt3gl
d1123f8c75
Update README.md 2023-08-08 16:05:57 -07:00
bt3gl
e0ef50da5b
Update bst_is_valid.py 2023-08-08 16:05:32 -07:00
bt3gl
f8dc224ae5
Update bst_lowest_common_ancestor.py 2023-08-08 16:00:29 -07:00
bt3gl
6f312b7631
Rename bt_simple.py to bt_cute.py 2023-08-08 15:56:48 -07:00
bt3gl
cb2909d421
Update bst_insert_node.py 2023-08-08 15:46:10 -07:00
bt3gl
a3ce5db3a5
Update bst_delete_node.py 2023-08-08 15:41:34 -07:00
bt3gl
122a535241
Update bs_sucessor_and_precessor.py 2023-08-08 15:39:55 -07:00
bt3gl
27f5ce1c6f
Rename bst_sucessor_and_precessor.py to bs_sucessor_and_precessor.py 2023-08-08 15:39:44 -07:00
bt3gl
ef073d11ca
Update and rename bst_inorder_iterator.py to bt_inorder_iterator.py 2023-08-08 15:37:13 -07:00
bt3gl
d50ed323fd
Update bst_search.py 2023-08-08 15:35:17 -07:00
bt3gl
8bc3090801
Rename bst_sucessors_and_precessors.py to bst_sucessor_and_precessor.py 2023-08-08 15:32:38 -07:00
bt3gl
f08037aeb8
Rename bst_pre_sucessor.py to bst_sucessors_and_precessors.py 2023-08-08 15:32:21 -07:00
bt3gl
23c20d4aaa
Rename bst_find_successor_inorder.py to bst_sucessor_two_nodes.py 2023-08-08 15:31:45 -07:00
bt3gl
5d56bb3855
Update and rename bst_find_inorder_successor.py to bst_find_successor_inorder.py 2023-08-08 15:28:11 -07:00
bt3gl
cba141be6a
Update bst_convert_sorted_array.py 2023-08-08 15:22:34 -07:00
bt3gl
75bb0277cd
Rename bst_is_balanced.py to bt_is_balanced.py 2023-08-08 15:04:04 -07:00
bt3gl
39922339a3
Update bst_is_balanced.py 2023-08-08 15:03:55 -07:00
bt3gl
f7dc8af9c4
Delete bt_serialization.py 2023-08-08 15:00:00 -07:00
bt3gl
bb47074bdd
Delete bt_find_duplicate_subtrees.py 2023-08-08 14:58:11 -07:00
bt3gl
94de93780a
Update bt_count_unival.py 2023-08-08 14:55:51 -07:00
bt3gl
b61c58b158
Update and rename bt_construction_inorder_postorder.py to bt_construct_inorder_postorder.py 2023-08-08 14:51:08 -07:00
bt3gl
dd98393aa4
Update bt_construct_inorder_preorder.py 2023-08-08 14:47:15 -07:00
bt3gl
e5efd5424a
Update bt_construct_inorder_preorder.py 2023-08-08 14:43:04 -07:00
bt3gl
83fc152596
Update README.md 2023-08-08 14:43:01 -07:00
bt3gl
b91db08a40
Update bt_has_path_sum.py 2023-08-08 14:37:44 -07:00
bt3gl
ff3987dffc
Update bt_postorder.py 2023-08-08 14:32:28 -07:00
bt3gl
15d407b4ef
Update bt_inorder.py 2023-08-08 14:27:07 -07:00
bt3gl
a42c13186c
Update bt_preorder.py 2023-08-08 14:21:03 -07:00
bt3gl
5eba7a1a80
Delete bt_preorder_transversal.py 2023-08-08 14:18:35 -07:00
bt3gl
f7bc342551
Update bt_preorder_transversal.py 2023-08-08 14:18:30 -07:00
bt3gl
ba1a8755f0
Update bt_bfs.py 2023-08-08 14:17:34 -07:00
bt3gl
f1a8659193
Update bt_bfs.py 2023-08-08 14:17:26 -07:00
bt3gl
1044a13ad9
Update bt_bfs.py 2023-08-08 14:16:02 -07:00
bt3gl
95fd556031
Update bt_lowest_common_ancestor.py 2023-08-08 14:11:00 -07:00
bt3gl
f41011e849
Update bt_is_tree_symmetric.py 2023-08-08 13:56:19 -07:00
bt3gl
153e85ca03
Update bt_is_same_trees.py 2023-08-08 13:52:20 -07:00
bt3gl
3606be45c1
Update bt_is_same_trees.py 2023-08-08 13:52:00 -07:00
bt3gl
faeb83a072
Update bt_height.py 2023-08-08 13:49:24 -07:00
bt3gl
ffe28f3d8e
Update README.md 2023-08-08 13:48:50 -07:00
bt3gl
66060486a4
Update bt_height.py 2023-08-08 13:44:06 -07:00
bt3gl
a78436b51b
Update bt_height.py 2023-08-08 13:44:00 -07:00
bt3gl
91cd6134b6
Update bt_find_max_depth.py 2023-08-08 13:42:15 -07:00
bt3gl
b5c71cf3d5
Update bt.py 2023-08-08 13:39:07 -07:00
bt3gl
096185a6e8
Create bt_postorder.py 2023-08-08 13:37:21 -07:00
bt3gl
0e2b6b39b0
Create bt_preorder.py 2023-08-08 13:36:59 -07:00
bt3gl
9486e25675
Create bt_inorder.py 2023-08-08 13:36:28 -07:00
bt3gl
b1a9367ee4
Rename bst_all_subnodes.py to bst_all_subnodes.py 2023-08-08 13:29:07 -07:00
bt3gl
eedb6b6863
Update and rename bst_all_subnodes.py to bst_all_subnodes.py 2023-08-08 13:28:30 -07:00
bt3gl
cd5ac00126
Update README.md 2023-08-08 13:28:00 -07:00
bt3gl
cf170e3d57
Update bt_bfs.py 2023-08-08 13:23:11 -07:00
bt3gl
3e375366ae
Update README.md 2023-08-08 13:19:30 -07:00
marina
5844ecc8bf
Update README.md 2023-08-07 23:12:04 -07:00
marina
f2b423db58
Update README.md 2023-08-07 23:01:42 -07:00
marina
b6faf3956b
Update README.md 2023-08-07 22:37:51 -07:00
marina
f2091f10d2
Update README.md 2023-08-07 22:31:42 -07:00
marina
ff73b28ae7
Delete rotated_array.py 2023-08-07 22:31:10 -07:00
marina
79872f08eb
Update find_pair_nums.py 2023-08-07 22:27:38 -07:00
marina
e25dd1f601
Update README.md 2023-08-07 22:16:22 -07:00
marina
3b3a40d782
Update README.md 2023-08-07 22:15:51 -07:00
marina
c4e0cdc9ff
Update find_peak_element.py 2023-08-07 22:15:42 -07:00
marina
56af227e6e
Update README.md 2023-08-07 21:53:55 -07:00
marina
b52c7e0d03
Update README.md 2023-08-07 21:49:23 -07:00
marina
e63cfe856f
Update sqrt_x.py 2023-08-07 21:49:19 -07:00
marina
855ecff683
Update README.md 2023-08-07 21:47:12 -07:00
marina
e372bbe6f7
Update binary_search.py 2023-08-07 21:47:06 -07:00
marina
8ef56f3b77
Update README.md 2023-08-07 21:21:15 -07:00
marina
fa5bba3881
Update README.md 2023-08-07 21:15:05 -07:00
marina
8857af6e97
Update README.md 2023-08-07 20:55:59 -07:00
marina
35fb490c38
Update seletction_sort.py 2023-08-07 20:38:23 -07:00
marina
1ac9dbd6d5
Update quick_sort.py 2023-08-07 20:38:09 -07:00
marina
ee9384b374
Update quick_sort.py 2023-08-07 20:37:59 -07:00
marina
40a4976c5f
Update random_set.py 2023-08-07 20:31:43 -07:00
marina
6f1dd06515
Update README.md 2023-08-07 20:31:35 -07:00
marina
06e19d394b
Update README.md 2023-08-07 20:31:27 -07:00
marina
813cd4db01
Update README.md 2023-08-07 20:31:01 -07:00
marina
dbcf75bcac
Update README.md 2023-08-07 20:12:57 -07:00
marina
a4fc7156af
Update README.md 2023-08-07 20:05:13 -07:00
marina
8da5fea499
Create queue_list_II.py 2023-08-07 20:05:00 -07:00
marina
7e40ca15da
Update and rename circular_queue_list.py to queue_list.py 2023-08-07 19:59:38 -07:00
marina
5f44f6b89f
Update README.md 2023-08-07 19:37:37 -07:00
marina
af264699b7
Update moving_average.py 2023-08-07 18:57:15 -07:00
marina
db7be11ea0
Update and rename logger_rate_limiter.py to stream_with_rate_limiter.py 2023-08-07 18:53:53 -07:00
marina
2c1df477e2
Update circular_queue_array.py 2023-08-07 18:51:39 -07:00
marina
5ab9d7582a
Delete simple_queue.py 2023-08-07 18:08:30 -07:00
marina
c176257c26
Update README.md 2023-08-07 18:07:35 -07:00
marina
f895ac1da8
Update README.md 2023-08-07 18:07:20 -07:00
marina
18c33edfb0
Update and rename circular_queue_III.py to circular_queue_list.py 2023-08-07 18:06:56 -07:00
marina
ad2c24a519
Delete circular_queue_list.py 2023-08-07 18:06:54 -07:00
marina
afe695c69f
Update and rename circular_queue_II.py to circular_queue_list.py 2023-08-07 18:05:28 -07:00
marina
71ca605489
Update and rename circular_queue.py to circular_queue_array.py 2023-08-07 18:05:15 -07:00
marina
3d361330b7
Update README.md 2023-08-07 18:04:47 -07:00
marina
6ed5cb896b
Update and rename stack_II.py to stack.py 2023-08-07 17:58:03 -07:00
marina
27bc931a53
Update README.md 2023-08-07 17:57:39 -07:00
marina
a8e6ec8884
Update README.md 2023-08-07 17:56:19 -07:00
marina
66a2a3ad3a
Update README.md 2023-08-07 17:54:59 -07:00
marina
f55ce43de3
Delete stack.py 2023-08-07 17:53:19 -07:00
marina
a079cef3d2
Update stack_II.py 2023-08-07 17:52:44 -07:00
marina
975b4d7dbd
Update stack.py 2023-08-07 17:51:46 -07:00
marina
fd439a2d84
Update README.md 2023-08-07 17:47:21 -07:00
marina
87f52134da
Update README.md 2023-08-07 17:46:11 -07:00
marina
60c86f0759
Update README.md 2023-08-07 17:39:51 -07:00
marina
7d89916381
Update README.md 2023-08-07 17:38:59 -07:00
marina
e6b5af60e3
Update README.md 2023-08-07 17:38:41 -07:00
marina
fd291fa48b
Update unique_word_abbreviation.py 2023-08-07 17:38:13 -07:00
marina
b9b5d8e21c
Update and rename str-longest-non-repeating.py to longest_non_repeating.py 2023-08-07 17:36:23 -07:00
marina
e54535ae2b
Update playing_with_strings.py 2023-08-07 17:35:27 -07:00
marina
a37d96b756
Update pivot_index_array.py 2023-08-07 17:35:15 -07:00
marina
a4fe8d519e
Update and rename permutation.py to permutations.py 2023-08-07 17:34:32 -07:00
marina
0b6dbbaa27
Update palindrome.py 2023-08-07 17:33:48 -07:00
marina
250e136166
Update and rename matrix-sum-diagonals.py to matrix_sum_diagonals.py 2023-08-07 17:33:29 -07:00
marina
b14d9fcee2
Update is_anagram.py 2023-08-07 17:31:39 -07:00
marina
2d0842019d
Update intersection_two_arrays.py 2023-08-07 17:31:08 -07:00
marina
2fe4c94c7f
Update check_permutation_strings_is_palindrome.py 2023-08-07 17:29:58 -07:00
marina
b81ccd579b
Update and rename array-remove-duplicate-inplace.py to remove_dups_inplace.py 2023-08-07 17:26:48 -07:00
marina
2f1db3f84e
Update and rename array-move-zeros-inplace.py to move_zeros_inplace.py 2023-08-07 17:26:30 -07:00
marina
86a538032a
Update and rename array-merge-inplace.py to merge_inplace.py 2023-08-07 17:26:09 -07:00
marina
761c1f0670
Update and rename array-duplicate-zeros.py to duplicate_zeros_inplace.py 2023-08-07 17:25:19 -07:00
marina
5c0e0228e6
Update and rename array-check_mountain.py to check_mountain.py 2023-08-07 17:24:20 -07:00
marina
37a25d4423
Rename check-if-exist.py to check_if_exist.py 2023-08-07 17:23:36 -07:00
marina
c73adbc7b8
Rename 3rd-distinct-0n.py to 3rd_distinct_n.py 2023-08-07 17:23:28 -07:00
marina
7e6f0817be
Rename array-check-if-exist.py to check-if-exist.py 2023-08-07 17:23:16 -07:00
marina
cf27a0741e
Rename array-3rd-distinct-0n.py to 3rd-distinct-0n.py 2023-08-07 17:23:01 -07:00
marina
15135b757e
Update array-check-if-exist.py 2023-08-07 17:22:45 -07:00
marina
17f53eb593
Update README.md 2023-08-07 17:10:22 -07:00
marina
6dbd139af1
Update playing_with_math.py 2023-08-07 17:09:47 -07:00
marina
3d8721aaeb
Update pascal_triangle.py 2023-08-07 17:08:53 -07:00
marina
9a820d8599
Update fibonacci.py 2023-08-07 17:05:59 -07:00
marina
5d9313dd85
Update check_sudoku_board.py 2023-08-07 17:05:44 -07:00
marina
3215e25e12
Update check_sudoku_board.py 2023-08-07 17:05:29 -07:00
marina
e1e46e59c8
Update binary_exponentiation.py 2023-08-07 17:05:08 -07:00
marina
d61684057c
Update README.md 2023-08-07 17:00:38 -07:00
marina
e84d63ff68
Update README.md 2023-08-07 16:59:09 -07:00
marina
0aa2a467e1
Update README.md 2023-08-07 16:58:22 -07:00
marina
d407a66536
Update README.md 2023-08-07 16:58:11 -07:00
marina
4ed4ef89c6
Update README.md 2023-08-07 16:57:28 -07:00
marina
56c0e95516
Update climbing_stairs.py 2023-08-07 16:56:28 -07:00
marina
784b8a8698
Update climbing_stairs.py 2023-08-07 16:55:25 -07:00
marina
bce645eb9e
Update README.md 2023-08-07 16:55:23 -07:00
marina
6b3923e32c
Update and rename all_subnotes_bst.py to bst_all_subnodes.py 2023-08-07 16:53:25 -07:00
marina
aca9429097
Update README.md 2023-08-07 16:51:23 -07:00
marina
2861501448
Update hash_set_bst.py 2023-08-07 16:47:56 -07:00
marina
240d008647
Update README.md 2023-08-07 16:47:45 -07:00
marina
2f8af300a6
Update hash_set_linked_list.py 2023-08-07 16:45:02 -07:00
marina
178b3aea34
Update hash_set_bst.py 2023-08-07 16:44:51 -07:00
marina
e65d65d6eb
Update hash_map_array.py 2023-08-07 16:44:39 -07:00
marina
00dada5ff3
Update README.md 2023-08-07 16:44:10 -07:00
marina
95f73c5771
Update hash_set_linked_list.py 2023-08-07 16:42:22 -07:00
marina
d1e0aa2a52
Update README.md 2023-08-07 16:41:00 -07:00
marina
38f6c1491a
Update README.md 2023-08-07 16:39:43 -07:00
marina
dd2462222f
Update hash_set_bst.py 2023-08-07 16:39:20 -07:00
marina
0f92fc245c
Update hash_map_array.py 2023-08-07 16:37:51 -07:00
marina
e01b5b5e2a
Update hash_map_array.py 2023-08-07 16:35:36 -07:00
marina
85f1f87c8d
Update flatten_list.py 2023-08-07 16:22:14 -07:00
marina
ea12ccce74
Update README.md 2023-08-07 16:21:59 -07:00
marina
0389271f6b
Update remove_kth_node.py 2023-08-07 16:17:11 -07:00
marina
d8d1887a85
Update rotate_list_by_k.py 2023-08-07 16:13:15 -07:00
marina
f6e853a5ab
Update detect_cycle_II.py 2023-08-07 15:56:27 -07:00
marina
544caafaa3
Update detect_cycle.py 2023-08-07 15:56:18 -07:00
marina
8b3feb691e
Update README.md 2023-08-07 15:56:04 -07:00
marina
69d068678b
Update swap_every_two_nodes.py 2023-08-07 15:54:37 -07:00
marina
93c18361f3
Update doubly_linked_list.py 2023-08-07 15:52:35 -07:00
marina
4a03488022
Update add_two_numbers.py 2023-08-07 15:51:56 -07:00
marina
60b5ec4a88
Update reverse_linked_list_II.py 2023-08-07 15:51:00 -07:00
marina
b16196e810
Update reverse_linked_list_II.py 2023-08-07 15:50:35 -07:00
marina
3024f285e5
Update merge_two_lists.py 2023-08-07 15:48:48 -07:00
marina
8d8b3f7e53
Update linked_list_fifo.py 2023-08-07 15:48:20 -07:00
marina
08a29ececf
Update finding_intersection.py 2023-08-07 15:47:08 -07:00
marina
e06d9fbbf6
Update doubly_linked_list_II.py 2023-08-07 15:46:38 -07:00
marina
1c51827e08
Update detect_cycle_II.py 2023-08-07 15:45:14 -07:00
marina
907bf738ec
Create bfs.py 2023-08-06 17:08:35 -07:00
marina
35c888571e
Create dfs.py 2023-08-06 17:06:38 -07:00
marina
e333844d4d
Create heap.py 2023-08-06 17:04:12 -07:00
marina
e80361656e
Update README.md 2023-08-06 11:30:19 -07:00
marina
18a5fbd75c
Update README.md 2023-08-04 18:47:47 -07:00
marina
a2f5521bd3
Update README.md 2023-08-03 20:31:19 -07:00
marina
0e5c36f426
Update README.md 2023-08-03 20:09:21 -07:00
marina
b7475a8481
Update README.md 2023-08-03 19:38:36 -07:00
marina
cd2e4557dc
Create bt_is_same_trees.py 2023-08-03 19:36:17 -07:00
marina
390316781e
Rename bs_find_pair_nums.py to find_pair_nums.py 2023-08-03 19:34:33 -07:00
marina
7da5b84f60
Rename bs_rotated_array.py to rotated_array.py 2023-08-03 19:34:22 -07:00
marina
1821dd41e0
Create bs_find_pair_nums.py 2023-08-03 19:34:04 -07:00
marina
74f6ef2913
Delete bs_find_pair_nums.py 2023-08-03 19:34:00 -07:00
marina
d7280726ad
Create rotate_list_by_k.py 2023-08-03 18:53:47 -07:00
marina
18389003c4
Create flatten_list.py 2023-08-03 18:06:53 -07:00
marina
86d533c4bf
Create trie_find_height.py 2023-08-03 17:04:33 -07:00
marina
feb21289db
Create trie_bfs.py 2023-08-03 16:59:19 -07:00
marina
c041716806
Create trie_postorder.py 2023-08-03 16:56:05 -07:00
marina
141a6b5944
Create trie_preorder.py 2023-08-03 16:53:01 -07:00
marina
e95aa5a731
Create map_sum.py 2023-08-03 16:39:19 -07:00
marina
faf6e7321e
Update README.md 2023-08-03 16:32:11 -07:00
marina
fb6507ce38
Update README.md 2023-08-03 16:29:43 -07:00
marina
39262bfbe4
add trie class 2023-08-03 16:24:41 -07:00
marina
05ffc6e0b7
Create trie.py 2023-08-03 16:24:22 -07:00
marina
eb7a7af574
Create bst_convert_sorted_array.py 2023-08-03 16:05:01 -07:00
marina
072febeb9c
Update README.md 2023-08-03 16:02:59 -07:00
marina
50c188a88c
notes on balanced 2023-08-03 15:56:35 -07:00
marina
817cbb57a2
Create bst_is_balanced.py 2023-08-03 15:55:38 -07:00
marina
177914c7be
add note on height 2023-08-03 15:50:59 -07:00
marina
46b4f11520
Create bt_height.py 2023-08-03 15:50:27 -07:00
marina
75eb7e2dd9
Update README.md 2023-08-03 15:39:36 -07:00
marina
50436468d3
add avl tree class 2023-08-03 15:37:11 -07:00
marina
270783268c
add notes on lca 2023-08-03 15:26:48 -07:00
marina
fab5bed80f
Create bst_lowest_common_ancestor.py 2023-08-03 15:26:35 -07:00
marina
e3e5e4bf35
Update README.md 2023-08-03 14:28:06 -07:00
marina
15e4b6068c
Update README.md 2023-08-03 14:25:22 -07:00
marina
5c2393dc07
add delete node info 2023-08-03 14:23:25 -07:00
marina
0c05504ae1
Create bst_delete_node.py 2023-08-03 14:23:13 -07:00
marina
e1a2904cfe
Create bst_pre_sucessor.py 2023-08-03 13:56:53 -07:00
marina
2fe870650b
add notes on bst 2023-08-03 13:52:49 -07:00
marina
8e8f934d12
Create bst_insert_node.py 2023-08-03 13:47:22 -07:00
marina
fb8081ae42
Update bst_search.py 2023-08-03 13:31:57 -07:00
marina
419eeee0dc
Create bst_search.py 2023-08-03 13:22:06 -07:00
marina
169d2197c9
Rename binary_tree.py to bt.py 2023-08-03 13:20:49 -07:00
marina
070071e687
Update and rename tree_bfs.py to bt_bfs.py 2023-08-03 13:20:29 -07:00
marina
9d1aa92451
Rename tree_serialization.py to bt_serialization.py 2023-08-03 13:20:09 -07:00
marina
919111cd22
Rename sum_2_numbers_with_bs.py to bs_find_pair_nums.py 2023-08-03 13:19:59 -07:00
marina
4aba894c46
Rename simple_tree.py to bt_simple.py 2023-08-03 13:19:35 -07:00
marina
84b35ceaf3
Update and rename preorder_transversal.py to bt_preorder_transversal.py 2023-08-03 13:18:57 -07:00
marina
7520042ef9
Update and rename lowest_common_ancestor.py to bt_lowest_common_ancestor.py 2023-08-03 13:18:31 -07:00
marina
ca5c15c9b6
Rename is_valid_bst.py to bst_is_valid.py 2023-08-03 13:17:57 -07:00
marina
7d6d6189e5
Update and rename is_tree_symmetric.py to bt_is_tree_symmetric.py 2023-08-03 13:17:44 -07:00
marina
5159d766d9
Update and rename has_path_sum.py to bt_has_path_sum.py 2023-08-03 13:17:12 -07:00
marina
e7284b27e2
Update bt_find_max_depth.py 2023-08-03 13:16:54 -07:00
marina
a0b0090f8a
Update and rename find_max_depth_tree.py to bt_find_max_depth.py 2023-08-03 13:16:41 -07:00
marina
e0d9624032
Rename find_inorder_successor.py to bst_find_inorder_successor.py 2023-08-03 13:16:23 -07:00
marina
57075bd388
Update and rename find_duplicate_subtrees.py to bt_find_duplicate_subtrees.py 2023-08-03 13:16:07 -07:00
marina
0871054dd3
Rename count_unival.py to bt_count_unival.py 2023-08-03 13:15:34 -07:00
marina
5b67529485
Rename construct_bt_inorder_preorder.py to bt_construct_inorder_preorder.py 2023-08-03 13:15:19 -07:00
marina
9cfd35035a
Update and rename construct_tree_inorder_preorder.py to construct_bt_inorder_preorder.py 2023-08-03 13:14:55 -07:00
marina
753ce86ad2
Rename construct_tree_inorder_postorder.py to bt_construction_inorder_postorder.py 2023-08-03 13:14:17 -07:00
marina
1a9f793b21
Rename bst.py to binary_tree.py 2023-08-03 13:13:51 -07:00
marina
51e6497cef
Update bst.py 2023-08-03 13:13:18 -07:00
marina
a2dce9493e
Create bst_inorder_iterator.py 2023-08-03 13:10:38 -07:00
marina
abbad25ed8
Create find_inorder_successor.py 2023-08-03 13:01:04 -07:00
marina
3d8bf7d339
add notes on bst 2023-08-03 12:40:33 -07:00
marina
b69bc7db19
Create is_valid_bst.py 2023-08-03 12:38:44 -07:00
marina
4475910493
Rename SimpleTree.py to simple_tree.py 2023-08-03 11:08:12 -07:00
marina
ff1a7e5d51
Rename BinaryTree.py to bst.py 2023-08-03 11:08:01 -07:00
marina
5b38a549a7
Update seletction_sort.py 2023-08-02 23:42:21 -07:00
marina
1f23338150
Update insertion_sort.py 2023-08-02 23:41:46 -07:00
marina
bcc9398a27
Update counting_sort.py 2023-08-02 23:41:18 -07:00
marina
02c26f8d8a
Update bucket_sort.py 2023-08-02 23:40:13 -07:00
marina
d357be4e52
Update bubble_sort.py 2023-08-02 23:39:04 -07:00
marina
2e7f4a9410
Update README.md 2023-08-02 22:13:16 -07:00
marina
7bc4115287
Create delete_node_without_head.py 2023-08-02 21:29:02 -07:00
marina
d3143cc5fb
Update README.md 2023-08-02 21:14:00 -07:00
marina
908352604b
Update README.md 2023-08-02 21:00:21 -07:00
marina
0ba5a05762
quick_sort.py 2023-08-02 20:57:44 -07:00
marina
96607ab5e2
Update README.md 2023-08-02 20:57:18 -07:00
marina
e7995a9461
Update README.md 2023-08-02 20:57:05 -07:00
marina
c3e12c40a4
Create merge_sort.py 2023-08-02 20:56:55 -07:00
marina
384b79adf8
Create bucket_sort.py 2023-08-02 20:56:20 -07:00
marina
4d2e7857b2
Create counting_sort.py 2023-08-02 20:55:05 -07:00
marina
28d28b817e
Create insertion_sort.py 2023-08-02 20:54:05 -07:00
marina
52cba3f861
Create bubble_sort.py 2023-08-02 20:53:18 -07:00
marina
e1805c9fb5
Create seletction_sort.py 2023-08-02 20:52:30 -07:00
marina
b068e60212
Create add_two_numbers.py 2023-08-02 20:37:09 -07:00
marina
e5c9084b64
Create group_odd_and_even.py 2023-08-02 19:19:54 -07:00
marina
e085d74110
Update detect_cycle.py 2023-08-02 19:19:38 -07:00
marina
3d5ed34eab
Update README.md 2023-08-02 19:14:44 -07:00
marina
0ea70e2122
Update README.md 2023-08-02 19:11:01 -07:00
marina
57ddd32859
Update remove_elements.py 2023-08-02 19:10:37 -07:00
marina
2c1c7c0ff7
Create remove_elements.py 2023-08-02 19:10:26 -07:00
marina
fb7059d0e6
Update README.md 2023-08-02 18:42:48 -07:00
marina
fd5bbaee8d
Update README.md 2023-08-02 18:40:43 -07:00
marina
f567a5a594
Update README.md 2023-08-02 18:40:27 -07:00
marina
7d62415e5f
Update README.md 2023-08-02 18:40:15 -07:00
marina
98ece41e3b
Update README.md 2023-08-02 18:39:45 -07:00
marina
4a762cf606
Update README.md 2023-08-02 18:39:23 -07:00
marina
50409a0e85
Update README.md 2023-08-02 18:38:43 -07:00
marina
9441428acf
Update README.md 2023-08-02 18:37:49 -07:00
marina
5ea9c0bbbf
Update README.md 2023-08-02 18:37:14 -07:00
marina
79fc85b28d
Create doubly_linked_list_II.py 2023-08-02 18:34:17 -07:00
marina
f5a30a6176
Update and rename double_linked_list.py to doubly_linked_list.py 2023-08-02 18:24:28 -07:00
marina
82ac14af5d
add notes on reversing 2023-08-02 18:17:34 -07:00
marina
397402f144
Create reverse_linked_list_II.py 2023-08-02 18:13:43 -07:00
marina
c004a953a9
Update reverse_linked_list.py 2023-08-02 17:49:22 -07:00
marina
17ca5877bf
Update README.md 2023-08-02 17:48:09 -07:00
marina
31c7cc4654
Create remove_kth_node.py 2023-08-02 17:46:34 -07:00
marina
eb36c2249d
Create finding_intersection.py 2023-08-02 17:14:46 -07:00
marina
654bb8c76f
Create detect_cycle_II.py 2023-08-02 17:06:05 -07:00
marina
5eaeb66493
Update linked_list_II.py 2023-08-02 16:41:10 -07:00
marina
5ea3de0fc9
Update linked_list_II.py 2023-08-02 16:40:59 -07:00
marina
67656b197d
Update detect_cycle.py 2023-08-02 16:40:19 -07:00
marina
4e82aa6060
Create detect_cycle.py 2023-08-02 16:39:40 -07:00
marina
94db93ff42
Create linked_list_II.py 2023-08-02 16:31:26 -07:00
marina
296c30779b
Create median_from_stream.py 2023-08-02 14:56:16 -07:00
marina
8509c2f7a1
Create free_rooms.py 2023-08-02 14:30:48 -07:00
marina
4ce3ef0daa
Create k_smallest_matrix.py 2023-08-02 14:21:59 -07:00
marina
586803c39b
Create largest_k_matrix.py 2023-08-02 14:17:23 -07:00
marina
2ac7e9a678
Update compare_2_tops.py 2023-08-02 14:16:12 -07:00
marina
25054eabb1
Create compare_2_tops.py 2023-08-02 14:05:23 -07:00
marina
d6fedcee53
Create k_element_stream.py 2023-08-02 13:56:52 -07:00
marina
3eb6a7c828
Update README.md 2023-08-02 13:52:45 -07:00
marina
c04d598bfa
Update README.md 2023-08-02 13:52:15 -07:00
marina
29b7948275
Update README.md 2023-08-02 13:51:00 -07:00
marina
b53b78285d
Update README.md 2023-08-02 13:40:47 -07:00
marina
f7779dc6e3
Create heap_sort.py 2023-08-02 13:32:18 -07:00
marina
4caa1fe7f4
Update README.md 2023-08-02 13:31:19 -07:00
marina
07f6564fe6
add notes on heapify 2023-08-02 13:26:08 -07:00
marina
179bbd568e
Update README.md 2023-08-02 13:06:21 -07:00
marina
0588483a19
Update heapify.py 2023-08-02 13:05:42 -07:00
marina
8f4fc49e7a
Update README.md 2023-08-02 13:03:15 -07:00
marina
f595c7b2cf
Update heapify.py 2023-08-02 13:01:14 -07:00
marina
e8882c2da0
Create heapify.py 2023-08-02 12:59:18 -07:00
marina
cf0a3cd358
Update README.md 2023-08-02 12:28:54 -07:00
marina
041e403d46
Update README.md 2023-08-02 12:28:39 -07:00
marina
f5b741f0c4
Update README.md 2023-08-02 12:28:32 -07:00
marina
e47e3241b8
add code for max and min heap 2023-08-02 12:01:57 -07:00
marina
5a3aaf58e3
Create max_heap.py 2023-08-02 12:01:30 -07:00
marina
d27d42a800
Create min_heap.py 2023-08-02 11:57:10 -07:00
marina
b38403f6de
Update README.md 2023-08-01 20:43:48 -07:00
marina
52bf99bd0f
Update README.md 2023-08-01 19:36:59 -07:00
marina
1ddc83c1ff
Create stack_II.py 2023-08-01 18:20:59 -07:00
marina
e0d4dd2066
Create matrix_dfs_and_bfs.py 2023-08-01 16:20:00 -07:00
marina
4530fcce5c
Rename tree_level_traversal.py to tree_bfs.py 2023-08-01 15:21:59 -07:00
marina
00d8c462bf
Create matrix_bfs.py 2023-08-01 15:21:20 -07:00
marina
543e2d7d29
add ll and array example 2023-08-01 14:58:37 -07:00
marina
743f091905
my favorite implementation 2023-08-01 14:56:03 -07:00
marina
eb45cdd938
Update README.md 2023-08-01 14:51:34 -07:00
marina
fb971d112c
add bfs and dfs 2023-08-01 14:49:29 -07:00
marina
3f8f299f37
add bfs and dft 2023-08-01 14:48:46 -07:00
marina
1295041070
Update circular_queue_II.py 2023-08-01 14:46:05 -07:00
marina
969435d08f
Update README.md 2023-08-01 14:44:37 -07:00
marina
d4e17ad741
Update circular_queue.py 2023-08-01 14:42:23 -07:00
marina
84a9c9fb9d
Rename queue.py to simple_queue.py 2023-08-01 14:40:39 -07:00
marina
04cd4a4b7b
Update circular_queue_II.py 2023-08-01 14:40:02 -07:00
marina
0bc7deb3af
Update README.md 2023-07-31 18:48:02 -07:00
marina
0cd3198d05
add note on 2d arrays 2023-07-31 18:20:46 -07:00
marina
8c631c5cd0
Create return_matrix_in_spiral.py 2023-07-31 17:36:30 -07:00
marina
b467dca561
Create pivot_index_array.py 2023-07-31 16:32:41 -07:00
marina
0963a43bcc
Update README.md 2023-07-31 16:18:44 -07:00
marina
649a881647
Create find_minimum_rotated_array.py 2023-07-31 16:09:47 -07:00
marina
06f3c4dd1e
Create find_peak_element.py 2023-07-31 15:57:30 -07:00
marina
d0bbfed0e5
Update bs_rotated_array.py 2023-07-31 15:42:22 -07:00
marina
5456593be9
Update binary_search.py 2023-07-31 15:41:56 -07:00
marina
a449abf709
Create bs_rotated_array.py 2023-07-31 15:39:08 -07:00
marina
2626cec18a
Create sqrt_x.py 2023-07-31 15:10:15 -07:00
marina
398c10877c
Update binary_search.py 2023-07-31 14:59:00 -07:00
marina
2396654457
Update binary_search.py 2023-07-31 14:58:10 -07:00
marina
afdff04a69
Create all_subnotes_bst.py 2023-07-31 14:00:52 -07:00
marina
40c0dd37dd
Create merge_two_lists.py 2023-07-31 13:44:12 -07:00
marina
914d1eda87
add note on stack overflow 2023-07-31 13:36:48 -07:00
marina
65615f2f05
Create binary_exponentiation.py 2023-07-31 13:35:08 -07:00
marina
48d1683be5
Update README.md 2023-07-31 13:27:44 -07:00
marina
16d09b5b0d
Update README.md 2023-07-31 13:05:44 -07:00
marina
78f2ab992e
add memoization 2023-07-31 12:50:59 -07:00
marina
e15c16c55b
Create pascal_triangle.py 2023-07-31 12:46:59 -07:00
marina
614f985f1a
Create reverse_linked_list.py 2023-07-31 12:21:30 -07:00
marina
40034ce8bd
Rename linked_list-double.py to double_linked_list.py 2023-07-31 12:00:43 -07:00
marina
84f2a8fe94
Create swap_every_two_nodes.py 2023-07-31 12:00:18 -07:00
marina
eb7bc74843
Rename LinkedListFIFO.py to linked_list_fifo.py 2023-07-31 11:59:00 -07:00
marina
c2799fec3a
Update random_set.py 2023-07-31 10:54:14 -07:00
marina
a853cb34c5
Update README.md 2023-07-31 10:54:00 -07:00
marina
50878d0b85
Create random_set.py 2023-07-31 10:50:05 -07:00
marina
a50bbdf518
Update README.md 2023-07-31 10:49:35 -07:00
marina
1202f248cf
Rename Stack.py to stack.py 2023-07-31 10:11:16 -07:00
marina
06b74ecc34
Update README.md 2023-07-31 10:10:33 -07:00
marina
8f9fc12b05
Create README.md 2023-07-31 10:09:54 -07:00
marina
1fd4595e92
Update README.md 2023-07-31 09:07:52 -07:00
Marina S
a7864edb7f
Update README.md 2023-07-30 21:48:58 -07:00
Marina S
b66625f149
Update README.md 2023-07-30 21:48:33 -07:00
Marina S
06d7a6633e
Update README.md 2023-07-30 21:48:15 -07:00
Marina S
166afb1ce1
Update README.md 2023-07-30 21:47:39 -07:00
Marina S
f39587af7f
Update README.md 2023-07-30 21:47:10 -07:00
Marina S
a1b611ac72
Update README.md 2023-07-30 21:46:57 -07:00
Marina S
9f532c9b01
Update README.md 2023-07-30 21:46:16 -07:00
Marina S
16a1b8b501
Update README.md 2023-07-30 21:46:09 -07:00
Marina S
7fdb76fce8
Create README.md 2023-07-30 21:45:52 -07:00
Marina S
321ef3b254
Create README.md 2023-07-30 21:45:39 -07:00
Marina S
d94f45a59a
Rename Queue.py to queue.py 2023-07-30 21:45:28 -07:00
Marina S
8978a8b74c
Create README.md 2023-07-30 21:45:11 -07:00
Marina S
913a26b906
Update README.md 2023-07-30 21:44:51 -07:00
Marina S
da47a56961
Update README.md 2023-07-30 21:44:16 -07:00
Marina S
cdfd761d87
Create README.md 2023-07-30 21:43:36 -07:00
Marina S
f5490128cd
Update README.md 2023-07-30 21:43:03 -07:00
Marina S
22adc6f880
Create README.md 2023-07-30 21:42:46 -07:00
Marina S
c17c348eed
Create README.md 2023-07-30 21:42:25 -07:00
Marina S
0033b2ee00
Update README.md 2023-07-30 21:41:52 -07:00
Marina S
0a2c958014
Create README.md 2023-07-30 21:41:11 -07:00
bt3gl
a85ed914d3 👾 2023-07-30 21:40:09 -07:00
Marina S
1d44d182e2
Update README.md 2023-07-30 21:39:27 -07:00
Marina S
696c045a16
Create unique_word_abbreviation.py 2023-07-30 20:22:30 -07:00
Marina S
0ad1ab44be
Rename anagram.py to is_anagram.py 2023-07-30 20:21:03 -07:00
Marina S
f4e431412e
Create top_k_frequent_heap.py 2023-07-30 19:43:59 -07:00
bt3gl
fa7c3cde66
Update README.md 2023-07-30 17:57:20 -07:00
bt3gl
ec9ccd5dfd
Update README.md 2023-07-30 17:53:18 -07:00
bt3gl
402b6d3cf8
Create find_duplicate_subtrees.py 2023-07-30 17:49:12 -07:00
bt3gl
2e37835477
Update check_sudoku_board.py 2023-07-30 17:33:00 -07:00
bt3gl
d982849688
Create check_sudoku_board.py 2023-07-30 17:32:38 -07:00
bt3gl
0ae7126e96
Create logger_rate_limiter.py 2023-07-30 16:48:52 -07:00
bt3gl
fcdf1422ac
Update README.md 2023-07-30 16:13:15 -07:00
bt3gl
a9127ff3fc
Update moving_average.py 2023-07-30 15:58:36 -07:00
bt3gl
50ba4aaed4
Update circular_queue_II.py 2023-07-30 15:58:30 -07:00
bt3gl
03a836ca53
Update circular_queue.py 2023-07-30 15:58:20 -07:00
bt3gl
cd0575f81e
Update binary_search.py 2023-07-30 15:58:03 -07:00
bt3gl
e4bfc72334
Update playing_with_math.py 2023-07-30 15:57:50 -07:00
bt3gl
e522443df1
Update happy_number.py 2023-07-30 15:57:44 -07:00
bt3gl
cf32f0112c
Update climbing_stairs.py 2023-07-30 15:57:34 -07:00
bt3gl
45a3a9b050
Update linked_list-double.py 2023-07-30 15:57:23 -07:00
bt3gl
805e80144d
Update sum_with_bitwise.py 2023-07-30 15:57:08 -07:00
bt3gl
3fbab4d88f
Update reverse_bits.py 2023-07-30 15:57:01 -07:00
bt3gl
e85b88725f
Update count_1s.py 2023-07-30 15:56:51 -07:00
bt3gl
818626f205
Update convert_to_hex.py 2023-07-30 15:56:44 -07:00
bt3gl
c87740bc66
Update convert_any_base.py 2023-07-30 15:56:37 -07:00
bt3gl
737898f55d
Update two_sums.py 2023-07-30 15:56:20 -07:00
bt3gl
bed6d221fd
Update str-longest-non-repeating.py 2023-07-30 15:56:13 -07:00
bt3gl
72c11a1b44
Update matrix-sum-diagonals.py 2023-07-30 15:56:00 -07:00
bt3gl
f374afd0c7
Update is_isomorphic.py 2023-07-30 15:55:48 -07:00
bt3gl
7a44401e4c
Update intersection_two_arrays.py 2023-07-30 15:55:34 -07:00
bt3gl
1d556cfd04
Update hash_set_linked_list.py 2023-07-30 15:55:26 -07:00
bt3gl
0013f69950
Update hash_set_bst.py 2023-07-30 15:55:05 -07:00
bt3gl
cd9326891f
Update hash_map_array.py 2023-07-30 15:54:57 -07:00
bt3gl
e6f990cab6
Update check_permutation_strings_is_palindrome.py 2023-07-30 15:54:47 -07:00
bt3gl
158eb74e76
Update array-remove-duplicate-inplace.py 2023-07-30 15:54:41 -07:00
bt3gl
3b218fae01
Update array-move-zeros-inplace.py 2023-07-30 15:54:34 -07:00
bt3gl
e96bf43463
Update array-merge-inplace.py 2023-07-30 15:54:27 -07:00
bt3gl
153b111e09
Update array-duplicate-zeros.py 2023-07-30 15:54:21 -07:00
bt3gl
896aaaf88f
Update array-check_mountain.py 2023-07-30 15:54:14 -07:00
bt3gl
0672ae9a3a
Update array-check-if-exist.py 2023-07-30 15:54:07 -07:00
bt3gl
79f1970f2e
Update array-3rd-distinct-0n.py 2023-07-30 15:54:00 -07:00
bt3gl
f519830497
Update tree_serialization.py 2023-07-30 15:53:25 -07:00
bt3gl
efd9f72f84
Update tree_level_traversal.py 2023-07-30 15:53:18 -07:00
bt3gl
24b38f0d5b
Update sum_2_numbers_with_bs.py 2023-07-30 15:53:08 -07:00
bt3gl
092700f566
Update preorder_transversal.py 2023-07-30 15:52:59 -07:00
bt3gl
35b14ddfde
Update lowest_common_ancestor.py 2023-07-30 15:52:52 -07:00
bt3gl
d5089d5b0e
Update is_tree_symmetric.py 2023-07-30 15:52:35 -07:00
bt3gl
93c8e2abf7
Update has_path_sum.py 2023-07-30 15:52:27 -07:00
bt3gl
f6477288e1
Update find_max_depth_tree.py 2023-07-30 15:52:19 -07:00
bt3gl
6ed9a5376b
Update dijkstra_adj_matrix.py 2023-07-30 15:52:12 -07:00
bt3gl
cd4d8dea44
Update count_unival.py 2023-07-30 15:52:05 -07:00
bt3gl
e7d855b99e
Update construct_tree_inorder_preorder.py 2023-07-30 15:51:57 -07:00
bt3gl
38cbe1c55b
Update construct_tree_inorder_postorder.py 2023-07-30 15:51:43 -07:00
bt3gl
0526bb7aee
Rename Trees.py to SimpleTree.py 2023-07-30 15:50:34 -07:00
bt3gl
23881f329f
Create intersection_two_arrays.py 2023-07-30 15:38:07 -07:00
bt3gl
f2418e56c1
Create is_isomorphic.py 2023-07-30 14:13:02 -07:00
bt3gl
bc0d591be1
Create two_sums.py 2023-07-30 13:56:04 -07:00
bt3gl
48ce09742e
Create happy_number.py 2023-07-30 13:04:04 -07:00
bt3gl
8d6fac8dc9
Create check_permutation_strings_is_palindrome.py 2023-07-30 12:39:53 -07:00
bt3gl
e428fb1d50
Create str-longest-non-repeating.py 2023-07-30 12:39:24 -07:00
bt3gl
3bbe283cd7
Update climbing_stairs.py 2023-07-30 12:38:49 -07:00
bt3gl
50e749dcc2
Delete str-longest-non-repeating.py 2023-07-30 12:35:42 -07:00
bt3gl
16359103a9
Delete check_permutation_strings_is_palindrome.py 2023-07-30 12:34:49 -07:00
bt3gl
0ed8794fda
Update array-3rd-distinct-0n.py 2023-07-30 12:34:01 -07:00
bt3gl
6dc689f3a0
Update hash_map_array.py 2023-07-30 12:26:33 -07:00
bt3gl
606784af38
Create hash_map_array.py 2023-07-30 12:23:34 -07:00
bt3gl
1f174755c9
Update README.md 2023-07-30 12:22:54 -07:00
bt3gl
7f7d1bdf24
Create hash_set_bst.py 2023-07-30 11:57:17 -07:00
bt3gl
918a38bc9e
Create hash_set_linked_list.py 2023-07-30 11:47:08 -07:00
Marina
df0c4465f2
Update README.md 2023-07-30 11:04:32 -07:00
Marina
185bbbc341
Update README.md 2023-07-30 11:04:07 -07:00
Marina
ef2a1cf18c
Update README.md 2023-07-30 10:18:00 -07:00
bt3gl
47085d5d94
Update README.md 2023-07-29 21:24:56 -07:00
bt3gl
483e7c1805
Update README.md 2023-07-29 21:20:39 -07:00
bt3gl
abc3e2abf8
Update README.md 2023-07-29 21:08:20 -07:00
bt3gl
90ef21f8be
Update README.md 2023-07-29 21:03:50 -07:00
bt3gl
24df4c93d7
Update README.md 2023-07-29 21:00:47 -07:00
bt3gl
f0c936fe6c
Update README.md 2023-07-29 20:59:35 -07:00
bt3gl
16f0dff34e
Update README.md 2023-07-29 20:49:45 -07:00
bt3gl
93b3587bca
Update README.md 2023-07-29 20:48:55 -07:00
bt3gl
2d481f78b0
play with dijkstra 2023-07-29 20:43:32 -07:00
bt3gl
690d8bd706
Update README.md 2023-07-29 20:38:33 -07:00
bt3gl
937183da0c
Update README.md 2023-07-29 20:34:26 -07:00
bt3gl
8a30000724
Add files via upload 2023-07-29 20:30:18 -07:00
bt3gl
132a5700c4
Update README.md 2023-07-29 20:30:08 -07:00
bt3gl
621f32f4aa
Update README.md 2023-07-29 20:28:00 -07:00
bt3gl
006074a1c7
Add files via upload 2023-07-29 20:25:23 -07:00
bt3gl
cf5bcd8020
Add files via upload 2023-07-29 20:24:59 -07:00
bt3gl
06722c4871
playing with linked lists 2023-07-29 20:23:51 -07:00
bt3gl
465e840600
Update README.md 2023-07-29 20:22:59 -07:00
bt3gl
c1949996e4
play with dijkstra 2023-07-29 20:19:22 -07:00
bt3gl
4b22537ee7
play with bits 2023-07-29 20:18:30 -07:00
bt3gl
c77eb0dd00
Update README.md 2023-07-29 20:17:31 -07:00
bt3gl
f0f0be2375
Update README.md 2023-07-29 18:19:08 -07:00
bt3gl
dcaef97146
Update README.md 2023-07-29 18:14:15 -07:00
bt3gl
bd0a4c9ee3
Create tree_serialization.py 2023-07-29 18:11:41 -07:00
bt3gl
f32e58cc68
Update README.md 2023-07-29 18:01:16 -07:00
bt3gl
84d1bf598d
Update README.md 2023-07-29 17:52:50 -07:00
bt3gl
9e938fa336
Update tree_level_traversal.py 2023-07-29 17:45:56 -07:00
bt3gl
c64f3318f8
Update lowest_common_ancestor.py 2023-07-29 17:45:13 -07:00
bt3gl
da0f3fd5d8
Create lowest_common_ancestor.py 2023-07-29 17:41:24 -07:00
bt3gl
bfeb0bf97c
Create construct_tree_inorder_preorder.py 2023-07-29 16:13:26 -07:00
bt3gl
cf4a797646
Rename construct_tree.py to construct_tree_inorder_postorder.py 2023-07-29 15:49:48 -07:00
bt3gl
135c6bd58a
Create construct_tree.py 2023-07-29 15:49:16 -07:00
bt3gl
5ec8587911
Update README.md 2023-07-29 15:37:01 -07:00
bt3gl
ea039f5514
Create count_unival.py 2023-07-29 15:03:42 -07:00
bt3gl
bb72bab679
add some fun tree playing 2023-07-29 14:28:17 -07:00
bt3gl
48720ada4d
Update README.md 2023-07-29 14:28:02 -07:00
Marina S
1caaed58a1
dp 2023-07-29 11:13:47 -07:00
Marina S
bfcfec83b6
math, logic, dynamic programming 2023-07-29 11:13:29 -07:00
Marina S
ad4b836800
Rename README.md to README.md 2023-07-29 11:13:04 -07:00
Marina S
cdae9ca4f7
Rename playing_with_math.py to playing_with_math.py 2023-07-29 11:12:51 -07:00
Marina S
8a8884839d
Rename fibonacci.py to fibonacci.py 2023-07-29 11:12:39 -07:00
Marina S
2654ba1a75
add some dynamic programming 2023-07-29 11:12:10 -07:00
Marina S
5a07abce93
add some dynamic programming 2023-07-29 11:11:45 -07:00
Marina S
769129ecae
playing with strs 2023-07-29 11:10:59 -07:00
Marina S
5c55b81641
add some array playing 2023-07-29 11:08:44 -07:00
Dr. Marina Souza, PhD
5732cfcc61
Fun day, but i miss rust already 😅 (#36) 2023-07-16 18:30:04 -07:00
Dr. Marina Souza, PhD
0f455a0322
Add some cool queue, stacks, strings, math, bit manipulation examples (#35) 2023-07-16 17:35:14 -07:00
Dr. Marina Souza, PhD
f3ee2cdf52
Add trees, binary trees, bst, transversals (#34) 2023-07-16 15:21:40 -07:00
dependabot[bot]
5af08f7498
Bump sqlalchemy from 0.9.7 to 1.3.0 in /book/ebook_src (#33)
Bumps [sqlalchemy](https://github.com/sqlalchemy/sqlalchemy) from 0.9.7 to 1.3.0.
- [Release notes](https://github.com/sqlalchemy/sqlalchemy/releases)
- [Changelog](https://github.com/sqlalchemy/sqlalchemy/blob/main/CHANGES.rst)
- [Commits](https://github.com/sqlalchemy/sqlalchemy/commits)

---
updated-dependencies:
- dependency-name: sqlalchemy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-15 22:07:15 -07:00
steinkirch.eth, phd
ea7a3fdfbb start refactor 2023-07-15 21:57:39 -07:00
dependabot[bot]
8a9868fe7d
Bump flask from 1.0 to 2.2.5 in /book (#30)
Bumps [flask](https://github.com/pallets/flask) from 1.0 to 2.2.5.
- [Release notes](https://github.com/pallets/flask/releases)
- [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/flask/compare/1.0...2.2.5)

---
updated-dependencies:
- dependency-name: flask
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-11 14:10:20 -07:00
dependabot[bot]
8e4f1f5f4f
Bump scipy from 0.12.1 to 1.10.0 (#31)
Bumps [scipy](https://github.com/scipy/scipy) from 0.12.1 to 1.10.0.
- [Release notes](https://github.com/scipy/scipy/releases)
- [Commits](https://github.com/scipy/scipy/compare/v0.12.1...v1.10.0)

---
updated-dependencies:
- dependency-name: scipy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-11 14:10:14 -07:00
dependabot[bot]
ef55c8c8fd
Bump scipy from 0.12.1 to 1.10.0 in /book (#32)
Bumps [scipy](https://github.com/scipy/scipy) from 0.12.1 to 1.10.0.
- [Release notes](https://github.com/scipy/scipy/releases)
- [Commits](https://github.com/scipy/scipy/compare/v0.12.1...v1.10.0)

---
updated-dependencies:
- dependency-name: scipy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-11 14:10:05 -07:00
steinkirch.eth, phd
6c7eae7715
🐚 2023-04-25 08:51:13 -07:00
steinkirch.eth, phd
7403b5f900
4.6/5 stars and 33 reviews for a book written in school, not bad 2023-04-16 14:36:17 -07:00
dependabot[bot]
7c0583efbd
Bump ipython from 0.13.2 to 8.10.0 (#28) 2023-02-21 14:26:05 -08:00
dependabot[bot]
013c5cfb3a
Bump ipython from 7.16.3 to 8.10.0 in /book (#29) 2023-02-21 14:25:55 -08:00
dr. mia von steinkirch, phd
35816e90f0
when this repo used to have 600+ stars 2023-02-14 11:36:44 -08:00
dr. mia von steinkirch, phd
0a13fcc208
when this repo used to have 600+ stars 2023-02-14 11:35:31 -08:00
dr. mia von steinkirch, phd
405421ec19
being ref for a cmu computer science course 2023-02-11 12:13:58 -08:00
dependabot[bot]
c299610a4c
Bump ipython from 0.13.2 to 7.16.3 in /book (#24)
Bumps [ipython](https://github.com/ipython/ipython) from 0.13.2 to 7.16.3.
- [Release notes](https://github.com/ipython/ipython/releases)
- [Commits](https://github.com/ipython/ipython/compare/rel-0.13.2...7.16.3)

---
updated-dependencies:
- dependency-name: ipython
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-07 06:12:01 -08:00
dr. mia von steinkirch, phd
223ef93067
Update README.md 2023-01-20 09:26:16 -08:00
dr. mia von steinkirch, phd
90e734fe30
Update README.md 2023-01-20 09:25:59 -08:00
mia von steinkirch, phd
3844a4352f
👾 here is a proof that this repo used to have 600 stars and 300+ forks before shit happened 2022-11-13 14:24:38 -08:00
Dr. Mia von Steinkirch
d116ed2935
🏴‍☠️ fix typo 2022-10-20 10:50:57 -07:00
dependabot[bot]
89c43077b7
Bump numpy from 1.8.2 to 1.22.0 (#26)
Bumps [numpy](https://github.com/numpy/numpy) from 1.8.2 to 1.22.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst)
- [Commits](https://github.com/numpy/numpy/compare/v1.8.2...v1.22.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-13 14:26:19 -07:00
dependabot[bot]
59dfa3d95b
Bump numpy from 1.8.2 to 1.22.0 in /book (#27)
Bumps [numpy](https://github.com/numpy/numpy) from 1.8.2 to 1.22.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst)
- [Commits](https://github.com/numpy/numpy/compare/v1.8.2...v1.22.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-13 14:26:11 -07:00
bt3gl
eb4a362049
Update README.md 2022-06-16 08:27:57 -07:00
bt3gl
a28975720d
Delete .gitignore 2022-06-16 08:21:25 -07:00
bt3gl
c5311d2f42
Delete FUNDING.yml 2022-06-16 08:21:11 -07:00
bt3gl
ed16bb8ed4
Update README.md 2022-03-06 06:32:18 -08:00
bt3gl
234b4b1fc8
Update README.md 2021-03-27 21:43:22 -07:00
Mia von Steinkirch
600dcc25c7
🏡 Add names. 2020-11-10 08:55:01 -08:00
bt3gl
a82a93987b
🏣 Clean up for arxiv 2020-05-19 10:40:09 -07:00
Mia von Steinkirch
96b0c06106
🐮 Updating funding 2020-03-22 10:23:18 -07:00
Mia von Steinkirch
dfa9c32576 🏣 Clean up for arxiv 2020-03-04 17:48:52 -08:00
Mia von Steinkirch
41756cb10c 🏣 Clean up for arxiv 2020-03-04 17:47:53 -08:00
Mia von Steinkirch, PhD, MSc
1b969e7db3
️Fix broken link 2020-02-10 15:54:25 -08:00
Mia von Steinkirch, PhD, MSc
978a053fdb
🪐 Fix broken link 2020-02-10 15:53:15 -08:00
Mia von Steinkirch, PhD, MSc
f30b2c45ca
🧠Fix link 2020-02-10 15:50:40 -08:00
Mia von Steinkirch, PhD, MSc
4263555391
👾Fix some typos 2020-02-10 12:16:01 -08:00
Mia von Steinkirch, PhD, MSc
95864fe473
🪁Update readme 2020-02-09 15:51:38 -08:00
Mia von Steinkirch, PhD, MSc
87447ad43d ️Buy me a coffee 2020-02-09 12:33:50 -08:00
Mia von Steinkirch
bb3ad8dcdc fix readme 2020-02-08 17:21:47 -08:00
Mia von Steinkirch
003f5953ed remove old dirs 2020-02-08 17:20:52 -08:00
Mia von Steinkirch
5fafebba15 add boilerplate for second edition 2020-02-08 17:20:00 -08:00
Mia von Steinkirch
dc3ebf3173 add boilerplate for second edition 2020-02-08 17:18:16 -08:00
bt3gl
5fd154f3fd
🌲The Zen of Python 2019-11-26 22:18:50 -08:00
MvS
70b22c1738 🔮 Clean up and arxiv my python book, no plans for future updates 2019-11-14 18:40:48 -08:00
Mia Steinkirch
cc27c43b91 🎡 Remove flask 2019-10-27 20:34:18 -07:00
Mia Steinkirch
70b28d5622 🛣 Add readme 2019-10-27 20:32:58 -07:00
Mia Steinkirch
87fefbae69 🏭 Add link for second edition, 2019 2019-10-27 20:31:41 -07:00
Mia Steinkirch
baac84ae3f 🕍 Clean up gitignore 2019-10-27 20:29:50 -07:00
Mia Steinkirch
5581a47a1a 🚀 remove extra dir 2019-10-27 20:28:49 -07:00
Mia Steinkirch
1963988230 🎃 Remove workflows since it is pointless in this repo 2019-10-27 20:28:22 -07:00
Mia Steinkirch
e303e3c507 🏝 Clean up readme 2019-10-27 20:27:18 -07:00
Mia Steinkirch
0c765993ce Merge branch 'master' of github.com:bt3gl/Book-Python_and_Algorithms 2019-10-27 20:26:46 -07:00
Mia Steinkirch
bf7d1053df 🍕 Clean up and move dirs 2019-10-27 20:26:35 -07:00
Mia von Steinkirch
c22225ec08
Update README.md 2019-10-27 13:59:02 -07:00
Mia von Steinkirch
28f35a0c2b
Update pythonapp.yml 2019-10-20 23:21:19 -07:00
Mia von Steinkirch
878cac0daf
Merge pull request #16 from bt3gl/dependabot/pip/flask-1.0
Bump flask from 0.10.1 to 1.0
2019-10-20 22:56:11 -07:00
Mia von Steinkirch
afcc80bcac
Merge pull request #17 from bt3gl/dependabot/pip/scapy-2.4.1
Bump scapy from 2.2.0 to 2.4.1
2019-10-20 22:55:44 -07:00
dependabot[bot]
eebc81ed07
Bump scapy from 2.2.0 to 2.4.1
Bumps [scapy](https://github.com/secdev/scapy) from 2.2.0 to 2.4.1.
- [Release notes](https://github.com/secdev/scapy/releases)
- [Commits](https://github.com/secdev/scapy/compare/v2.2.0...v2.4.1)

Signed-off-by: dependabot[bot] <support@github.com>
2019-10-12 23:10:41 +00:00
dependabot[bot]
b4416bc8f0
Bump flask from 0.10.1 to 1.0
Bumps [flask](https://github.com/pallets/flask) from 0.10.1 to 1.0.
- [Release notes](https://github.com/pallets/flask/releases)
- [Changelog](https://github.com/pallets/flask/blob/master/CHANGES.rst)
- [Commits](https://github.com/pallets/flask/compare/0.10.1...1.0)

Signed-off-by: dependabot[bot] <support@github.com>
2019-10-12 23:10:34 +00:00
Mia Steinkirch
3c5ee16ff0 clean up 2019-10-12 16:09:21 -07:00
Mia Steinkirch
397584b1de clean up 2019-10-12 16:08:51 -07:00
Mia Steinkirch
e0eb554dfd clean up 2019-10-12 16:07:57 -07:00
Mia von Steinkirch
67419cf9de
Update README.md 2019-10-12 15:44:45 -07:00
Mia von Steinkirch
09633fd797
Create FUNDING.yml 2019-10-11 16:01:53 -07:00
Mia Steinkirch
1ef64d6e17 rv image
Signed-off-by: Mia Steinkirch <mia.steinkirch@gmail.com>
2019-10-11 04:41:45 -07:00
Mia Steinkirch
af25278fb3 typos 2019-10-11 04:40:21 -07:00
Mia Steinkirch
6ac18187a3 typos 2019-10-11 04:37:40 -07:00
Mia Steinkirch
2e96a35a0d reorganize 2019-10-11 04:32:52 -07:00
Mia Steinkirch
2fdaad121c organize
Signed-off-by: Mia Steinkirch <mia.steinkirch@gmail.com>
2019-10-11 04:32:02 -07:00
Mia Steinkirch
a8e71c50db reorganize dir
Signed-off-by: Mia Steinkirch <mia.steinkirch@gmail.com>
2019-10-11 04:29:17 -07:00
Mia
1b6f705e7c
typo 2019-09-29 18:05:16 -07:00
Dr. Marina Steinkirch
fc419aadcc
Update README.md 2019-09-10 17:37:17 -07:00
Dr. Marina Steinkirch
8acbecd2b0
Update README.md 2019-09-10 17:36:58 -07:00
Mia Steinkirch
9d671e5685
typo 2019-09-02 13:36:00 -10:00
Mia Steinkirch
286316a29f
Grammar check 2019-06-11 22:33:23 -07:00
Mia von Steinkirch
8e9cbfd87f more 2019-05-13 16:08:11 -07:00
Mia von Steinkirch
a5b67b61c0 more ex 2019-05-13 15:22:37 -07:00
Mia von Steinkirch
1b336bf09a so easy 2019-05-13 14:42:48 -07:00
Mia von Steinkirch
d99d1d27dc easy as a piece of cake 2019-05-13 14:15:20 -07:00
Mia von Steinkirch
85ecba5ace more ex 2019-05-13 13:50:21 -07:00
Mia von Steinkirch
bb6afce467 add some exe 2019-05-13 13:16:03 -07:00
Mia von Steinkirch
47e5ee3918 some ex 2019-05-13 12:26:14 -07:00
Mia von Steinkirch
9b4c8df7f7 add some exs 2019-05-12 21:23:24 -07:00
Mia von Steinkirch
0d5e21b867 bitwise 2019-05-12 18:00:11 -07:00
Mia von Steinkirch
fa83f7e42a add some int-cake problems 2019-05-09 20:18:06 -07:00
Mia von Steinkirch
e04656170b cleanup 2019-05-08 12:06:02 -07:00
Mia von Steinkirch
fb81535ffb cleanup 2019-05-08 12:04:12 -07:00
Mia von Steinkirch
1d476139a8 cleanup 2019-05-08 11:51:45 -07:00
the byt3girl
4d9c04e61d
Update README.md 2019-03-16 12:39:08 -10:00
bt3
ac67b30284 Add a useful way to understand python decorator 2018-06-24 13:22:15 -07:00
Mia Steinkirch
3cc8c1d5c0
add some notes on "Python solutions for every exercises from "Cracking the Code Interview" 2018-06-20 18:11:28 -07:00
Mia Steinkirch
1b5c89e75f
add license 2018-06-17 21:04:34 -07:00
Mia Steinkirch
47321c03fc
Add files via upload 2018-06-14 17:23:02 -07:00
Mia Steinkirch
ad67d2045f
Update README.md 2018-06-14 17:22:42 -07:00
Mia Steinkirch
6680aa6414
Update README.md 2018-06-14 15:51:07 -07:00
Marina von Steinkirch
2f4a9638c0 Change the dir structure slightly 2018-06-14 15:50:29 -07:00
Mia Steinkirch
6b6fe21db3
Update README.md 2018-06-14 15:48:12 -07:00
Mia Steinkirch
7097288107
Update README.md 2018-06-14 15:47:51 -07:00
Mia Steinkirch
0b79a1a1c6
Update README.md 2018-06-14 15:47:16 -07:00
Mia Steinkirch
277b556961
Update README.md 2018-06-14 15:46:01 -07:00
Mia Steinkirch
8e0dbb67df
Update README.md 2018-05-14 04:12:02 -10:00
Dr. bt3 cool af
47fed55509 Update README.md 2017-04-26 00:19:10 -07:00
Dr. bt3 cool af
aef15cfe84 Update README.md 2017-04-26 00:18:36 -07:00
bt3
d2c082d261 Update README.md 2016-03-13 21:34:12 -07:00
bt3
8aca11b171 warmup, preparing to give interviews 2015-10-25 20:15:48 -07:00
bt3
b240b35433 Delete balance_parenthesis.py 2015-10-25 20:15:33 -07:00
bt3
b7f8e031c3 warmup, preparing to give interviews 2015-10-25 19:51:07 -07:00
bt3
8b4aa469a7 warmup, preparing to give interviews 2015-10-25 17:13:11 -07:00
bt3
792434e3af warmup, preparing to give interviews 2015-10-25 17:12:45 -07:00
bt3
20c3036b4d Delete combinations.py 2015-10-25 16:44:56 -07:00
bt3
9c4f52e7bc Delete find_longest_common_prefix.py 2015-10-25 16:44:19 -07:00
bt3
9b8453e57e Update README.md 2015-10-19 13:50:33 -07:00
Mari Wahl
faa442ccb5 last fixes: tree common ancestor 2015-01-10 19:20:16 -05:00
Mari Wahl
cc8f1099d6 another possibility for binary trees with traversals for generators 2015-01-10 16:29:05 -05:00
Mari Wahl
c3cb3f1c1b ... 2015-01-10 01:09:23 -05:00
Mari Wahl
bc442a0727 more typos! 😓 2015-01-09 15:33:43 -05:00
Mari Wahl
56ad845ccc fix the image 💚 2015-01-09 13:41:26 -05:00
Mari Wahl
792a269597 typo fixed in the comb.py 👽 2015-01-09 13:37:18 -05:00
Mari Wahl
62601a8556 Release 3.0.1 🌟 2015-01-08 20:34:11 -05:00
Mari Wahl
4aac7e9d9b Release 3.0.1 :start2: 2015-01-08 20:33:07 -05:00
Mari Wahl
f59008eeb4 book: bits -> bit 2015-01-08 14:37:27 -05:00
Mari Wahl
137ffd8264 final revision of the book, ready to ship 2015-01-08 00:09:06 -05:00
Mari Wahl
813d29653f edited trees in the book 2015-01-07 23:46:05 -05:00
Mari Wahl
6f5dfa743d search and sorting edits in the book 2015-01-07 22:56:55 -05:00
Mari Wahl
0dd174bf3a abstracted structure edited in the book 2015-01-07 20:50:26 -05:00
Mari Wahl
864418ef79 good practices edited in the book 2015-01-07 19:59:22 -05:00
Mari Wahl
9c2c9b557c oop edited in the book 2015-01-07 19:17:20 -05:00
Mari Wahl
44b93d8117 modules chapter done 2015-01-07 18:22:28 -05:00
Mari Wahl
fc7949d7e9 new version book with the first 2 chapters edited, examples added 2015-01-07 17:00:49 -05:00
Mari Wahl
5161f9d08a rename files to easily grouping 2015-01-07 14:07:47 -05:00
Mari Wahl
52752fb931 trees organized 2015-01-07 13:43:37 -05:00
Mari Wahl
28b84cef65 searching and sorting organized 2015-01-07 12:40:24 -05:00
Mari Wahl
91825867f6 bitwise scripts fixed 2015-01-06 21:55:53 -05:00
Mari Wahl
01703751f1 abstracted structures fixed 2015-01-06 21:11:21 -05:00
Mari Wahl
3fdbc2a605 cleaning up and organizing old problems (builtin) 2015-01-06 20:10:48 -05:00
Mari Wahl
6afe96fa4d organization in the src structure, modification of README 2015-01-06 18:30:04 -05:00
Mari Wahl
c2ca11f247 all interview problems organized, and cleaned up repeats 2015-01-06 18:19:00 -05:00
Mari Wahl
a4637a3411 interview problems: trees 2015-01-06 18:05:11 -05:00
Mari Wahl
e31b9e4d5f 2014 interview problems organized 2015-01-06 14:14:25 -05:00
Mari Wahl
d29e0d82ad organizing 2014 interview problems 2015-01-06 02:30:59 -05:00
Mari Wahl
4b1fe33f96 glassdoor 2014 2015-01-06 00:49:32 -05:00
Mari Wahl
ee01cd9446 simple examples, glassdoor 2015-01-05 22:16:56 -05:00
Mari Wahl
87a257c09c readme 2015-01-04 00:28:44 -05:00
Mari Wahl
56d224a80c readme 2015-01-04 00:27:03 -05:00
Mari Wahl
1f6a54c87a book pdf 2015-01-04 00:24:38 -05:00
Mari Wahl
35e2780fea simple examples 2015-01-03 23:23:35 -05:00
Mari Wahl
52fdba36de some simple examples 2015-01-03 19:33:07 -05:00
Mari Wahl
2e3116f207 readme 2015-01-03 10:01:39 -05:00
Mari Wahl
ff9d598a9c requirements.txt update 2015-01-03 09:59:05 -05:00
Mari Wahl
373adef285 readme for requirements 2015-01-03 09:57:14 -05:00
Mari Wahl
ac4d1152c6 some simple example 2015-01-01 13:06:36 -05:00
Mari Wahl
c3d315eb4f some simple examples: threading and logging 2014-12-31 10:34:43 -05:00
Mari Wahl
045e2cc061 some simple interview problems 2014-12-30 14:21:58 -05:00
Mari Wahl
3536f80ca0 travis 2014-12-28 16:26:01 -05:00
Mari Wahl
e1c6e92a2a requirements 2014-12-28 16:23:09 -05:00
Mari Wahl
b698d79bb5 readme 2014-12-23 19:39:13 -05:00
Mari Wahl
09357abe64 readme 2014-12-23 19:38:11 -05:00
Mari Wahl
d410174ef5 some typos fixed, thanks to yoonas kassa to point them out 2014-12-15 04:54:28 -05:00
bt3gl
da6dca2805 license 2014-12-02 13:39:00 -05:00
bt3gl
84e8d42871 doctest simple example 2014-11-26 13:34:23 -05:00
Mari Wahl
ac0c509a73 useful scripts word frequency 2014-11-24 08:55:19 -05:00
Mari Wahl
fda02ef3c8 interview problems 2014-10-27 20:30:47 -04:00
Mari Wahl
0f559fa0d7 some interview problems 2014-10-27 10:12:15 -04:00
Mari Wahl
899a11e9ad some small fixes 2014-09-17 14:53:51 -04:00
486 changed files with 30151 additions and 3810 deletions

39
.gitignore vendored
View file

@ -1,39 +0,0 @@
*.py[cod]
*~
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
nosetests.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# PyCharm
.idea

BIN
MY_BOOK/600_stars.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 KiB

View file

@ -0,0 +1,41 @@
#!/usr/bin/env python
__author__ = "bt3"
class HashTable(object):
def __init__(self, slots=10):
self.slots = slots
self.table = []
self.create_table()
def hash_key(self, value):
return hash(value)%self.slots
def create_table(self):
for i in range(self.slots):
self.table.append([])
def add_item(self, value):
key = self.hash_key(value)
self.table[key].append(value)
def print_table(self):
for key in range(len(self.table)):
print "Key is %s, value is %s." %(key, self.table[key])
def find_item(self, item):
pos = self.hash_key(item)
if item in self.table[pos]:
return True
else:
return False
if __name__ == '__main__':
dic = HashTable(5)
for i in range(1, 40, 2):
dic.add_item(i)
dic.print_table()
assert(dic.find_item(20) == False)
assert(dic.find_item(21) == True)

View file

@ -0,0 +1,47 @@
#!/usr/bin/env python
# Time: 5 min
__author__ = "bt3"
class Queue(object):
def __init__(self):
self.enq = []
self.deq = []
def enqueue(self, item):
return self.enq.append(item)
def deque(self):
if not self.deq:
while self.enq:
self.deq.append(self.enq.pop())
return self.deq.pop()
def peak(self):
if not self.deq:
while self.enq:
self.deq.append(self.enq.pop())
if self.deq:
return self.deq[-1]
def size(self):
return len(self.enq) + len(self.deq)
def isempty(self):
return not (self.enq + self.deq)
if __name__ == '__main__':
q = Queue()
for i in range(1,11):
q.enqueue(i)
print 'Size:', q.size()
print 'Is empty?', q.isempty()
print 'Peak: ', q.peak()
print
print 'Dequeuing...'
for i in range(10):
print q.deque()
print 'Size:', q.size()
print 'Is empty?', q.isempty()
print 'Peak: ', q.peak()

View file

@ -0,0 +1,63 @@
#!/usr/bin/env python
__author__ = "bt3"
class Stack(object):
def __init__(self):
self.content = []
self.min_array = []
self.min = float('inf')
def push(self, value):
if value < self.min:
self.min = value
self.content.append(value)
self.min_array.append(self.min)
def pop(self):
if self.content:
value = self.content.pop()
self.min_array.pop()
if self.min_array:
self.min = self.min_array[-1]
return value
else:
return 'Empty List. '
def find_min(self):
if self.min_array:
return self.min_array[-1]
else:
return 'No min value for empty list.'
def size(self):
return len(self.content)
def isEmpty(self):
return not bool(self.content)
def peek(self):
if self.content:
return self.content[-1]
else:
print('Stack is empty.')
def __repr__(self):
return '{}'.format(self.content)
if __name__ == '__main__':
q = Stack()
for i in range(15,20):
q.push(i)
for i in range(10,5,-1):
q.push(i)
for i in range(1, 13):
print q.pop(), q.find_min()

View file

@ -1,13 +1,13 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
import heapq
def find_N_largest_items_seq(seq, N):
''' find the N largest items in a sequence '''
return heapq.nlargest(N,seq)
def find_N_smallest_items_seq(seq, N):
''' find the N smallest items in a sequence '''
return heapq.nsmallest(N, seq)
@ -18,7 +18,7 @@ def find_smallest_items_seq_heap(seq):
''' pops the smallest item, O(logN) '''
heapq.heapify(seq)
return heapq.heappop(seq)
def find_smallest_items_seq(seq):
''' if it is only one item, min() is faster '''
return min(seq)
@ -26,7 +26,7 @@ def find_smallest_items_seq(seq):
def find_N_smallest_items_seq_sorted(seq, N):
''' N ~ len(seq), better sort instead'''
return sorted(seq)[:N]
def find_N_largest_items_seq_sorted(seq, N):
''' N ~ len(seq), better sort instead'''
return sorted(seq)[len(seq)-N:]
@ -41,7 +41,7 @@ def test_find_N_largest_smallest_items_seq(module_name='this module'):
assert(find_N_smallest_items_seq_sorted(seq, N) == [1,2,3])
assert(find_smallest_items_seq(seq) == 1)
assert(find_smallest_items_seq_heap(seq) == 1)
s = 'Tests in {name} have {con}!'
print(s.format(name=module_name, con='passed'))

View file

@ -1,13 +1,13 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
class Heapify(object):
def __init__(self, data=None):
self.data = data or []
for i in range(len(data)//2, -1, -1):
self.__max_heapify__(i)
def __repr__(self):
return '{}'.format(self.data)
@ -19,12 +19,12 @@ class Heapify(object):
def right_child(self, i):
return (i << 1) + 2 # +2 instead of +1 because it's 0-indexed.
def __max_heapify__(self, i):
largest = i
left = self.left_child(i)
right = self.right_child(i)
n = len(self.data)
n = len(self.data)
largest = (left < n and self.data[left] > self.data[i]) and left or i
largest = (right < n and self.data[right] > self.data[largest]) and right or largest
if i is not largest:
@ -44,7 +44,6 @@ def test_Heapify():
l1 = [3, 2, 5, 1, 7, 8, 2]
h = Heapify(l1)
assert(h.extract_max() == 8)
print ("Tests Passed!")
if __name__ == '__main__':
test_Heapify()

View file

@ -1,6 +1,6 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
import heapq
@ -19,9 +19,7 @@ def test_merge_sorted_seq(module_name='this module'):
seq2 = [2, 3, 4, 5, 6, 7, 9]
seq3 = seq1 + seq2
assert(merge_sorted_seqseq1, seq2) == sorted(seq3))
s = 'Tests in {name} have {con}!'
print(s.format(name=module_name, con='passed'))
if __name__ == '__main__':

View file

@ -1,6 +1,6 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
import heapq
@ -9,11 +9,11 @@ class PriorityQueue(object):
def __init__(self):
self._queue = []
self._index = 0 # comparying same priority level
def push(self, item, priority):
heapq.heappush(self._queue, (-priority, self._index, item))
heapq.heappush(self._queue, (-priority, self._index, item))
self._index += 1
def pop(self):
return heapq.heappop(self._queue)[-1]
@ -32,7 +32,6 @@ def test_PriorityQueue():
q.push(Item('test2'), 4)
q.push(Item('test3'), 3)
assert(str(q.pop()) == "Item('test2')")
print('Tests passed!'.center(20,'*'))
if __name__ == '__main__':

View file

@ -1,8 +1,6 @@
#!/usr/bin/python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
#!/usr/bin/env python
__author__ = "bt3"
''' implement a function to see whether a linked list is circular.

View file

@ -1,7 +1,6 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
__author__ = "bt3"
''' Implement a double-linked list, which is very simple, we just need inherits
from a Linked List Class and add an attribute for previous.'''
@ -18,7 +17,6 @@ class dNode(object):
class dLinkList(LinkedListFIFO):
# print each node's value, starting from tail
def printListInverse(self):
node = self.tail
while node:
@ -28,8 +26,6 @@ class dLinkList(LinkedListFIFO):
except:
break
# add a node in a position different from head,
# ie, in the end of the list
def _add(self, value):
self.length += 1
node = dNode(value)
@ -38,14 +34,12 @@ class dLinkList(LinkedListFIFO):
node.previous = self.tail
self.tail = node
# delete a node in some position
def _delete(self, node):
self.length -= 1
node.previous.pointer = node.pointer
if not node.pointer:
self.tail = node.previous
# locate node with some index
def _find(self, index):
node = self.head
i = 0
@ -66,11 +60,6 @@ class dLinkList(LinkedListFIFO):
print('Node with index {} not found'.format(index))
if __name__ == '__main__':
from collections import Counter

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "bt3"
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
''' Find the mth-to-last element of a linked list.
One option is having two pointers, separated by m. P1 start at the roots

View file

@ -1,15 +1,12 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
__author__ = "bt3"
''' A class for a linked list that has the nodes in a FIFO order (such as a queue)'''
from node import Node
class LinkedListFIFO(object):
def __init__(self):
@ -17,32 +14,24 @@ class LinkedListFIFO(object):
self.length = 0
self.tail = None # this is different from ll lifo
# print each node's value, starting from the head
def _printList(self):
node = self.head
while node:
print(node.value)
node = node.pointer
# add a node in the first position
# read will never be changed again while not empty
def _addFirst(self, value):
self.length = 1
node = Node(value)
self.head = node
self.tail = node
# delete a node in the first position, ie
# when there is no previous node
def _deleteFirst(self):
self.length = 0
self.head = None
self.tail = None
print('The list is empty.')
# add a node in a position different from head,
# ie, in the end of the list
def _add(self, value):
self.length += 1
node = Node(value)
@ -50,15 +39,12 @@ class LinkedListFIFO(object):
self.tail.pointer = node
self.tail = node
# add nodes in general
def addNode(self, value):
if not self.head:
self._addFirst(value)
else:
self._add(value)
# locate node with some index
def _find(self, index):
prev = None
node = self.head
@ -69,7 +55,6 @@ class LinkedListFIFO(object):
i += 1
return node, prev, i
# delete nodes in general
def deleteNode(self, index):
if not self.head or not self.head.pointer:
self._deleteFirst()
@ -87,9 +72,6 @@ class LinkedListFIFO(object):
print('Node with index {} not found'.format(index))
if __name__ == '__main__':
ll = LinkedListFIFO()
for i in range(1, 5):

View file

@ -1,9 +1,6 @@
#!/usr/bin/python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
#!/usr/bin/env python
__author__ = "bt3"
''' Implement a unordered linked list, i.e. a LIFO linked list (like a stack) '''
@ -16,15 +13,12 @@ class LinkedListLIFO(object):
self.head = None
self.length = 0
# print each node's value, starting from the head
def _printList(self):
node = self.head
while node:
print(node.value)
node = node.pointer
# delete a node, given the previous node
def _delete(self, prev, node):
self.length -= 1
if not prev:
@ -32,14 +26,10 @@ class LinkedListLIFO(object):
else:
prev.pointer = node.pointer
# add a new node, pointing to the previous node
# in the head
def _add(self, value):
self.length += 1
self.head = Node(value, self.head)
# locate node with some index
def _find(self, index):
prev = None
node = self.head
@ -50,7 +40,6 @@ class LinkedListLIFO(object):
i += 1
return node, prev, i
# locate node by value
def _find_by_value(self, value):
prev = None
node = self.head
@ -63,8 +52,6 @@ class LinkedListLIFO(object):
node = node.pointer
return node, prev, found
# find and delete a node by index
def deleteNode(self, index):
node, prev, i = self._find(index)
if index == i:
@ -72,8 +59,6 @@ class LinkedListLIFO(object):
else:
print('Node with index {} not found'.format(index))
# find and delete a node by value
def deleteNodeByValue(self, value):
node, prev, found = self._find_by_value(value)
if found:

View file

@ -1,8 +1,6 @@
#!/usr/bin/python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
#!/usr/bin/env python
__author__ = "bt3"
class Node(object):
def __init__(self, value=None, pointer=None):

View file

@ -1,7 +1,6 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
__author__ = "bt3"
''' This function divides a linked list in a value, where everything smaller than this value
goes to the front, and everything large goes to the back:'''

View file

@ -1,7 +1,6 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
__author__ = "bt3"
''' Supposing two linked lists representing numbers, such that in each of their
nodes they carry one digit. This function sums the two numbers that these

View file

@ -1,7 +1,6 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
__author__ = "bt3"
""" A class for an animal shelter with two queues"""

View file

@ -1,7 +1,6 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
__author__ = "bt3"
''' a class for a double ended queue (also inefficient) '''

View file

@ -1,7 +1,6 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
__author__ = "bt3"
''' Queue acts as a container for nodes (objects) that are inserted and removed according FIFO'''

View file

@ -1,17 +1,19 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "bt3"
""" Using our deque class and Python's deque class """
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
import string
import collections
from deque import Deque
STRIP = string.whitespace + string.punctuation + "\"'"
""" Using our deque class and Python's deque class """
def palindrome_checker_with_deque(str1):
d1 = Deque()

View file

@ -1,10 +1,6 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
''' an example of a queue implemented from 2 stacks '''
__author__ = "bt3"
class Queue(object):
@ -13,17 +9,13 @@ class Queue(object):
self.in_stack = []
self.out_stack = []
# basic methods
def _transfer(self):
while self.in_stack:
self.out_stack.append(self.in_stack.pop())
def enqueue(self, item):
return self.in_stack.append(item)
def dequeue(self):
if not self.out_stack:
self._transfer()
@ -32,11 +24,9 @@ class Queue(object):
else:
return "Queue empty!"
def size(self):
return len(self.in_stack) + len(self.out_stack)
def peek(self):
if not self.out_stack:
self._transfer()
@ -54,9 +44,7 @@ class Queue(object):
return "Queue empty!"
def isEmpty(self):
return not ((bool(self.in_stack) or bool(self.out_stack)))
return not (bool(self.in_stack) or bool(self.out_stack))
if __name__ == '__main__':

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "bt3"
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
'''transform a decimal number to a binary number with a stack '''

View file

@ -1,13 +1,11 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
__author__ = "bt3"
""" A stack made of linked list"""
class Node(object):
def __init__(self, value=None, pointer=None):
self.value = value

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "bt3"
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
''' Uses a stack to reverse a string '''

View file

@ -1,7 +1,6 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
__author__ = "bt3"
""" define a class for a set of stacks """

View file

@ -0,0 +1,65 @@
#!/usr/bin/env python
# copy of the class ../Stack.py
__author__ = "bt3"
class Stack(object):
def __init__(self):
self.content = []
self.min_array = []
self.min = float('inf')
def push(self, value):
if value < self.min:
self.min = value
self.content.append(value)
self.min_array.append(self.min)
def pop(self):
if self.content:
value = self.content.pop()
self.min_array.pop()
if self.min_array:
self.min = self.min_array[-1]
return value
else:
return 'Empty List. '
def find_min(self):
if self.min_array:
return self.min_array[-1]
else:
return 'No min value for empty list.'
def size(self):
return len(self.content)
def isEmpty(self):
return not bool(self.content)
def peek(self):
if self.content:
return self.content[-1]
else:
print('Stack is empty.')
def __repr__(self):
return '{}'.format(self.content)
if __name__ == '__main__':
q = Stack()
for i in range(15,20):
q.push(i)
for i in range(10,5,-1):
q.push(i)
for i in range(1, 13):
print q.pop(), q.find_min()

View file

@ -1,7 +1,6 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
__author__ = "bt3"
''' A stack with a minimum lookup '''

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
#!/usr/bin/env python
__author__ = "bt3"
__author__ = "Mari Wahl"
__email__ = "marina.w4hl@gmail.com"
""" Implement the 'towers of hanoi'"""

View file

@ -1,17 +1,16 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
''' Example of how to use a bit array in python as a "counter" dict:
__author__ = "bt3"
''' Example of how to use a bit array in python as a "counter" dict'''
def print_dupl_ba(l1):
'''
>>> l1 = [0, 1, 2, 3, 4, 2, 6, 7, 8, 9]
>>> print_dupl_ba(l1)
2
'''
'''
def print_dupl_ba(l1):
bs = bytearray(10)
for i in range(len(l1)):
if i == l1[i]:
@ -22,9 +21,6 @@ def print_dupl_ba(l1):
return None
if __name__ == '__main__':
import doctest

View file

@ -0,0 +1,33 @@
BIT-WISE
----------------------
1. To find a number:
11000101 is 2^0+2^2+2^6+2^7 = 197
2. Left shifting:
0010 1011 << 4 ---> 1011 000
3. Right shifting:
0010 1011 >> 4 ---> 0000 0010
or it can be filled with the copy of the first bit, instead of 0:
1011 0010 >> 4 ---> 1111 1011
4. XOR can cancels out:
15 ^ 12 ^ 15 = 12
5. 2^x:
left-shift 1 by x:
0000 0001 << x
so if x = 2, 2^2 = 4 -> 100
0000 0001 << 2 ---> 0000 0100
6. Is power of 2?
just do x&(x-1).
if 0 --> yes!

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
__author__ = "bt3"
''' Clear a bit in a binary number.
Like the reverse of set bit:
1) first create a number filled of 1s,
with 0 at i (can create 0001000 and ~)
2) AND the number so it clears the ith bit
'''
def clear_bit(num, i):
mask = ~ (1 << i) # -0b10001
return bin(num & mask)
def clear_all_bits_from_i_to_0(num, i):
mask = ~ ( (1 << (i+1)) - 1)
return bin(num & mask)
def clear_all_bits_from_most_sig_to_1(num, i):
mask = ( 1 << i) -1
return bin(num & mask)
if __name__ == '__main__':
num = int('10010000', 2)
print clear_bit(num, 4) # '0b10000000'
num = int('10010011', 2)
print clear_all_bits_from_i_to_0(num, 2) # '0b10010000'
num = int('1110011', 2)
print clear_all_bits_from_most_sig_to_1(num, 2) #'0b11'

View file

@ -1,28 +1,25 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
''' Find how many bits a int has:
1) Start with a mask of 1
2) Mask with AND
3) if result (if true): count += 1
(obs: to find the int of a bin do int('1001', 2)) and to show in bin do bin(int))
>>> for i in range(17): print(find_bit_len(i))
(obs: to find the int of a bin do int('1001', 2)) and to show in bin
do bin(int))
'''
def find_bit_len(int_num):
lenght = 0
while int_num:
int_num >>= 1
lenght += 1
return lenght
if __name__ == '__main__':
import doctest
doctest.testmod()
for i in range(17):
print(find_bit_len(i))
print i.bit_length()

View file

@ -1,21 +1,22 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
''' Find how many 1s in the binary:
1) Start with a mask of 1
2) Mask with AND
3) if result (if true): count += 1
(obs: to find the int of a bin do int('1001', 2)) and to show in bin do bin(int))
>>> find_how_many_1_in_a_binary(9)
2
(obs: to find the int of a bin do int('1001',
2)) and to show in bin do bin(int))
'''
def find_how_many_1_in_a_binary(n):
'''
>>> find_how_many_1_in_a_binary(9)
2
'''
counter = 0
while n:
if n & 1:
@ -24,9 +25,6 @@ def find_how_many_1_in_a_binary(n):
return counter
if __name__ == '__main__':
import doctest

View file

@ -0,0 +1,27 @@
#!/usr/bin/env python
__author__ = "bt3"
''' Get a bit in a binary number:
1) Shifts 1 over by i bits
2) make an AND with the number
3) all the other than the bit at i are clean, now compare to 0
4) if the new value is not 0, bit i is 1
'''
def get_bit(num, i):
mask = 1 << i
return num & mask != 0
if __name__ == '__main__':
num = int('0100100', 2)
get_bit(num, 0) # 0
get_bit(num, 1) # 0
get_bit(num, 2) # 1
get_bit(num, 3) # 0
get_bit(num, 4) # 0
get_bit(num, 5) # 1
get_bit(num, 6) # 0

View file

@ -1,20 +1,22 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
''' Given a real number between 0 and 1 (eg: 0.72), this method print the binary
representation. If the Number cannot be represented accurately in binary, with at
most 32 chars, print error:
'''
def get_float_rep(num):
'''
>>> get_float_rep(0.72)
('Error 2', '.1011100001010001111010111000010')
>>> get_float_rep(0.1)
('Error 2', '.0001100110011001100110011001100')
>>> get_float_rep(0.5)
'.1'
'''
'''
def get_float_rep(num):
if num >= 1 or num <= 0: return 'Error 1'
result = '.'
while num:
@ -27,7 +29,7 @@ def get_float_rep(num):
result += '0'
num = r
return result
if __name__ == '__main__':
import doctest

View file

@ -1,33 +1,34 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
''' Given two 32-bit numbers, N and M, and two bit positions, i and j, this
method insert M into N such that M starts at bit j and ends at bit i:
method insert M into N such that M starts at bit j and ends at bit i:
1) clear the bits j thru i in N'
2) shift M so that it lines up with bits j thru i
3) merge M and N
'''
def insert_small_bin_into_big_bin(M, N, i, j):
'''
>>> N = 0b10000000000
>>> M = 0b10011
>>> j = 6
>>> i = 2
>>> insert_small_bin_into_big_bin(M, N, i, j)
'0b10001001100'
'''
'''
def insert_small_bin_into_big_bin(M, N, i, j):
allOnes = ~0
left = allOnes << (j+1) # 1110000
right = ( (1 << i) - 1) # 0000111
mask = left | right # 1110111
N_cleared = N & mask
M_shifted = M << i
return bin( N_cleared | M_shifted)
if __name__ == '__main__':
import doctest

View file

@ -1,27 +1,19 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
''' Give a positive int, print the next smallest and next largest ints with
same number of 1 bits.
The brute force is:
1) find number of 1 bits
2) loop above and down until find same, checking for each
>>> num = 0b1001
>>> next = '0b1010'
>>> prev = '0b110'
>>> print_prev_same_1s(num) == prev
True
>>> print_next_same_1s(num) == next
True
'''
def print_prev_same_1s(num):
n1s = find_num_1s(num)
n1s = find_num_1s(num)
# find prev
i = num-1
while True:
@ -31,10 +23,10 @@ def print_prev_same_1s(num):
i -= 1
if i < 0:
return None
def print_next_same_1s(num):
n1s = find_num_1s(num)
# find next
n1s = find_num_1s(num)
# find next
i = num+1
while True:
n1s_here = find_num_1s(i)
@ -43,8 +35,8 @@ def print_next_same_1s(num):
i += 1
if i < 0:
return None
def find_num_1s(num):
counter = 0
@ -54,11 +46,14 @@ def find_num_1s(num):
num >>= 1
return counter
if __name__ == '__main__':
import doctest
doctest.testmod()
num = 0b1001
n = '0b1010'
p = '0b110'
print_prev_same_1s(num) == p
print_next_same_1s(num) == n

View file

@ -1,18 +1,12 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
''' This method returns the number of bits that are necessary to change to convert two
numbers A and B:
1) XOR
2) count 1s
>>> a = int('10010000', 2)
>>> b = int('01011010', 2)
>>> count_bits_swap(a, b)
4
>>> count_bits_swap2(a, b)
4
'''
def count_bits_swap2(a, b):
@ -28,8 +22,8 @@ def count_bits_swap2(a, b):
def count_bits_swap(a, b):
m = a^b
return count_1s(m)
def count_1s(m):
count = 0
while m:
@ -37,9 +31,10 @@ def count_1s(m):
count +=1
m >>= 1
return count
if __name__ == '__main__':
import doctest
doctest.testmod()
a = int('10010000', 2)
b = int('01011010', 2)
print count_bits_swap(a, b) #4
print count_bits_swap2(a, b) #4

View file

@ -0,0 +1,26 @@
#!/usr/bin/env python
__author__ = "bt3"
''' Set a bit in a binary number:
1) Shifts 1 over by i bits
2) make an OR with the number, only the value at bit i will change and all the others bit
of the mask are zero so will not affect the num
'''
def set_bit(num, i):
mask = 1 << i
return bin( num | mask )
if __name__ == '__main__':
num = int('0100100', 2)
print set_bit(num, 0) #'0b100101'
print set_bit(num, 1) #'0b100110'
print set_bit(num, 2) # nothing change '0b100100'
print set_bit(num, 3) #'0b101100'
print set_bit(num, 4) #'0b110100'
print set_bit(num, 5) # nothing change '0b100100'

View file

@ -0,0 +1,23 @@
#!/usr/bin/env python
__author__ = "bt3"
'''
swapping values in place without extra memory
'''
def swap_bit(a, b):
'''
>>> swap_bit(14, 73)
(73, 14)
'''
a = a^b
b = a^b
a = a^b
return a, b
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -1,6 +1,7 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
''' Swap odd and even bits in a smart way in a binary:
1) first for odds, take n and move the odd:
@ -8,17 +9,18 @@
(b) shift by right by 1
2) do the same to ints with 01010101
3) merge
>>> num = 0b11011101
>>> result = '0b1101110'
>>> swap_odd_even(num) == result
True
'''
def swap_odd_even(num):
'''
>>> num = 0b11011101
>>> result = '0b1101110'
>>> swap_odd_even(num) == result
True
'''
mask_odd = 0xAA # 0b10101010
mask_even = 0x55 # 0b1010101
odd = num & mask_odd
@ -28,9 +30,6 @@ def swap_odd_even(num):
return bin(odd | even)
if __name__ == '__main__':
import doctest

View file

@ -1,26 +1,22 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
''' This method merges set bit and clean bit:
1) first clear the bit at i using a mask such as 1110111
2) then shift the intended value v by i bits
3) this will create a number with bit i to v and all other to 0
4) finally update the ith bit with or
>>> num = int('10010000', 2)
>>> update_bit(num, 2, 1)
'0b10010100'
'''
def update_bit(num, i, v):
mask = ~ (1 << i)
return bin( (num & mask) | (v << i) )
return bin( (num & mask) | (v << i) )
if __name__ == '__main__':
import doctest
doctest.testmod()
num = int('10010000', 2)
print update_bit(num, 2, 1) # '0b10010100'

View file

@ -0,0 +1,51 @@
#!/usr/bin/env python
__author__ = "bt3"
from collections import Counter
def is_anagram(s1, s2):
'''
>>> is_anagram('cat', 'tac')
True
>>> is_anagram('cat', 'hat')
False
'''
counter = Counter()
for c in s1:
counter[c] += 1
for c in s2:
counter[c] -= 1
for i in counter.values():
if i:
return False
return True
''' verify if words are anagrams by comparing a sum of Unicode code
point of the character'''
def get_unicode_sum(word):
s = 0
for p in word:
s += ord(p)
return s
def is_anagram2(word1, word2):
'''
>>> is_anagram2('cat', 'tac')
True
>>> is_anagram2('cat', 'hat')
False
'''
return get_unicode_sum(word1) == get_unicode_sum(word2)
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,9 @@
__author__ = "bt3"
This is the classic "you have 8 balls/coins, which are the same weight, except for one which is slightly heavier than the others. You also have an old-style balance. What is the fewest number of weighings to find the heavy coin/ball?
Answer: 2! You need to use every information available:
Weight 3 x 3 balls/coins.
If they weight the same: weight the 2 balls/coins left outside.
Else, measure 2 of the 3 heavier balls/coins.

View file

@ -0,0 +1,40 @@
#!/usr/bin/env python
__author__ = "bt3"
'''
Given a N different open and close braces in a string "( { [ } ] )".
How do you check whether the string has matching braces.
'''
from collections import Counter
def check_if_balance(string):
'''
>>> check_if_balance('{[[(])}]')
True
>>> check_if_balance('{[[()}]')
False
>>> check_if_balance('')
True
'''
table = Counter()
for i in string:
index = str(ord(i))[0]
if i in '{[(':
table[index] += 1
elif i in ')}]':
table[index] -= 1
for i in table.values():
if i !=-0:
return False
return True
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,71 @@
#!/usr/bin/env python
__author__ = "bt3"
"""
Given an integer x and an unsorted array of integers, describe an
algorithm to determine whether two of the numbers add up to x.
1. Using hash tables.
2. Sorting the array and keeping two pointers in the array, one in
the beginning and one in the end. Whenever the sum of the current
two integers is less than x, move the first pointer forwards, and
whenever the sum is greater than x, move the second pointer
backwards. O(nln n).
3. Create a BST with x minus each element in the array.
Check whether any element of the array appears in the BST.
It takes O(nlog n) times two.
"""
from collections import defaultdict, Counter
def check_sum(array, k):
'''
>>> check_sum([3, 2, 6, 7, 9, 1], 8)
[(6, 2), (1, 7)]
>>> check_sum([5, 2, 6, 7, 9, 1], 4)
[]
>>>
'''
dict = defaultdict()
res = []
for i in array:
if k-i in dict:
res.append((i, k-i))
del dict[k-i]
else:
dict[i] = 1
return res
def check_sum2(array, k):
'''
>>> check_sum2([1, 4, 2, 7, 1, 3, 10, 15, 3, 1], 6)
set([(3, 3)])
>>> check_sum2([1, 4, 2, 7, 1, 3, 10, 15, 3, 1], 0)
set([])
'''
dict = Counter()
res = set()
for i in array:
dict[i] += 1
for i in array:
if dict[k-i] > 0:
if i == k-i and dict[k-i] > 1:
res.add((i, k-i))
dict[k-i] -= 2
elif i == k-i:
res.add((i, k-i))
dict[k-i] -= 1
return res
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,36 @@
#!/usr/bin/env python
__author__ = "bt3"
''' Determine if an Array of integers contains 3 numbers that sum to 0 '''
from collections import defaultdict
def find_3_number(array):
'''
>>> find_3_number([1,5,56,11,-3,-12])
1 11 -12
True
>>> find_3_number([] )
False
'''
hash_ = defaultdict()
for i in array:
hash_[i] = 1
for i, x in enumerate(array):
for y in array[i+1:]:
if -(x+y) in hash_:
print x, y, -(x+y)
return True
return False
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,35 @@
#!/usr/bin/env python
__author__ = "bt3"
'''
given an array of intervals, return max number of non-overlapping intervals
'''
from collections import defaultdict
def non_overlapping(array):
'''
>>> non_overlapping([(1,2), (2,5), (1, 6)])
[[(1, 2), (2, 5)]]
>>> non_overlapping([(1,4), (2,5), (3, 6)])
[]
'''
total = []
for i, t in enumerate(array):
start = t[0]
end = t[1]
for tt in array[i+1:] :
if end <= tt[0]:
total.append([(start, end), (tt[0], tt[1])])
return total
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,64 @@
#!/usr/bin/env python
__author__ = "bt3"
''' convert an integer to a string in any base'''
def convert_from_dec_to_any_base(number, base):
'''
>>> number, base = 9, 2
>>> convert_from_dec_to_any_base(number, base)
'1001'
'''
convertString = '012345679ABCDEF'
if number < base:
return convertString[number]
else:
return convert_from_dec_to_any_base(number//base, base) + \
convertString[number%base]
def convert_from_decimal_to_binary(number, base):
'''
>>> number, base = 9, 2
>>> convert_from_decimal_to_binary(number, base)
1001
'''
multiplier, result = 1, 0
while number > 0:
result += number%base*multiplier
multiplier *= 10
number = number//base
return result
def convert_from_decimal_larger_bases(number, base):
'''
>>> number, base = 31, 16
>>> convert_from_decimal_larger_bases(number, base)
'1F'
'''
strings = "0123456789ABCDEFGHIJ"
result = ""
while number > 0:
digit = number%base
result = strings[digit] + result
number = number//base
return result
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -1,9 +1,10 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
''' two routines to convert str to int and int to str:
- bc: negative str, zero, exp numbers (ex. 1e5), other bases, NAN
__author__ = "bt3"
def conv_int2str(int1):
'''
>>> conv_str2int('367')
367
>>> conv_str2int('0')
@ -12,46 +13,59 @@
-10
>>> conv_str2int('1e5')
100000
>>> conv_int2str(0)
'0'
>>> conv_int2str(1e5)
'100000'
>>> conv_int2str(367)
'367'
>>> conv_int2str(-10)
'-10'
'''
'''
def conv_int2str(int1):
aux_dict = {key:value for key in range(10) for value in '0123456789'[key]}
if int1 == 0: return '0' # REMEMBER TO HANDLE 0
if int1 < 0: # REMEMBER TO HANDLE NEGATIVE
if int1 == 0:
return '0'
elif int1 < 0:
sign = '-'
int1 = int1*(-1)
else:
sign = ''
aux_ls = []
while int1 > 0:
c = int1%10
int1 = int1//10
cadd = aux_dict[c]
aux_ls.append(cadd)
aux_ls.reverse() # REMEMBER TO REVERSE
aux_ls.reverse()
return sign + ''.join(aux_ls)
def conv_str2int(str1):
if not str1: return None
'''
>>> conv_int2str(0)
'0'
>>> conv_int2str(1e5)
'100000'
>>> conv_int2str(367)
'367'
>>> conv_int2str(-10)
'-10'
'''
if not str1:
return None
aux_dict = {key:value for value in range(10) for key in '0123456789'[value]}
if str1[0] == '-':
if str1[0] == '-':
sign = -1
str1 = str1[1:] # REMEMBER TO CUT THE SIGN FROM THE STR
else:
str1 = str1[1:]
else:
sign = 1
dec, result = 1, 0
for i in range(len(str1)-1, -1, -1): # REMEMBER TO FINISH IN -1, NOT 0, AND
aux = str1[i] # AND DO THE STEPS -1
for i in range(len(str1)-1, -1, -1):
aux = str1[i]
if aux == 'e':
exp_num = conv_str2int(str1[i+1:])
number = conv_str2int(str1[:i])
@ -59,8 +73,9 @@ def conv_str2int(str1):
break
result += aux_dict[aux]*dec
dec *= 10
return result*sign
if __name__ == '__main__':
import doctest

View file

@ -1,21 +1,26 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
import collections
import string
import sys
def count_unique_word():
words = collections.defaultdict(int)
strip = string.whitespace + string.punctuation + string.digits + "\"'"
strip = string.whitespace + string.punctuation + string.digits + "\"'"
for filename in sys.argv[1:]:
with open(filename) as file:
for line in file:
for line in file:
for word in line.lower().split():
word = word.strip(strip)
if len(word) > 2:
words[word] = +1
for word in sorted(words):
print("'{0}' occurs {1} times.".format(word, words[word]))

View file

@ -0,0 +1,49 @@
#!/usr/bin/env python
__author__ = "bt3"
''' find and delete all the duplicate characters in a string '''
from collections import Counter
def delete_unique(str1):
'''
>>> delete_unique("Trust no one")
'on'
>>> delete_unique("Mulder?")
''
'''
str_strip = ''.join(str1.split())
repeat = Counter()
for c in str_strip:
repeat[c] += 1
result = ''
for c, count in repeat.items():
if count > 1:
result += c
return result
def removing_duplicates_seq(str1):
'''
>>> delete_unique("Trust no one")
'on'
>>> delete_unique("Mulder?")
''
'''
seq = str1.split()
result = set()
for item in seq:
if item not in result:
#yield item
result.add(item)
return result
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,60 @@
#!/usr/bin/env python
__author__ = "bt3"
def fib_generator():
a, b = 0, 1
while True:
yield b
a, b = b, a+b
def fib(n):
'''
>>> fib(2)
1
>>> fib(5)
5
>>> fib(7)
13
'''
if n < 3:
return 1
a, b = 0, 1
count = 1
while count < n:
count += 1
a, b = b, a+b
return b
def fib_rec(n):
'''
>>> fib_rec(2)
1
>>> fib_rec(5)
5
>>> fib_rec(7)
13
'''
if n < 3:
return 1
return fib_rec(n - 1) + fib_rec(n - 2)
if __name__ == '__main__':
import doctest
doctest.testmod()
fib = fib_generator()
print(next(fib))
print(next(fib))
print(next(fib))
print(next(fib))

View file

@ -1,8 +1,8 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
def find_0_MxN(m):
''' find 0s in a matrix and replace the col and row to 0s:
>>> m1 = [[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16]]
@ -13,6 +13,7 @@ def find_0_MxN(m):
[[0, 2, 3, 4], [0, 0, 0, 0], [0, 10, 11, 12], [0, 14, 15, 16]]
'''
index = []
for row in range(len(m)):
for col in range(len(m[0])):
if m[row][col] == 0:
@ -24,9 +25,10 @@ def find_0_MxN(m):
m[row][i] = 0
for i in range(len(m[0])):
m[i][col] = 0
return m
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,32 @@
#!/usr/bin/env python
__author__ = "bt3"
'''
given 2 dice, determine number of ways to sum S if all dice are rolled
'''
from collections import Counter, defaultdict
def find_dice_probabilities(S=5, n_faces=6):
if S > 2*n_faces or S < 2:
return None
cdict = Counter()
ddict = defaultdict(list)
for dice1 in range(1, n_faces+1):
for dice2 in range(1, n_faces+1):
t = [dice1, dice2]
cdict[dice1+dice2] += 1
ddict[dice1+dice2].append( t)
return [cdict[S], ddict[S]]
if __name__ == '__main__':
results = find_dice_probabilities()
assert(results[0] == len(results[1]))

View file

@ -0,0 +1,43 @@
#!/usr/bin/env python
__author__ = "bt3"
''' computes the edit distance between two strings '''
def find_edit_distance(str1, str2):
'''
>>> s = 'sunday'
>>> t = 'saturday'
>>> find_edit_distance(s, t)
3
'''
m = len(str1)
n = len(str2)
diff = lambda c1, c2: 0 if c1 == c2 else 1
E = [[0] * (n + 1) for i in range(m + 1)]
for i in range(m + 1):
E[i][0] = i
for j in range(1, n + 1):
E[0][j] = j
for i in range(1, m + 1):
for j in range(1, n + 1):
E[i][j] = min(E[i-1][j] + 1, E[i][j-1] + 1, E[i-1][j-1] + diff(str1[i-1], str2[j-1]))
return E[m][n]
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,29 @@
#!/usr/bin/env python
__author__ = "bt3"
from collections import Counter
def find_non_rep_char(s1):
'''
>>> s1 = 'aabbcceff'
>>> find_non_rep_char(s1)
e
>>> find_non_rep_char('ccc')
'''
aux_dict = Counter()
for i in s1:
aux_dict[i] += 1
for k, v in aux_dict.items():
if v < 2:
print k
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -1,13 +1,14 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
def finding_gcd(a, b):
''' implements the greatest common divider algorithm '''
while(b != 0):
result = b
a, b = b, a % b
a, b = b, a % b
return result
@ -22,7 +23,7 @@ if __name__ == '__main__':

View file

@ -0,0 +1,36 @@
#!/usr/bin/env python
__author__ = "bt3"
def find_substr(s1, s2):
if len(s1) < len(s2):
bs = s2
ss = s1
else:
bs = s1
ss = s2
ps = 0
for c in bs:
if ss[ps] == c:
ps += 1
else:
ps = 0
if ps == len(ss)-1:
return True
return False
if __name__ == '__main__':
s1 = 'buffy is a vampire slayer'
s2 = 'vampire'
s3 = 'angel'
assert(find_substr(s2, s1) == True)
assert(find_substr(s3, s1) == False)

View file

@ -0,0 +1,32 @@
#!/usr/bin/env python
__author__ = "bt3"
import collections
def find_if_unique_chars(word):
"""
>>> find_if_unique_chars('abcde')
True
>>> find_if_unique_chars('abcae')
False
"""
unique = True
counter = collections.Counter()
for c in word:
if not counter[c]:
counter[c] += 1
else:
unique = False
return unique
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,42 @@
#!/usr/bin/env python
__author__ = "bt3"
'''
You are given an array of integers (both positive and negative).
Find the contiguous sequence with the largest sum.
'''
def find_largest_sum(array):
'''
>>> find_largest_sum([-1, 2, -3, 5, 3, 1, -16, 7, 1, -13, 1])
9
>>> find_largest_sum([])
0
>>> find_largest_sum([1])
1
'''
sum_ = 0
sum_here = 0
for i in array:
sum_here += i
if sum_here < 0:
sum_here = 0
if sum_ < sum_here:
sum_ = sum_here
return sum_
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,34 @@
#!/usr/bin/env python
__author__ = "bt3"
''' find the longest continuous increasing subsequence'''
def find_long_con_inc(seq):
'''
>>> find_long_con_inc([1, -2, 3, 5, 1, -1, 4, -1, 6])
[-2, 3, 5]
>>> find_long_con_inc([1, 3, -2, 3, 5, 6])
[-2, 3, 5, 6]
>>> find_long_con_inc([1, 3, 4, -13, 2, 5, 8, -1, 2,-17])
[-13, 2, 5, 8]
'''
res, aux = [], []
seq.append(-float('infinity'))
for i, n in enumerate(seq[:-1]):
aux.append(n)
if n > seq[i+1]:
if len(res) < len(aux):
res = aux[:]
aux = []
return res
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,38 @@
#!/usr/bin/env python
__author__ = "bt3"
'''
given a string, find longest string with unique characters
'''
def find_longest(string):
'''
>>> find_longest('abfgrhgtrdsandwejfhdasjcbdsjvrejwghireeej')
'wejfhdas'
>>> find_longest('abcabcabcabcdefabcccc')
'defabc'
'''
maxs = ''
result = ''
for c in string:
if c in result:
if len(maxs) < len(result):
maxs = result
result = ''
else:
result += c
if result and len(maxs) < len(result):
maxs = result
return maxs
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,33 @@
#!/usr/bin/env python
__author__ = "bt3"
from collections import defaultdict
def find_unique_number(array):
'''
>>> find_unique_number([1, 3, 6, 1, 5, 6, 9, 3, 7])
[1, 6, 3]
>>> find_unique_number([1, 3, 5, 6, 9, 7])
[]
'''
table = defaultdict()
total = []
for i in array:
if i in table:
total.append(i)
else:
table[i] = 1
return total
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,42 @@
#!/usr/bin/env python
__author__ = "bt3"
'''Given an array of numbers, replace each number with the product of all
the numbers in the array except the number itself *without* using division
'''
def find_product_without_division(seq):
'''
>>> seq = [2,3,4]
>>> find_product_without_division(seq)
[12, 8, 6]
'''
forw = []
bacw = []
for i in range(len(seq)):
prod_f, prod_b = 1, 1
for next in range(i+1, len(seq)):
prod_f *= seq[next]
for before in range(0, i):
prod_b *= seq[before]
forw.append(prod_f)
bacw.append(prod_b)
for i in range(len(seq)):
seq[i] = forw[i] * bacw[i]
return seq
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -1,6 +1,6 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
from collections import Counter
@ -8,24 +8,20 @@ def find_top_N_recurring_words(seq, N):
''' find the top N recurring words in a file:
1) use a hash table to find counts
2) sort the list on base of the maximum counts
3) return the last N words '''
3) return the last N words
'''
dcounter = Counter()
for word in seq.split():
dcounter[word] += 1
dcounter[word] += 1
return dcounter.most_common(N)
def test_find_top_N_recurring_words(module_name='this module'):
seq = 'buffy angel monster xander a willow gg buffy the monster super buffy angel'
N = 3
assert(find_top_N_recurring_words(seq, N) == [('buffy', 3), ('monster', 2), ('angel', 2)])
s = 'Tests in {name} have {con}!'
print(s.format(name=module_name, con='passed'))
if __name__ == '__main__':
test_find_top_N_recurring_words()
seq = 'buffy angel monster xander a willow gg buffy the monster super buffy angel'
N = 3
assert(find_top_N_recurring_words(seq, N) == [('buffy', 3), ('monster', 2), ('angel', 2)])

View file

@ -0,0 +1,56 @@
#!/usr/bin/env python
__author__ = "bt3"
"""
Two numbers out of n numbers from 1 to n are missing.
The remaining n-2 numbers are in the array but not sorted.
Find the missing numbers The sum1 is the sum of all the elements in n.
The sum2 is the sum of all the elements in n-2. sum1 - sum2 = num1 + num2 = s.
The prod1 is the prod of all the elements in n. The prod2 is the prod of all
the elements in n-2. prod1/prod2 = num1*num2 =p.
Runtime is O(n), because it scan 3 times. Space is O(1)
In case of finding one integer, Let the missing number be M. We know that
the sum of first N natural numbers is N*(N+1)/2. Traverse through the array
once and calculate the sum. This is the sum of first N natural numbers -
M or S=N*(N+1)/2 - M. Therefore M = N*(N+1)/2 - S.
"""
import math
def find_two_missing_numbers(l1):
'''
>>> l1 = [1, 3, 5]
>>> find_two_missing_numbers(l1)
(4, 2)
'''
n_min_2 = len(l1)
n = n_min_2 + 2
sum1, sum2, prod1, prod2 = 0, 0, 1, 1
sum2 = sum(l1[:])
sum1 = sum(range(1,n+1))
s = sum1 - sum2
for i in range(1, n-1):
prod1 = prod1*i
prod2 = prod2*l1[i-1]
prod1 = prod1*n*(n-1)
p = prod1/prod2
num1 = (s + math.sqrt(s*s - 4*p))/2
num2 = (s - math.sqrt(s*s - 4*p))/2
return int(num1), int(num2)
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,29 @@
#!/usr/bin/env python
__author__ = "bt3"
''' Given a real number between 0 and 1 (eg: 0.72), this method print the
binary representation. If the Number cannot be represented accurately
in binary, with at exit most 32 chars, print error:
'''
def get_float_rep(num):
if num >= 1 or num <= 0: return 'Error 1'
result = '.'
while num:
if len(result) >= 32: return 'Error 2', result
r = num*2
if r >= 1:
result += '1'
num = r - 1
else:
result += '0'
num = r
return result
if __name__ == '__main__':
print get_float_rep(0.72) #('Error 2', '.1011100001010001111010111000010')
print get_float_rep(0.1) # ('Error 2', '.0001100110011001100110011001100')
print get_float_rep(0.5) #'.1'

View file

@ -0,0 +1,63 @@
#!/usr/bin/env python
__author__ = "bt3"
def intersection_two_arrays_sets(seq1, seq2):
'''
>>> intersection_two_arrays_sets([1,2,3,5,7,8], [3,5,6])
set([3, 5])
>>> intersection_two_arrays_sets([1,2,7,8], [3,5,6])
set([])
'''
# O(n)
set1 = set(seq1)
set2 = set(seq2)
return set1.intersection(set2) #same as list(set1 & set2)
def intersection_two_arrays_On2(seq1, seq2):
'''
>>> intersection_two_arrays_On2([1,2,3,5,7,8], [3,5,6])
[3, 5]
>>> intersection_two_arrays_On2([1,2,7,8], [3,5,6])
[]
'''
final = []
for i in seq1:
for j in seq2:
if i == j:
final.append(i)
return final
def intersection_two_arrays_On(seq1, seq2):
'''
>>> intersection_two_arrays_On([1,2,3,5,7,8], [3,5,6])
[5, 3]
>>> intersection_two_arrays_On([1,2,7,8], [3,5,6])
[]
'''
final = []
while seq1 and seq2:
if seq1[-1] == seq2[-1]:
final.append(seq1.pop())
seq2.pop()
elif seq1[-1] > seq2[-1]:
seq1.pop()
else:
seq2.pop()
return final
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,54 @@
#!/usr/bin/env python
__author__ = "bt3"
def beating_stock(array):
imin = 0
# first deal is just buying in the next day (1)
deal = [array[1] - array[imin], imin, 1]
for i, d in enumerate(array):
deal_here = d - array[imin]
if deal_here > deal[0]:
deal = [deal_here, imin, i]
elif d < array[imin]:
imin = i
return deal[0], array[deal[1]], array[deal[2]]
def beating_stock2(array):
deal = 0
min_value = array[0]
for i, d in enumerate(array):
deal_here = d - min_value
if deal_here > deal:
deal = deal_here
else:
if min_value > array[i]:
min_value = array[i]
return deal
if __name__ == '__main__':
array = [7, 2, 3, 6, 5, 8, 5, 3, 4]
deal = beating_stock(array)
print("Profit: %d, buying at %d, selling at %d." %(deal[0], deal[1], deal[2]))
deal = beating_stock2(array)
print "Profit: " + str(deal)

View file

@ -0,0 +1,15 @@
#!/usr/bin/env python
__author__ = "bt3"
How to know how many 0 are in 100!
You look for the primes that multiply to 10, i.e. 2 and 5.
There are more 5 than 2s so you can count the fives.
there is 100/5 = 20, so 20 5s. However, there are two 5s in 25, 50, 75 and 100.
result: 20+4 = 24

View file

@ -0,0 +1,33 @@
#!/usr/bin/env python
__author__ = "bt3"
from collections import defaultdict
def is_palindrome(array):
'''
>>> is_palindrome('subi no onibus')
True
>>> is_palindrome('helllo there')
False
>>> is_palindrome('h')
True
>>> is_palindrome('')
True
'''
array = array.strip(' ')
if len(array) < 2:
return True
if array[0] == array[-1]:
return is_palindrome(array[1:-1])
else:
return False
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,70 @@
#!/usr/bin/env python
__author__ = "bt3"
def perm(str1):
'''
>>> perm('123')
['123', '132', '231', '213', '312', '321']
'''
if len(str1) < 2:
return str1
res = []
for i, c in enumerate(str1):
for cc in perm(str1[i+1:] + str1[:i]):
res.append(c + cc)
return res
def perm2(str1):
'''
>>> perm2('123')
['123', '132', '213', '231', '312', '321']
'''
from itertools import permutations
return [''.join(p) for p in permutations(str1)]
def ispermutation(s1, s2):
'''
>>> ispermutation('231', '123')
True
>>> ispermutation('231', '153')
False
'''
from collections import Counter
aux = Counter()
for i in s1:
aux[i] += 1
for i in s2:
aux[i] -= 1
for v in aux.values():
if v != 0:
return False
return True
def ispermutation2(s1, s2):
'''
>>> ispermutation2('231', '123')
True
>>> ispermutation2('231', '153')
False
'''
if sorted(s1) == sorted(s2):
return True
else:
return False
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
__author__ = "bt3"
''' Write code to generate all possible case permutations of a given
lower-cased string
'''
def alpha_permutation(string):
'''
>>> alpha_permutation('0ab')
['0Ab', '0Ab', '0ab', '0ab', '0Ba', '0Ba', '0ba', '0ba', 'ab0', 'a0b', 'a0b', 'b0a', 'b0a', 'ba0']
>>> alpha_permutation('')
''
'''
if len(string) < 2:
return string
result = []
for i, c in enumerate(string):
rest = string[i+1:] + string[:i]
for cc in alpha_permutation(rest):
if cc.isalpha():
result.append(c.upper() + cc)
result.append(c + cc)
return result
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,47 @@
#!/usr/bin/env python
__author__ = "bt3"
'''
find prime factors of a number.
'''
import math
import random
def find_prime_factors(n):
'''
>>> find_prime_factors(14)
[2, 7]
>>> find_prime_factors(19)
[]
'''
divisors = [d for d in range(2, n//2 + 1) if n % d == 0]
primes = [d for d in divisors if is_prime(d)]
return primes
def is_prime(n):
for j in range(2, int(math.sqrt(n))):
if (n % j) == 0:
return False
return True
''' return a n-bit prime '''
def generate_prime(number=3):
while 1:
p = random.randint(pow(2, number-2), pow(2, number-1)-1)
p = 2 * p + 1
if find_prime_factors(p):
return p
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,28 @@
#!/usr/bin/env python
__author__ = "bt3"
def get_products_of_all_except_at_index(array):
'''
>>> a = [1, 7, 3, 4]
>>> get_products_of_all_except_at_index(a)
[84, 12, 28, 21]
'''
total = 1
for n in array:
total *= n
new_array = []
for n in array:
if n is not 0:
item = total/n
new_array.append(item)
else:
new_array.append(n)
return new_array
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,34 @@
#!/usr/bin/env python
__author__ = "bt3"
from collections import Counter
def check_if_ransom_note(magazines, note):
count = Counter()
pm, pn = 0, 0
while pn < len(note) and pm < len(magazines):
char_note = note[pn]
if count[char_note]>0:
count[char_note] -= 1
pn += 1
else:
char_magazine = magazines[pm]
count[char_magazine] += 1
pm +=1
return pn == len(note)
if __name__ == '__main__':
magazines1 = "avfegthhgrebvkdsvnijnvyijfdmckdsmovkmmfvskumvl;cdkmioswckofjbkreenyukjemjgnmkmvkmnvdkmvkr g gmvdvmldm vldfkmbldkmlvdkm"
magazines2 = "adfsfa"
note = "you should disobey"
print(check_if_ransom_note(magazines1, note))
print(check_if_ransom_note(magazines2, note))

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
__author__ = "bt3"
def revert(string):
'''
>>> s = 'hello'
>>> revert(s)
'olleh'
>>> revert('')
''
'''
return string[::-1]
def reverse_string_inplace(s):
'''
>>> s = 'hello'
>>> reverse_string_inplace(s)
'olleh'
>>> reverse_string_inplace('')
''
'''
if s:
s = s[-1] + reverse_string_inplace(s[:-1])
return s
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -0,0 +1,45 @@
#!/usr/bin/env python
__author__ = "bt3"
def reversing_words(word):
"""
>>> reversing_words('buffy is awesome')
'awesome is buffy'
"""
new_word = []
words = word.split(' ')
for word in words[::-1]:
new_word.append(word)
return " ".join(new_word)
def reversing_words2(s):
"""
>>> reversing_words2('buffy is awesome')
'awesome is buffy'
"""
words = s.split()
return ' '.join(reversed(words))
def reversing_words3(s):
"""
>>> reversing_words('buffy is awesome')
'awesome is buffy'
"""
words = s.split(' ')
words.reverse()
return ' '.join(words)
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -1,8 +1,7 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
def rotate_NxN(m):
n = len(m)
for layer in range(n//2):
@ -16,7 +15,7 @@ def rotate_NxN(m):
m[last][last-offset] = m[i][last]
m[i][last] = top
return m
def main():
@ -25,7 +24,7 @@ def main():
assert(rotate_NxN(m) == mr)
m2 = [[1,2,3],[4,5,6],[7,8,9]]
print(rotate_NxN(m2))
if __name__ == '__main__':
main()

View file

@ -1,9 +1,19 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
'''To use timeit you create a Timer object whose parameters are two Python statements. The first parameter is a Python statement that you want to time; the second parameter is a statement that will run once to set up the test. The timeit module will then time how long it takes to execute the statement some number of times. By default timeit will try to run the statement one million times. When its done it returns the time as a floating point value representing the total number of seconds. However, since it executes the statement a million times you can read the result as the number of microseconds to execute the test one time. You can also pass timeit a named parameter called number that allows you to specify how many times the test statement is executed. The following session shows how long it takes to run each of our test functions 1000 times. '''
'''To use timeit you create a Timer object whose parameters are two Python
statements. The first parameter is a Python statement that you want to time;
the second parameter is a statement that will run once to set up the test.
The timeit module will then time how long it takes to execute the statement
some number of times. By default timeit will try to run the statement one
million times. When its done it returns the time as a floating point value
representing the total number of seconds. However, since it executes the
statement a million times you can read the result as the number of
microseconds to execute the test one time. You can also pass timeit a
named parameter called number that allows you to specify how many times the
test statement is executed. The following session shows how long it takes to
run each of our test functions 1000 times. '''
import timeit
@ -19,7 +29,7 @@ for i in range(10000,1000001,20000):
print("%d,%10.3f,%10.3f" % (i, lst_time, d_time))
""" There rersults are:
""" There results are:
10000, 0.192, 0.002
30000, 0.600, 0.002
50000, 1.000, 0.002

View file

@ -1,7 +1,6 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
'''To use timeit you create a Timer object whose parameters are two Python statements. The first parameter is a Python statement that you want to time; the second parameter is a statement that will run once to set up the test. The timeit module will then time how long it takes to execute the statement some number of times. By default timeit will try to run the statement one million times. When its done it returns the time as a floating point value representing the total number of seconds. However, since it executes the statement a million times you can read the result as the number of microseconds to execute the test one time. You can also pass timeit a named parameter called number that allows you to specify how many times the test statement is executed. The following session shows how long it takes to run each of our test functions 1000 times. '''

View file

@ -1,18 +1,22 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
''' Search an Entry in a Matrix where the Rows and columns are Sorted
In this 2D matrix, every row is increasingly sorted from left to right,
and every column is increasingly sorted from top to bottom.
The runtime is O(m+n).
'''
def find_elem_matrix_bool(m1, value):
''' Search an Entry in a Matrix where the Rows and columns are Sorted
In this 2D matrix, every row is increasingly sorted from left to right,
and every column is increasingly sorted from top to bottom.
The runtime is O(m+n). '''
found = False
row = 0
col = len(m1[0]) - 1
while row < len(m1) and col >= 0:
if m1[row][col] == value:
found = True
break
@ -20,8 +24,9 @@ def find_elem_matrix_bool(m1, value):
col-=1
else:
row+=1
return found
def test_find_elem_matrix_bool(module_name='this module'):
@ -30,9 +35,6 @@ def test_find_elem_matrix_bool(module_name='this module'):
assert(find_elem_matrix_bool(m1,3) == False)
m2 = [[0]]
assert(find_elem_matrix_bool(m2,0) == True)
s = 'Tests in {name} have {con}!'
print(s.format(name=module_name, con='passed'))
if __name__ == '__main__':

View file

@ -1,11 +1,19 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
from collections import Counter
def str_comp(s):
''' basic str compression with counts of repeated char'''
'''
>>> s1 = 'aabcccccaaa'
>>> str_comp(s1)
'a2b1c5a3'
>>> str_comp('')
''
'''
count, last = 1, ''
list_aux = []
for i, c in enumerate(s):
@ -17,16 +25,10 @@ def str_comp(s):
list_aux.append(c)
count = 1
last = c
list_aux.append(str(count))
list_aux.append(str(count))
return ''.join(list_aux)
def main():
s1 = 'aabcccccaaa'
s2 = ''
print(str_comp(s1)) # 'a2b1c5a3'
print(str_comp(s2))
if __name__ == '__main__':
main()
import doctest
doctest.testmod()

View file

@ -0,0 +1,41 @@
#!/usr/bin/env python
__author__ = "bt3"
'''
find the sum of two integers represented as strings,
return the sum as string, i.e "123" and "456" would return "579"
'''
def get_number(s):
count = 1
num = 0
p = len(s) -1
while p >= 0:
num = num + int(s[p])*count
count *= 10
p -= 1
return num
def sum_string(s1, s2):
'''
>>> sum_string('10', '5')
'15'
>>> sum_string('0', '1')
'1'
>>> sum_string('123', '456')
'579'
'''
n1 = get_number(s1)
n2 = get_number(s2)
return str(n2 + n1)
if __name__ == '__main__':
import doctest
doctest.testmod()

View file

@ -1,6 +1,6 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
__author__ = "bt3"
from functools import wraps
@ -20,7 +20,7 @@ def memo(func):
def find_fibonacci_seq_rec(n):
''' implements the nth fibonacci value in a recursive exponential runtime '''
if n < 2: return n
return find_fibonacci_seq_rec(n - 1) + find_fibonacci_seq_rec(n - 2)
return find_fibonacci_seq_rec(n - 1) + find_fibonacci_seq_rec(n - 2)
def test_memo():
n = 50
@ -31,9 +31,9 @@ def test_memo():
if __name__ == '__main__':
test_memo()

View file

@ -1,7 +1,6 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
__author__ = "bt3"
from itertools import combinations
from bisect import bisect
@ -14,7 +13,7 @@ def naive_longest_inc_subseq(seq):
for sub in combinations(seq, length):
if list(sub) == sorted(sub):
return len(sub)
def longest_inc_subseq1(seq):
''' an iterative algorithm for the longest increasing subsequence problem '''
@ -24,8 +23,8 @@ def longest_inc_subseq1(seq):
if idx == len(end): end.append(val)
else: end[idx] = val
return len(end)
def longest_inc_subseq2(seq):
''' another iterative algorithm for the longest increasing subsequence problem '''
L = [1] * len(seq)
@ -51,17 +50,17 @@ def memoized_longest_inc_subseq(seq):
@benchmark
def test_naive_longest_inc_subseq():
print(naive_longest_inc_subseq(s1))
benchmark
def test_longest_inc_subseq1():
def test_longest_inc_subseq1():
print(longest_inc_subseq1(s1))
@benchmark
def test_longest_inc_subseq2():
def test_longest_inc_subseq2():
print(longest_inc_subseq2(s1))
@benchmark
def test_memoized_longest_inc_subseq():
def test_memoized_longest_inc_subseq():
print(memoized_longest_inc_subseq(s1))
@ -73,9 +72,9 @@ if __name__ == '__main__':
test_longest_inc_subseq1()
test_longest_inc_subseq2()
test_memoized_longest_inc_subseq()

View file

@ -1,6 +1,8 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
import os
import sys
@ -12,12 +14,12 @@ def change_file_ext():
print("Usage: change_ext.py filename.old_ext 'new_ext'")
sys.exit()
name = os.path.splitext(sys.argv[1])[0] + "." + sys.argv[2]
name = os.path.splitext(sys.argv[1])[0] + "." + sys.argv[2]
print (name)
try:
shutil.copyfile(sys.argv[1], name)
except OSError as err:
shutil.copyfile(sys.argv[1], name)
except OSError as err:
print (err)

View file

@ -1,24 +1,28 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/python
__author__ = "bt3"
import collections
import string
import sys
def count_unique_word():
''' list every word and number of times in alphabetical order for input files '''
words = {} # create an empty dictionary
strip = string.whitespace + string.punctuation + string.digits + "\"'"
def count_unique_word_file():
if len(sys.argv) < 2:
print "Usage: python count_unique_word.py NAMEFILE"
words = collections.defaultdict(int)
strip = string.whitespace + string.punctuation + string.digits + "\"'"
for filename in sys.argv[1:]:
with open(filename) as file:
for line in file:
for line in file:
for word in line.lower().split():
word = word.strip(strip)
if len(word) > 2:
words[word] = words.get(word,0) +1
words[word] = +1
for word in sorted(words):
print("'{0}' occurs {1} times.".format(word, words[word]))
count_unique_word()
if __name__ == '__main__':
count_unique_word_file()

View file

@ -0,0 +1,15 @@
#!/usr/bin/python
__author__ = "bt3"
import collections
import sys
def count_unique_word_freq():
return collections.Counter(\
sys.stdin.read().lower().split()).most_common(n)
if __name__ == '__main__':
count_unique_word_freq()

View file

@ -1,6 +1,7 @@
#!/usr/bin/python3
# mari von steinkirch @2013
# steinkirch at gmail
#!/usr/bin/env python
__author__ = "bt3"
import sys
@ -13,7 +14,7 @@ def grep_word_from_files():
if word in line:
print("{0}:{1}:{2:.40}".format(filename, lino, line.rstrip()))
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Usage: grep_word_from_files.py word infile1 [infile2...]")

Some files were not shown because too many files have changed in this diff Show more