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

Improvements to Vampire Number #6110

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Shisoik
Copy link

@Shisoik Shisoik commented Dec 23, 2024

Several improvements to maths/VampireNumber code:

  1. Fixes a bug in same length of fangs detection for pseudo vampire numbers. Now it is done in the most straight-forward way.
  2. Adds tests for the VampireNumber class.
  3. Fixed several typos in code and comments.
  4. Generally simplifies code and improves readability.
  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

- Remove unused code
- Just print formatted lines instead of accumulating them in a StringBuilder
- Rename the method to reflect what it does
- Make pseudo vampire number choice an argument
- Fix a bug in check for pseudo vampire number
- Make method that split into digits accept vararg and slightly simplify it
@codecov-commenter
Copy link

codecov-commenter commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 52.38095% with 10 lines in your changes missing coverage. Please review.

Project coverage is 73.74%. Comparing base (2fff579) to head (357da09).

Files with missing lines Patch % Lines
...in/java/com/thealgorithms/maths/VampireNumber.java 52.38% 9 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6110      +/-   ##
============================================
+ Coverage     73.64%   73.74%   +0.10%     
- Complexity     5112     5119       +7     
============================================
  Files           658      658              
  Lines         17649    17641       -8     
  Branches       3396     3394       -2     
============================================
+ Hits          12997    13010      +13     
+ Misses         4147     4127      -20     
+ Partials        505      504       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Shisoik Shisoik marked this pull request as ready for review December 23, 2024 12:55
@Shisoik
Copy link
Author

Shisoik commented Dec 23, 2024

IMHO, limiting tests to just 3 static imports and forbidding to static import org.junit.jupiter.api.Assertions.* is too strict and actually hurts readability. Not gonna argue, juest a thought.

@Shisoik Shisoik changed the title Vampire Improvements to Vampire Number Dec 23, 2024
// methode to Split the numbers to Digits
static String splitIntoDigits(int num, int num2) {
StringBuilder res = new StringBuilder();
static void printVampireNumbers(int startValue, int stopValue, boolean ignorePseudoVampireNumbers) {
Copy link
Member

Choose a reason for hiding this comment

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

Please remove main and printVampireNumbers, we don't usually add visualization, only algorithms

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.

3 participants