Skip to content

Instantly share code, notes, and snippets.

@Caleb2501
Caleb2501 / Code3
Created January 21, 2013 07:24
Reddit daily coding challenge. WIN! sort of I didn't make this ignore numbers or symbols.
#write a program that can encrypt texts with an alphabetical caesar cipher.
#This cipher can ignore numbers, symbols, and whitespace.
x = 0
scramb = ""
final = ""
characterloc = 0
cleanword = raw_input("please input your secret message: ")
cleanword = str.upper(cleanword)
clean_array = list()
cipher = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ ")
@Caleb2501
Caleb2501 / gist:4591296
Last active June 11, 2017 09:55
Reddit Daily Coding, Challenge#4!
# Your challenge for today is to create a random password generator!
# For extra credit, allow the user to specify the amount of passwords to generate.
# For even more extra credit, allow the user to specify the length of the strings
# he wants to generate!
import random
userChoice = 0
loop = True
passChar = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$^&*()abcdefghijklmnopqrstuvwxyz')
while loop == True:
print "What would you like to do?"
@Caleb2501
Caleb2501 / Challenge5.py
Created January 23, 2013 03:49
Well here it is challenge 5. I don't think it is super awesome, but it did what it was supposed to do. I didn't have it write to a file. Perhaps I will get another challenge that is "Write something to a file!" then I will do it.
#Your challenge for today is to create a program which is password protected, and wont open unless the correct user and password is given.
#For extra credit, have the user and password in a seperate .txt file.
#for even more extra credit, break into your own program :)
userChoice = 0
valUser = ''
valPass = ''
progQuest = 0
loop = True
userList = {'admin':'password'}
while loop:
@Caleb2501
Caleb2501 / challenge6.py
Created January 24, 2013 01:38
Well, here it is. Lame. I know. This was not my best work, but I did learn about using imported modules.
#You're challenge for today is to create a program that can
#calculate pi accurately to at least 30 decimal places.
import math
#or import math *
jelly = math.pi
#if the second method was used I would write:
#jelly = pi
print jelly
@Caleb2501
Caleb2501 / challenge7.py
Created January 25, 2013 03:52
Reddit challenge #7 Woot! This one was pretty fun. decoding secret messages how awesome is that!
#Write a program that can translate Morse code in the format of ...---...
#A space and a slash will be placed between words. ..- / --.-
alphaBeta = {
'.-' : 'a',
'-...' : 'b',
'-.-.' : 'c',
'-..' : 'd',
'.' : 'e',
'..-.' : 'f',
#write a program that will print the lyrics to
#"99 bottles of beer on the wall".
#for extra credit, do not allow the program to
#print each loop on a new line
n = 99
x = 0
for x in range(0, 99):
if n == 1:
print "%d bottle of beer on the wall, %d bottle of beer." % (n, n)
else:
@Caleb2501
Caleb2501 / challenge9.py
Last active December 11, 2015 18:39
Challenge #9 TIL that the %d function works with the raw_input string, but must be placed inside the parentheses. I also used range as a for _ in _ value. That worked awesome!
#write a program that will allow the user to input digits, and arrange
#them in numerical order.
#for extra credit, have it also arrange strings in alphabetical order
sortList = []
print "Please enter the amount of items you would like to sort:"
times = raw_input('1 - 20)> ')
if 1 <= times <= 20:
for x in range(1, times + 1):
sortItem = raw_input("please enter item #%d: " % x)
sortList.append(sortItem)
@Caleb2501
Caleb2501 / challenge10.py
Created January 27, 2013 23:58
challenge 10! This is the last one I will be doing for now.
#The exercise today asks you to validate a telephone number, as if written on an input form. Telephone numbers can be written as ten digits, or with dashes, spaces, or dots between the three segments, or with the area code parenthesized; both the area code and any white space between segments are optional.
#Thus, all of the following are valid telephone numbers: 1234567890, 123-456-7890, 123.456.7890, (123)456-7890, (123) 456-7890 (note the white space following the area code), and 456-7890.
#The following are not valid telephone numbers: 123-45-6789, 123:4567890, and 123/456-7890.
import re
phoneNum = raw_input("Please enter a phone number: ")
matchObj = re.match( r'^([1]?)([\(\/\. ]?)[2-9][\d]{2}([\.\- \)]?)[2-9][\d][\d][/\.\- ]?[\d]{4}$', phoneNum)
if matchObj:
print "Great! you gave me a good phone number: %s" % phoneNum
else:
print "You should try again that phone number sucked!"
@Caleb2501
Caleb2501 / birthday.py
Created March 7, 2013 02:25
Birthday AWESOME! Reddit challenge 11.
import datetime
Days = ['Monday', 'Tuesday', 'Wedneday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
loop = True
print "Welcome to the magical emporium of fun!"
print "Give me your birth date, and I will tell you what day of the week you were born on."
while loop:
year = input('Enter your birth year (YYYY): ')
month = input('Enter your birth month (MM): ')
@Caleb2501
Caleb2501 / daycalc.py
Created March 17, 2013 01:06
Daily programing challenge number 12!
#find the number of the year for the given date. For example, January 1st
#would be 1, and december 31st is 365
import datetime
loop = True
print "We are going to figure out what day number you chose based on the date you input."
while loop:
year = input('Enter a year (YYYY): ')
month = input('Enter a month (MM): ')