Answer the question
In order to leave comments, you need to log in
How to write a complex algorithm?
There is an array:
var level = [
[
'один', // 4 буквы
'два', // 3 буквы
'три', // 3 буквы
'четыре' // 6 букв
// и того 16 букв
]
];
Answer the question
In order to leave comments, you need to log in
Not a complicated algorithm. You take a table and start from left to right:
1. You take a word;
2. You choose the first free cell that comes across (when walking from left to right, top to bottom, especially for longclaps . First this is a corner, then how it goes);
3. You choose a random direction of movement from the available ones (there must be at least one free cell in this direction);
4. You start spelling the word using depth-first traversal (cell cells are graph vertices, edges are formed between two free cells connected at a right angle), with a priority to maintain direction (no turns, except when resting against a wall);
5. If there are more words - take them and go to step 1.
For example: 16 letters = 4*4, 20 letters = 4*5, etc. That is, to be able to optionally specify the proportions of the grid, depending on the number of letters.The square root of the number of letters, or the closest square root of the given number to be extracted (whose modulus difference is smaller):
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question