Skip to content

Instantly share code, notes, and snippets.

View coderodde's full-sized avatar

Rodion Efremov coderodde

View GitHub Profile
@coderodde
coderodde / funny_array.cpp
Created October 20, 2021 13:36
CodeReview answer for funny arrays
#include <iostream>
// Modifies array!
int numberOfTimes(int array[], int n) {
int count = 0;
int flag = 0;
int sizeCounter = 0;
while (true) {
for (int i = 0; i < n - 1; ++i) {
if (array[i] <= array[i + 1]) {
@coderodde
coderodde / RodioningEndpoint.java
Created September 18, 2021 07:58
CR: WebSocket app runs on localhost but not on Heroku
package com.github.coderodde.rodioning;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.websocket.CloseReason;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.Session;
@coderodde
coderodde / main.py
Created September 15, 2021 08:17
CR.SudokuSolverInPython
board = [
[8, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 3, 6, 0, 0, 0, 0, 0],
[0, 7, 0, 0, 9, 0, 2, 0, 0],
[0, 5, 0, 0, 0, 7, 0, 0, 0],
[0, 0, 0, 0, 4, 5, 7, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 3, 0],
[0, 0, 1, 0, 0, 0, 0, 6, 8],
[0, 0, 8, 5, 0, 0, 0, 1, 0],
[0, 9, 0, 0, 0, 0, 4, 0, 0]
@coderodde
coderodde / PlateNumberIterable.java
Last active August 19, 2021 08:46
Comparing the CR plate number iterators
import java.util.Iterator;
import java.util.NoSuchElementException;
public final class PlateNumberIterable implements Iterable<String> {
@Override
public Iterator<String> iterator() {
return new PlateNumberIterator();
}
import java.net.URI;
import java.net.URISyntaxException;
import java.time.Duration;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
public class Main {
public static void main(String[] args) {
package net.coderodde.datamining.lottery;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.SortedMap;
import java.util.TreeMap;
@coderodde
coderodde / heap_selection_sort.js
Created April 5, 2020 09:08
HeapSelectionSort for Javascript
function ArrayRangeException(message) {
this.message = message;
this.getMessage = function() { return this.message; }
}
function RangeCheck(arrayLength, fromIndex, toIndex) {
if (fromIndex < 0) {
throw new ArrayRangeException("'fromIndex' is negative: " + fromIndex);
}
package net.coderodde.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
public class CoderoddeArrays {
@coderodde
coderodde / biddfs.js
Last active September 7, 2019 16:08
BIDDFS in Javascript.
<html>
<body>
<div id="output">
</div>
<script>
function NodeSet() {
this.array = [];
}
<form enctype="multipart/form-data">
<input type="file"/>
</form>
<button onclick="yeah()">update avatar</button>
<script>
function yeah() {
var formData = new FormData();
formData.append("fileName", get_file_or_something().name);
formData.append(cropped_image);
}