Comments (3)
If I'm not mistaken this would require handling the new cases with
BigInt
.
You are correct, int
in Dart is limited to 64 bits. We have to use BigInt
Do you think this would be a good addition for this track?
Yes, I have been bitten by not using the correct numeric type in my Databases and code in the past. It's helpful to know.
As far as I know, we don't cover this anywhere? @Stargator
Right now
armstrong-numbers
is listed as difficulty 1 (scale is 1-10). Would adding BigInt complicate matters enough that we would have to bump the difficulty up a bit? Do we want to do that?
The complexity would not increase. It is a matter of changing types. If we must increase the difficulty, I would say increase by 0.5
.
I don't have a strong opinion, but at the moment I'm leaning slightly in favor of leaving the exercise as is. I'm happy to be convinced otherwise, though.
The existing solutions would break for sure.
However, it would be good dogfood for your test generator and see how it reacts?. Generating tests for this exercise would not be trivial!
To make the tests spec compliant and working, following changes would need to be made
example.dart
class ArmstrongNumbers {
/// The parameters and variables within the method that are set to final in order to prevent the accidentally modification of the value.
/// As those variables are not needed to be changed.
bool isArmstrongNumber(final String input) {
final numOfDigits = input.length;
var sum = BigInt.from(0);
for (var count = 0; count < numOfDigits; count++) {
final digitAsString = input.substring(count, count + 1);
final digit = BigInt.parse(digitAsString);
sum += digit.pow(numOfDigits);
}
return input == sum.toString();
}
}
armstrong_numbers_test.dart
Instead of using number literals, we need to use '<literal>'
- final bool result = armstrongNumbers.isArmstrongNumber(0);
+ final result = armstrongNumbers.isArmstrongNumber('0');
from dart.
Excellent. Difficulties are ints, not floats, so we could bump it to 2.
I will give this a shot.
from dart.
As far as I know, we don't cover this anywhere? @Stargator
Correct. We don't use BigInt anywhere nor do we have anything related to databases.
I agree with devkabiir's response. This shouldn't be a change, despite breaking the current solutions.
from dart.
Related Issues (20)
- Add or Update existing GitHub Action to check for bad links HOT 7
- Should the template for "Isbn Verifier" have a class? HOT 1
- Replace all dartlang.org links with dart.dev
- Does ABOUT.md Need a Mention of Flutter? HOT 3
- Configure Online Editor Task Complete
- Make Test Driven Development More Prominent in Exercise Instructions HOT 4
- Dart tests are default on skip:true HOT 1
- Structure of test files for generated exercises? HOT 12
- How to best run tests locally on just the exercise being worked on? HOT 5
- Question about initialization in test suites HOT 6
- dart fix is removing import in test suite HOT 5
- [CI] Re-enable link checker HOT 11
- Drop use of types for variables when not necessary HOT 1
- Syntax question -- lists, and types and lists of lists HOT 2
- Why is skip true for all the tests? HOT 2
- Gigasecond method name could be changed HOT 2
- Wide right section cause layout issues HOT 2
- Deprecate `beer song`? HOT 1
- I noticed all the testcases except first one are marked for skip. Any reasons ? HOT 2
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 dart.