Skip to content

Instantly share code, notes, and snippets.

"""
Implements a simple HTTP/1.0 Server
"""
import socket
def handle_request(request):
"""Handles the HTTP request."""
@joaoventura
joaoventura / sierpinski.py
Created February 15, 2016 12:05
Sierpinski Triangle (with the animations)
"""
Creates the Sierpinski triangle using the Chaos Game technique.
Starts from a vertex of a triangle, chooses randomly the next vertex and
draw a pixel in the middle. Then, iteratively selects a new vertex and
draws in the middle point.
"""
import random
"""
Implements linear search and probabilistic search to analyse time complexity.
"""
import random
from matplotlib import pyplot as plt
@joaoventura
joaoventura / binary_search.py
Created December 16, 2015 20:17
Comparison of linear-search and binary-search algorithms
"""
Implements linear search and binary search to analyse time complexity.
"""
import random
from matplotlib import pyplot as plt
# A solution to the problem stated in
# https://www.codeeval.com/browse/170/
import math
def middleNumber(a, b):
""" Finds the middle integer between a and b.
If it is not a round number it rounds up to the
next integer.