7
I’m trying to develop an algorithm that can get an array of strings, sort by word size downwards, and put them into a char matrix by fitting all the words together if possible. The idea of everything would be like creating a grid and having the words "connect" through letters in common, to draw the idea imagine a word search.
Ex:
String[] palavras = new String[]{"vidro", "plastico", "amarelo", "madeira", "metal"};
palavras = OrdernarPorTamanho(palavras, DECRESCENTE);
char[][] grid = new char[15][15];
for(int linha = 0; linha < 15; linha++)
{
for(int coluna = 0; coluna < 15; coluna++)
{
// Aqui viria as verificações para colocar todas as palavras do vetor dentro da matriz
}
}
My desired output from the matrix would be as follows:
Ex:
- P L A S T I C O - - - - - -
- - - M E T A L - - - - - - -
- - - A - - - - - - - - - - -
- - - R - - - - - - - - - - -
M A D E I R A - - - - - - - -
- - - L - - - - - - - - - - -
- - - O R D I V - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
Does anyone have any suggestions on how to make this algorithm?
Thanks :)
What language?
– user28595
@diegofm any one, but at first it would be Java
– Jose Felipe Blum de Araujo
I think this problem requires a genetic algorithm. Spreading words becomes complicated as words that are already on the board may be occupying drawn spaces for the next.
– Celso Marigo Jr
@Celsomarigojr Some suggestion of algorithmism?
– Jose Felipe Blum de Araujo