Skip to content

Instantly share code, notes, and snippets.

View mettledrum's full-sized avatar

Andrew Hoyle mettledrum

View GitHub Profile
@mettledrum
mettledrum / recursive_change.py
Last active August 29, 2015 13:59
The classic change-finding recursive algorithm
# gets combinations of coinage for your change
# makes sure not to repeat combos by using skip_list
# generates partial solutions using partial_list
# when value is reached, partial_list is stuffed into final_list
def spare_a_dime_brotha(money, global_skip_list, global_partial_list, final_list):
# make copies local to the scope
partial_list = global_partial_list[:]
skip_list = global_skip_list[:]
@mettledrum
mettledrum / gist:9441272
Last active August 29, 2015 13:57
Rails eager_load controller example
def scoring
@heat = Heat.find(params[:heat_id])
@judge = current_user
@event = Event.find(params[:event_id])
# {st_id => [team#, [team, member, names]]}
@team_info = ScheduledTeam.eager_load(
heat: {
score_system: :score_terms,
scheduled_teams: {
registered_team: {