Skip to content

Instantly share code, notes, and snippets.

@preshing
preshing / rsu.cpp
Created December 24, 2012 04:07
A C++ source file to test the RandomSequenceOfUnique random number generator using TestU01's SmallCrush test suite.
#include "randomsequence.h"
#include <stdio.h>
#include <string.h>
extern "C"
{
#include "unif01.h"
#include "bbattery.h"
#include "util.h"
}
@preshing
preshing / validate.py
Created November 5, 2012 02:54
Python script to help validate 1MB Sorter
from subprocess import *
import time
def validate(sequence):
start = time.clock()
sorter = Popen('sort1mb.exe', stdin=PIPE, stdout=PIPE, stderr=PIPE)
for value in sequence:
sorter.stdin.write('%08d\n' % value)
sorter.stdin.close()
result = [int(line) for line in sorter.stdout]
@preshing
preshing / sort1mb.cpp
Created November 5, 2012 02:52
Sort one million 8-digit numbers in 1MB RAM, with statistics
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------
@preshing
preshing / sort1mb.cpp
Created October 25, 2012 11:28
Sort one million 8-digit numbers in 1MB RAM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------