LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

Rep: Reputation: 31

Quote:
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.
 
  


Reply


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


All times are GMT -5. The time now is 11:59 PM.

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