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 | |
| square_tri = [] | |
| def tri(n): | |
| return n*(n+1)/2 | |
| k = 1 | |
| while len(square_tri) < 4: | |
| val = math.sqrt(tri(k)) |
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 | |
| import numpy | |
| a = 2*math.pi | |
| b = 4*math.pi | |
| step = (b - a)/8 | |
| for x in numpy.arange(a, b, step): | |
| print("({0}, {1})".format(x, math.cos(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
| for s in range(3, 23, 2): | |
| for t in range(1, s, 2): | |
| divides = False | |
| for d in range(2, t + 1): | |
| if s % d == 0 and t % d == 0: | |
| divides = True | |
| break | |
| if divides: continue | |
| c = int((s**2 + t**2)/2) | |
| b = int((s**2 - t**2)/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
| <?xml version="1.0" encoding="UTF-8" ?> | |
| <Module> | |
| <ModulePrefs title="TestWarn"> | |
| <Require feature="google.calendar-0.5"/> | |
| <Require feature="google.calendar-0.5.read"/> | |
| </ModulePrefs> | |
| <Content type="html"> | |
| <![CDATA[ | |
| <!DOCTYPE html> | |
| <html> |
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 rprime(x, y): | |
| for d in range(2, min(x, y) + 1): | |
| if x % d == 0 and y % d == 0: | |
| return False | |
| return True | |
| for u in range(1, 26): | |
| for v in range(1, u): | |
| a = u**2 - v**2 | |
| b = 2*u*v |
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_list = [] | |
| b_list = [] | |
| c_list = [] | |
| c_max = 1225 | |
| a_max = int((c_max**2)**(1.0/3.0)) | |
| for c in range(1, c_max + 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
| #!/usr/bin/python | |
| import sys | |
| def is_triple(a, b, c): | |
| return a**3 + b**3 == c**2 | |
| def primitive(a, b, c): | |
| for d in range(2, min(a, b, c) + 1): | |
| d_squared = d ** 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
| import argparse | |
| import collections | |
| import ConfigParser | |
| import gspread | |
| import pyvotecore.irv | |
| import pyvotecore.plurality | |
| import pyvotecore.schulze_method | |
| import pyvotecore.stv | |
| parser = argparse.ArgumentParser(description='Tally votes in a Google Spreadsheet.') |
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 sys | |
| def euclid(a, b): | |
| if a == 0 or b == 0: | |
| return 0 | |
| if a % b == 0: | |
| return b | |
| return euclid(b, a % b) | |
| print(euclid(int(sys.argv[1]), int(sys.argv[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
| import sys | |
| def lcm(a, b): | |
| bigger = max(a, b) | |
| lcm = bigger | |
| while lcm % a != 0 or lcm % b != 0: | |
| lcm += bigger | |
| return lcm | |
| a, b = [int(k) for k in sys.argv[1:3]] |