From 36b52ed4673735a28a5eb6476029fa990541c878 Mon Sep 17 00:00:00 2001 From: Karan Goel Date: Tue, 13 May 2014 08:26:36 -0700 Subject: [PATCH] remove my solutions --- Classes/product_inventory.py | 80 ----------- Classic Algorithms/collatz.py | 29 ---- Numbers/alarm.py | 49 ------- Numbers/binary_decimal.py | 50 ------- Numbers/calc.py | 17 --- Numbers/change.py | 39 ------ Numbers/credit_card_validator.py | 41 ------ Numbers/distance.py | 55 -------- Numbers/factorial.py | 33 ----- Numbers/fibonacci.py | 15 -- Numbers/happy_numbers.py | 40 ------ Numbers/next_prime.py | 25 ---- Numbers/pi.py | 10 -- Numbers/prime.py | 23 --- Numbers/tax.py | 15 -- Numbers/tile.py | 11 -- Numbers/unit.py | 91 ------------ README-scratch.md | 234 ------------------------------- README.md | 100 +++++-------- Text/caesar_cipher.py | 40 ------ Text/count_vowels.py | 19 --- Text/count_words.py | 26 ---- Text/palindrome.py | 12 -- Text/piglatin.py | 37 ----- Text/reverse.py | 11 -- Text/rss.py | 29 ---- Web/page_scraper.py | 33 ----- Web/time.py | 25 ---- 28 files changed, 38 insertions(+), 1151 deletions(-) delete mode 100644 Classes/product_inventory.py delete mode 100644 Classic Algorithms/collatz.py delete mode 100644 Numbers/alarm.py delete mode 100644 Numbers/binary_decimal.py delete mode 100644 Numbers/calc.py delete mode 100644 Numbers/change.py delete mode 100644 Numbers/credit_card_validator.py delete mode 100644 Numbers/distance.py delete mode 100644 Numbers/factorial.py delete mode 100644 Numbers/fibonacci.py delete mode 100644 Numbers/happy_numbers.py delete mode 100644 Numbers/next_prime.py delete mode 100644 Numbers/pi.py delete mode 100644 Numbers/prime.py delete mode 100644 Numbers/tax.py delete mode 100644 Numbers/tile.py delete mode 100644 Numbers/unit.py delete mode 100644 README-scratch.md delete mode 100644 Text/caesar_cipher.py delete mode 100644 Text/count_vowels.py delete mode 100644 Text/count_words.py delete mode 100644 Text/palindrome.py delete mode 100644 Text/piglatin.py delete mode 100644 Text/reverse.py delete mode 100644 Text/rss.py delete mode 100644 Web/page_scraper.py delete mode 100644 Web/time.py diff --git a/Classes/product_inventory.py b/Classes/product_inventory.py deleted file mode 100644 index df1ef1afa..000000000 --- a/Classes/product_inventory.py +++ /dev/null @@ -1,80 +0,0 @@ -""" -Product Inventory Project - Create an application which manages -an inventory of products. Create a product class which has a -price, id, and quantity on hand. Then create an inventory class -which keeps track of various products and can sum up the inventory -value. -""" - -class Product: - - def __init__(self, price, pid, qty): - """ - Class constructor that needs a price, a product id, - and quantity. - """ - self.price = price - self.pid = pid - self.qty = qty - - def update_qty(self, qty, method='add'): - """ - Updates the quantity of produts. By default, adds the - passed quantity. Pass method as 'subtract' to subtract - the quantity. - """ - if method == 'add': - self.qty += qty - elif method == 'subtract': - self.qty = max(0, self.qty - qty) - - def print_product(self): - """ - Prints a single product. - """ - print '%d\t%s\t%.02f each' % (self.pid, self.qty, self.price) - -class Inventory: - - def __init__(self): - """ - Initializes the class instance. - """ - self.products = [] # list to hold all products - - def add(self, product): - """ - Adds a passed Product to the list of products. - """ - self.products.append(product) - - def print_inventory(self): - """ - Prints the current inventory, and the total value - of products. - """ - value = 0 - for product in self.products: - print '%d\t%s\t%.02f each' % (product.pid, - product.qty, - product.price) - value += (product.price * product.qty) - print '\nTotal value: %.02f' % value - -if __name__ == '__main__': - p1 = Product(1.4, 123, 5) - p2 = Product(1, 3432, 100) - p3 = Product(100.4, 2342, 99) - - - i = Inventory() - i.add(p1) - i.add(p2) - i.add(p3) - i.print_inventory() - - p1.update_qty(10) - i.print_inventory() - - p1.update_qty(10, method='subtract') - i.print_inventory() diff --git a/Classic Algorithms/collatz.py b/Classic Algorithms/collatz.py deleted file mode 100644 index 3881ea11e..000000000 --- a/Classic Algorithms/collatz.py +++ /dev/null @@ -1,29 +0,0 @@ -""" -Collatz Conjecture - Start with a number n > 1. -Find the number of steps it takes to reach one using -the following process: If n is even, divide it by 2. -If n is odd, multiply it by 3 and add 1. -""" - -def main(): - try: - n = int(raw_input('Enter a number: ')) - except ValueError: - print 'Enter only an integer value, n > 1.' - - steps = 0 - - print '\n%d' % n, - - while n > 1: - if n % 2 == 0: - n /= 2 - else: - n = (n * 3) + 1 - steps += 1 - print ' -> %d' % n, - - print '\n\n%d steps take to reach ONE.' % steps - -if __name__ == '__main__': - main() diff --git a/Numbers/alarm.py b/Numbers/alarm.py deleted file mode 100644 index 2d7be3678..000000000 --- a/Numbers/alarm.py +++ /dev/null @@ -1,49 +0,0 @@ -""" -Alarm Clock - A simple clock where it plays a sound after -X number of minutes/seconds or at a particular time. - -Dependencies: -pyglet - pip install pyglet -""" - -import time -import winsound -import pyglet - -def play(hh, mm): - not_alarmed = 1 - - while(not_alarmed): - cur_time = list(time.localtime()) # get the time right now - hour = cur_time[3] # find the hour - minute = cur_time[4] # and the minute - if hour == hh and minute == mm: - song = pyglet.media.load('bin/sound.wav') - song.play() # play the sound - pyglet.app.run() - not_alarmed = 0 # stop the loop - -if __name__ == '__main__': - - print """ - 1. Play sound after X minutes - 2. Play sound at an exact time - """ - choice = input('What do you want to do? ') - - if choice == 1: - mins = input('How many minutes from now? ') - hh_from_now = mins / 60 # if minutes > 60, this will adjust the hours - mm_from_now = mins % 60 # and then the minutes - cur_time = list(time.localtime()) # get the time right now - hour = cur_time[3] # find the current hour - minute = cur_time[4] # and the current minute - hh = (hour + hh_from_now+(minute+mm_from_now)/60) % 24 # cycle through the clock if hh > 24 - mm = (minute + mm_from_now) % 60 # cycle through the clock if mm > 60 - play(hh, mm) - elif choice == 2: - hh = input('What hour do you want to wake up (0-23)? ') - mm = input('What minute do you want to wake up (0-59)? ') - play(hh, mm) - diff --git a/Numbers/binary_decimal.py b/Numbers/binary_decimal.py deleted file mode 100644 index b6846b726..000000000 --- a/Numbers/binary_decimal.py +++ /dev/null @@ -1,50 +0,0 @@ -""" -Binary to Decimal and Back Converter -Develop a converter to convert a decimal number to binary -or a binary number to its decimal equivalent. -""" - -def binary_to_decimal(binary): - """ - Converts a binary number into a decimal number. - """ - decimal = 0 - index = 0 - while binary > 0: - last = binary % 10 - binary = binary / 10 - decimal += (last * (2 ** index)) - index += 1 - return decimal - -def decimal_to_binary(decimal): - """ - Converts a decimal number into a binary number. - """ - binary = "" - remainders = [] - while decimal > 0: - remainders.append(str(decimal % 2)) - decimal /= 2 - remainders.reverse() - binary = "".join(remainders) - return 0 if binary == "" else binary - -if __name__ == '__main__': - print """ - 1. Binary to Decimal - 2. Decimal to Binary\n - """ - - choice = input("Make a choice: ") - - if choice == 1: - binary = input("Binary to convert: ") - print "The binary number %d in decimal is %d" % \ - (binary, binary_to_decimal(binary)) - elif choice == 2: - decimal = input("Decimal to convert: ") - print "The decimal number %d in binary is %s" % \ - (decimal, decimal_to_binary(decimal)) - else: - print "Invalid choice" diff --git a/Numbers/calc.py b/Numbers/calc.py deleted file mode 100644 index e6ea5f7f2..000000000 --- a/Numbers/calc.py +++ /dev/null @@ -1,17 +0,0 @@ -""" -Calculator - A simple calculator to do basic operators. -""" - -if __name__ == '__main__': - try: - num1 = int(raw_input("Number 1: ")) - num2 = int(raw_input("Number 2: ")) - except: - print 'Invalid input' - else: - op = raw_input("Operation (+, -, /, *): ") - if op not in '+-/*': - print "Invalid operator" - else: - print "%d %s %d = %d" % \ - (num1, op, num2, eval(str(num1) + op + str(num2))) diff --git a/Numbers/change.py b/Numbers/change.py deleted file mode 100644 index 8bce7273e..000000000 --- a/Numbers/change.py +++ /dev/null @@ -1,39 +0,0 @@ -# Change Return Program - The user enters a cost and -# then the amount of money given. The program will figure -# out the change and the number of quarters, dimes, nickels, -# pennies needed for the change. - -if __name__ == '__main__': - cost = input("What's the cost in dollars? ") - given = input("What's the amount of dollars given? ") - - change = given - cost - - print "\n" - if change < 0: - print "Please ask for $%.2f more from the customer." % (-change) # double negation - else: - print "The change is $%.2f." % change - - q = 0 # 0.25 - d = 0 # 0.10 - n = 0 # 0.05 - p = 0 # 0.01 - - change = int(change * 100) # let's talk about cents - - if change >= 25: - q = int(change / 25) - change = change % 25 - if change >= 10: - d = int(change / 10) - change = change % 10 - if change >= 5: - n = int(change / 5) - change = change % 5 - if change >= 1: - p = change # rest all change is in pennies - - print "Give the following change to the customer:" - print "Quarters: %d\tDimes: %d\tNickels: %d\tPennies: %d" \ - % (q, d, n, p) diff --git a/Numbers/credit_card_validator.py b/Numbers/credit_card_validator.py deleted file mode 100644 index fb4e8fc95..000000000 --- a/Numbers/credit_card_validator.py +++ /dev/null @@ -1,41 +0,0 @@ -""" -Credit Card Validator - Takes in a credit card number from a -common credit card vendor (Visa, MasterCard, American Express, -Discoverer) and validates it to make sure that it is a valid -number (look into how credit cards use a checksum). - -This program works with *most* credit card numbers. - -Uses Luhn Algorithm (http://en.wikipedia.org/wiki/Luhn_algorithm). - -1. From the rightmost digit, which is the check digit, moving -left, double the value of every second digit; if product of this -doubling operation is greater than 9 (e.g., 7 * 2 = 14), then -sum the digits of the products (e.g., 10: 1 + 0 = 1, 14: 1 + 4 = 5). - -2. Add together doubled digits with the undoubled digits from the -original number. - -3. If the total modulo 10 is equal to 0 (if the total ends in zero) -then the number is valid according to the Luhn formula; else it is -not valid. -""" - -if __name__ == '__main__': - number = raw_input('Enter the credit card number of check: ').replace(' ', '') - #if not number.isdigit(): - # raise Exception('Invalid credit card number. Make sure it\'s all digits (with optional spaces in between).' - - digits = [int(char) for char in number] - - # double alternate digits (step 1) - doubled = [(digit * 2) if (i % 2 == 0) else digit \ - for (i, digit) in enumerate(digits)] # i <3 python - # sum digits of number > 10 (step 2) - summed = [num if num < 10 else sum([int(dig) for dig in str(num)]) \ - for num in doubled] # i <3 python ** 2 - # step 3 - if sum(summed) % 10 == 0: - print 'The number is valid' - else: - print 'The number is invalid' diff --git a/Numbers/distance.py b/Numbers/distance.py deleted file mode 100644 index 65cfc9a9b..000000000 --- a/Numbers/distance.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python - -""" -Distance Between Two Cities - Calculates the distance between -two cities and allows the user to specify a unit of distance. -This program may require finding coordinates for the cities -like latitude and longitude. - -Uses the Haversine formula -(http://www.movable-type.co.uk/scripts/latlong.html) - -Dependencies: -geopy - pip install geopy -""" - -from geopy import geocoders # to find lat/lon for the city -import math - -R = 6373 # km - -city1 = raw_input('Enter city 1: ') -city2 = raw_input('Enter city 2: ') -unit = raw_input('Enter unit of distance (Enter "K" for KM or "M" for MI): ').lower() - -if unit in 'km': - - g = geocoders.GoogleV3() - - try: - city1, (lat1, lon1) = g.geocode(city1) - city2, (lat2, lon2) = g.geocode(city2) - except: - raise Exception('Unable to locate the citites. Check the city names.') - - # convert decimal locations to radians - lat1 = math.radians(lat1) - lon1 = math.radians(lon1) - lat2 = math.radians(lat2) - lon2 = math.radians(lon2) - - # start haversne formula - dlon = lon2 - lon1 - dlat = lat2 - lat1 - a = (math.sin(dlat/2) ** 2) + math.cos(lat1) * math.cos(lat2) * \ - (math.sin(dlon/2) ** 2) - c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)) - d = R * c - - if unit == 'k': - print 'Distance between %s and %s is %.04f km' % (city1, city2, d) - else: - print 'Distance between %s and %s is %.04f mi' % (city1, city2, d / 1.60934) -else: - print 'Invalid unit input!' diff --git a/Numbers/factorial.py b/Numbers/factorial.py deleted file mode 100644 index cd8e753fc..000000000 --- a/Numbers/factorial.py +++ /dev/null @@ -1,33 +0,0 @@ -""" -Factorial Finder - The Factorial of a positive integer, n, -is defined as the product of the sequence n, n-1, n-2, ...1 -and the factorial of zero, 0, is defined as being 1. Solve -this using both loops and recursion. -""" - -def fact_loop(n): - """ - Returns the factorial of a given positive, non-zero integer - using loops. - """ - fact = 1 - while n > 0: - fact *= n - n -= 1 - return fact - -def fact_recursion(n): - """ - Returns the factorial of a given positive, non-zero integer - using recursion. - """ - return 1 if n == 0 else n * fact_recursion(n - 1) # if user as ternary operator - -if __name__ == '__main__': - n = input('Enter a positive number: ') - - if n >= 0: - print 'Factorial of %d by loops is %d' % (n, fact_loop(n)) - print 'Factorial of %d by recursion is %d' % (n, fact_recursion(n)) - else: - print 'Not a valid number' diff --git a/Numbers/fibonacci.py b/Numbers/fibonacci.py deleted file mode 100644 index 2c239b48d..000000000 --- a/Numbers/fibonacci.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: cp1252 -*- -# Fibonacci Sequence - Enter a number and have the -# program generate the Fibonacci sequence to that number -# or to the Nth number - -n = int(raw_input('How many numbers do you need? ')) -series = [1] - -while len(series) < n: - if len(series) == 1: - series.append(1) - else: - series.append(series[-1] + series[-2]) - -print series diff --git a/Numbers/happy_numbers.py b/Numbers/happy_numbers.py deleted file mode 100644 index a50f05f92..000000000 --- a/Numbers/happy_numbers.py +++ /dev/null @@ -1,40 +0,0 @@ -""" -Happy Numbers - A happy number is defined by the -following process. Starting with any positive integer, -replace the number by the sum of the squares of its -digits, and repeat the process until the number equals -1 (where it will stay), or it loops endlessly in a -cycle which does not include 1. Those numbers for which -this process ends in 1 are happy numbers, while those -that do not end in 1 are unhappy numbers. Take an input -number from user, and find first 8 happy numbers from -that input. -""" - -NUMBERS_REQUIRED = 8 # number of happy numbers required - -def is_happy_number(num): - seen = [] - while True: - sum_digits = sum(int(digit) ** 2 for digit in str(num)) - if sum_digits == 1: - return True - elif sum_digits in seen: - return False - else: - num = sum_digits - seen.append(num) - -if __name__ == '__main__': - - happies = [] # list of happy numbers found - - num = input('Start at: ') - - while len(happies) != NUMBERS_REQUIRED: - if is_happy_number(num): - happies.append(num) - num += 1 - - print happies - diff --git a/Numbers/next_prime.py b/Numbers/next_prime.py deleted file mode 100644 index 3d479bd07..000000000 --- a/Numbers/next_prime.py +++ /dev/null @@ -1,25 +0,0 @@ -# Next Prime Number - Have the program find prime -# numbers until the user chooses to stop asking for -# the next one. - -def next_prime(current): - next_prime = current + 1 # start checking for primes 1 number after the current one - i = 2 - while next_prime > i: # check with numbers up to next_prime - 1 - if next_prime % i == 0: # if number is divisible - next_prime += 1 # ready to check the next number - i = 2 # reset i to check divisibility again from 2 - else: - i += 1 # increment the divisor - return next_prime - -if __name__ == '__main__': - current_prime = 2 - while True: - response = raw_input('Do you want the next prime? (Y/N) ') - - if response.lower().startswith('y'): - print current_prime - current_prime = next_prime(current_prime) - else: - break diff --git a/Numbers/pi.py b/Numbers/pi.py deleted file mode 100644 index 027c63e50..000000000 --- a/Numbers/pi.py +++ /dev/null @@ -1,10 +0,0 @@ -# Find PI to the Nth Digit - -from math import * - -digits = raw_input('Enter number of digits to round PI to: ') - -# print ('{0:.%df}' % min(20, int(digits))).format(math.pi) # nested string formatting - -# calculate pi using Machin-like Formula -print ('{0:.%df}' % min(30, int(digits))).format(4 * (4 * atan(1.0/5.0) - atan(1.0/239.0))) diff --git a/Numbers/prime.py b/Numbers/prime.py deleted file mode 100644 index ffa1ea83c..000000000 --- a/Numbers/prime.py +++ /dev/null @@ -1,23 +0,0 @@ -# Prime Factorization - Have the user enter a number -# and find all Prime Factors (if there are any) and -# display them. - - -def is_a_prime(x): - for i in range(2, x): - if x % i == 0: - return False - return True - -# standard boilerplate -if __name__ == '__main__': - n = int(raw_input('Enter the number to find prime factors of: ')) - - factors = [] - - for i in range(2, n + 1): - while n % i == 0: # Thanks @madsulrik - if is_a_prime(i): - factors.append(i) - n /= i - print factors diff --git a/Numbers/tax.py b/Numbers/tax.py deleted file mode 100644 index 76ccf776a..000000000 --- a/Numbers/tax.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -TAXES = { - 'WA': 9.5, - 'CA': 7.5, - 'FL': 10.8, - 'OH': 7.8 -} - -state = raw_input('What\'s your state (WA / CA / FL / OH)?: ') -cost = float(raw_input('And the cost?: ')) - -tax = TAXES[state] / 100 * cost - -print 'Cost: %.02f\nTax: %.02f\n----------\nTotal: %.02f' % (cost, tax, cost + tax) \ No newline at end of file diff --git a/Numbers/tile.py b/Numbers/tile.py deleted file mode 100644 index 1b5b23408..000000000 --- a/Numbers/tile.py +++ /dev/null @@ -1,11 +0,0 @@ -# Find Cost of Tile to Cover W x H Floor - Calculate -# the total cost of tile it would take to cover a floor -# plan of width and height, using a cost entered by the user. - -# Use input as the input can be integer and float -cost = input("What's the cost per sq. feet? ") -width = input("What's the width of the floor? ") -height = input("What's the height of the floor? ") - -print "The total cost is $%.2f for %.2f square feet" \ - % (width * height * cost, width * height) diff --git a/Numbers/unit.py b/Numbers/unit.py deleted file mode 100644 index 383044e99..000000000 --- a/Numbers/unit.py +++ /dev/null @@ -1,91 +0,0 @@ -""" -Unit Converter (temp, currency, volume, mass and more) - Converts -various units between one another. The user enters the type of unit -being entered, the type of unit they want to convert to and then -the value. The program will then make the conversion. -""" - -from __future__ import division -from urllib2 import urlopen -import json - -# 1 (std unit) = these many units -MULTIPLIERS_TO_STD = { - 'length': { - 'cm': 0.01, - 'm': 1, # std unit - 'km': 1000, - 'mi': 1609.34, - 'ft': 0.3048 - }, - 'temp': { - 'C': 1, # std unit - 'F': 33.8 - } -} - -# These many units = 1 (std unit) -MULTIPLIERS_FROM_STD = { - 'length': { - 'cm': 100, - 'm': 1, # std unit - 'km': 0.001, - 'mi': 0.000621371, - 'ft': 3.28084 - }, - 'temp': { - 'C': 1, # std unit - 'F': -17.2222 - } -} - - -def get_user_input(choice): - units = ', '.join(MULTIPLIERS_TO_STD[choice].keys()) - source_unit = raw_input('\nEnter source unit (%s): ' % units) - source_val = float(raw_input('How many %s\'s? ' % source_unit)) - convert_to = raw_input('Convert to? (%s): ' % units) - return source_unit, source_val, convert_to - -def get_currency(source_unit, source_val, convert_to): - url = 'http://rate-exchange.appspot.com/currency?from=%s&to=%s&q=%s' % ( - source_unit, convert_to, str(source_val)) - content = urlopen(url).read() - return json.loads(content)['v'] - -def main(): - print """Unit Converter - 1. Length - 2. Temperature - 3. Currency""" - - choice = int(raw_input('What do you want to convert: ')) - - if choice == 1: - source_unit, source_val, convert_to = get_user_input('length') - print '%f%s = %f%s' % (source_val, source_unit, - source_val * \ - MULTIPLIERS_TO_STD['length'][source_unit] * \ - MULTIPLIERS_FROM_STD['length'][convert_to], \ - convert_to) - elif choice == 2: - source_unit, source_val, convert_to = get_user_input('temp') - if (source_unit, convert_to) == ('F', 'C'): # F -> C - value = (source_val - 32) * (5/9) - elif (source_unit, convert_to) == ('C', 'F'): # C -> F - value = (source_val * (9/5)) + 32 - else: - value = source_val - print '%f%s = %f%s' % (source_val, source_unit, - value, convert_to) - - elif choice == 3: - source_unit = raw_input('\nEnter source currency (eg USD, INR etc): ') - source_val = float(raw_input('How many %s\'s? ' % source_unit)) - convert_to = raw_input('Convert to? (eg USD, INR etc): ') - print '%f%s = %f%s' % (source_val, source_unit, - get_currency(source_unit, source_val, convert_to), - convert_to) - -if __name__ == '__main__': - main() diff --git a/README-scratch.md b/README-scratch.md deleted file mode 100644 index 9be6373b3..000000000 --- a/README-scratch.md +++ /dev/null @@ -1,234 +0,0 @@ -Mega Project List -======== - -Numbers ---------- - -**Find PI to the Nth Digit** - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go. - -**Fibonacci Sequence** - Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number. - -**Prime Factorization** - Have the user enter a number and find all Prime Factors (if there are any) and display them. - -**Next Prime Number** - Have the program find prime numbers until the user chooses to stop asking for the next one. - -**Find Cost of Tile to Cover W x H Floor** - Calculate the total cost of tile it would take to cover a floor plan of width and height, using a cost entered by the user. - -**Mortgage Calculator** - Calculate the monthly payments of a fixed term mortgage over given Nth terms at a given interest rate. Also figure out how long it will take the user to pay back the loan. - -**Change Return Program** - The user enters a cost and then the amount of money given. The program will figure out the change and the number of quarters, dimes, nickels, pennies needed for the change. - -**Binary to Decimal and Back Converter** - Develop a converter to convert a decimal number to binary or a binary number to its decimal equivalent. - -**Calculator** - A simple calculator to do basic operators. Make it a scientific calculator for added complexity. - -**Unit Converter (temp, currency, volume, mass and more)** - Converts various units between one another. The user enters the type of unit being entered, the type of unit they want to convert to and then the value. The program will then make the conversion. - -**Alarm Clock** - A simple clock where it plays a sound after X number of minutes/seconds or at a particular time. - -**Distance Between Two Cities** - Calculates the distance between two cities and allows the user to specify a unit of distance. This program may require finding coordinates for the cities like latitude and longitude. - -**Credit Card Validator** - Takes in a credit card number from a common credit card vendor (Visa, MasterCard, American Express, Discoverer) and validates it to make sure that it is a valid number (look into how credit cards use a checksum). - -**Tax Calculator** - Asks the user to enter a cost and either a country or state tax. It then returns the tax plus the total cost with tax. - -**Factorial Finder** - The Factorial of a positive integer, n, is defined as the product of the sequence n, n-1, n-2, ...1 and the factorial of zero, 0, is defined as being 1. Solve this using both loops and recursion. - -**Complex Number Algebra** - Show addition, multiplication, negation, and inversion of complex numbers in separate functions. (Subtraction and division operations can be made with pairs of these operations.) Print the results for each operation tested. - -**Happy Numbers** - A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers. Display an example of your output here. Find first 8 happy numbers. - -**Number Names** - Show how to spell out a number in English. You can use a preexisting implementation or roll your own, but you should support inputs up to at least one million (or the maximum value of your language's default bounded integer type, if that's less). *Optional: Support for inputs other than positive integers (like zero, negative integers, and floating-point numbers).* - -**Coin Flip Simulation** - Write some code that simulates flipping a single coin however many times the user decides. The code should record the outcomes and count the number of tails and heads. - -Classic Algorithms ------------------ - -**Collatz Conjecture** - Start with a number *n > 1*. Find the number of steps it takes to reach one using the following process: If *n* is even, divide it by 2. If *n* is odd, multiply it by 3 and add 1. - -**Sorting** - Implement two types of sorting algorithms: Merge sort and bubble sort. - -**Closest pair problem** - The closest pair of points problem or closest pair problem is a problem of computational geometry: given *n* points in metric space, find a pair of points with the smallest distance between them. - -**Sieve of Eratosthenes** - The sieve of Eratosthenes is one of the most efficient ways to find all of the smaller primes (below 10 million or so). - - -Graph --------- -**Graph from links** - Create a program that will create a graph or network from a series of links. - -**Eulerian Path** - Create a program which will take as an input a graph and output either a Eulerian path or a Eulerian cycle, or state that it is not possible. A Eulerian Path starts at one node and traverses every edge of a graph through every node and finishes at another node. A Eulerian cycle is a eulerian Path that starts and finishes at the same node. - -**Connected Graph** - Create a program which takes a graph as an input and outputs whether every node is connected or not. - -**Dijkstra’s Algorithm** - Create a program that finds the shortest path through a graph using its edges. - -Data Structures ---------- - -**Inverted index** - An [Inverted Index](http://en.wikipedia.org/wiki/Inverted_index) is a data structure used to create full text search. Given a set of text files, implement a program to create an inverted index. Also create a user interface to do a search using that inverted index which returns a list of files that contain the query term / terms. The search index can be in memory. - - -Text ---------- - -**Reverse a String** - Enter a string and the program will reverse it and print it out. - -**Pig Latin** - Pig Latin is a game of alterations played on the English language game. To create the Pig Latin form of an English word the initial consonant sound is transposed to the end of the word and an ay is affixed (Ex.: "banana" would yield anana-bay). Read Wikipedia for more information on rules. - -**Count Vowels** - Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found. - -**Check if Palindrome** - Checks if the string entered by the user is a palindrome. That is that it reads the same forwards as backwards like “racecar” - -**Count Words in a String** - Counts the number of individual words in a string. For added complexity read these strings in from a text file and generate a summary. - -**Text Editor** - Notepad style application that can open, edit, and save text documents. *Optional: Add syntax highlighting and other features.* - -**RSS Feed Creator** - Given a link to RSS/Atom Feed, get all posts and display them. - -**Post it Notes Program** - A program where you can add text reminders and post them. *Optional: You can have the program also add popup reminders.* - -**Quote Tracker (market symbols etc)** - A program which can go out and check the current value of stocks for a list of symbols entered by the user. The user can set how often the stocks are checked. For CLI, show whether the stock has moved up or down. *Optional: If GUI, the program can show green up and red down arrows to show which direction the stock value has moved.* - -**Guestbook / Journal** - A simple application that allows people to add comments or write journal entries. It can allow comments or not and timestamps for all entries. Could also be made into a shout box. *Optional: Deploy it on Google App Engine or Heroku or any other PaaS (if possible, of course).* - -**Fortune Teller (Horoscope)** - A program that checks your horoscope on various astrology sites and puts them together for you each day. - -**Vigenere / Vernam / Ceasar Ciphers** - Functions for encrypting and decrypting data messages. Then send them to a friend. - -**Random Gift Suggestions** - Enter various gifts for certain people when you think of them. When its time to give them a gift (xmas, birthday, anniversary) it will randomly pick one. *Optional: Suggest places you can get it (link to Amazon page?).* - -**Markdown to HTML Converter** - Converts Markdown formatted text into HTML files. Implement basic tags like `p`, `strong`, `em` etc. *Optional: Implement all tags from [Markdown Syntax Docs](http://daringfireball.net/projects/markdown/syntax).* - -**Regex Query Tool** - A tool that allows the user to enter a text string and then in a separate control enter a regex pattern. It will run the regular expression against the source text and return any matches or flag errors in the regular expression. - -Networking ---------- - -**FTP Program** - A file transfer program which can transfer files back and forth from a remote web sever. - -**Bandwidth Monitor** - A small utility program that tracks how much data you have uploaded and downloaded from the net during the course of your current online session. See if you can find out what periods of the day you use more and less and generate a report or graph that shows it. - -**Port Scanner** - Enter an IP address and a port range where the program will then attempt to find open ports on the given computer by connecting to each of them. On any successful connections mark the port as open. - -**Mail Checker (POP3 / IMAP)** - The user enters various account information include web server and IP, protocol type (POP3 or IMAP) and the application will check for email at a given interval. - -**Country from IP Lookup** - Enter an IP address and find the country that IP is registered in. *Optional: Find the Ip automatically.* - -**Whois Search Tool** - Enter an IP or host address and have it look it up through whois and return the results to you. - -**Site Checker with Time Scheduling** - An application that attempts to connect to a website or server every so many minutes or a given time and check if it is up. If it is down, it will notify you by email or by posting a notice on screen. - -Classes ---------- - -**Product Inventory Project** - Create an application which manages an inventory of products. Create a product class which has a price, id, and quantity on hand. Then create an *inventory* class which keeps track of various products and can sum up the inventory value. - -**Airline / Hotel Reservation System** - Create a reservation system which books airline seats or hotel rooms. It charges various rates for particular sections of the plane or hotel. Example, first class is going to cost more than coach. Hotel rooms have penthouse suites which cost more. Keep track of when rooms will be available and can be scheduled. - -**Bank Account Manager** - Create a class called Account which will be an abstract class for three other classes called CheckingAccount, SavingsAccount and BusinessAccount. Manage credits and debits from these accounts through an ATM style program. - -**Patient / Doctor Scheduler** - Create a patient class and a doctor class. Have a doctor that can handle multiple patients and setup a scheduling program where a doctor can only handle 16 patients during an 8 hr work day. - -**Recipe Creator and Manager** - Create a recipe class with ingredients and a put them in a recipe manager program that organizes them into categories like deserts, main courses or by ingredients like chicken, beef, soups, pies etc. - -**Image Gallery** - Create an image abstract class and then a class that inherits from it for each image type. Put them in a program which displays them in a gallery style format for viewing. - -**Shape Area and Perimeter Classes** - Create an abstract class called Shape and then inherit from it other shapes like diamond, rectangle, circle, triangle etc. Then have each class override the area and perimeter functionality to handle each shape type. - -**Flower Shop Ordering To Go** - Create a flower shop application which deals in flower objects and use those flower objects in a bouquet object which can then be sold. Keep track of the number of objects and when you may need to order more. - -**Family Tree Creator** - Create a class called Person which will have a name, when they were born and when (and if) they died. Allow the user to create these Person classes and put them into a family tree structure. Print out the tree to the screen. - -Threading ---------- - -**Create A Progress Bar for Downloads** - Create a progress bar for applications that can keep track of a download in progress. The progress bar will be on a separate thread and will communicate with the main thread using delegates. - -**Bulk Thumbnail Creator** - Picture processing can take a bit of time for some transformations. Especially if the image is large. Create an image program which can take hundreds of images and converts them to a specified size in the background thread while you do other things. For added complexity, have one thread handling re-sizing, have another bulk renaming of thumbnails etc. - -Web ---------- - -**Page Scraper** - Create an application which connects to a site and pulls out all links, or images, and saves them to a list. *Optional: Organize the indexed content and don’t allow duplicates. Have it put the results into an easily searchable index file.* - -**Web Browser with Tabs** - Create a small web browser that allows you to navigate the web and contains tabs which can be used to navigate to multiple web pages at once. For simplicity don’t worry about executing Javascript or other client side code. - -**Online White Board** - Create an application which allows you to draw pictures, write notes and use various colors to flesh out ideas for projects. *Optional: Add feature to invite friends to collaborate on a white board online.* - -**Get Atomic Time from Internet Clock** - This program will get the true atomic time from an atomic time clock on the Internet. Use any one of the atomic clocks returned by a simple Google search. - -**Fetch Current Weather** - Get the current weather for a given zip/postal code. *Optional: Try locating the user automatically.* - -**Scheduled Auto Login and Action** - Make an application which logs into a given site on a schedule and invokes a certain action and then logs out. This can be useful for checking web mail, posting regular content, or getting info for other applications and saving it to your computer. - -**E-Card Generator** - Make a site that allows people to generate their own little e-cards and send them to other people. Do not use Flash. Use a picture library and perhaps insightful mottos or quotes. - -**Content Management System** - Create a content management system (CMS) like Joomla, Drupal, PHP Nuke etc. Start small. *Optional: Allow for the addition of modules/addons.* - -**Web Board (Forum)** - Create a forum for you and your buddies to post, administer and share thoughts and ideas. - -**CAPTCHA Maker** - Ever see those images with letters a numbers when you signup for a service and then asks you to enter what you see? It keeps web bots from automatically signing up and spamming. Try creating one yourself for online forms. - -Files ---------- - -**Quiz Maker** - Make an application which takes various questions form a file, picked randomly, and puts together a quiz for students. Each quiz can be different and then reads a key to grade the quizzes. - -**File Explorer** - Create your own simple windows explorer program. Add feature(s) you always thought are missing from MS Windows Explorer or Mac Finder. - -**Sort Excel/CSV File Utility** - Reads a file of records, sorts them, and then writes them back to the file. Allow the user to choose various sort style and sorting based on a particular field. - -**Create Zip File Maker** - The user enters various files from different directories and the program zips them up into a zip file. *Optional: Apply actual compression to the files. Start with Huffman Algorithm.* - -**PDF Generator** - An application which can read in a text file, html file or some other file and generates a PDF file out of it. Great for a web based service where the user uploads the file and the program returns a PDF of the file. *Optional: Deploy on GAE or Heroku if possible.* - -**Mp3 Tagger** - Modify and add ID3v1 tags to MP3 files. See if you can also add in the album art into the MP3 file’s header as well as other ID3v2 tags. - -**Code Snippet Manager** - Another utility program that allows coders to put in functions, classes or other tidbits to save for use later. Organized by the type of snippet or language the coder can quickly look up code. *Optional: For extra practice try adding syntax highlighting based on the language.* - -Databases ---------- - -**SQL Query Analyzer** - A utility application which a user can enter a query and have it run against a local database and look for ways to make it more efficient. - -**Remote SQL Tool** - A utility that can execute queries on remote servers from your local computer across the Internet. It should take in a remote host, user name and password, run the query and return the results. - -**Report Generator** - Create a utility that generates a report based on some tables in a database. Generates a sales reports based on the order/order details tables or sums up the days current database activity. - -**Event Scheduler and Calendar** - Make an application which allows the user to enter a date and time of an event, event notes and then schedule those events on a calendar. The user can then browse the calendar or search the calendar for specific events. *Optional: Allow the application to create re-occurrence events that reoccur every day, week, month, year etc.* - -**Budget Tracker** - Write an application that keeps track of a household’s budget. The user can add expenses, income, and recurring costs to find out how much they are saving or losing over a period of time. *Optional: Allow the user to specify a date range and see the net flow of money in and out of the house budget for that time period.* - -**Address Book** - Keep track of various contacts, their numbers, emails and little notes about them like a Rolodex in the database. - -**TV Show Tracker** - Got a favorite show you don’t want to miss? Don’t have a PVR or want to be able to find the show to then PVR it later? Make an application which can search various online TV Guide sites, locate the shows/times/channels and add them to a database application. The database/website then can send you email reminders that a show is about to start and which channel it will be on. - -**Travel Planner System** - Make a system that allows users to put together their own little travel itinerary and keep track of the airline / hotel arrangements, points of interest, budget and schedule. - -Graphics and Multimedia ---------- - -**Slide Show** - Make an application that shows various pictures in a slide show format. *Optional: Try adding various effects like fade in/out, star wipe and window blinds transitions.* - -**Stream Video from Online** - Try to create your own online streaming video player. - -**Mp3 Player** - A simple program for playing your favorite music files. Add features you though are missing from your favorite music player. - -**Watermarking Application** - Have some pictures you want copyright protected? Add your own logo or text lightly across the background so that no one can simply steal your graphics off your site. Make a program that will add this watermark to the picture. *Optional: Use threading to process multiple images simultaneously.* - -**Turtle Graphics** - This is a common project where you create a floor of 20 x 20 squares. Using various commands you tell a turtle to draw a line on the floor. You have move forward, left or right, lift or drop pen etc. Do a search online for "Turtle Graphics" for more information. *Optional: Allow the program to read in the list of commands from a file.* - -Security -------------- - -**Caesar cipher** - Implement a Caesar cipher, both encoding and decoding. The key is an integer from 1 to 25. This cipher rotates the letters of the alphabet (A to Z). The encoding replaces each letter with the 1st to 25th next letter in the alphabet (wrapping Z to A). So key 2 encrypts "HI" to "JK", but key 20 encrypts "HI" to "BC". This simple "monoalphabetic substitution cipher" provides almost no security, because an attacker who has the encoded message can either use frequency analysis to guess the key, or just try all 25 keys. - -=============================================== - -Sources -======= - -* [Martyr2’s Mega Project List](http://www.dreamincode.net/forums/topic/78802-martyr2s-mega-project-ideas-list/) -* [Rosetta Code](http://rosettacode.org/) diff --git a/README.md b/README.md index afd482ad6..4e14db857 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,21 @@ Mega Project List ======== -A list of practical projects that anyone can solve in any programming language (See [solutions](https://github.com/thekarangoel/Projects-Solutions)). These projects are divided in multiple categories, and each category has it's own folder. +A list of practical projects that anyone can solve in any programming language (See [solutions](https://github.com/thekarangoel/Projects-Solutions)). These projects are divided in multiple categories, and each category has it's own folder. + +To get started, simply fork this repo. -#### [RECOGNITION](https://github.com/thekarangoel/Projects/tree/master/RECOGNITION) +## [CONTRIBUTING](https://github.com/thekarangoel/Projects/blob/master/CONTRIBUTING.md) -Ever since this repo was created, it has been in the top list on GH. Be it the daily or weekly list! This repo is in the top 5 on GitHub on [July 14 2013](https://raw.github.com/thekarangoel/Projects/master/RECOGNITION/top5-2013-07-14.png). (And again on [July 22, 2013](https://raw.github.com/thekarangoel/Projects/master/RECOGNITION/top5-2013-07-22%2013_10_30.png), and again on [July 23, 2013](https://raw.github.com/thekarangoel/Projects/master/RECOGNITION/top5-2013-07-23.png).) And on [weekly](https://raw.github.com/thekarangoel/Projects/master/RECOGNITION/top5-weekly-2013-07-22.png) [list](https://github.com/thekarangoel/Projects/blob/master/RECOGNITION/top5-weekly-2013-07-23.png) during the week of July 2013. In the last week of July, *Projects* was in the monthly top list on GH. +See ways of [contributing](https://github.com/thekarangoel/Projects/blob/master/CONTRIBUTING.md) to this repo. You can contribute **solutions** (will be published in this [repo](https://github.com/thekarangoel/Projects-Solutions)) to existing problems, **add new projects** or remove existing ones. Make sure you follow all instructions properly. -![July 25, 2013](https://raw.github.com/thekarangoel/Projects/master/RECOGNITION/top5-monthly-2013-07-25.png) -=============================== +## [Solutions](https://github.com/thekarangoel/Projects-Solutions) -### [CONTRIBUTING](https://github.com/thekarangoel/Projects/blob/master/CONTRIBUTING.md) +You can find implementations of these projects in many other languages by other users in [this repo](https://github.com/thekarangoel/Projects-Solutions). -See ways of [contributing](https://github.com/thekarangoel/Projects/blob/master/CONTRIBUTING.md) to this repo. You can contribute solutions (will be published in this [repo](https://github.com/thekarangoel/Projects-Solutions)) to existing problems, add new projects or remove existing ones. Make sure you follow all instructions properly. -================================ - -### [Solutions](https://github.com/thekarangoel/Projects-Solutions) - -You can find implementations of these projects in many other languages by other users in this [repo](https://github.com/thekarangoel/Projects-Solutions). - -================================ - -### Donations +## Donations If *Projects* has helped you in any way, and you'd like to help the developer, please consider donating. @@ -35,57 +27,42 @@ If *Projects* has helped you in any way, and you'd like to help the developer, p ================================ -Some details about this repo: - -* I will use Python to solve these. Why? Because I want to learn the language quickly. -* I have no interest in making games, so I'm excluding those from the list below. -* I'm not interested in networking, so I *might* skip all (or some) of them. -* The projects will not be made in the order posted. -* I may not be able to complete all of them. -* My method of solving them may not be the best. If you do not like my algorithm(s), please add a comment for the file/commit or open an issue, and I'll try to improve. - -I will link to each project that I complete. Some will be in this same repo, some bigger ones will have dedicated repos. - -To get started, fork this repo, delete this README and rename [*README-scratch.md*](https://github.com/thekarangoel/Projects/blob/master/README-scratch.md) to *README.md*. - -=============================== - Numbers --------- -[**Find PI to the Nth Digit**](https://github.com/thekarangoel/Projects/blob/master/Numbers/pi.py) - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go. +**Find PI to the Nth Digit** - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go. -[**Fibonacci Sequence**](https://github.com/thekarangoel/Projects/blob/master/Numbers/fibonacci.py) - Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number. +**Fibonacci Sequence** - Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number. -[**Prime Factorization**](https://github.com/thekarangoel/Projects/blob/master/Numbers/prime.py) - Have the user enter a number and find all Prime Factors (if there are any) and display them. +**Prime Factorization** - Have the user enter a number and find all Prime Factors (if there are any) and display them. -[**Next Prime Number**](https://github.com/thekarangoel/Projects/blob/master/Numbers/next_prime.py) - Have the program find prime numbers until the user chooses to stop asking for the next one. +**Next Prime Number** - Have the program find prime numbers until the user chooses to stop asking for the next one. -[**Find Cost of Tile to Cover W x H Floor**](https://github.com/thekarangoel/Projects/blob/master/Numbers/tile.py) - Calculate the total cost of tile it would take to cover a floor plan of width and height, using a cost entered by the user. +**Find Cost of Tile to Cover W x H Floor** - Calculate the total cost of tile it would take to cover a floor plan of width and height, using a cost entered by the user. **Mortgage Calculator** - Calculate the monthly payments of a fixed term mortgage over given Nth terms at a given interest rate. Also figure out how long it will take the user to pay back the loan. -[**Change Return Program**](https://github.com/thekarangoel/Projects/blob/master/Numbers/change.py) - The user enters a cost and then the amount of money given. The program will figure out the change and the number of quarters, dimes, nickels, pennies needed for the change. +**Change Return Program** - The user enters a cost and then the amount of money given. The program will figure out the change and the number of quarters, dimes, nickels, pennies needed for the change. -[**Binary to Decimal and Back Converter**](https://github.com/thekarangoel/Projects/blob/master/Numbers/binary_decimal.py) - Develop a converter to convert a decimal number to binary or a binary number to its decimal equivalent. +**Binary to Decimal and Back Converter** - Develop a converter to convert a decimal number to binary or a binary number to its decimal equivalent. -[**Calculator**](https://github.com/thekarangoel/Projects/blob/master/Numbers/calc.py) - A simple calculator to do basic operators. Make it a scientific calculator for added complexity. +**Calculator** - A simple calculator to do basic operators. Make it a scientific calculator for added complexity. -[**Unit Converter (temp, currency, volume, mass and more)**](https://github.com/thekarangoel/Projects/blob/master/Numbers/unit.py) - Converts various units between one another. The user enters the type of unit being entered, the type of unit they want to convert to and then the value. The program will then make the conversion. +**Unit Converter (temp, currency, volume, mass and more)** - Converts various units between one another. The user enters the type of unit being entered, the type of unit they want to convert to and then the value. The program will then make the conversion. -[**Alarm Clock**](https://github.com/thekarangoel/Projects/blob/master/Numbers/alarm.py) - A simple clock where it plays a sound after X number of minutes/seconds or at a particular time. +**Alarm Clock** - A simple clock where it plays a sound after X number of minutes/seconds or at a particular time. -[**Distance Between Two Cities**](https://github.com/thekarangoel/Projects/blob/master/Numbers/distance.py) - Calculates the distance between two cities and allows the user to specify a unit of distance. This program may require finding coordinates for the cities like latitude and longitude. +**Distance Between Two Cities** - Calculates the distance between two cities and allows the user to specify a unit of distance. This program may require finding coordinates for the cities like latitude and longitude. -[**Credit Card Validator**](https://github.com/thekarangoel/Projects/blob/master/Numbers/credit_card_validator.py) - Takes in a credit card number from a common credit card vendor (Visa, MasterCard, American Express, Discoverer) and validates it to make sure that it is a valid number (look into how credit cards use a checksum). +**Credit Card Validator** - Takes in a credit card number from a common credit card vendor (Visa, MasterCard, American Express, Discoverer) and validates it to make sure that it is a valid number (look into how credit cards use a checksum). -[**Tax Calculator**](https://github.com/karan/Projects/blob/master/Numbers/tax.py) - Asks the user to enter a cost and either a country or state tax. It then returns the tax plus the total cost with tax. +**Tax Calculator** - Asks the user to enter a cost and either a country or state tax. It then returns the tax plus the total cost with tax. -[**Factorial Finder**](https://github.com/thekarangoel/Projects/blob/master/Numbers/factorial.py) - The Factorial of a positive integer, n, is defined as the product of the sequence n, n-1, n-2, ...1 and the factorial of zero, 0, is defined as being 1. Solve this using both loops and recursion. +**Factorial Finder** - The Factorial of a positive integer, n, is defined as the product of the sequence n, n-1, n-2, ...1 and the factorial of zero, 0, is defined as being 1. Solve this using both loops and recursion. **Complex Number Algebra** - Show addition, multiplication, negation, and inversion of complex numbers in separate functions. (Subtraction and division operations can be made with pairs of these operations.) Print the results for each operation tested. -[**Happy Numbers**](https://github.com/thekarangoel/Projects/blob/master/Numbers/happy_numbers.py) - A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers. Take an input number from user, and find first 8 happy numbers from that input. +**Happy Numbers** - A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers. Display an example of your output here. Find first 8 happy numbers. **Number Names** - Show how to spell out a number in English. You can use a preexisting implementation or roll your own, but you should support inputs up to at least one million (or the maximum value of your language's default bounded integer type, if that's less). *Optional: Support for inputs other than positive integers (like zero, negative integers, and floating-point numbers).* @@ -94,7 +71,7 @@ Numbers Classic Algorithms ----------------- -[**Collatz Conjecture**](https://github.com/thekarangoel/Projects/blob/master/Classic%20Algorithms/collatz.py) - Start with a number *n > 1*. Find the number of steps it takes to reach one using the following process: If *n* is even, divide it by 2. If *n* is odd, multiply it by 3 and add 1. +**Collatz Conjecture** - Start with a number *n > 1*. Find the number of steps it takes to reach one using the following process: If *n* is even, divide it by 2. If *n* is odd, multiply it by 3 and add 1. **Sorting** - Implement two types of sorting algorithms: Merge sort and bubble sort. @@ -102,9 +79,9 @@ Classic Algorithms **Sieve of Eratosthenes** - The sieve of Eratosthenes is one of the most efficient ways to find all of the smaller primes (below 10 million or so). -Graphs ---------- +Graph +-------- **Graph from links** - Create a program that will create a graph or network from a series of links. **Eulerian Path** - Create a program which will take as an input a graph and output either a Eulerian path or a Eulerian cycle, or state that it is not possible. A Eulerian Path starts at one node and traverses every edge of a graph through every node and finishes at another node. A Eulerian cycle is a eulerian Path that starts and finishes at the same node. @@ -118,22 +95,23 @@ Data Structures **Inverted index** - An [Inverted Index](http://en.wikipedia.org/wiki/Inverted_index) is a data structure used to create full text search. Given a set of text files, implement a program to create an inverted index. Also create a user interface to do a search using that inverted index which returns a list of files that contain the query term / terms. The search index can be in memory. + Text --------- -[**Reverse a String**](https://github.com/thekarangoel/Projects/blob/master/Text/reverse.py) - Enter a string and the program will reverse it and print it out. +**Reverse a String** - Enter a string and the program will reverse it and print it out. -[**Pig Latin**](https://github.com/thekarangoel/Projects/blob/master/Text/piglatin.py) - Pig Latin is a game of alterations played on the English language game. To create the Pig Latin form of an English word the initial consonant sound is transposed to the end of the word and an ay is affixed (Ex.: "banana" would yield anana-bay). Read Wikipedia for more information on rules. +**Pig Latin** - Pig Latin is a game of alterations played on the English language game. To create the Pig Latin form of an English word the initial consonant sound is transposed to the end of the word and an ay is affixed (Ex.: "banana" would yield anana-bay). Read Wikipedia for more information on rules. -[**Count Vowels**](https://github.com/thekarangoel/Projects/blob/master/Text/count_vowels.py) - Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found. +**Count Vowels** - Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found. -[**Check if Palindrome**](https://github.com/thekarangoel/Projects/blob/master/Text/palindrome.py) - Checks if the string entered by the user is a palindrome. That is that it reads the same forwards as backwards like “racecar” +**Check if Palindrome** - Checks if the string entered by the user is a palindrome. That is that it reads the same forwards as backwards like “racecar” -[**Count Words in a String**](https://github.com/thekarangoel/Projects/blob/master/Text/count_words.py) - Counts the number of individual words in a string and display the top 5/10 most used words. +**Count Words in a String** - Counts the number of individual words in a string. For added complexity read these strings in from a text file and generate a summary. **Text Editor** - Notepad style application that can open, edit, and save text documents. *Optional: Add syntax highlighting and other features.* -[**RSS Feed Creator**](https://github.com/thekarangoel/Projects/blob/master/Text/rss.py) - Given a link to RSS/Atom Feed, get all posts and display them. +**RSS Feed Creator** - Given a link to RSS/Atom Feed, get all posts and display them. **Post it Notes Program** - A program where you can add text reminders and post them. *Optional: You can have the program also add popup reminders.* @@ -171,7 +149,7 @@ Networking Classes --------- -[**Product Inventory Project**](https://github.com/thekarangoel/Projects/blob/master/Classes/product_inventory.py) - Create an application which manages an inventory of products. Create a product class which has a price, id, and quantity on hand. Then create an *inventory* class which keeps track of various products and can sum up the inventory value. +**Product Inventory Project** - Create an application which manages an inventory of products. Create a product class which has a price, id, and quantity on hand. Then create an *inventory* class which keeps track of various products and can sum up the inventory value. **Airline / Hotel Reservation System** - Create a reservation system which books airline seats or hotel rooms. It charges various rates for particular sections of the plane or hotel. Example, first class is going to cost more than coach. Hotel rooms have penthouse suites which cost more. Keep track of when rooms will be available and can be scheduled. @@ -199,15 +177,15 @@ Threading Web --------- -[**Page Scraper**](https://github.com/thekarangoel/Projects/blob/master/Web/page_scraper.py) - Create an application which connects to a site and pulls out all links, or images, and saves them to a list. *Optional: Organize the indexed content and don’t allow duplicates. Have it put the results into an easily searchable index file.* +**Page Scraper** - Create an application which connects to a site and pulls out all links, or images, and saves them to a list. *Optional: Organize the indexed content and don’t allow duplicates. Have it put the results into an easily searchable index file.* **Web Browser with Tabs** - Create a small web browser that allows you to navigate the web and contains tabs which can be used to navigate to multiple web pages at once. For simplicity don’t worry about executing Javascript or other client side code. **Online White Board** - Create an application which allows you to draw pictures, write notes and use various colors to flesh out ideas for projects. *Optional: Add feature to invite friends to collaborate on a white board online.* -[**Get Atomic Time from Internet Clock**](https://github.com/thekarangoel/Projects/blob/master/Web/time.py) - This program will get the true atomic time from an atomic time clock on the Internet. Use any one of the atomic clocks returned by a simple Google search. +**Get Atomic Time from Internet Clock** - This program will get the true atomic time from an atomic time clock on the Internet. Use any one of the atomic clocks returned by a simple Google search. -[**Fetch Current Weather**](https://github.com/thekarangoel/GAE-weather) - Get the current weather for a given zip/postal code. *Optional: Try locating the user automatically.* +**Fetch Current Weather** - Get the current weather for a given zip/postal code. *Optional: Try locating the user automatically.* **Scheduled Auto Login and Action** - Make an application which logs into a given site on a schedule and invokes a certain action and then logs out. This can be useful for checking web mail, posting regular content, or getting info for other applications and saving it to your computer. @@ -271,7 +249,7 @@ Graphics and Multimedia Security ------------- -**Caesar cipher** - Implement a Caesar cipher, both encoding and decoding. The key is an integer from 1 to 26. This cipher rotates the letters of the alphabet (A to Z). The encoding replaces each letter with the 1st to 26th next letter in the alphabet (wrapping Z to A). So key 2 encrypts "HI" to "JK", but key 20 encrypts "HI" to "BC". This simple "monoalphabetic substitution cipher" provides almost no security, because an attacker who has the encoded message can either use frequency analysis to guess the key, or just try all 26 keys. +**Caesar cipher** - Implement a Caesar cipher, both encoding and decoding. The key is an integer from 1 to 25. This cipher rotates the letters of the alphabet (A to Z). The encoding replaces each letter with the 1st to 25th next letter in the alphabet (wrapping Z to A). So key 2 encrypts "HI" to "JK", but key 20 encrypts "HI" to "BC". This simple "monoalphabetic substitution cipher" provides almost no security, because an attacker who has the encoded message can either use frequency analysis to guess the key, or just try all 25 keys. =============================================== @@ -280,5 +258,3 @@ Sources * [Martyr2’s Mega Project List](http://www.dreamincode.net/forums/topic/78802-martyr2s-mega-project-ideas-list/) * [Rosetta Code](http://rosettacode.org/) -* Lots and lots of contributors. Thank you all. - diff --git a/Text/caesar_cipher.py b/Text/caesar_cipher.py deleted file mode 100644 index 5e2698679..000000000 --- a/Text/caesar_cipher.py +++ /dev/null @@ -1,40 +0,0 @@ -""" -Caesar Cipher - Enter the cipher number and the program will "encrypt" them with -the Caesar cipher (a.k.a. ROT #). Type the word "exit" when you're finished. -""" - -while True: - try: - cipher = int(raw_input("Enter the cipher number: ")) - break - except ValueError: - print "I need a valid integer, please." - -print "Enter the text to be encoded." -print "Enter \"exit\" to leave." - -if __name__ == '__main__': - while True: - text = raw_input("> ") - encoded = [] - - if text.lower() == "exit": - break - - for letter in text: - if letter.isalpha(): - is_upper = False - - if letter == letter.upper(): - is_upper = True - letter = letter.lower() - - value = (ord(letter) - 97 + cipher) % 26 - if is_upper: - value -= 32 - - encoded.append(chr(value + 97)) - else: - encoded.append(letter) - - print ''.join(encoded) diff --git a/Text/count_vowels.py b/Text/count_vowels.py deleted file mode 100644 index fe55626f1..000000000 --- a/Text/count_vowels.py +++ /dev/null @@ -1,19 +0,0 @@ -""" -Count Vowels - Enter a string and the program counts -the number of vowels in the text. For added complexity -have it report a sum of each vowel found. -""" - -from collections import defaultdict - -if __name__ == '__main__': - string = raw_input('Enter a string: ').lower() - - vowels = ['a', 'e', 'i', 'o', 'u'] - counts = defaultdict(int) - - for char in string: - if char in vowels: - counts[char] += 1 - - print counts.items() diff --git a/Text/count_words.py b/Text/count_words.py deleted file mode 100644 index afe0daccc..000000000 --- a/Text/count_words.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -Count Words in a String - Counts the number of individual -words in a string and display the top 5/10 most used words. -""" - -from collections import defaultdict -import operator - -if __name__ == '__main__': - text = raw_input('Enter some text: \n') - words = text.split() # very naive approach, split at space - - counts = defaultdict(int) # no need to check existence of a key - - # find count of each word - for word in words: - counts[word] += 1 - - # sort the dict by the count of each word, returns a tuple (word, count) - sorted_counts = sorted(counts.iteritems(), \ - key=operator.itemgetter(1), \ - reverse=True) - - # print top 5 words - for (word,count) in sorted_counts[:5]: # thanks @jrwren for this! - print (word, count) diff --git a/Text/palindrome.py b/Text/palindrome.py deleted file mode 100644 index 8e9cf3a38..000000000 --- a/Text/palindrome.py +++ /dev/null @@ -1,12 +0,0 @@ -""" -Check if Palindrome - Checks if the string entered -by the user is a palindrome. That is that it reads -the same forwards as backwards like "racecar" -""" - -string = raw_input('Enter a string: ').lower() - -if string == string[::-1]: - print '%s is a palindrome' % string -else: - print '%s is not a palindrome' % string diff --git a/Text/piglatin.py b/Text/piglatin.py deleted file mode 100644 index 37313a6c2..000000000 --- a/Text/piglatin.py +++ /dev/null @@ -1,37 +0,0 @@ -""" -Pig Latin - Pig Latin is a game of alterations played -on the English language game. To create the Pig Latin -form of an English word the initial consonant sound is -transposed to the end of the word and an ay is affixed -(Ex.: "banana" would yield anana-bay). Read Wikipedia -for more information on rules. -""" - -word = raw_input('What\'s your word? ').lower() -vowels = 'aeiou' - -pig = 'ay' - -consonant = [] -count = 0 -copy = [c for c in word] - -for i in range(len(copy) - 1): - count = i - if copy[i] in vowels: - break - else: - consonant.append(copy[i]) - -new = word[count:] + "".join(consonant) + pig - -""" -first = word[0] - -if first in vowels: - new = word + pig -else: - new = word[1:] + first + pig -""" - -print new diff --git a/Text/reverse.py b/Text/reverse.py deleted file mode 100644 index 3a1296545..000000000 --- a/Text/reverse.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: cp1252 -*- -""" -Reverse a String - Enter a string and the program -will reverse it and print it out. -""" - -string = raw_input("Whatchu wanna say to me? ") -copy = [c for c in string] -for i in range(len(copy) / 2): - copy[i], copy[len(copy) - i - 1] = copy[len(copy) - i - 1], copy[i] -print "You say %s, I say %s" % (string, ''.join(copy)) diff --git a/Text/rss.py b/Text/rss.py deleted file mode 100644 index 25f8c8f1d..000000000 --- a/Text/rss.py +++ /dev/null @@ -1,29 +0,0 @@ -""" -RSS Feed Creator - Given a link to RSS/Atom Feed, -get all posts and display them. -""" - -import re -import urllib2 - - -def main(): - """ - Takes in a Feedburned feed URL. - - Eg: http://feeds.feedburner.com/WebDesignLedger - """ - feed_url = raw_input('Enter Feedburner RSS URL: ') - content = urllib2.urlopen(feed_url).read() # get the source code of feed - - link_pattern = re.compile('(.*)') - title_pattern = re.compile('(.*)') - - links = re.findall(link_pattern, content)[1:] # skip blog url - titles = re.findall(title_pattern, content)[1:] # skip the page title - - for (link, title) in zip(links, titles): - print '{0}\n{1}\n'.format(title, link) - -if __name__ == '__main__': - main() diff --git a/Web/page_scraper.py b/Web/page_scraper.py deleted file mode 100644 index ccfd191fa..000000000 --- a/Web/page_scraper.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: cp1252 -*- -""" -Page Scraper - Create an application which connects to a -site and pulls out all links, or images, and saves them to -a list. Optional: Organize the indexed content and dont -allow duplicates. Have it put the results into an easily -searchable index file. -""" - -import urllib2 -from bs4 import BeautifulSoup - - -def print_list(stuff): - print '\n'.join(stuff) - print '\n====================\n' - -if __name__ == '__main__': - - url = raw_input('Enter a URL: ') - - choice = input('What to scrape?\n1. Links\n2. Images\n3. Both\n') - - soup = BeautifulSoup(urllib2.urlopen(url).read()) - - if choice == 1 or choice == 3: - urls = [link.get('href') for link in soup.findAll('a')] - print 'URLs:' - print_list(urls) - if choice == 2 or choice ==3: - images = [image['src'] for image in soup.findAll("img")] - print 'Images:' - print_list(images) diff --git a/Web/time.py b/Web/time.py deleted file mode 100644 index 073d75f47..000000000 --- a/Web/time.py +++ /dev/null @@ -1,25 +0,0 @@ -""" -Get Atomic Time from Internet Clock - This program will get -the true atomic time from an atomic time clock on the Internet. -Use any one of the atomic clocks returned by a simple Google search. -""" - -import re -from urllib2 import urlopen - - -def main(): - url = 'http://time.is/just' - content = urlopen(url).read() - pattern = re.compile('
(.*)(AM|PM)
') - - find_match = re.search(pattern, content) - - location_pat = re.compile('

(.*)

') - location_match = re.search(location_pat, content) - - print 'The time in %s is %s %s' % \ - (location_match.group(1), find_match.group(1), find_match.group(2)) - -if __name__ == '__main__': - main()