5 kyu
[Code Golf] Fill matrix with a zigzag
11 of 56AndreyMaksimov
Description:
About
In this task, you will write a "determinateValue" function that will determine the value of an element in a matrix. The matrix should be filled with a zigzag, example matrix 5x5:
[
[ 1, 2, 6, 7, 15],
[ 3, 5, 8, 14, 16],
[ 4, 9, 13, 17, 22],
[10, 12, 18, 21, 23],
[11, 19, 20, 24, 25]
]
In example above if x = 2, y = 1 and n = 5, result should be 9 ( matrix[2][1] = 9 )
The function "determinateValue" will be called to determine the value of each element in the matrix, it is passed three parameters:
- x - index of array position (vertical index).
- y - index of element position in array (horizontal index).
- n - Matrix size.
Simple "code golf" conditions:
- C# - 250 chars limit.
- JS - 150 chars limit.
- Python - 160 chars limit.
Note
- Matrices can be very large.
- Values must not go beyond the matrix (filling in the form of a big triangle will not work).
The direction of filling, for clarity.
Matrix
Algorithms
Restricted
Similar Kata:
Stats:
Created | May 24, 2022 |
Published | May 24, 2022 |
Warriors Trained | 323 |
Total Skips | 14 |
Total Code Submissions | 1008 |
Total Times Completed | 56 |
C# Completions | 11 |
Python Completions | 34 |
JavaScript Completions | 24 |
Total Stars | 28 |
% of votes with a positive feedback rating | 93% of 20 |
Total "Very Satisfied" Votes | 17 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 9 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 6 kyu |