Skip to content

Instantly share code, notes, and snippets.

@tomstuart
tomstuart / combinations_spec.rb
Created July 22, 2016 14:39 — forked from tuzz/combinations_spec.rb
Generates combinations from an array
require "rspec"
def combinations(array, length)
if length.zero?
[[]]
else
array.each_index.map { |i| array.drop(i) }.flat_map do |head, *tail|
combinations(tail, length - 1).map do |combination|
[head] + combination
end
#http://www.nhs.uk/NHSEngland/Healthcosts/Pages/Prescriptioncosts.aspx
Given a user who is 60 or older
When they collect a prescription
Then it should be free
Given a user who is younger than 16
When they collect a prescription
Then it should be free
module ScoreHelpers
def self.extended(base)
base.class_eval do
let(:scores) { {} }
end
end
def the_letter(letter, options)
score = options[:is_worth]