Skip to content

London | 26-SDC-March | Jamal Laqdiem| Sprint 2 | Improve code with caches - #214

Open
jamallaqdiem wants to merge 3 commits into
CodeYourFuture:mainfrom
jamallaqdiem:improve_with_cahes
Open

London | 26-SDC-March | Jamal Laqdiem| Sprint 2 | Improve code with caches#214
jamallaqdiem wants to merge 3 commits into
CodeYourFuture:mainfrom
jamallaqdiem:improve_with_cahes

Conversation

@jamallaqdiem

Copy link
Copy Markdown

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Optimised both exercises using local function caches and index-based tracking to eliminate global scope variables and slow array allocations

@jamallaqdiem jamallaqdiem added Module-Complexity The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 13, 2026
Comment on lines +36 to +37
ways_to_make_change_helper(total - current_coin, coins, coin_index) +
ways_to_make_change_helper(total, coins, coin_index + 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original "loop" version and your "without loop" version differ in terms of how deep the recursion can go, which affects the amount of stack space required at runtime. For a large total, the program may exceed the available stack space and fail.

Could you update your code to match the original approach as much as possible?

Notes:

  • Supposedly, one level of loop is enough.
  • When there is only one coin left to consider, there is a much quicker way to figure out if there is 0 or 1 way to make the change.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Complexity The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants