Skip to content

Instantly share code, notes, and snippets.

View robot-dreams's full-sized avatar

Elliott Jin robot-dreams

  • San Francisco, CA
View GitHub Profile
@robot-dreams
robot-dreams / project-euler-001.sol
Last active March 18, 2018 05:39
Project Euler #1 as an Ethereum contract (written in Solidity)
pragma solidity ^0.4.0;
contract ProjectEuler001 {
// For the low price of 1000 wei, you can solve Project Euler Problem 1!
uint price = 1000;
event Solved(uint n, uint result);
// Returns the n-th triangular number 1 + 2 + ... + n
function t(uint n) private pure returns (uint) {
@robot-dreams
robot-dreams / goldenSpiral.pde
Last active May 3, 2023 09:56
Draw a golden spiral with Processing
float PHI = (1 + sqrt(5)) / 2;
void goldenSpiral(float h) {
// Base case: stop drawing if the height is too small.
if (h < 2) {
return;
}
// Draw bounding box and quarter circle. For some reason, using 2 * h - 1
// looks better than using 2 * h.