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/env python3 | |
import argparse | |
import random | |
def generateGraph(v, e, m): | |
print(v) | |
print(e) | |
matrix = [0] * (v*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
num=int(input()) | |
for i in range(num, -1, -1): | |
print(" "*i + "*"*((num-i)*2+1)) | |
for i in range(1, num+1): | |
print(" "*i + "*"*((num-i)*2+1)) | |
for i in range(num*2+1): | |
print("*"*(num*2+1)) | |
for i in range(num, -1, -1): | |
print(" "*i + "*"*((num-i)*2+1)) | |
for i in range(1, num+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
Height: Width: | |
. 7 7 9 5 2 8 5 6 6 1 9 2 1 4 4 8 4 6 4 6 2 9 3 8 1 6 4 9 6 | |
. . 7 4 6 1 5 6 8 3 8 9 9 1 8 6 6 5 3 1 5 3 7 3 4 2 8 5 6 3 | |
7 . . . . . . 3 6 4 7 9 6 8 9 5 2 3 1 9 1 8 3 7 9 9 8 5 9 2 | |
2 8 3 3 7 8 . 5 8 1 9 2 5 1 3 9 3 8 1 4 4 6 5 5 5 1 8 5 1 7 | |
9 1 9 1 1 9 . . . 9 8 1 8 8 3 5 4 4 4 9 3 8 6 6 5 4 4 1 7 3 | |
9 1 2 2 6 6 5 6 . . . . . 6 1 9 3 5 1 6 6 5 2 2 3 7 1 5 1 9 | |
6 1 5 1 8 2 1 9 8 5 4 6 . 2 8 6 8 1 2 3 9 2 7 2 8 8 8 9 1 5 | |
8 5 5 7 1 9 8 9 4 8 4 4 . . . . 9 9 3 8 4 6 8 6 6 1 2 2 2 8 | |
8 6 3 1 6 6 5 8 9 3 9 4 5 7 7 . . . . . 1 2 3 4 4 6 3 8 4 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
""" | |
Suppose we create a 2 unit by 2 unit square. | |
Suppose we drop that square's center on the origin point | |
of a Cartesian graph. | |
The area of this square is 4. | |
Suppose we then create a 1 unit radius circle and drop |
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
""" | |
pow is a function that computes $a^b$ in $O(lg b)$ time. | |
Here, I compute $3^0$ to $3^9$ and compare the results to Python's math.pow function. | |
""" | |
import math |
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 tkinter as t | |
d=500 | |
w=t.Canvas(t.Tk(),width=d,height=d) | |
w.pack() | |
x=d/2;y=x;v=1;z=0;c=2;r=1;p=[] | |
for i in range(2,d*200): | |
x+=v;y+=z | |
if r*2==c:z=v;v=0 | |
if r==c:v=-z;z=0;c+=2;r=0 | |
r+=1;t=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
// Bubble Sort | |
// By James Church | |
// 2016-10-20 | |
// | |
// How this works: | |
// Scroll down the bottom of this file. | |
// You'll see 10 values that are randomly | |
// ordered. This is the input to the algorithm. | |
// These can be rearranged into any order. | |
// |
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
public class MyFormatter { | |
public static void main(String[] args) { | |
System.out.println(String.format("%s", "Hi Chris")); // "Hi Chris" | |
System.out.println(String.format("%d", 42)); // "42" | |
System.out.println(String.format("%f", Math.PI)); // "3.141593" | |
System.out.println(); | |
System.out.println(String.format("%4d", 2)); // " 4" | |
System.out.println(String.format("%04d", 2)); // "0004" | |
System.out.println(); | |
System.out.println(String.format("%.3f", Math.PI)); // "3.142" |
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/env python3 | |
import datetime | |
import argparse | |
import re | |
def createDate(stringDate): | |
if re.match("\d\d\d\d-\d\d-\d\d$", stringDate) is None: | |
raise ValueError("This is not in the correct date format. Use YYYY-MM-DD") |
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 re | |
import urllib.request | |
import urllib.parse | |
def downloadPage(domain, path): | |
filehandle = urllib.request.urlopen(domain + path) | |
page = filehandle.readlines() | |
return page | |
def getEntry(page, i): |