Skip to content

Instantly share code, notes, and snippets.

View vaskoz's full-sized avatar
🏠
Working from home

Vasko Zdravevski vaskoz

🏠
Working from home
View GitHub Profile
@vaskoz
vaskoz / SudokuBacktracker.java
Last active January 1, 2016 22:39
A simple backtracker implementation of a Sudoku Solver. This was created quick and dirty just as a baseline to compare against a forthcoming "dancing links algorithm X" to solve Sudoku as an Exact Cover problem.
import java.util.Scanner;
public class SudokuBacktracker {
/**
* Reads Sudoku Puzzle from STDIN in the following format.
* First number, should be N, which is the value for this board configuration N^2 * N^2 = N^4 size board
* Prints answer to STDOUT
* <p/>
* 3
* 4 0 0 0 0 0 0 0 5
java.lang.RuntimeException: Error scanning file PingController.class
at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:705)
at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686)
at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686)
at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686)
at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:821)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:111)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:472)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
@vaskoz
vaskoz / QuickCheck.scala
Created November 13, 2013 15:03
QuickCheck Scala Reactive programming class submission.
package quickcheck
import common._
import org.scalacheck._
import Arbitrary._
import Gen._
import Prop._
import Math._
@vaskoz
vaskoz / rubyconf2013schedule.md
Last active December 27, 2015 13:59
My RubyConf 2013 schedule picks

Friday, Nov 7th, 2013

11:10-11:55 Jason R Clark Extending Gems - Patterns and Anti-Patterns of Making Your Gem Pluggable Salon 2

1:10-1:55 Casey Rosenthal Fault Tolerant Data: Surviving the Zombie Apocalypse

@vaskoz
vaskoz / WorldPartyRsvp.java
Created October 6, 2013 01:27
non-probabilistic java.util.BitSet implementation to test for worldwide party RSVP.
import java.util.List;
import java.util.ArrayList;
import java.util.BitSet;
/**
* Error free (non probabilistic) Set membership
*/
public final class WorldPartyRsvp {
private static final long DESIRED_REGION_SIZE = Integer.MAX_VALUE;
private static final long MAX_INVITE_SIZE = DESIRED_REGION_SIZE * DESIRED_REGION_SIZE;
@vaskoz
vaskoz / RandomizationHistogram.java
Created September 14, 2013 02:03
Count the occurrences of random numbers across threads
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadLocalRandom;
@vaskoz
vaskoz / prims.rb
Created September 8, 2013 06:21
O(m*n) implementation of Prim's algorithm in Ruby
# Input: vertex1 (integer), vertex2 (integer), weight (integer)
require 'set'
edges = ARGF.readlines
edges.shift # Ignore first line if it has n, m don't need them
edges.map! {|a| a.split.map! {|j| j.to_i} }
vertices = Set.new(edges[0][0,1])
mst = []
until edges.empty?
min_edge = edges.min_by {|e| vertices.include?(e[0]) || vertices.include?(e[1]) ? e[-1] : Float::INFINITY}
vertices.merge(min_edge[0,2])
@vaskoz
vaskoz / FasterFib.java
Last active December 22, 2015 02:18
Logarithmic vs Linear Fibonacci
import java.math.BigInteger;
import java.util.Map;
import java.util.HashMap;
public class FasterFib {
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Usage: a single positive java integer representing Fibonacci sequence number");
System.exit(1);
}
import java.math.BigInteger;
public class SimpleFib {
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Usage: a single positive java integer representing Fibonacci sequence number");
System.exit(1);
}
int n = Integer.parseInt(args[0]);
System.out.println("Recursive: " + recursiveFib(n));
class Animal
def makeSpeak(method, block)
self.class.send(:define_method, method.to_sym, &block)
end
end
a = Animal.new
woof = Proc.new { puts "Woof!" }
chirp = Proc.new { puts "Chirp!" }
yelp = Proc.new { puts "Yelp!" }