Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add change exercise #386

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Add change exercise #386

merged 1 commit into from
Jan 23, 2025

Conversation

ErikSchierboom
Copy link
Member

No description provided.

stopifnot(target > 0)
stopifnot(min(coins) <= target)

min_amount_coins <- rep(Inf, target + 1)
Copy link
Member Author

Choose a reason for hiding this comment

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

I struggled a bit with how to model the "the value is not yet there at that index" placeholder. I'm open to suggestions how to improve

Copy link
Contributor

Choose a reason for hiding this comment

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

Conventionally, this would use NA. Line 9 then becomes

  min_amount_coins <- rep(NA, target + 1)

and line 27 becomes

  stopifnot(!is.na(min_amount_coins[[target + 1]]))

The tests still pass when I tested this locally. Is that the sort of thing you were asking about?

Copy link
Contributor

@colinleach colinleach left a comment

Choose a reason for hiding this comment

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

I'll approve but not merge for now. Make changes if you wish, then merge when you're ready.

@ErikSchierboom
Copy link
Member Author

Yeah, I'll to make it clearer using NA.

@ErikSchierboom ErikSchierboom merged commit 1733535 into main Jan 23, 2025
3 checks passed
@ErikSchierboom ErikSchierboom deleted the change branch January 23, 2025 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants