Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-27-2003, 11:21 AM   #16
Registered: Jun 2001
Location: Houston, TX, USA
Distribution: Debian
Posts: 569

Rep: Reputation: 31

Originally posted by kev82
my method bounds the elements(to the maximium value of an int) i just thought that a bound of 9 was quite low, and i couldnt see an easy way to modify it(but i dont know python) your algorithm is much simpler than mine and probably better at low vales of n and k but i like to solve the problem in general not just in a few cases which is why i made the comment.
Well, really mine is a general solution as well if you abstract away the 0-9 assumption. The general solution I suggest is just: create all the combinations and just iterate through them, eliminating invalid ones. Of course, for things that use the 0-9 assumption creating the range is eased by the functionality offered by some languages (like Python) in that they will create the list for you. But if you have to create the list yourself, you can still do the same thing, only it makes sense to cull up front instead of after the list is done.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best Guess on Gnome 2.8? 2Gnu Slackware 3 09-16-2004 06:06 PM
LILO problem... I guess :( jmut Slackware 8 05-05-2004 07:53 AM
problem with keyboard i guess :s Defuntu Linux - Newbie 3 03-11-2004 01:48 PM
So guess what Cichlid Linux - Networking 0 03-16-2002 05:22 PM
/etc/resolv.conf problem I guess...... cvlinux Linux - Networking 3 09-13-2001 03:46 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration