Skip to content

Instantly share code, notes, and snippets.

View coderodde's full-sized avatar

Rodion Efremov coderodde

View GitHub Profile
@coderodde
coderodde / main.c
Last active September 27, 2016 11:26
TelephoneBookV2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MAX_RECORD_TOKEN_LENGTH 64
#define MAX_RECORD_TOKEN_LENGTH_STRING "64"
#define TELEPHONE_RECORD_BOOK_FILE_NAME ".telephone_book"
static const char* TITLE_LAST_NAME = "Last name";
#include "mergesort.h"
#include <algorithm>
#include <chrono>
#include <cstdint>
#include <iostream>
#include <random>
#include <vector>
using std::boolalpha;
using std::copy;
@coderodde
coderodde / BackwardDigraphNodeExpander.java
Created September 9, 2016 16:10
Provides the performance demonstration for DelayedGraphSearchLibrary algorithm vs. bidirectional BFS.
import java.util.ArrayList;
import java.util.List;
import net.coderodde.graph.pathfinding.uniform.delayed.AbstractNodeExpander;
public class BackwardDigraphNodeExpander
extends AbstractNodeExpander<DigraphNode> {
@Override
public List<DigraphNode> expand(DigraphNode node) {
#include "stable_sort.h"
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct run_length_queue
{
size_t* storage;
function fuckyeah_bling(fuckyeah_text_element) {
var black = true;
function fuckyeah_bling_func() {
var colors = ["red", "orange", "yellow", "green", "blue", "violet"];
var index = Math.floor(Math.random() * 6);
fuckyeah_text_element.style.color = colors[index];
fuckyeah_text_element.style.backgroundColor = black ? "black" : "white";
black = !black;
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;
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 {
/******************
* File: execres.c *
******************/
#include "execres.h"
#include <stdlib.h>
PExecResult execTime( void* (*code)( void*), void* param ){
PExecResult result = (PExecResult) malloc( sizeof(ExecResult) );
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;
@coderodde
coderodde / sylvester.py
Created April 25, 2016 11:43
Computing Sylvester numbers for CR
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