This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator, csv | |
pyramid = [] | |
with open ('triangle.txt', 'rb') as csvfile: | |
reader = csv.reader(csvfile, delimiter='\n') | |
for row in reader: | |
temp = row[0].split() | |
for x in range(len(temp)): | |
temp[x]=int(temp[x]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i = 1 | |
n = 0 | |
a = 1 | |
b = 1 | |
while n < 1000: | |
temp = b | |
b = a + b | |
a = temp | |
n = len(str(b)) | |
i += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging, math | |
logging.basicConfig(level=logging.INFO) | |
def d(n): | |
#cribbed directly from problem 21; gives the sum of proper divisors | |
sum = 0 | |
for i in range(1, int(math.sqrt(n)+1)): | |
if (n % i == 0): | |
sum += i | |
return sum | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
day = 1 | |
hits = 0 | |
year = 1900 | |
while year < 2001: | |
for x in range(12): | |
if (day % 7 == 0 and year != 1900): | |
hits += 1 | |
amount = 31 | |
if ((x < 7 and x % 2 == 1) or (x > 7 and x % 2 == 0)): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
pyramid = [[75], [95,64], [17,47,82], [18,35,87,10], [20,04,82,47,65], [19,01,23,75,03,34], [88,02,77,73,07,63,67], [99,65,04,28,06,16,70,92], [41,41,26,56,83,40,80,70,33], [41,48,72,33,47,32,37,16,94,29], [53,71,44,65,25,43,91,52,97,51,14], [70,11,33,28,77,73,17,78,39,68,17,57], [91,71,52,38,17,14,91,43,58,50,27,29,48], [63,66,04,68,89,53,67,30,73,16,69,87,40,31], [04,62,98,27,23,9,70,98,73,93,38,53,60,04,23]] | |
sums = [0]*len(pyramid) | |
for row in reversed(pyramid): | |
row = map (operator.add, row, sums) | |
print (row) | |
sums = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
a = math.factorial(100) | |
b = str(a) | |
d = 0 | |
for c in b: | |
d += int(c) | |
print (d) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def d(n): | |
sum = 0 | |
for i in range(1, int(math.sqrt(n)+1)): | |
if (n % i == 0): | |
sum += i | |
return sum | |
amicable = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
ints = range(10) | |
perms = list(itertools.permutations(ints)) | |
print (perms[999999]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
names = [] | |
sum = 0 | |
with open ('names.txt', 'rb') as csvfile: | |
namereader = csv.reader(csvfile, delimiter=',', quotechar='"') | |
for row in namereader: | |
names = names + row | |
names.sort() | |
for i in range(len(names)): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Dice Roller</title> | |
</head> | |
<body> | |
<?php | |
#first things first - if the user didn't specify a name, die. | |
IF ($_POST['name'] != null){ | |
#looks like they gave a name! |
OlderNewer