Skip to content

Instantly share code, notes, and snippets.

psstoev / gist:7531555
Created Nov 18, 2013
Memoize solutions
View gist:7531555
# Solution 1:
class Memoizer < BasicObject
def initialize(instance)
@instance = instance
@cache = {}
def cache(method, *args)
@cache["#{method}, #{args}"] = @instance.public_send method, *args
psstoev / emacs-scheme-after-save-hook.el
Created Apr 2, 2012
Custom mode-hook for Emacs, to run Scheme "unit tests".
View emacs-scheme-after-save-hook.el
;; Add this to your .emacs, the function supposes, that you have a
;; subdirectory "tests", where there is a file with the same name as
;; the file you are editing. Not very interesting, but convinient.
(add-hook 'scheme-mode-hook
(lambda ()
(add-hook 'after-save-hook
(lambda ()
(let ((file-name (file-name-nondirectory buffer-file-name)))
(if (file-exists-p (concat "tests/" file-name))
View count-change.txt
T(0, n) = 1
⎧ 0, m < 0 или n = 0
T(m, n) = ⎨
⎩ T(m, n - 1) + T(m - Cₙ, n), Cₙ - номиналът на n-тата монета, някаква константа
View Robert_Heinlein
A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects.
-- Robert Heinlein
psstoev / sample_spec.rb
Created Dec 16, 2011
Sample spec for task 6
View sample_spec.rb
# encoding: utf-8
describe GameOfLife::Board do
describe 'initialization' do
it 'accepts multiple coords in the constructor' do
board = new_board [0, 0], [1, 1], [2, 2]
describe 'corner cases' do
psstoev / sample_spec2.1.rb
Created Oct 26, 2011
Ruby homework2 additional tests
View sample_spec2.1.rb
describe Collection do
let(:additional_tags) do
'John Coltrane' => %w[saxophone],
'Bach' => %w[piano polyphony],
let(:input) do