5 kyu
Shuffle It Up
433 of 574raulbc777
Description:
We have an array of unique elements. A special kind of permutation is the one that has all of its elements in a different position than the original.
Let's see how many of these permutations may be generated from an array of four elements. We put the original array with square brackets and the wanted permutations with parentheses.
arr = [1, 2, 3, 4]
(2, 1, 4, 3)
(2, 3, 4, 1)
(2, 4, 1, 3)
(3, 1, 4, 2)
(3, 4, 1, 2)
(3, 4, 2, 1)
(4, 1, 2, 3)
(4, 3, 1, 2)
(4, 3, 2, 1)
_____________
A total of 9 permutations with all their elements in different positions than arr
The task for this kata would be to create a code to count all these permutations for an array of certain length.
Features of the random tests:
l = length of the array
10 ≤ l ≤ 5000
See the example tests.
Enjoy it!
Performance
Algorithms
Mathematics
Machine Learning
Combinatorics
Number Theory
Similar Kata:
Stats:
Created | Sep 12, 2018 |
Published | Sep 12, 2018 |
Warriors Trained | 3283 |
Total Skips | 236 |
Total Code Submissions | 3889 |
Total Times Completed | 574 |
Python Completions | 433 |
Ruby Completions | 39 |
Haskell Completions | 34 |
JavaScript Completions | 86 |
Factor Completions | 6 |
Rust Completions | 14 |
Go Completions | 5 |
Total Stars | 77 |
% of votes with a positive feedback rating | 87% of 107 |
Total "Very Satisfied" Votes | 84 |
Total "Somewhat Satisfied" Votes | 18 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 4 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |