This repository was archived by the owner on Jan 18, 2024. It is now read-only.
Least Change#67
Open
JimmyQuenichet wants to merge 2 commits into
Open
Conversation
Newby555
reviewed
May 6, 2021
|
|
||
| s.add(equation_1 == target, | ||
| equation_2 == min_coins, | ||
| min_coins > 0, |
Contributor
There was a problem hiding this comment.
Should this comma be removed if this is the last item in .add()?
Newby555
reviewed
May 6, 2021
| @@ -0,0 +1,27 @@ | |||
| from z3 import * | |||
|
|
|||
| def least_change(coins, target): | |||
Contributor
There was a problem hiding this comment.
This file should be empty for the user to write their code in
grantg012
reviewed
May 7, 2021
| @@ -0,0 +1,49 @@ | |||
| import unittest | |||
| from z3 import * | |||
| from .least_change import * | |||
Contributor
There was a problem hiding this comment.
Is there a reason this is a relative import?
grantg012
reviewed
May 7, 2021
|
|
||
| class ChangeTest(unittest.TestCase): | ||
| def test_single_coin_change(self): | ||
| self.assertEqual(str(least_change([1, 5, 10, 25, 100], 25)), "[10 = 0, 25 = 1, 100 = 0, 5 = 0, min_coins = 1, " |
Contributor
There was a problem hiding this comment.
Is there a reason you're converting it to a string rather than making a direct comparison between two lists? Seems a little error prone if the formatting was to change
grantg012
reviewed
May 7, 2021
| min_coins = Int("min_coins") | ||
|
|
||
| # Fill in the solver with the necessary constraints | ||
| for i in range(len(coins)): |
Contributor
There was a problem hiding this comment.
I would recommend using zip() and/or enumerate() rather than indexing
grantg012
reviewed
May 7, 2021
| def test_another_possible_change_without_unit_coins_available(self): | ||
| self.assertEqual(str(least_change([4, 5], 27)), "[4 = 3, 5 = 3, min_coins = 6]") | ||
|
|
||
| def test_no_coins_make_0_change(self): |
Contributor
There was a problem hiding this comment.
Intuitively, I would this a solver should return 0 for every coin rather than None (for not solveable)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.