Skip to content

Instantly share code, notes, and snippets.

View coderodde's full-sized avatar

Rodion Efremov coderodde

View GitHub Profile
@coderodde
coderodde / SnailMatrixGenerator.py
Last active April 22, 2024 03:59
A class for generating snail matrices.
type Matrix = list[list[int]]
"""
This class is responsible for generating snail matrices of dimensions n * n.
"""
class SnailMatrixGenerator:
"""
Constructs this generator.
"""
@coderodde
coderodde / CoderoddeBinaryHeap.cs
Last active April 18, 2024 07:58
An efficient binary heap for C#.
namespace CR.PriorityQueues
{
class CoderoddeBinaryHeap<TElement, TPriority> : PriorityQueue<TElement, TPriority>
where TElement : notnull
where TPriority : notnull
{
private static readonly int INITIAL_CAPACITY = 16;
private class HeapNode<Element, Priority> where Element : notnull where Priority : notnull
{
@coderodde
coderodde / ArrayContraction.java
Created April 13, 2024 10:01
My MSc thesis research program.
public class ArrayContraction {
public static void main(String[] args) {
Array a = new Array(2, 3);
System.out.println("Add");
for (int i = 0; i < 8; i++) {
System.out.println(a);
a.add();
}
@coderodde
coderodde / colorful_subgraph.py
Created April 3, 2024 19:54
Colorful subgraph problem.
from itertools import combinations
import time
def millis():
return round(1000 * time.time())
def powerset(iterable):
s = list(iterable)
int, double (ret_int, ret_double) my_foo(a, b, c):
if specified a:
print "a"
if specified b:
print "b"
if specified c:
print "c"
if is_requested ret_int:
print "int on return requested"
if is_requested ret_double:
@coderodde
coderodde / .bashrc
Last active February 1, 2024 09:00
Directory switcher for *nix.
# ...
alias ds='source ds.sh'
# ...
@coderodde
coderodde / MultiplePermuter.java
Last active January 1, 2024 12:44
Helper data structure for AiGA.
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
public class MultiplePermuter<T> {
private final List<List<T>> data;
private final Deque<Integer> indexStack;
private final List<List<List<T>>> result;
private final int numberOfGroups;
@coderodde
coderodde / MScCourseList.txt
Last active December 12, 2023 08:12
MSc course list
Design and Analysis of Algorithms - 5 / 5
Distributed Systems - 5 / 10
Introduction to Machine Learning - 5 / 15
Master's thesis - 30 / 45 TODO
CSC - 5 / 50 TODO
String processing algorithms - 5 / 55
Data Compression Techniques - 5 / 60
Seminar on Tractability - 3 / 63
Seminar on Combinatorial Pattern Matching - 3 / 66
Tiedon louhinta - 5 / 71
@coderodde
coderodde / RegexParserResearch.java
Last active November 15, 2023 10:31
Regex parsing research
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
class RegexParserResearch {
public static Deque<Token> shuntingYardAlgorithm(String regex) {
List<Token> tokens = tokenize(regex);
Deque<Token> output = new ArrayDeque<>();
@coderodde
coderodde / ThreadPreemption.c
Created October 11, 2023 04:54
The source file for the ThreadPreemptionCounter.
#include <windows.h>
#include <stdio.h>
#define MAX(X, Y) (((X) < (Y)) ? (Y) : (X))
int main() {
ULONGLONG ta = GetTickCount64();
ULONGLONG maximumDuration = 0;