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 | |
import socket | |
from time import time | |
args = sys.argv[1:] | |
if len(args) not in [1,2]: | |
print("usage: tls_prank_call hostname [port]") | |
hostname = args[0] | |
port = 443 if len(args) == 1 else int(args[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 java.util.Random; | |
import java.util.Scanner; | |
// We discussed academic honesty, so when you re-type this code, be sure to cite it in a comment! | |
// This is the only time you MUST cite code from me, the instructor. | |
public class GuessingGame { | |
/** One more than the highest possible number in the game. */ | |
private static final int HIGH = 100; | |
/** The lowest possible number in the game. */ |
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
/** | |
* Every Java file must have a class defined in it! | |
* Notice that the name of this file is Welcome.java | |
* .. and we define class Welcome! | |
* .. that's super important to Java. It's picky like that. | |
*/ | |
public class Welcome { | |
/** | |
* Don't change any details about the outside of this `main` function | |
* ... it needs to be precise! |
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 timeit | |
# Complexity experiment time. | |
# Both sum_1x and sum_2x are O(n) functions. | |
# Let's investigate which is faster AND see if it's linear. | |
def sum_2x(target: list) -> int: | |
total = 0 | |
for x in target: |
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 pygame | |
import random | |
__version__ = "2021.11.15.0" | |
class SimplePygame: | |
def __init__(self, screen): | |
self.screen = screen | |
self.has_quit = False | |
self.fonts = {} |
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
# 17b_notes.py | |
## Recursion Breakdown | |
def countdown(n: int): | |
print("begin: countdown(",n,")") | |
if n == 0: | |
print("output:\t\tBlastoff!") | |
else: | |
print("before:\t\t", n) |
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
### | |
# Recursive GCD: | |
# | |
# One of the oldest known algorithms, dating back to the | |
# 5th century BCE, is Euclid’s algorithm for computing the | |
# greatest common divisor (GCD) of two integers. | |
# | |
# The GCD of 36 and 24 is 12. | |
# It works as follows: | |
# Let a, b be positive integers. |
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 typing import List, Tuple, Dict | |
ROOM = { | |
"name": "basement", | |
"description": """You have found the basement of the mansion. | |
It is darker down here. | |
You get the sense a secret is nearby, but you only see the stairs you came from.""", | |
"exits": [ | |
{ | |
"destination": "entranceHall", |
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 os | |
from typing import List | |
def diff_compress(numbers: List[int]) -> List[int]: | |
previous = 0 | |
encoded = [] | |
for n in numbers: | |
encoded.append(n - previous) | |
previous = n |
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 maxmin(xs): | |
""" | |
This function simultaneously computes the maximum | |
and the minimum values present in a list. | |
Input: a list of ordered values. | |
Returns: [maximum, minimum] or [None, None] for an empty list. | |
""" | |
minimum = None | |
maximum = None |
NewerOlder