Skip to content

Instantly share code, notes, and snippets.

View neptunius's full-sized avatar
🌈

Alan Davis // Rainbow neptunius

🌈
View GitHub Profile
@neptunius
neptunius / EggBalancing.py
Created May 5, 2011 20:21
Python solution to the Egg-Balancing Puzzle I invented.
#!python
## Egg-Balancing Puzzle
## Alan Davis - 5/4/2011
from __future__ import division # to ensure true division
import sys # to read input from standard input
import json # to decode input in JSON format
## Attempt to balance the given egg carton
def balance_carton(width, height, eggs):
@neptunius
neptunius / The-Four-Frames-of-Leap.loop
Last active October 4, 2015 02:05
The Four Frames of Leap.loop
Peter and I started prototyping what multiple device support would look like in LeapJS with skeleton tracking and ended up at this wild callback with quadruply-nested for-loops:
Leap.loop ->
for frame in arguments
for hand in frame
for finger in hand
for joint in finger
drawSphere joint.position
/*==================================================================================================================
Copyright (c) 2010 - 2014 Leap Motion. All rights reserved.
The intellectual and technical concepts contained herein are proprietary and confidential to Leap Motion, and are
protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from Leap Motion.
===================================================================================================================*/
#!/usr/local/bin/python3
class Node(object):
def __init__(self, data=None):
self.data = data
self.next = None
def __str__(self):
@neptunius
neptunius / recursion.py
Last active March 31, 2016 00:44
Comparison of iterative and recursive functions
import unittest
def factorial(n):
"""factorial(n) returns the product of the integers 1 through n for n >= 0,
otherwise raises ValueError for n < 0 or non-integer n"""
# implement factorial_iterative and factorial_recursive below, then
# change this to call your implementation to verify it passes all tests
# return factorial_iterative(n)
return factorial_recursive(n)
@neptunius
neptunius / squareup.py
Created February 8, 2019 09:02
Asim's square up coding challenge
#!python3
def square_up(n):
"""Simple test cases in docstring
>>> square_up(2)
[0, 1, 2, 1]
>>> square_up(3)
[0, 0, 1, 0, 2, 1, 3, 2, 1]
>>> square_up(4)

Cracking WSP Encryption

Project Background

An unnamed government security agency has recently begun intercepting numerous messages encrypted with a state of the art, never before seen algorithm. Because everything in government needs an acronym, the application of this algorithm has been nicknamed "WSP Encryption."

Up to this point in time, a team of seven highly paid PhD analysts has been staffed to manually decrypt each and every WSP-encrypted message they receive. The analysts have not slept or eaten in twelve days, and many of them are beginning to face burnout. Meanwhile, the stack of encrypted messages continues to grow.

As a frantic last ditch effort, the director of the unnamed agency performed a late night PRISM search to identify a coder capable of automating the decryption processes. As a top Make School student, YOU have been selected to carry out this task!

@neptunius
neptunius / cs-1.1-01-snippets.py
Last active August 28, 2019 21:41 — forked from ibirnam/cs-1.1-01-snippets.py
code snippets used for the first class of CS 1.1
# CS-1.1 Variables, Function, and Program Design
def greet_by_name(name):
greeting = "Hello, " + name + "!"
return greeting
print(greet_by_name("Alan"))
# Hello, Alan!
print(greet_by_name("Jess"))
@neptunius
neptunius / madlibs.py
Created September 11, 2019 22:06
Code snippets to show how to reduce line length and complexity
madlib = (madlib.replace(word_type, input("Enter a {}: ".format(word_type)), 1))
prompt = "Enter a {}: ".format(word_type)
user_word = input(prompt)
madlib = madlib.replace(word_type, user_word, 1)
################################################################################
for x in range(len(stories[story]["words"])):
stories[story]["words"][x] = input(stories[story]["words"][x] + ": ")
@neptunius
neptunius / litebrite.py
Last active October 9, 2019 03:14
Rainbow code for Dani's Lite Brite activity – client: make.sc/litebrite-client and server: make.sc/litebrite-repo
from math import sin, cos, radians
import os
import pusher
# Step 1: Change YOUR_NAME to your own name!
YOUR_NAME = 'Rainbow'
# Step 2: Choose a color and assign it to YOUR_COLOR.
# HINT 1: Value should always be a six character hex code with a # in front.
# HINT 2: Find colors that will look good in the demo here: https://github.com/yeun/open-color#available-colors