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
def monty_hall | |
doors = ['goat', 'stupid goat', 'car'] | |
doors.delete choice = doors.sample | |
doors.delete reveal = doors.grep(/goat/).sample | |
puts 'Stay or switch?' until %w[stay switch].include? action = gets.chomp | |
choice = doors.last if action == 'switch' |
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
; brainfuck interpreter in Whitespace assembly | |
; To facilitate the interpretation of "literate" brainfuck, consecutive newlines | |
; are used to signal the end of program input. Thus, the previous character must | |
; be remembered. Also, non-brainfuck characters must be passed over silenty. The | |
; heap is used for these processes to avoid having to juggle the stack too much. | |
push , | |
push . | |
push < | |
push > |
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 <stdio.h> | |
#include <stdlib.h> | |
unsigned char convert(unsigned char c) | |
{ | |
return (c & 0x40) << 1 | |
| (c & 0x07) << 4 | |
| (c & 0x80) >> 4 | |
| (c & 0x38) >> 3; | |
} |
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
<map> | |
<boolean name="lineWrap" value="true"/> | |
<boolean name="alternativeActionBar" value="true"/> | |
<boolean name="actionBar" value="true"/> | |
<boolean name="rootMode" value="false"/> | |
<string name="theme.0.background">#ff002b36</string> | |
<boolean name="actionBarTabs" value="true"/> | |
<string name="theme.0.type">#ffb58900</string> | |
<boolean name="bugsense" value="true"/> | |
<string name="lineBreak">linux</string> |
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
class Object | |
def >> _ | |
_.send *self | |
end | |
end | |
['get', '/', &-> { ['haml', 'to_sym' >> 'index'] >> self }] >> self |
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
module ReverseSend | |
def self.extended klass | |
klass.send(:define_method, '>>') do |obj| | |
obj.send *self | |
end | |
end | |
end | |
class String | |
extend ReverseSend |
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
require 'church' | |
include Church, Church::Utils | |
$_ = JOIN[MAP[CHARS[$_], &ROT13], ''] |
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
MAP = -> coll, &fn { | |
coll == [] ? [] : [fn[coll[0]]] + MAP[coll[1..-1], &fn] | |
} | |
SIZE = -> coll { | |
coll == [] || coll == '' ? 0 : 1 + SIZE[coll[1..-1]] | |
} | |
FILTER = -> coll, &fn { | |
coll == [] ? [] : (fn[coll[0]] ? [coll[0]] : []) + FILTER[coll[1..-1], &fn] |
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
require 'church' | |
include Church | |
GORELLIAN = -> n, alphabet, words { | |
alphabet = MAP[CHARS[alphabet], &-> a { ORD[a] | 32 }] | |
EACH[SORT_BY[words, &-> w {MAP[CHARS[w], | |
&-> c { INDEX[alphabet, ORD[c] | 32] }] }], &PUTS] | |
} |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define MAXWORD 80 | |
char alphabet[27]; | |
int gorellian_strcmp(const void *va, const void *vb) | |
{ | |
size_t i; |
NewerOlder