This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Solution 1: | |
class Memoizer < BasicObject | |
def initialize(instance) | |
@instance = instance | |
@cache = {} | |
end | |
def cache(method, *args) | |
@cache["#{method}, #{args}"] = @instance.public_send method, *args |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
T(0, n) = 1 | |
⎧ 0, m < 0 или n = 0 | |
T(m, n) = ⎨ | |
⎩ T(m, n - 1) + T(m - Cₙ, n), Cₙ - номиналът на n-тата монета, някаква константа |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] | |
end | |
end | |
describe 'corner cases' do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe Collection do | |
let(:additional_tags) do | |
{ | |
'John Coltrane' => %w[saxophone], | |
'Bach' => %w[piano polyphony], | |
} | |
end | |
let(:input) do | |
<<-END |