Skip to content

Instantly share code, notes, and snippets.

View Janiczek's full-sized avatar

Martin Janiczek Janiczek

View GitHub Profile
@Janiczek
Janiczek / ProjectEuler.coffee
Created May 31, 2011 21:57
First few Project Euler problems solved in CoffeeScript. Comments on how to make it more beautiful (in terms of CoffeeScript, not algorithm) highly appreciated!
@_1 = ->
# sum of multiples of 3 or 5 (not both) under 1K
answer = 0
for n in [1...1000]
if n % 3 == 0 or n % 5 == 0
answer += n
@Janiczek
Janiczek / mm_algos.py
Created August 5, 2011 20:19
Memory Management algorithms
# =======================================================================
# =======================================================================
# =======================================================================
# =============================================================== Info ==
# This is also known as Bin Packing Problem
# http://en.wikipedia.org/wiki/Bin_packing_problem
# inspiration: http://www.developerfusion.com/article/5540/bin-packing/
# or maybe Knapsack Problem?
@Janiczek
Janiczek / genetics.coffee
Created April 12, 2012 13:43
Evoluční algoritmus
#======================================================================#
# Biologicke algoritmy (2) - Evoluční algoritmy #
# http://www.root.cz/clanky/biologicke-algoritmy-2-evolucni-algoritmy/ #
#======================================================================#
#
# hledame kruznice, ktere nejvic sedi na danou mnozinu bodu
#
# ----------------------------------------------------------
#
# jedinec = trojice kruznic
@Janiczek
Janiczek / sinfest_downloader.py
Created May 29, 2012 22:33
Sinfest downloader
# NOTE: some of these will be 404s (30th of February, days with no comics, etc.)
# 404s can be removed with `find . -type f -size -1000c -iname "*.gif" -exec rm {} \;`
from urllib import urlretrieve
for y in range(2000, 2013):
for m in range(1, 13):
print "starting", y, m
@Janiczek
Janiczek / Makefile
Created July 17, 2012 23:59
Binary search in Erlang
run:
erlc binary_search.erl
erl -noshell -s binary_search test -s init stop
tests:
python write_tests.py >binary_search_tests.erl
erlc binary_search_tests.erl
all: tests run
@Janiczek
Janiczek / yt.py
Created July 23, 2012 19:38
YouTube downloader
#! /usr/bin/env python
# dependencies: py-gdata
# example usage:
# ./yt.py "words that have to be in title"
import sys
import gdata
import gdata.youtube
@Janiczek
Janiczek / memoize.hs
Created September 14, 2012 00:05
Haskell memoization
-- from http://www.nadineloveshenry.com/haskell/memofib.html#memoize
-- had some problems when function had more arguments though, so saving this for future me :)
import Debug.Trace
import Data.Map as Map
import Control.Monad.State.Lazy as State
--------------------------------------------
type StateMap a b = State (Map a b) b
@Janiczek
Janiczek / primes.erl
Last active December 10, 2015 21:38
Imitation of http://numbersimulation.com/ using different languages and techniques, currently Go and Erlang.
-module(go).
-export([prime/3,
server/0,
server/4,
start/0]).
prime(OldTick, N, Server) ->
receive
false -> ok
end,
sieve_sundaram = (limit) ->
start = 4
half = limit/2
numbers = (n for n in [3...limit+1] by 2)
steps = numbers[..] # copy of numbers
callback = (start_and_nums,step) ->
@Janiczek
Janiczek / Praise Like Fireworks.txt
Last active December 14, 2015 20:09
Praise Like Fireworks
PRAISE LIKE FIREWORKS
------------
- první "You've given us a heart" - unisono, kluci klidně ve spodní oktávě
K+A+S: Gis Gis Gis Gis Gis Gis - hlavní
Gis Gis Gis Gis Gis
Gis A A A A A