Number generator
This is a simple number generator, written in Python 3, that will create all possible permutations
of n-elements
in a string of k-elements
where the digits 0 - 9
are the only elements used.
The below example shows n = 2
and k = 2
:
$ N=2; K=2
$ python3 numgen.py $N $K
00
01
10
11
The next axample shows n = 3
and k = 2
:
$ N=3; K=2
$ python3 numgen.py $N $K
00
10
20
01
11
21
02
12
22
Since only digits 0-9
are used, then the max number of elements n
is limited to 10:
$ N=11; K=1
$ python3 numgen.py $N $K
Maximum value of n is 10. Please try again.
Build image with accompanying docker file and use as follows
$ docker build -t numgen .
$ NUMGEN_NVAL=10; NUMGEN_KVAL=2
$ docker run -d \
--name numgen.$(date +%m%d%y%H%M%S) \
-v $PWD:/home/numgen \
-it numgen ash \
-c "time python /usr/src/numgen.py $NUMGEN_NVAL $NUMGEN_KVAL > output.$(date +%m%d%y%H%M%S).txt"
# How to view the time results
$ docker logs -f numgen.013120140955
real 0m 0.04s
user 0m 0.03s
sys 0m 0.00s
Output file will have format similar to output.013120140955.txt
where the 013120140955
is the
date the file was generated