Skip to content

Instantly share code, notes, and snippets.

Rodion Efremov coderodde

Block or report user

Report or block coderodde

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@coderodde
coderodde / main.c
Created Oct 2, 2017
Demo driver for linked list C code question
View main.c
#include "singly_linked_list.h"
#include <stdio.h>
#include <string.h>
int main() {
int i;
singly_linked_list_t* list = singly_linked_list_alloc();
singly_linked_list_iterator_t* iterator;
for (i = 1; i < 6; ++i)
View Pathfinders.js
/////////////
// HashMap //
/////////////
function HashMapNode(key, value) {
this.key = key;
this.value = value;
this.prev = null;
this.next = null;
}
View cr_sieve_of_eratosthenes.py
from time import time
def SieveofEratosthenes(primeseries):
i=1
primeserieslist = []
while(i<primeseries):
i=i+1
primeserieslist.append(i)
@coderodde
coderodde / InShuffleAlgorithm.java
Last active Aug 25, 2017
In-Shuffle algorithm in Java
View InShuffleAlgorithm.java
package net.coderodde.util;
import java.util.Arrays;
import java.util.Objects;
/**
* This class implements a linear-time, in-place in-shuffle algorithm.
*
* @author Rodion "rodde" Efremov
* @version 1.6 (Aug 25, 2017).
View Paddle.java
package square;
import java.awt.*;
public class Paddle {
public static final int RECT_WIDTH = 200;
public static final int RECT_HEIGHT = 100;
private int x = (Shapes.WIN_WIDTH - RECT_WIDTH) / 2;
private int y = (Shapes.WIN_HEIGHT - RECT_HEIGHT) / 2;
@coderodde
coderodde / dt.bat
Last active Aug 19, 2017
Directory tagging tool for Windows
View dt.bat
@echo off
del "C:\Users\Rodion Efremov\.dt\cd.bat"
if [%1] == [] (
dt_engine.exe > "C:\Users\Rodion Efremov\.dt\cd.bat"
) else (
dt_engine.exe %1 > "C:\Users\Rodion Efremov\.dt\cd.bat"
)
if %ERRORLEVEL% NEQ 0 (
View dijkstra.py
G16 = {'a':[('b',3),('c',2)], 'b':[('c',-2)], 'c':[('d',1)], 'd':[]}
# the graph is a dictionary with they "key" as nodes and the "value" as a
# list of tuples
# each of those tuples represent an edge from the key vertex to the first
# element of the tuple
# the second element of the tuple is the weight of that edge.
# so, 'a':[('b',3),('c',2)] means an edge from a to b with weight 3
# and another edge from a to c with weight 2.
class minq: #min_queue implementation to pop the vertex with the minimum distance
@coderodde
coderodde / a_star.hpp
Last active Jul 30, 2017
Practicing modern C++
View a_star.hpp
#ifndef NET_CODERODDE_PATHFINDING_A_STAR_HPP
#define NET_CODERODDE_PATHFINDING_A_STAR_HPP
#include "child_node_iterator.hpp"
#include "heuristic_function.hpp"
#include "path_not_found_exception.hpp"
#include "weighted_path.hpp"
#include "weight_function.hpp"
#include <iostream>
#include <queue>
View main.cpp
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
typedef std::vector<std::list<int>> AdjacencyList;
typedef std::unordered_map<int, std::unordered_map<int, size_t>> Weights;
std::pair<std::vector<int>, std::vector<size_t>> dijkstra(AdjacencyList &adj, Weights weights, int src) {
View insertion_sorts.py
from random import randint
from time import time
def insertionSort(lst):
for i in range(1, len(lst)):
if lst[i] < lst[i-1]:
for j in range(i):
if lst[i] < lst[j]:
lst[i], lst[j] = lst[j], lst[i]
You can’t perform that action at this time.