mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-06-24 14:50:48 -04:00
organization in the src structure, modification of README
This commit is contained in:
parent
c2ca11f247
commit
6afe96fa4d
165 changed files with 64 additions and 184 deletions
README.md
src
EXTRA_INTERVIEW_PROBLEMS
abstract_strucutres
advanced
bitwise
bitwise.txtclear_bits.pyfind_bit_len.pyget_bit.pynum_bits_to_convert_2_nums.pyset_bit.pyswap_in_place.pyupdate_bit.py
math_arrays_and_strings
alpha_permutation.pyanagram.pybalance.txtbalance_symbols.pycheck_if_2_numbers_sum_to_k.pycheck_if_3_numbers_sum_to_zero.pycheck_if_palindrome.pycheck_non_overlapping_intervals.pycombinations.pydelete_duplicate_char_str.pyfibonacci.pyfind_gcd.pyfind_if_is_substr.pyfind_if_unique_char.pyfind_largest_sum.pyfind_longest_str_unique_chars.pyfind_non_repeating_number.pyfind_prime_factors.pygenerate_prime.pyget_float_rep_bin.pyinterserction_two_arrays.pylongest_common_prefix.pymax_subarray_stocks.pynumber_of_zeros_factorial.txtpermutations.pyprod_other_ints.pyransom_note.pyrev_string.pyreverse_words.pysum_two_numbers_as_strings.py
sorting_and_searching
trees
USEFUL
basic_examples
example_args.pyexample_benchmark_decorator.pyexample_comp_lists.pyexample_decorators.pyexample_doctest.pyexample_generator.pyexample_lambda.pyexample_logging.pyexample_open_files.pyexample_pickle.pyexample_queue.pyexample_socket.pyexample_string_format.pyexample_subprocess.pyexample_telnet.pyexample_testing.pyexample_threads.pyexample_time.py
dynamic_programming
oop
useful_with_files
builtin_structures
dicts
Counter_example.pyOrderedDict_example.py__init__.pycount_unique_words_.pydefaultdict_example.pydelete_duplicate_char_str.pyfind_anagram_hash_function.pyfind_dice_probabilities.pyfind_top_N_recurring_words.pyruntime_dicts_with_timeit_module.pysetdeault_example.pyveirfy_two_strings_are_anagrams.py
lists_and_strings
24
README.md
24
README.md
|
@ -11,7 +11,7 @@ This repository contains a comprehensive study on Algorithms & Data Structures i
|
|||
|
||||
src/
|
||||
|
||||
├── abstract_structures
|
||||
└── abstract_structures
|
||||
|
||||
├── heap
|
||||
|
||||
|
@ -21,33 +21,19 @@ src/
|
|||
|
||||
└── stacks
|
||||
|
||||
├── builtin_structures
|
||||
|
||||
├── arrays_and_strings
|
||||
└── builtin_structures
|
||||
|
||||
├── dicts
|
||||
|
||||
├── lists
|
||||
├── lists_and_strings
|
||||
|
||||
├── numbers
|
||||
|
||||
├── sets
|
||||
|
||||
├── strings
|
||||
|
||||
└── tuples
|
||||
|
||||
├── graphs_and_trees
|
||||
|
||||
├── trees
|
||||
|
||||
├── programming_paradigms
|
||||
|
||||
├── dynamic_programming
|
||||
|
||||
├── modules
|
||||
|
||||
└── oop
|
||||
└── trees
|
||||
|
||||
└── searching_and_sorting
|
||||
|
||||
|
@ -57,6 +43,8 @@ src/
|
|||
|
||||
└── Extra Interview Problems
|
||||
|
||||
└── USEFUL
|
||||
|
||||
|
||||
----
|
||||
## Installation
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
__author__ = "bt3"
|
||||
|
||||
'''
|
||||
The doctest module automatically runs any statement begining with >>>
|
||||
The doctest module automatically runs any statement beginning with >>>
|
||||
and compares the following line with the output from the interpreter.
|
||||
|
||||
>>> 1 == 1
|
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/python3
|
||||
# mari von steinkirch @2013
|
||||
# steinkirch at gmail
|
||||
#!/usr/bin/python
|
||||
|
||||
__author__ = "bt3"
|
||||
|
||||
''' a simple example of how to time a function '''
|
||||
|
||||
import time
|
||||
|
||||
def sumOfN2(n):
|
||||
''' a simple example of how to time a function '''
|
||||
start = time.time()
|
||||
theSum = 0
|
||||
for i in range(1,n+1):
|
|
@ -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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
__author__ = "bt3"
|
||||
|
||||
|
||||
import collections
|
||||
import string
|
||||
import sys
|
|
@ -1,9 +1,14 @@
|
|||
#!/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)
|
||||
return collections.Counter(\
|
||||
sys.stdin.read().lower().split()).most_common(n)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
|
@ -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...]")
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
# mari von steinkirch @2013
|
||||
# steinkirch at gmail
|
||||
#!/usr/bin/env python
|
||||
|
||||
|
||||
__author__ = "bt3"
|
||||
|
||||
|
||||
|
||||
|
@ -46,8 +47,8 @@ def remove_blank_lines():
|
|||
lines = read_data(filename)
|
||||
if lines:
|
||||
write_data(lines, filename)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
remove_blank_lines()
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue