This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <stack> | |
#include <utility> | |
using namespace std; | |
struct Node { | |
int val = -1; | |
Node* left = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
"math/rand" | |
"time" | |
) | |
func calcPiRandom(nPoints int) float64 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |