4 kyu
Permutation by number
80 of 99Stein256
Loading description...
Algorithms
Mathematics
Strings
Permutations
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Haskell translation
Scala translation
You mean OCaml ;)
Basically the same thing.
Approved
Scala translation
Python translation
JS should probably use BigInts?
(JS) There's no sample tests that have the chars in
word
unsorted, meanwhile in the actual tests those kind ofword
is given. There should be some in the sample tests.fork with Node 18, chai, sample tests with unsorted words, and removal of the "anti cheat" (issue below)
Fork approved.
The
it
block inside thedescribe("Cheating check", ...)
has no assertions. In fact, there's no reason for such thing to be checked in the first place.Fixed by fork above.
A truly excellent Kata!
I wonder why the satisfaction rating is not much higher!
Elixir translation awaiting approval.
Why not use
BigInt
?The purpose of big numbers is to eliminate naive solutions. Standard js numbers are big enough for that. No need to make people think about specifics of data types in different languages.
Needs edge case
'', 0
and'', 1
.If ones solution doesn't handle such cases naturally than this rule will only make them add checks, not rethink the solution. People usually don't expect validation in algorithmic kata.
...What?
''
is a perfectly valid input, and it only has one permutation, aka itself.("BUECJZFHPZHQNCYRMKJRFQAO", 5587072446441114) - Expected: 'ABCCFZQYNHOQKZJHUFPRMRJE', instead got: 'ABCCFZQYNHOQKZJHUFPRREJM'
BUECJZFHPZHQNCYRMKJRFQAO
has about4.8e+21
permutations and it's way beyond safe integer range.Fixed and specified. Thanks for feedback!
Input range should be specified.
n
is 0-based in the tests, which is inconsistent with the usage implied by this sentence (1-based ordinal numbers).Also, it's only implied in the tests that only unique anagrams are counted, which should belong in the description as well.
Is this a sorted list of unique anagrams, or can there be duplicates in it? Or can there be no duplicate anagrams?
All anagrams are unique, that's where the difficulty comes from. If you allow duplicates or have each letter only ones in a word then it's just like counting in base number_of_letters.