Skip to content

Instantly share code, notes, and snippets.

@Descalon
Descalon / FindChildren.cpp
Last active December 12, 2015 07:48
Trying to find a binary tree in a Delaunay graph. This must be pretty inefficient.
bool findChildren(Center* root, Center* dNeighbour, float depth){
if(depth < 0) return false;
vector<vector<Center*>> checkLists;
vector<Center*> check;
if(dNeighbour != nullptr){
check = findSharedNodes(root, dNeighbour);
checkLists.push_back(check);
}
Center* c1, * c2;
@Descalon
Descalon / fizzbuzz.cs
Last active December 19, 2015 12:19 — forked from JeremyMorgan/fizzbuzz.cs
My most compact, sensible and readable answer to the FizzBuzz problem.
using System;
namespace CrapTester_vs10 {
public class Program {
static void Main(string[] args) {
string s;
for (int i = 1; i < 100; i++) {
s = "";
if (i % 3 == 0)
s += "Fizz";
if (i % 5 == 0)
@Descalon
Descalon / OneLineFizzBuzz.cs
Last active December 19, 2015 12:19
Nice FizzBuzz one liner.
public class Program {
static void Main(string[] args) {
string s;
for (int i = 1; i < 100; i++) {
s = (i % 15 == 0) ? "FizzBuzz" :(i % 3 == 0) ? "Fizz" : (i % 5 == 0) ? "Buzz" : i.ToString();
System.Console.WriteLine(s); //LOG
}
}
}
@Descalon
Descalon / MeshExtruder.cs
Created July 18, 2013 08:09
Unity Mesh Extruder found on Google Code
using UnityEngine;
using System.Collections;
/*
* An algorithm to extrude an arbitrary mesh along a number of sections.
The mesh extrusion has 2 steps:
1. Extracting an edge representation from an arbitrary mesh
- A general edge extraction algorithm is employed. (Same algorithm as traditionally used for stencil shadows) Once all unique edges are found, all edges that connect to only one triangle are extracted.
@Descalon
Descalon / lalg2e.tex
Created March 4, 2014 15:46
Latex algorithm2e usage
\usepackage[lined,boxed]{algorithm2e} %preamble
%algorithm usage
\begin{algorithm}
\KwIn{entities; actors; player; customRules;}
\KwOut{new world state}
let \textit{entities} be all entities, excluding actors and the player\;
let \textit{actors} be all actors, including the player\;
\ForEach{actor in actors}{
actor.rules.Invoke()\;
@Descalon
Descalon / FileReader
Created March 12, 2015 13:45
New proposition file reader
public static bool Foo(byte[] txt)
{
var ms = new MemoryStream(txt);
using (var sr = new StreamReader(ms))
{
DynamicElement.ChangedElements.Clear();
DynamicElement.TrainElements.Clear();
while (!sr.EndOfStream)
{
@Descalon
Descalon / rules.ts
Created October 8, 2016 14:41
Powershell formatting rules
let rules: [RegExp,string][] = [
[/\bbegin\b/ig, 'Begin'],
[/\bbreak\b/ig, 'Break'],
[/\bcatch\b/ig, 'Catch'],
[/\bcontinue\b/ig, 'Continue'],
[/\bdata\b/ig, 'Data'],
[/\bdo\b/ig, 'Do'],
[/\bdynamicparam\b/ig, 'DynamicParam'],
[/\belse\b/ig, 'Else'],
[/\belseif\b/ig, 'Elseif'],
module ModularExponentiation where
slowExM :: Integer -> Integer -> Integer -> Integer
slowExM x e m = (x ^ e) `mod` m
exM :: Integer -> Integer -> Integer -> Integer
exM x e m =
let exM' c e' = if e' < e then exM' c' (e'+1) else c'
where c' = (x * c) `mod` m
in exM' 1 1
@Descalon
Descalon / Report.md
Last active October 10, 2019 12:18
Poging tot een deur

AML Report

Spec findings

  • Most SUTs implement a response shut_off that is not specified. If this was a singular case - only one SUT had this response - then I'd regard it as an anomaly, but (for now) the count is 3.

Besto

  • Locking while locked should give a !invalid_command but SUT sends !locked
  • Implements !shut_off
IEnumerable<int> Foo (int[] vals, int padding) {
var start = vals[0];
for(var i = 1; i > vals.Length; i++){
var v = vals[i];
var padded = start + (padding * i);
yield return System.Math.Max(padded, v)
}
}