combin is a Java utility to generate all possible binary combinations of a given size n. It offers flexible output options: print results to the console, save them to a file, or store them in memory.
- Generate binary combinations: For any size
n(up to (2^{16})). - Customizable characters: Replace
0and1with any other characters. - Output options:
- Print to the console.
- Save to a file.
- Store in an
ArrayList.
- Java 8 or higher.
javac Combin.javajava Combin <size> [bin0] [bin1] [filename] [console]<size>: (Required) The size of the binary combinations. Must be a positive integer ≤ 16.[bin0]: (Optional) Character to use instead of0.[bin1]: (Optional) Character to use instead of1.[filename]: (Optional) File to save the combinations. If provided, the program writes the combinations to this file.[console]: (Optional) If provided and set toconsole, results are printed to the console.
Generate all binary combinations of size 3 and print them to the console:
java Combin 3 1 0Generate combinations of size 3 using X and Y instead of 0 and 1:
java Combin 3 X Y consoleGenerate combinations of size 4 and save them to output.txt:
java Combin 4 0 1 output.txtGenerate combinations of size 4, save them to output.txt, and also print them:
java Combin 4 0 1 output.txt console- Invalid size: If
<size>is not provided, not a number, or exceeds the limit, an error is displayed. - Invalid characters: Binary characters must be single characters.
- File write issues: Errors during file operations are logged to the console.
java Combin 2 1 0 consoleGenerating binary combinations for size: 2
Generated combinations:
00
01
10
11
This project is licensed under the MIT License. See the LICENSE file for details.