Comments (5)
I would like to fix this, but I found another problem with the tests. Calculating abilities does not test that 3 largest numbers are used as the exercise description says
...You do this by rolling four 6-sided dice and record the sum of the largest three dice
For example, some solutions contain code like this new Random().ints(4, 1, 7).sorted().limit(3).sum();
, but .sorted()
sorts in ascending order so the sum of the smallest numbers is returned.
Maybe a solution could be that throwing dice is refactored into its own function that returns a list of 4 numbers. Also, the ability function should then be changed to take a list of 4 numbers as input. This way ability calculation can be tested with certain input and expected results.
List<Integer> throwDice() {..}
int ability(List<Integer> diceValues) {..}
@Test
public void testAbilityCalculation() {
assertEquals(9, dndCharacter.ability(List.of(1,2,3,4)));
}
from java.
Thanks for reporting this!
This is indeed an issue with the lack of tests.
keeping a copy of the first character and making sure that at least one of the 1000 other generated characters is different. Without actually trying to do the calculations, the chance of generating 1000 identical characters should be sufficiently zero to not be concerned about false negatives.
I agree with this solution, anyone is welcome to submit a PR for it! However, I don't think we need 1000 iterations, maybe 100, 500 max is enough?
from java.
Re: 1000 - that suggests mainly comes from the fact it already does an iteration of 1000
@umuser - that's a good spot too! Certainly would be happy with ability taking in a List as a solution to that, although I wouldn't necessarily mandate that you use a throwDice function defined as such? It's probably the nicest way to do it, but since we won't be testing the throwDice method directly we should just let it be defined privately however people want?
from java.
@umuser Feel free to submit a PR fixing that problem too.
I think it's reasonable to have ability
take a list as an argument, and I'm also ok with having a throwDice
function defined like that. However, if adding such function, we should add tests for that function too.
from java.
PR #2218 has been merged.
from java.
Related Issues (20)
- wizards-and-warriors: describe Analyzer feedback in `.meta/design.md`
- wizards-and-warriors-2: describe Analyzer feedback in `.meta/design.md`
- Add GitHub Actions workflow that fails if any deprecated exercise files change
- Only run tests for exercises that have changed
- Add document to describe the representation process for mentors
- Check if ``Bird Watcher`` current test suite is complete/correct HOT 2
- #48in24: Add approaches to Parallel Letter Frequency
- #48in24: Add approaches to Bank Account HOT 5
- #48in24: Add approaches to Knapsack HOT 2
- #48in24: Add analyzer feedback for Parallel Letter Frequency HOT 5
- #48in24: Add analyzer feedback for Bank Account
- #48in24: Add analyzer feedback for Knapsack
- Wizards and Warriors exercise reformat
- Add GitHub Actions workflow step to add summary for test-runner results HOT 2
- Karls Language introduces multiple concepts HOT 3
- Find a way to always have reference documentation updated HOT 3
- Make class names the exercise names if makes sense HOT 4
- Inconsistency between Need for Speed task 6 analyzer feedback and instructions HOT 1
- Collatz Conjecture: Test case should be added to check for more than one method call HOT 2
- Mentoring signup url broken HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java.