A classic example of the machine that returns change optimizing the amount of elements it gives for a given amount
I'm a beginner in Go, so I thought of using this example as practice. I'll be trying to apply some minor optimizations/refactor than what I usually did
You'll be given a numeric input of the amount that needs the return from.
You should output how much of each element (5x1 dolar bills, 10x50 dolar bills, 2x1 cents, etc.)
The least return the better solution, the less code and more readable, the finer.
Given it's a small example with predefined best solutions, it'd be nice to clearly identify the possibilities.
Test Driven Development is a nice addition to this clear exercise.
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
To my teacher (Pilar) from whom I learned this exercise.
And to Chelo, a teacher that mentioned this as a technical challenge for some bussiness.
To this article Golang Import Local Package for explaining and providing helpful examples about import of local go packages.
- Complete the base exercise
- Use a map to compute the operations
- Implement an amount for the change
- Implement a smart amount for the change, meaning, if we can supply change by using lower value currency, that's still considered a good solution
- Implement a (clearly defined) test set