Skip to content

Instantly share code, notes, and snippets.

View chipbell4's full-sized avatar
๐Ÿ‘Š
KAMPUTORS!

Chip Bell chipbell4

๐Ÿ‘Š
KAMPUTORS!
View GitHub Profile
@chipbell4
chipbell4 / funday.py
Created November 10, 2014 03:04
My Funday Solution
import datetime
N = int(input().strip())
for i in range(N):
# read in the date
current_date = datetime.datetime.strptime(input().strip(), '%B %d, %Y')
# diff with our reference point
delta = current_date - datetime.datetime(2000, 1, 1)
@chipbell4
chipbell4 / zellers.py
Created November 10, 2014 02:51
One Liner trick for Zeller's Congruence Cheat
import datetime
# This is TOTALLY in the builtin Python docs.
# help(datetime.datetime)
datetime.datetime.strptime('OctoBER 31, 2013', '%B %d, %Y').strftime('%A %B %d, %Y')
@chipbell4
chipbell4 / recycle.py
Created November 10, 2014 02:49
My Solution For Recycle Calendar
import datetime
def yearsShareCalendar(year1, year2):
# years match if their starting days and ending days of the week match
year1_start = datetime.datetime(year1, 1, 1)
year2_start = datetime.datetime(year2, 1, 1)
year1_end = datetime.datetime(year1, 12, 31)
year2_end = datetime.datetime(year2, 12, 31)
return year1_start.weekday() == year2_start.weekday() and year1_end.weekday() == year2_end.weekday()
@chipbell4
chipbell4 / generateKenKenJudging.py
Created November 9, 2014 20:53
Judge Input Generator for the Ken Ken Problem
import sys
n_max = int(sys.argv[1])
k_max = int(sys.argv[2])
c_max = int(sys.argv[3])
print(n_max * k_max * c_max)
for n in range(1, n_max + 1):
for k in range(1, k_max + 1):
for c in range(1, c_max + 1):
@chipbell4
chipbell4 / ken.py
Last active August 29, 2015 14:09
Ken Ken Solution
def memoize(func):
hashed_states = {}
def memoized_func(*args):
if args not in hashed_states:
hashed_states[args] = func(*args)
return hashed_states[args]
return memoized_func
@chipbell4
chipbell4 / pages.py
Created August 22, 2014 02:36
My Missing Pages solution (Practice 8/21/2014)
def pagesTaken(N, P):
original_p = P
# adjust P to be less than N/2
if P > N/2:
P = N - P + 1
# if even, move back a page
if P % 2 == 0:
P -= 1
@chipbell4
chipbell4 / digit.py
Created August 22, 2014 02:30
My Solution For Digit Sum (Still buggy) for Practice 8/21/2014
def buildDigits(digit_list):
# sort the digit list
# TODO: Here's where the bug is. Because the 0's get pushed to the front of the list, I put 0's at the beginning of numbers.
# What would need to happen is potentially a sort, and then pushing 0's back in the list a couple spaces?
digit_list.sort(reverse = True)
summands = ['', '']
# Here's the basic idea for the algorithm: Sort the digits, then divide them equally (in sorted order) among two strings
@chipbell4
chipbell4 / sortme.py
Created August 22, 2014 02:22
My (untested) solution for Sort Me Practice 8/21/2014
# Note: This is NOT tested!
# There's a constant in Python for this, but I couldn't remember
ABC = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def getWordList(length):
words = []
for i in range(length):
words.append(input().strip())
return words
/*!
*
* welcome to wavepot
* ------------------
*
* this is a live editor. you create a function named `dsp`
* that accepts the parameter `t`, the coefficient of time,
* which you use to generate a single sample (range -1..1)
*
@chipbell4
chipbell4 / tutorial.md
Last active August 29, 2015 14:02
Short Markdown Tutorial

Here's how to do markdown :) Note that you can look at the raw source of this document, which is here

To embed a link, you can simply put something like this in a file:

[This links to mtzionsmarr.com](http://mtzionsmarr.com)

and it renders like this: This links to mtzionsmarr.com

To do headers and what not, you can precede a line with a hash: