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

feat: kata/sort-an-array-by-value-and-index #726

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
docs: kata description
ParanoidUser committed Dec 20, 2024
commit 2cbc7af047708a405dd302d1cb75358a00b31041
19 changes: 12 additions & 7 deletions kata/7-kyu/sort-an-array-by-value-and-index/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
# [Sort an array by value and index](https://www.codewars.com/kata/sort-an-array-by-value-and-index "https://www.codewars.com/kata/58e0cb3634a3027180000040")

# Sort an array by value and index

Your task is to sort an array of integer numbers by the product of the value and the index of the positions.
<br><br>
For sorting the index starts at 1, NOT at 0!<br>
The sorting has to be ascending.<br>
The array will never be null and will always contain numbers.
<br><br>
Example:

```
Input: 23, 2, 3, 4, 5
Product of value and index:
23 => 23 * 1 = 23 -> Output-Pos 4
2 => 2 * 2 = 4 -> Output-Pos 1
3 => 3 * 3 = 9 -> Output-Pos 2
4 => 4 * 4 = 16 -> Output-Pos 3
5 => 5 * 5 = 25 -> Output-Pos 5
23 => 23 LICENSE build.gradle.kts docs gradle gradle.properties gradlew gradlew.bat kata settings.gradle.kts 1 = 23 -> Output-Pos 4
2 => 2 LICENSE build.gradle.kts docs gradle gradle.properties gradlew gradlew.bat kata settings.gradle.kts 2 = 4 -> Output-Pos 1
3 => 3 LICENSE build.gradle.kts docs gradle gradle.properties gradlew gradlew.bat kata settings.gradle.kts 3 = 9 -> Output-Pos 2
4 => 4 LICENSE build.gradle.kts docs gradle gradle.properties gradlew gradlew.bat kata settings.gradle.kts 4 = 16 -> Output-Pos 3
5 => 5 LICENSE build.gradle.kts docs gradle gradle.properties gradlew gradlew.bat kata settings.gradle.kts 5 = 25 -> Output-Pos 5
Output: 2, 3, 4, 23, 5
```
```
<br><br><br>
Have fun coding it and please don't forget to vote and rank this kata! :-)

I have also created other katas. Take a look if you enjoyed this kata!