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 <iostream> | |
#include <fstream> | |
#include <cctype> | |
using namespace std; | |
class Trie | |
{ | |
public: | |
struct Node | |
{ |
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
``` cpp | |
void inc(int& n) | |
{ | |
int off = 1; | |
while(n & off) | |
{ | |
n ^= off; | |
off <<= 1; | |
} | |
n ^= off; |
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 inc(int& n) | |
{ | |
int off = 1; | |
while(n & off) | |
{ | |
n ^= off; | |
off <<= 1; | |
} | |
n ^= off; | |
} |
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
(defn circle-test [x y] | |
(not ( > ( + (* (- x 0.5) (- x 0.5)) (* (- y 0.5) (- y 0.5))) 0.25))) | |
(defn error [est] | |
(Math/abs (* (/ (- Math/PI est) Math/PI) 100))) | |
(defn pi [n] | |
(loop [hits 0 total 0] | |
(let [x (rand) y (rand)] | |
(if (< total n) |
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 <unistd.h> | |
int main() | |
{ | |
pid_t pid = fork(); | |
if(pid == -1) | |
fprintf(stderr,"There was an error\n"); | |
else if(pid == 0) | |
printf("I am the child. I do not know my pid.\n"); |
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 distance(a,b) | |
matrix = Array.new(a.size + 1) { Array.new(b.size + 1) } | |
(0..a.size).each { |i| matrix[i][0] = i } | |
(0..b.size).each { |j| matrix[0][j] = j } | |
(1..a.size).each do |i| | |
(1..b.size).each do |j| | |
if a[i-1] == b[j-1] | |
matrix[i][j] = matrix[i-1][j-1] | |
else | |
matrix[i][j] = [matrix[i-1][j] + 1,matrix[i][j-1] + 1,matrix[i-1][j-1] + 1].min |
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
$ ./test | |
./test: error while loading shared libraries: libSDL_draw-1.2.so.0: cannot open shared object file: No such file or directory | |
$ which libSDL_draw-1.2.so.0 | |
/usr/local/lib/libSDL_draw-1.2.so.0 |
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
/* | |
LEAST LIKELY TO COMPILE SUCCESSFULLY: | |
Ian Phillipps, Cambridge Consultants Ltd., Cambridge, England | |
*/ | |
#include <stdio.h> | |
main(t,_,a) | |
char | |
* | |
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
redis.zrevrangebyscore(@id_info_key, a, b, {:limit => [0,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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#include <plot.h> | |
const double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282; | |
const double F = 2; | |
double arr[16]; |