el 06-12-2020 09:43 PM
Necesito generar todas las posibles permutaciones de un numero entero de cuatro digitos. Ejm: 7812, permutaciones son 8172,7821,2871,etc
I need to generate all possible permutations of a four digit integer. Ex: 7812, permutations are 8172,7821,2871, etc.
el 06-13-2020 09:41 AM
Este no es un foro para cumplir deseos de usuarios.
Se trata de apoyar en dudas, guiar y aconsejar.
"Necesito hacer X cosa" no menciona cuál es tu problema o duda. Tampoco compartes tus intentos o código que has hecho hasta el momento.
06-13-2020 01:47 PM - editado 06-13-2020 01:53 PM
Format as string and separate into an array of single digits, then start reading here. Scan back into numeric if desired.
Is it always four digits or can it be any number of digits? For very long inputs, you might run out of memory.
(Of course if some values are in duplicate, you need to filter at the end to only retain the unique results (e.g. 7745 has duplicates while an input of 4444 only has exactly one solution). removing duplicates is easy, though. See how far you get. You could even avoid storing duplicates by accumulating results into a "set".
el 06-13-2020 02:24 PM
@altenbach wrote:
You could even avoid storing duplicates by accumulating results into a "set".
Here's how that could look like (requires LabVIEW 2019 or newer):
See if you can recreate it 😉
The use of a set correctly eliminates duplicates: