diff --git a/archive/p/python/Dockerfile b/archive/p/python/Dockerfile deleted file mode 100644 index 1de0169c5..000000000 --- a/archive/p/python/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -# Pull base image -FROM ubuntu - -# Install Python -RUN \ - apt-get update && \ - apt-get install -y python python-dev python-pip python-virtualenv && \ - rm -rf /var/lib/apt/lists/* - -# Define working directory -WORKDIR /data - -# Define default command -CMD ["bash"] diff --git a/archive/p/python/README.md b/archive/p/python/README.md index c5903e832..c1699d6b4 100644 --- a/archive/p/python/README.md +++ b/archive/p/python/README.md @@ -1,36 +1,36 @@ # Sample Programs in Python -Welcome to Sample Programs in Python! +Welcome to Sample Programs in Python! To find documentation related to the Python +code in this repo, look [here][trc-python-docs]. ## Sample Programs -- [Anagram in Python][40] - [Baklava in Python][22] - Solution borrowed from @erayak via the [baklava repo][21] - [Binary Search][31] - [Bubble Sort in Python][31] - Capitalize in Python +- [Convex Hull in Python][44] - [Even Odd in Python][32] - [Factorial in Python][33] - [Fibonacci Sequence in Python][24] - [File IO in Python][29] -- [Fizz Buzz in Python][1] -- [Game of Life in Python][4] -- [Hello World in Python][0] +- [Fizz Buzz in Python][fizz-buzz-article] +- [Game of Life in Python][game-of-life-article-issue] +- [Hello World in Python][hello-world-article] - [Insertion Sort in Python][34] -- [Job Sequencing with Deadlines in Python][30] +- [Job Sequencing with Deadlines in Python][job-sequencing-article-issue] - [Longest Common Subsequence][26] - [Longest Palindromic Subsequence][42] - [Merge Sort in Python][35] - [Minimum Spanning Tree][43] - [Prime Number in Python][36] - [Quick Sort in Python][37] -- [Quine in Python][3] -- [Reverse a String in Python][2] +- [Quine in Python][quine-article-issue] +- [Reverse a String in Python][reverse-a-string-article] - [Roman Numberal Conversion in Python][25] - [ROT-13 in Python][38] - [Selection Sort in Python][39] -- [Convex Hull in Python][44] - [Sleep sort in Python][45] ## Fun Facts @@ -103,19 +103,22 @@ Welcome to Sample Programs in Python! ## References -- [Python Wiki][6] -- [Python Docs][7] -- [Python REPL][8] +- [Python Wiki][python-wiki] +- [Python Docs][python-website] +- [Python REPL][python-online-repl] + +[fizz-buzz-article]: https://therenegadecoder.com/code/fizz-buzz-in-python/ +[game-of-life-article-issue]: https://github.com/jrg94/sample-programs/issues/111 +[hello-world-article]: https://therenegadecoder.com/code/hello-world-in-python/ +[job-sequencing-article-issue]: https://github.com/TheRenegadeCoder/sample-programs-website/issues/70 +[python-online-repl]: https://repl.it/languages/python3 +[python-website]: https://www.python.org/ +[python-wiki]: https://en.wikipedia.org/wiki/Python_(programming_language) +[reverse-a-string-article]: https://therenegadecoder.com/code/reverse-a-string-in-python/ +[trc-python-docs]: https://sample-programs.therenegadecoder.com/languages/python/ +[quine-article-issue]: https://github.com/TheRenegadeCoder/sample-programs-website/issues/223 -[0]: https://therenegadecoder.com/code/hello-world-in-python/ -[1]: https://therenegadecoder.com/code/fizz-buzz-in-python/ -[2]: https://therenegadecoder.com/code/reverse-a-string-in-python/ -[3]: https://github.com/jrg94/sample-programs/issues/319 -[4]: https://github.com/jrg94/sample-programs/issues/111 [5]: https://github.com/jrg94/sample-programs/blob/ed000670bc5ecd2778a65571752ec983be7a14e7/archive/p/python/fizz-buzz.py#L2 -[6]: https://en.wikipedia.org/wiki/Python_(programming_language) -[7]: https://www.python.org/ -[8]: https://repl.it/languages/python3 [9]: https://github.com/jrg94/sample-programs/blob/ed000670bc5ecd2778a65571752ec983be7a14e7/archive/p/python/fizz-buzz.py#L3 [10]: https://github.com/jrg94/sample-programs/blob/d91bd1c507723448314d18a377c1ac729172ddf6/archive/p/python/game-of-life.py#L24 [11]: https://github.com/jrg94/sample-programs/blob/d91bd1c507723448314d18a377c1ac729172ddf6/archive/p/python/game-of-life.py#L1 @@ -137,7 +140,6 @@ Welcome to Sample Programs in Python! [27]: https://github.com/Boot-Error/sample-programs/blob/ced2e54804d8f801aee2b37fee6f443a6432cb9b/archive/p/python/lcs.py#L16 [28]: https://github.com/Boot-Error/sample-programs/blob/ced2e54804d8f801aee2b37fee6f443a6432cb9b/archive/p/python/lcs.py#L17 [29]: https://therenegadecoder.com/code/file-io-in-python/ -[30]: https://github.com/TheRenegadeCoder/sample-programs/issues/765 [31]: https://github.com/TheRenegadeCoder/sample-programs/issues/811 [32]: https://github.com/TheRenegadeCoder/sample-programs/issues/849 [33]: https://github.com/TheRenegadeCoder/sample-programs/issues/852 @@ -147,7 +149,6 @@ Welcome to Sample Programs in Python! [37]: https://github.com/TheRenegadeCoder/sample-programs/issues/864 [38]: https://github.com/TheRenegadeCoder/sample-programs/issues/867 [39]: https://github.com/TheRenegadeCoder/sample-programs/issues/870 -[40]: https://github.com/TheRenegadeCoder/sample-programs/issues/1161 [41]: https://www.python.org/dev/peps/pep-0020/ [42]: https://github.com/TheRenegadeCoder/sample-programs/blob/master/archive/p/python/longest_palindrome_substring.py [43]: https://github.com/TheRenegadeCoder/sample-programs/issues/1536 @@ -167,4 +168,4 @@ Welcome to Sample Programs in Python! [57]: https://github.com/TheRenegadeCoder/sample-programs/blob/master/archive/p/python/binary_search.py#L15 [58]: https://github.com/TheRenegadeCoder/sample-programs/blob/master/archive/p/python/longest_palindrome_substring.py#L17 [59]: https://github.com/TheRenegadeCoder/sample-programs/blob/master/archive/p/python/prime_number.py#L7 -[60]: https://github.com/TheRenegadeCoder/sample-programs/blob/master/archive/p/python/rot_13.py#L7 \ No newline at end of file +[60]: https://github.com/TheRenegadeCoder/sample-programs/blob/master/archive/p/python/rot_13.py#L7 diff --git a/archive/p/python/anagram.py b/archive/p/python/anagram.py deleted file mode 100644 index 23e87e23f..000000000 --- a/archive/p/python/anagram.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -import sys - - -def anagram(str1, str2): - str1 = str1.replace(" ", "").lower() - str2 = str2.replace(" ", "").lower() - - # Edge case check - if len(str1) != len(str2): - return False - - count = {} - - for letter in str1: - if letter in count: - count[letter] += 1 - else: - count[letter] = 1 - - for letter in str2: - if letter in count: - count[letter] -= 1 - else: - count[letter] = 1 - - for k in count: - if count[k] != 0: - return False - - return True - - -def input_list(list_str): - return [x for x in list_str.split(',')][:2] - - -def exit_with_error(): - print('Usage: please provide two strings in the format "first_string,secondString"') - sys.exit(1) - - -def main(args): - try: - str1, str2 = input_list(args[0]) - print(anagram(str1, str2)) - except (IndexError,ValueError): - exit_with_error() - - -if __name__ == "__main__": - main(sys.argv[1:]) diff --git a/archive/p/python/first_non_repeating_character.py b/archive/p/python/first_non_repeating_character.py deleted file mode 100644 index 4f66fa641..000000000 --- a/archive/p/python/first_non_repeating_character.py +++ /dev/null @@ -1,24 +0,0 @@ -#First Non-Repeating Character -def fnrc(arr): - - #A copy of the given array - temp = list(arr) - - #A hash map to save the items and the number of times they appear - map = {i:0 for i in temp} - - #Adds one to each element in the hash every time they appear in the list - for x in temp: - map[x]+=1 - - #Iterates over the list and compares to the hash to see if some item appeared only one time - for x in temp: - if map[x]==1: return x - - #If not - return False - - - -print(fnrc(["a",1,2,1,2,"a",3,2,3,4,3,5,6,4,6])) -#Output: 5 diff --git a/archive/p/python/palindrome.py b/archive/p/python/palindrome.py deleted file mode 100644 index ed70c7f52..000000000 --- a/archive/p/python/palindrome.py +++ /dev/null @@ -1,8 +0,0 @@ -string = str(input("Enter the string:")) -L = len(string) -for i in range(L, 0, -1): - for j in range(L): - if string[i] == string[j]: - print("Palindrome.") - else: - print("Not Palindrome.") diff --git a/archive/p/python/zen_of_python.py b/archive/p/python/zen_of_python.py deleted file mode 100644 index 3024c9174..000000000 --- a/archive/p/python/zen_of_python.py +++ /dev/null @@ -1,25 +0,0 @@ -import this -#output -""" -The Zen of Python, by Tim Peters - -Beautiful is better than ugly. -Explicit is better than implicit. -Simple is better than complex. -Complex is better than complicated. -Flat is better than nested. -Sparse is better than dense. -Readability counts. -Special cases aren't special enough to break the rules. -Although practicality beats purity. -Errors should never pass silently. -Unless explicitly silenced. -In the face of ambiguity, refuse the temptation to guess. -There should be one-- and preferably only one --obvious way to do it. -Although that way may not be obvious at first unless you're Dutch. -Now is better than never. -Although never is often better than *right* now. -If the implementation is hard to explain, it's a bad idea. -If the implementation is easy to explain, it may be a good idea. -Namespaces are one honking great idea -- let's do more of those! -"""