Re: [go-nuts] Generation of Strings - generation

2016-07-22 Thread Tong Sun
Don't feel frustrated Michael. All the good advice from everyone here will benefit many more people besides OP. I myself learned a lot (especially, me too don't like the idea why channels has to be involved for such simple task initially, then saw that mind-opening comment from Paul Borman a

Re: [go-nuts] Generation of Strings - generation

2016-07-15 Thread Michael Jones
Whatever they wanted, we've put far more into answering it than than they have in responding. I sent my response taking time from the Farnborough Air Show, not wanting their concerns to go unaddressed. Disappointed to see no following reply to all the good advice from everyone here. On Jul 15, 2016

Re: [go-nuts] Generation of Strings - generation

2016-07-15 Thread 'Paul Borman' via golang-nuts
It wasn't clear to me what the OP wanted. Did they just want to print them? Did they want to use them? For use, I think the channel is probably the most straightforward to use, but the OP didn't want any channels at all. The underlying array that slices refer to could also be made smaller, for

Re: [go-nuts] Generation of Strings - generation

2016-07-15 Thread Bakul Shah
Ah. Should've read your original play link more carefully! You could've made it a bit more efficient by allocating one large string (N^N+N) and one Printf! Of course, that'd fall apart once you have more combinations than can fit in memory but that is easily solved. Still interested in knowing if

Re: [go-nuts] Generation of Strings - generation

2016-07-15 Thread 'Paul Borman' via golang-nuts
BTW, the solution I provided does change one digit at a time, working just like an odometer. The OP privately said that even the reporting channel was undesired in my solution, so I sent the OP a link to one that allocated a slice and then filled it in, rather than sending it down a channel. The

Re: [go-nuts] Generation of Strings - generation

2016-07-14 Thread Bakul Shah
What the OP wants is equivalent to generating *all* n digit numbers in base n. For example, given aa ab ba bb if you map a to 0 and b to 1 you get numbers 0..3 (base 2). In general you have n^n combinations.. If you consider only the cost of *copying* (or changing an existing string to a diff

Re: [go-nuts] Generation of Strings - generation

2016-07-12 Thread 'Paul Borman' via golang-nuts
Something like https://play.golang.org/p/dZjaaorPcb ? On Tue, Jul 12, 2016 at 1:54 PM, The MrU wrote: > Hi, > > I have this code https://play.golang.org/p/9o5TReZ7jT3 > > > My idea was to generate all possible combinations pretty much this: > > aaa > bbb >

[go-nuts] Generation of Strings - generation

2016-07-12 Thread The MrU
Hi, I have this code https://play.golang.org/p/9o5TReZ7jT3 My idea was to generate all possible combinations pretty much this: aaa bbb ccc abb acc baa bbb bcc caa cbb ccc aba abb abc you get the picture I think. I got this solution but the objective is