A collection of trinket-sized projects.

Oneliner-izer 𓆙

January 2015

Oh dear God, why?

Oneliner-izer is a “compiler” that converts any Python file into a single line of code with the same functionality. Really, just one line! No newlines or semicolons allowed!

Take a look at the interactive demo or the PyCon talk to learn more about how it works.

Before:

def guess_my_number(n):
    while True:
        user_input = raw_input("Enter a positive integer to guess: ")
        if len(user_input)==0 or not user_input.isdigit():
            print "Not a positive integer!"
        else:
            user_input = int(user_input)
            if user_input > n:
                print "Too big! Try again!"
            elif user_input < n:
                print "Too small! Try again!"
            else:
                print "You win!"
                return True
guess_my_number(42)

After:

(lambda __builtin__: (lambda __print, __y, d: [(lambda ___: None)(d.guess_my_number(42)) for d.guess_my_number in [(lambda n:[(__y(lambda __this: (lambda d: (lambda __after: [(lambda __after: (lambda ___: __after(d))(__print('Not a positive integer!')) if (d.len(d.user_input)==0 or (not d.user_input.isdigit())) else [(lambda __after: (lambda ___: __after(d))(__print('Too big! Try again!')) if d.user_input>d.n else (lambda __after: (lambda ___: __after(d))(__print('Too small! Try again!')) if d.user_input<d.n else (lambda ___: d.True)(__print('You win!')))(lambda d: __after(d)))(lambda d: __after(d)) for d.user_input in [(d.int(d.user_input))]][0])(lambda d: __this(d)) for d.user_input in [(d.raw_input('Enter a positive integer to guess: '))]][0] if d.True else __after(d))(lambda d: None))))(d) for d.n in [(n)]][0])]][0])(__builtin__.__dict__['print'],(lambda f: (lambda x: x(x))(lambda y: f(lambda *args: y(y)(*args)))),type('StateDict',(),__builtin__.__dict__)()))(__import__('__builtin__'))

See the code on GitHub.



Quantum Mechanic: interactive quantum complexity theory 𓀨

December 2014

Play around with simulations of quantum circuits!

Quantum Mechanic simulates and displays quantum circuits using QuTiP, and outputs the behaviour of the resulting n-qubit circuit as a 2n-by-2n unitary matrix. (Naturally, this means you’re not allowed to use very many qubits!)

Built as my final project for Scott Aaronson’s class 6.845: Quantum Complexity Theory in 2014. Report here. See the code on GitHub.

Mattampa puang lé ri batara: a linguistics problem 𓏟

October 2014

There is no one to call the gods Lord, or to offer praise to the underworld. Why, Lord, don’t you have one of your children descend, and incarnate him on the earth? Do not leave the world empty and the earth uninhabited.

—The Sureq Galigo


I wrote this problem for the 2014 North American Computational Linguistics Olympiad involving the Lontara writing system. Solutions here.

Mathematical Insights in Computing 𓍝

August 2014

Problem-solving meets philosophy as we explore mind-blowing ideas from the theoretical study of complex systems: computers, minds, and beyond.

Mathematical Insights in Computing was a six-week-long, four-session-per-week class that I designed and taught for MIT ESP’s Junction summer program in 2014. Based on an MIT class I took – 6.045, Automata, Computability, and Complexity – this class synthesized many of my favorite concepts in computer science into a rigorous course for advanced high school students.

Readings I assigned:

Problem sets I assigned:

Just for fun:

USA Biology Olympiad lectures 𓅞

July 2014

Resources I created for students at 2014’s USA Biology Olympiad training camp.

Fun with Time Travel: retroactive data structures 𓁀

May 2014

Retroactive data structures are data structures in which operations and queries are allowed to be made in the past, updating the data structures as if history itself had been rewritten.

For my final project in 6.851: Advanced Data Structures, I implemented a library with several algorithms for producing retroactive data structures using Python. As an example, consider a list datastructure in which we’re allowed to insert or remove operations from the past:

>>> y = FullyRetroactive([1,2,3])
>>> y.insertAgo(appendOne, tminus=0)
>>> y.insertAgo(appendSix, tminus=0)  # This one should come last
>>> y.insertAgo(appendTen, tminus=2)  # This one should come first
>>> y.query()  # The current state of the data structure
[1, 2, 3, 10, 1, 6]
>>> y.query(1)
[1, 2, 3, 10, 1]
>>> y.query(2)
[1, 2, 3, 10]
>>> y.query(3)  # The state of the data structure way back in the past
[1, 2, 3]

For more information, see the code at GitHub.

Things Mimicking Other Things 𓆤

September 2013

Things Mimicking Other Things is an interactive exploration of animals, camouflage, and mimicry.

It uses Vivagraph.js to draw an interactive, draggable graph. Although the page is static, it is updated from basic data using a Python script whenever I add new entries.

The hardest part was getting performance just right: small images need to be converted to thumbnails (which is done using Python Image Library), and big images need to be pre-loaded in the background.

See the code on GitHub.

See also its sister project, Tree of Life, which is a simple visual study tool intended for anyone studying systematics from the International Biology Olympiad study guide.

Visual Traceroute 𓊝

April 2013

Traceroute is a tool for visually tracing packets through the Internet, from MIT’s servers to any website.

It uses traceroute to fetch IP addresses, maps those IP addresses to coordinates using ipinfo.io, and plots those coordinates with the Google Maps API.

This was inspired by a class I took in spring 2013: our class designed an exhibit about the Internet, Net Works, for the MIT Museum.

See the code on GitHub.

Procedurally-generated organic chemistry problems 𓊲

January 2013

Carbonate creates interactive organic chemistry practice problems, both simple one-step quizzes or complicated multi-step synthesis problems. It is intended as a tool to help organic chemistry students study.

The website uses the Django web framework to connect a drag-and-drop frontend UI with a Python backend that extensively represents the logic for chemical reactions. It’s capable of parsing molecules and applying reactions from Unit 1 and Unit 2 of MIT 5.12 (Organic Chemistry I). It uses the OpenBabel chemistry library to render molecules, and can interconvert between its molecule format (Python objects) and SMILES strings.

Built in collaboration with Felix Sun. Received the “MIT Utility Award” in 6.470, MIT’s web programming competition.

See the code on GitHub.