Skip to content

London | 25-SDC-Nov | Emiliano Uruena | Sprint 2 | Improve with caches#140

Open
Emilianouz wants to merge 3 commits intoCodeYourFuture:mainfrom
Emilianouz:Sprint2-ImproveWthCaches
Open

London | 25-SDC-Nov | Emiliano Uruena | Sprint 2 | Improve with caches#140
Emilianouz wants to merge 3 commits intoCodeYourFuture:mainfrom
Emilianouz:Sprint2-ImproveWthCaches

Conversation

@Emilianouz
Copy link

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

Optimize Fibonacci and Making Change functions with caching for improved performance

@github-actions

This comment has been minimized.

@Emilianouz Emilianouz added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 1, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 1, 2026
@Emilianouz Emilianouz changed the title London | SDC-25-Nov | Emiliano Uruena | Sprint 2 | Improving with cache London | 25-SDC-Nov | Emiliano Uruena | Sprint 2 | Improving with cache Mar 1, 2026
@github-actions

This comment has been minimized.

Refactored fibonacci function to use a cache for improved performance.
@Emilianouz Emilianouz changed the title London | 25-SDC-Nov | Emiliano Uruena | Sprint 2 | Improving with cache London | 25-SDC-Nov | Emiliano Uruena | Sprint 2 | Improve with caches Mar 1, 2026
@Emilianouz Emilianouz added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 1, 2026
@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 Mar 2, 2026
Add a count variable to track coin multiples in the change calculation.
@Emilianouz Emilianouz added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 2, 2026
Copy link

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Code looks good. Well done.

Note: Unrelated to cache, but we could further improve the performance by computing the number of ways in one operation when there is only one coin left to consider.

Comment on lines +33 to +39
count = 1
while coin * count <= total:
ways += ways_to_make_change_helper(total - coin * count, coins, coin_index + 1, cache)
count += 1

# counting combinations that don't use the current coin
ways += ways_to_make_change_helper(total, coins, coin_index + 1, cache)
Copy link

Choose a reason for hiding this comment

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

Line 39 is line 35 when count is 0.

Could probably save a few lines of code.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants