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
; A solution to the latest http://reaktor.fi/careers/fast_track/ | |
; | |
; Calculates recursively the maximum path function | |
; S(i,j) = W(i,j) + max { S(i-1, j-1), S(i-1, j) } | |
; | |
; Solution to the problem is just finding | |
; M = max { S(N, i) }, 1 <= i <= N (using 1-based indexing) | |
; | |
; then prints out the solution from the given node as an HTML table. | |
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
function calculate(o){return _.foldl(o,function(a,b){a[b.vat]=b.price+(a[b.vat]||0);return a},{})} |
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
(ns test.core | |
(:require [clojure.string :as str])) | |
(def morse | |
(into [] | |
(sort-by key (comparator (fn [x y] (<= (count x) (count y)))) | |
{".-" "A" "-..." "B" "-.-." "C" "-.." "D" "." "E" "..-." "F" "--." "G" "...." "H" ".." "I" ".---" "J" "-.-" "K" ".-.." "L" "--" "M" "-." "N" "---" "O" ".--." "P" "--.-" "Q" ".-." "R" "..." "S" "-" "T" "..-" "U" "...-" "V" ".--" "W" "-..-" "X" "-.--" "Y" "--.." "Z"}))) | |
(defn build-dfa | |
([codes] (build-dfa codes [])) |
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
NSArray *items = @[_gainSlider, _frequencySaturation, _driveSlider]; | |
NSArray *signals = [[[items rac_sequence] map:^id(id value) { | |
return [value rac_highlightSignal]; | |
}] array]; | |
__block BOOL triggering = NO; | |
[[RACSignal merge:signals] | |
subscribeNext:^(RACTuple* value) { | |
if(triggering) { return; } | |
triggering = YES; |
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
var find_greatest = function(input) { | |
var check = function(n) { | |
if(n==0) { return false; } | |
// n is of form x^5 + O(x^4), so we can pick it by taking the | |
// fifth root and taking the extra crust off | |
var x = Math.floor( Math.pow( n, 0.2 ) ) - 1 | |
return n === x*(x+1)*(x+2)*(x+3)*(x+4); | |
} | |
var slice_n = function(n,x) { |
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
qwerty = u"qwertyuiopåasdfghjklöä'zxcvbnm," | |
transpose = lambda s,t: ''.join([ (qwerty[qwerty.index(c)+t] if c in qwerty else c) for c in s]) | |
encode = lambda s: transpose(s, 1) | |
decode = lambda s: transpose(s, -1); |
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
// Texture: 1024 x 1024 x 4bpp | |
// Contains 1024 x 768 image from (0,0) to (1024, 768) | |
// Use glOrtho like glOrtho2d | |
glOrtho(0, width, height, 0, -1, 1); | |
// This solved it! | |
glClear(GL_COLOR_BUFFER_BIT); | |
glClearColor(0.0, 1.0, 0.0, 1.0); | |
glMatrixMode(GL_MODELVIEW); |
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
// Ah. Better. | |
typedef struct { | |
float x1, x2, y1, y2; | |
float c0, c1, c2, c3, c4; | |
} biquad_t; | |
typedef enum { | |
HIGH_SHELF, | |
LOW_SHELF, |
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
// init: | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'UA-FOOBAR-X']); | |
(function() { | |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | |
})(); |
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
double direction_x = 0.0, direction_y = 0.0, direction = 0.0; | |
CGPoint d = CGPointMake(current.x - previous.x, current.y - previous.y); | |
if(d.x != 0) { | |
if(current.y <= kCenterY) { | |
if(d.x > 0.0) { | |
direction_x = 1.0; | |
} else { | |
direction_x = -1.0; | |
} |