Skip to content

Instantly share code, notes, and snippets.

View coderodde's full-sized avatar

Rodion Efremov coderodde

View GitHub Profile
@coderodde
coderodde / Heapsort.java
Created May 30, 2023 11:56
Heapsort in Java.
package com.github.coderodde.util;
import java.util.Arrays;
import java.util.Random;
public final class Heapsort {
public static void sort(int[] array) {
if (array.length < 2) {
return;
@coderodde
coderodde / main.cpp
Created May 30, 2023 06:54
CR.NlogNSorting
#include <iostream>
#include <chrono>
#include <random>
#include <iomanip>
#include <cstring>
// coderodde's mergesort:
void coderodde_merge(int* source_array, int* target_array, int source_offset, int target_offset, int left_run_length, int right_run_length) {
int target_index = target_offset;
int left_index = source_offset;
@coderodde
coderodde / Instructions
Created May 13, 2023 18:47
My DOSKEYs.
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\Autorun <- DOSKEY /MACROFILE="C:\Users\rodio\setup.doskey"
0.02980 3224
0.03970 2354
0.06940 2340
0.07930 3074
0.08920 3525
0.09910 2074
0.11890 3494
0.12880 3266
0.13870 2216
0.16840 2908
@coderodde
coderodde / tictactoe.c
Created February 23, 2023 16:47
Tic-tac-toe in C with a alpha-beta pruning AI.
#ifdef _WIN32
// Otherwise, Visual Studio (2022) complains about scanf.
#define _CRT_SECURE_NO_WARNINGS
#endif // _WIN32
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
#include <wchar.h>
@coderodde
coderodde / ArithmeticSchemeValidator.java
Last active February 19, 2023 10:14
Validating the arithmetic expansion scheme expression.
import java.math.BigDecimal;
public class ArithmeticSchemeValidator {
private static final int MAX_D = 200;
private static final int MAX_M = 200;
private static final int MAX_N = 1_000;
public static int getC(int n, int m, int d) {
int y = myCeil(n, m, d);
@coderodde
coderodde / tictactoe.c
Last active November 1, 2022 07:14
CR.TicTacToe - A console Tic Tac Toe with a Minimax-based AI.
#ifdef _WIN32
#define _CRT_SECURE_NO_WARNINGS
#endif // _WIN32
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
#define HEIGHT 3
@coderodde
coderodde / EntropyToAmortizedWork.dat
Created October 24, 2022 09:30
The gnuplot data file for SO
0.01990 2815
0.04960 4517
0.05950 2848
0.09910 2173
0.10900 2975
0.14860 2232
0.24760 2350
0.27730 2111
0.33670 1623
0.35650 1368
@coderodde
coderodde / main.c
Last active October 6, 2022 12:20
C MSD radixsort for unsigned keys. Parallel vs. sequenttial vs. qsort.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#ifdef _WIN32
#include <Windows.h>
#else
#include <pthread.h>
#include <sys/time.h>
#include <unistd.h>
#endif
@coderodde
coderodde / FingersToEntropy.java
Last active May 11, 2023 05:18
Find all entropies
package com.github.coderodde;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class FingersToEntropy {