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 java.util.ArrayList; | |
import java.util.List; | |
import java.util.Scanner; | |
public final class FastRabinKarpHashFunction { | |
private final int[] map; | |
private final int[] factors; | |
private final int q; |
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
#! /bin/bash | |
# Below, XXXX asks for random characters in order to make a unique file name. | |
# Mac OSX seems to ignore XXXX, yet Ubuntu requires them. | |
# Create a temporary file name for the source code: | |
TMP_SOURCE_FILE="$(mktemp -t sourceXXXX).c" | |
# Create a temporary file name for the executable file: | |
TMP_PROGRAM_FILE="$(mktemp -t programXXXX)" |
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
#! /bin/bash | |
# Create a temporary file name for the executable file: | |
TMP_PROGRAM_FILE="$(mktemp programXXXXXX)" | |
# Compile the embedded C program: | |
gcc -o "$TMP_PROGRAM_FILE" -x c - <<- END_OF_SOURCE | |
#include <stdio.h> | |
int main(int argc, char* argv[]) |
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 <stdint.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
uint64_t read_time_stamp_counter() | |
{ | |
uint32_t my_edx; | |
uint32_t my_eax; | |
asm ("cpuid\n\t" |
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 java.util.Arrays; | |
import java.util.Random; | |
public class Mergesort { | |
public static int[] mergeSort(int[] arr) { | |
if (arr.length <= 1) { | |
return arr; | |
} |
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
from time import clock | |
def sylvester_number_original(n): | |
if n == 0: | |
return 2 | |
return sylvester_number_original(n - 1) * (sylvester_number_original(n - 1) - 1) + 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
import java.math.BigDecimal; | |
import java.math.RoundingMode; | |
import java.util.ArrayDeque; | |
import java.util.Queue; | |
import java.util.Random; | |
public class MovingAverageV2 { | |
private final Queue<BigDecimal> window = new ArrayDeque<>(); | |
private final int period; |
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
/****************** | |
* File: execres.c * | |
******************/ | |
#include "execres.h" | |
#include <stdlib.h> | |
PExecResult execTime( void* (*code)( void*), void* param ){ | |
PExecResult result = (PExecResult) malloc( sizeof(ExecResult) ); |
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
package net.coderodde.util; | |
/** | |
* This class contains static utility methods for dealing with matrices of | |
* {@code double} values. | |
* | |
* @author Rodion "rodde" Efremov | |
* @version 1.6 | |
*/ | |
public class MatrixUtils { |
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
package net.coderodde.util; | |
import java.util.ArrayDeque; | |
import java.util.Deque; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.NoSuchElementException; | |
import java.util.Objects; | |
import java.util.PriorityQueue; | |
import java.util.Random; |
OlderNewer