Skip to content

Instantly share code, notes, and snippets.

View geekynils's full-sized avatar
😄

Nils geekynils

😄
View GitHub Profile
#include <iostream>
#include <vector>
#include <stack>
#include <utility>
using namespace std;
struct Node {
int val = -1;
Node* left = 0;
// Linked list using optionals and enums with associated values.
// See https://medium.com/@andre_videla/total-programming-in-swift-526508c12a74
import Foundation
class Node<Elem> {
init(withElement elem: Elem, attachToList tail: List<Elem>) {
self.elem = elem
self.tail = tail
}
@geekynils
geekynils / DancingRect.qml
Created October 11, 2017 23:19
Dancing Rectangles
import QtQuick 2.0
Rectangle {
width: 40
height: 40
color: 'transparent'
property real distance: 1
Rectangle {
anchors.centerIn: parent
property real size: 32 - parent.distance * 0.2;
/**
* Koch Curve
* F -> F + F - F - F + F
* F means draw a straight line, + means turn left Pi/2 and - means turn
* right Pi/2.
* See wikipedia for more.
*
* by NilsB
*/
@geekynils
geekynils / MonteCarloPi
Created January 5, 2014 17:30
Calculating Pi..
package main
import (
"fmt"
"math"
"math/rand"
"time"
)
func calcPiRandom(nPoints int) float64 {
@geekynils
geekynils / Quicksort.py
Created October 22, 2012 12:13
Quicksort
from scene import *
import console
def swap(a, i, j):
tmp = a[i]
a[i] = a[j]
a[j] = tmp
def choose_pivot(a):
return len(a) / 2