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
// Feeling overwhelmed by "find the words in a grid" tasks for preschoolers? | |
// Look no further! | |
#include <leptonica/allheaders.h> | |
#include <tesseract/baseapi.h> | |
#include <fstream> | |
#include <iostream> | |
#include <sstream> | |
#include <string> | |
#include <vector> | |
using namespace std; |
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
namespace { | |
template <typename F, int I, typename L, typename R, typename ...A> | |
inline F convert(L&& l, R (*)(A...) noexcept(noexcept(::std::declval<F>()(::std::declval<A>()...)))) { | |
static thread_local L l_(::std::forward<L>(l)); | |
static thread_local bool full; | |
if (full) { | |
l_.~L(); | |
new (static_cast<void*>(&l_)) L(::std::forward<L>(l)); | |
} else |
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> | |
#include <stdint.h> | |
enum { | |
TAG = 0x100, COMMENT, REGULAR_MOVE, PROMOTION_MOVE, SHORT_CASTLE, LONG_CASTLE, | |
R1_0, R0_1, R12_12, RSTAR, CONTINUATION_MOVE_NUMBER, MOVE_NUMBER | |
}; |
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
// Public Domain. | |
#include <stdint.h> | |
#include <stdio.h> | |
uint32_t s, b; | |
void ccg_seed(uint32_t seed) { | |
s = (b = seed ^ 0xAAAAAAAA) | 1; | |
} | |
uint32_t ccg_next() { | |
uint32_t b = s >> 31; | |
s <<= 1, s ^= b * 0xEDB88320; |
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
#define COPY(dst, src, n) for (int i = 0; i < n; i++) dst = src; | |
typedef struct { | |
uint32_t range, FF, cache; uint64_t low; FILE * source; | |
} rc_t; | |
void rc_init(rc_t * rc, FILE * source) { | |
rc->range = 0xFFFFFFFF; | |
rc->FF = rc->cache = 0; rc->low = 0; | |
rc->source = source; | |
} | |
void rc_init_dec(rc_t * rc, FILE * source) { |
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
106 : ES6 | |
107 : Nim | |
110 : Keg | |
114 : Fig | |
115 : Cubix | |
116 : Attache | |
117 : k | |
122 : Ly | |
123 : tinylisp | |
124 : Oracle |
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 <book.h> | |
#define CODE_MAX 65534 | |
#define DICT (1 << 17) | |
#define LZWEOF 256 | |
struct { int32_t parent; int16_t c, code; } dict[DICT]; | |
void encode(FILE * in, FILE * out) { | |
int nc = LZWEOF + 1, c, sc, i; | |
COPY(dict[i].code, -1, DICT); | |
if ((sc = fgetc(in)) == EOF) sc = LZWEOF; | |
while ((c = fgetc(in)) != EOF) { |
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 Control.Monad | |
import System.Random | |
import Control.Monad.Trans.State | |
import Control.Lens hiding(under) | |
import Control.Conditional hiding(unless, when) | |
import Data.List | |
import Data.Functor | |
import Data.Random.Lift | |
import Control.Monad.IO.Class | |
import Control.Monad.Fix |
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
void magic(float * x, size_t n) { | |
uint32_t * result = malloc(n * sizeof(uint32_t)), | |
* buckets = malloc(0x100*sizeof(uint32_t)), | |
* si = malloc(0x100*sizeof(uint32_t)), | |
* y = (uint32_t *) x, key, temp; | |
for (size_t i = 0; i < n; i++) y[i] ^= 0x80000000; | |
for (int i = 0; i < n; ++i) ++buckets[y[i] & 0xFF]; | |
si[0] = 0; | |
for (int j = 1; j < 0x100; ++j) si[j] = si[j - 1] + buckets[j - 1]; | |
for (int i = n-1; i >= 0; --i) key = y[i] & 0xFF, result[si[key] + --buckets[key]] = y[i]; |
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
e1←{⍵/⍨⍵≥⌈\⍵} | |
e2←⌽⍷⍥⌽ | |
e3←{(⍺∘⌽⌷⍨∘⊂⍵⍳⍨⊢)' ',⎕A} | |
e4←×2⊥>-< | |
e5←{n,l-n←(l↑⍺)+.≤⍵↑⍨l←⍺⌊⍥≢⍵} | |
e6←(⊢⍴⍨2,⍨2÷⍨⍴)~⍤∊⍨⊆⊢ | |
e7←(,÷∨)∘1 | |
e8←{3↑⊃¯2⎕dt(1⎕dt⊂⍵)+⌊/644 924 759|⍺-⍥(1⎕dt⊆)⍵} | |
e9←{↑,/⌽¨⍵⊂⍨1 0⍴⍨≢⍵} | |
e0←{(⊢,(⊂'')↑⍨⍺-≢)1↓¨(' ',⍵)⊂⍨(⊢∧⍺≥+\)1,' '=⍵} |
NewerOlder