I
I
Insolation2018-02-22 17:23:30
JavaScript
Insolation, 2018-02-22 17:23:30

What is the algorithm for filling the matrix?

Hello gentlemen.
I need your advice, because I've been struggling with the problem for several hours now.
A task was set at the university:
There is an input, a number from 25 to 100 is entered into it. After that, an array is formed from 1 to the number from the input and a 5x5 matrix must be created, the values ​​in the "cells" must be within that array and then display the matrix on the page .
Example:
The number 40 was entered into the input. The numbers are randomly obtained from the array 1-40. As a result, the matrix looks like this:

1 10 17 26 33
3 11 18 27 34
4 12 19 29 35
5 14 21 31 36
8 16 24 32 40

My matrix code:
https://jsfiddle.net/4eofvvhr/11/
Question:
How to fill the matrix so that the numbers are displayed one after the other and split into columns? ( https://prnt.sc/iiawa4)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
davidnum95, 2018-02-22
@Insolation

Something like this

T
twobomb, 2018-02-22
@twobomb

I didn’t understand why an array is needed, or maybe in general I didn’t understand the task, well , it turned out like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question