项目作者: RagingTiger

项目描述 :
All Possible Permutations of Numeric Strings of Length N Using Digits 0 -> K
高级语言: Python
项目地址: git://github.com/RagingTiger/numgen.git
创建时间: 2020-01-31T19:15:29Z
项目社区:https://github.com/RagingTiger/numgen

开源协议:

下载


About

Number generator

Introduction

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:

  1. $ N=2; K=2
  2. $ python3 numgen.py $N $K
  3. 00
  4. 01
  5. 10
  6. 11

The next axample shows n = 3 and k = 2:

  1. $ N=3; K=2
  2. $ python3 numgen.py $N $K
  3. 00
  4. 10
  5. 20
  6. 01
  7. 11
  8. 21
  9. 02
  10. 12
  11. 22

Since only digits 0-9 are used, then the max number of elements n is limited to 10:

  1. $ N=11; K=1
  2. $ python3 numgen.py $N $K
  3. Maximum value of n is 10. Please try again.

Docker

Build image with accompanying docker file and use as follows

Build

  1. $ docker build -t numgen .

Run

  1. $ NUMGEN_NVAL=10; NUMGEN_KVAL=2
  2. $ docker run -d \
  3. --name numgen.$(date +%m%d%y%H%M%S) \
  4. -v $PWD:/home/numgen \
  5. -it numgen ash \
  6. -c "time python /usr/src/numgen.py $NUMGEN_NVAL $NUMGEN_KVAL > output.$(date +%m%d%y%H%M%S).txt"

Logs

  1. # How to view the time results
  2. $ docker logs -f numgen.013120140955
  3. real 0m 0.04s
  4. user 0m 0.03s
  5. sys 0m 0.00s

Output File

Output file will have format similar to output.013120140955.txt where the 013120140955 is the
date the file was generated