Most elegant way to generate 3-char sequence

A

akameswaran

I'm not sure if you ever got a good answer. I for one am too lazy to
look up the pages I found... but - check out
http://aspn.activestate.com/ASPN/search?query=combinations&section=PYTHONCKBK&type=Subsection

Tons of nice recipes... Personally I liked the one that dynamically
generated a nested function - just cuz it was cool - total overkill for
a 3 element permutation. otherwise a simple nested generator is
perfect for this solution. Actually you could use the generator
function generator to show you what the generator function should look
like - try sayin that five times fast.
 
R

Roberto Bonvallet

2006/6/10 said:
Right. But that wasn't the question :p

The question was about elegance, and elegance is when someone asks "do
something 4 times for 5 strings of length 3" and you solve it for "do
something n times for m strings of length p" :)
 
F

Fredrik Lundh

James said:
See the actual question:

if you don't think the context provided by the subject line and the
sentence before the question is important, how come you're so sure what
"this" refers to ?

</F>
 
J

James Stroud

Fredrik said:
if you don't think the context provided by the subject line and the
sentence before the question is important, how come you're so sure what
"this" refers to ?

</F>

I'm getting the feeling that "correct" answers have nothing to do with
correctness (i.e. working code) but on some vague notion of "elegance".
Please point me to the page where code elegance is precisely defined so
that I may construct my answers appropriately. And yes, I am too lazy to
google "code elegance".

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
 
S

sam

I have found that the more elegant the code is, the harder it is for me
to understand what it is trying to accomplish. It is my opinion that
"Keep It Simple" wins over elegance. When I have had the urge to get
elegant, I make sure I comment the elegance so my less elegant
co-workers can figure out what I was trying to accomplish.

Sam Schulenburg
 
P

Petr Jakes

sam said:
I have found that the more elegant the code is, the harder it is for me
to understand what it is trying to accomplish. It is my opinion that
"Keep It Simple" wins over elegance. When I have had the urge to get
elegant, I make sure I comment the elegance so my less elegant
co-workers can figure out what I was trying to accomplish.

Sam Schulenburg
+1

Petr Jakes
 
B

Bruno Desthuilliers

John Machin a écrit :
On 10/06/2006 7:49 AM, Rob Cowie wrote: (snip)


Why stop at two spaces? One-space indentation is syntactically correct :)

I very often uses 2-spaces indent when posting here, to avoid problems
with wrapping.
 
B

Bruno Desthuilliers

James Stroud a écrit :
Not necessarily vying for winner, but David's solution is highly
specific as it doesn't do so well for something like

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
.
.
.
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzy
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

And ? Was it asked for ?

I'd personaly start with David's solution - IOW : simplest thing that
could possibly work -, and only bother making it more generic if/when I
have a use case for a more generic solution.

Premature generalisation is the root of all evil !-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top