[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to print all 3 char length string made whitespace {0..9} {a..z}
From: |
Mike Jonkmans |
Subject: |
Re: how to print all 3 char length string made whitespace {0..9} {a..z} |
Date: |
Thu, 6 Aug 2020 11:05:40 +0200 |
On Thu, Aug 06, 2020 at 12:46:08AM -0300, Marco Ippolito wrote:
> On 02/08/2020 18:10, Mike Jonkmans wrote:
> >
> > Are you lookiung for this?
> > echo {{a..z},\ ,{0..9}}{{a..z},\ ,{0..9}}{{a..z},\ ,{0..9}}
>
> I was going to recommend this:
>
> e=({a..z} ' ' {0..9}); l=${#e[@]}; for ((i=0; i<l; i++)); do for ((j=0; j<l;
> j++)); do for ((y=0; y<l; y++)); do printf "${e[i]}${e[j]}${e[y]} "; done;
> done; done
>
> to make the space complexity, or memory footprint, of it depend linearly
> rather than exponentially (even if just to the 3rd power), on the input,
> allowing more characters in the set to be permuted (e.g. Chinese characters)
> without segfaulting on malloc.
>
> Marco Ippolito
> maroloccio@gmail.com
Hmm, my echo should have been be a printf "%s\n".
Both solutions seem to work.
The for-solution does take 4x longer to run though (when piped to wc -c).
When printed to the terminal, the difference in runtime is rather large.
At my desktop it is running 10 minutes (versus 0.2 seconds).
Calling printf repeatedly - 50653 times - makes the difference.
Kind of a memory-time tradeoff.
Regards, Mike Jonkmans
--
Mike Jonkmans <bashbug@jonkmans.nl>
- how to print all 3 char length string made whitespace {0..9} {a..z}, Peng Yu, 2020/08/02
- Re: how to print all 3 char length string made whitespace {0..9} {a..z}, Eli Schwartz, 2020/08/02
- Re: how to print all 3 char length string made whitespace {0..9} {a..z}, Peng Yu, 2020/08/02
- Re: how to print all 3 char length string made whitespace {0..9} {a..z}, Dennis Williamson, 2020/08/02
- Re: how to print all 3 char length string made whitespace {0..9} {a..z}, Mike Jonkmans, 2020/08/02
- Re: how to print all 3 char length string made whitespace {0..9} {a..z}, Marco Ippolito, 2020/08/05
- Re: how to print all 3 char length string made whitespace {0..9} {a..z},
Mike Jonkmans <=
- Re: how to print all 3 char length string made whitespace {0..9} {a..z}, Marco Ippolito, 2020/08/07
- Re: how to print all 3 char length string made whitespace {0..9} {a..z}, Greg Wooledge, 2020/08/07
- Re: how to print all 3 char length string made whitespace {0..9} {a..z}, Jeffrey Walton, 2020/08/07
- Re: how to print all 3 char length string made whitespace {0..9} {a..z}, Eli Schwartz, 2020/08/07
- Re: how to print all 3 char length string made whitespace {0..9} {a..z}, Eli Schwartz, 2020/08/02