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
from operator import mul | |
ns = [ | |
[ 8, 2,22,97,38,15, 0,40, 0,75, 4, 5, 7,78,52,12,50,77,91, 8], | |
[49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48, 4,56,62, 0], | |
[81,49,31,73,55,79,14,29,93,71,40,67,53,88,30, 3,49,13,36,65], | |
[52,70,95,23, 4,60,11,42,69,24,68,56, 1,32,56,71,37, 2,36,91], | |
[22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80], | |
[24,47,32,60,99, 3,45, 2,44,75,33,53,78,36,84,20,35,17,12,50], | |
[32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70], |
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
from itertools import count | |
from itertools import dropwhile | |
from math import sqrt | |
def factorise(n): | |
c = 0 | |
sr = int(sqrt(n)) | |
for i in range(1, sr + 1): | |
if n % i == 0: | |
c += 2 |
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
numbers = ( | |
37107287533902102798797998220837590246510135740250, | |
46376937677490009712648124896970078050417018260538, | |
74324986199524741059474233309513058123726617309629, | |
91942213363574161572522430563301811072406154908250, | |
23067588207539346171171980310421047513778063246676, | |
89261670696623633820136378418383684178734361726757, | |
28112879812849979408065481931592621691275889832738, | |
44274228917432520321923589422876796487670272189318, | |
47451445736001306439091167216856844588711603153276, |
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
def hotpo(n): | |
steps = 0 | |
while n > 1: | |
if n % 2 == 0: | |
n = n / 2 | |
else: | |
n = 3 * n + 1 | |
steps += 1 | |
return steps |
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
def fact(n): | |
s = 1 | |
while n > 0: | |
s = s * n | |
n -= 1 | |
return s | |
print fact(20 * 2) / (fact(20) * fact(20)) |
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
print sum(int(c) for c in str(2**1000)) |
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
def say_digit(n): | |
number = '' | |
if n == 1: | |
number = 'one' | |
elif n == 2: | |
number = 'two' | |
elif n == 3: | |
number = 'three' | |
elif n == 4: | |
number = 'four' |
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
tn = [ | |
[75], | |
[95,64], | |
[17,47,82], | |
[18,35,87,10], | |
[20, 4,82,47,65], | |
[19, 1,23,75, 3,34], | |
[88, 2,77,73, 7,63,67], | |
[99,65, 4,28, 6,16,70,92], | |
[41,41,26,56,83,40,80,70,33], |
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
#!/bin/ksh | |
count=0 | |
for year in {1901..2000}; do | |
for month in {1..12}; do | |
if cal $month $year | cut -b1,2 | grep ' 1' > /dev/null; then | |
((count = $count + 1)) | |
fi | |
done | |
done | |
echo $count |
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
def fact(n): | |
s = 1 | |
while n > 0: | |
s = s * n | |
n -= 1 | |
return s | |
print sum(int(c) for c in str(fact(100))) |