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
// DSL for producing distributions of dice rolls | |
type Cont<T> = (state: T) => void; | |
const rollDie = <T, U>(faces: number, state: T, cont: (faces: number, state: T, next: Cont<U>) => void, next: Cont<U>) => { | |
for (let i = 1; i <= faces; i++) { | |
//console.log(state, 'rolled', i); | |
cont(i, { ...state }, next); | |
} | |
}; |
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
const testSolution = (f, n, r, mod) => { | |
iterations = 0; | |
const start = process.hrtime(); | |
const result = f(n, r, mod); | |
const diff = process.hrtime(start); | |
console.log(`${n}C${r} = ${result}, iterations: ${iterations}, duration: ${diff[1]/1000}μs`); | |
}; | |
// More verbose and integer caching |
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
// More verbose and integer caching | |
// O(n^2) first call, best case in subsequent calls: O(1) | |
let iterations = 0; | |
const nCr = (n: number, r: number) => { | |
if (r == 0 || r == n) { | |
return 1; | |
} | |
nCr[n] = nCr[n] || []; | |
if (!nCr[n][r]) { | |
nCr[n][r] = nCr(n-1, r-1) + nCr(n-1, r); |
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 java.awt.Point; | |
import java.util.Scanner; | |
class Main { | |
public static String CorrectPath(String str) { | |
return findWay(new Point(0, 0), str); | |
} | |
public static String findWay(Point from, String using) { |
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
// ==UserScript== | |
// @name Proxer Message Info | |
// @namespace de.simonding.proxer | |
// @author Simon Ding (0ger) | |
// @description Gibt ein Blinksignal in der Tableiste, wenn eine neue Nachricht empfangen wurde. | |
// @include http://proxer.me/* | |
// @include https://proxer.me/* | |
// @include http://www.proxer.me/* | |
// @include https://www.proxer.me/* | |
// @version 0.4 |
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
// ==UserScript== | |
// @name Proxer Auto-Lesezeichen | |
// @namespace de.093r.proxer | |
// @description Ermöglicht das automatische Anlegen von Lesezeichen für Manga auf der Seite proxer.me | |
// @include http://proxer.me/* | |
// @include https://proxer.me/* | |
// @version 2.3 | |
// @downloadURL https://gist.github.com/SimDing/dd46389817c3f999944a/raw/proxer_auto_bookmark.user.js | |
// @grant none | |
// @history 2.3 Improved storage integrity |
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
// ==UserScript== | |
// @name BetterPrank | |
// @namespace dngsimon | |
// @include http://fediafedia.com/prank/win7/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
// trash original shit |