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

Improve Dart #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Improve Dart #70

wants to merge 1 commit into from

Conversation

eNotchy
Copy link

@eNotchy eNotchy commented Nov 7, 2024

This version runs about 10% faster on my machine, using Dart SDK 3.5.1

By the way, the native compiled version runs about 20% faster on my machine when I change isMunchausen to this:

bool isMunchausen(int number, final List<int> cache) {
  for (int n = number; n > 0; n ~/= 10) {
    final digit = n.remainder(10);
    number -= cache[digit];
    if (number < 0) {
      return false;
    }
  }
  return 0 == number;
}

But I guess that would make it less comparable to other language implementations.

This version runs about 10% faster on my machine, using Dart SDK 3.5.1

btw the native compiled version runs about 20% faster on my machine when I change isMunchausen to this:
```
bool isMunchausen(int number, final List<int> cache) {
  for (int n = number; n > 0; n ~/= 10) {
    final digit = n.remainder(10);
    number -= cache[digit];
    if (number < 0) {
      return false;
    }
  }
  return 0 == number;
}
```

But I guess that would make it less comparable to other language implementations.
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.

1 participant