Re: [Tutor] Algorithm

2015-12-28 Thread Alan Gauld
On 28/12/15 17:32, Joel Goldstick wrote: > I believe the code following should not be indented as that makes it part > of your function > > >> numlist1 = [1,2,3,4,5] >> numlist2 = [10,20,30,40,50] >> largest = get_algorithm_result(numlist1) >> print largest Ah, that makes se

Re: [Tutor] Algorithm

2015-12-28 Thread Alan Gauld
On 28/12/15 12:34, cicy felix wrote: > Create a function get_algorithm_result to implement the algorithm below > Get a list of numbers L1, L2, L3LN as argument > Assume L1 is the largest, Largest = L1 > Take next number Li from the list and do the following > If Largest is less than Li >

Re: [Tutor] Algorithm

2015-12-28 Thread Joel Goldstick
On Mon, Dec 28, 2015 at 7:34 AM, cicy felix wrote: > Hello there! > Thank you for the good work you are doing at helping newbies to python. > Please I'd like clarification with the exercise below: > > Create a function get_algorithm_result to implement the algorithm below > Get a list of number

Re: [Tutor] Algorithm for sequence matching

2011-07-03 Thread Albert-Jan Roskam
: [Tutor] Algorithm for sequence matching To: "Walter Prins" Cc: tutor@python.org Date: Sunday, July 3, 2011, 5:48 PM I know a way to do thatset1 = set(list1)set2 = set(list2)combined = set1&set2 On Sat, Jul 2, 2011 at 5:16 PM, Walter Prins wrote: Hi Ankur, On 2 July 2011 21:30,

Re: [Tutor] Algorithm for sequence matching

2011-07-03 Thread Christopher King
I know a way to do that set1 = set(list1) set2 = set(list2) combined = set1&set2 On Sat, Jul 2, 2011 at 5:16 PM, Walter Prins wrote: > Hi Ankur, > > On 2 July 2011 21:30, ANKUR AGGARWAL wrote: > >> Hey >> I am looking for an algo for the largest sequence search in the two list. >> >> Example :

Re: [Tutor] Algorithm for sequence matching

2011-07-02 Thread Steven D'Aprano
ANKUR AGGARWAL wrote: Hey I am looking for an algo for the largest sequence search in the two list. Example : list a accepts some say 'm' numbers. list b accept says 'n' numbers. I want to look for the largest same sequence between the two list and then display it. I tried out but failed to do s

Re: [Tutor] Algorithm for sequence matching

2011-07-02 Thread Walter Prins
Just to clarify further: On 2 July 2011 23:46, Walter Prins wrote: > On 2 July 2011 21:30, ANKUR AGGARWAL wrote: > >> Example : list a accepts some say 'm' numbers. list b accept says 'n' >> numbers. I want to look for the largest same sequence between the two list >> and then display it. I tri

Re: [Tutor] Algorithm for sequence matching

2011-07-02 Thread Walter Prins
Hi Ankur, On 2 July 2011 21:30, ANKUR AGGARWAL wrote: > Hey > I am looking for an algo for the largest sequence search in the two list. > > Example : list a accepts some say 'm' numbers. list b accept says 'n' > numbers. I want to look for the largest same sequence between the two list > and the

Re: [Tutor] Algorithm for sequence matching

2011-07-02 Thread Peter Otten
ANKUR AGGARWAL wrote: > Hey > I am looking for an algo for the largest sequence search in the two list. > > Example : list a accepts some say 'm' numbers. list b accept says 'n' > numbers. I want to look for the largest same sequence between the two list > and then display it. I tried out but fai

Re: [Tutor] Algorithm for sequence matching

2011-07-02 Thread Walter Prins
Forwarding back to list. -- Forwarded message -- From: ANKUR AGGARWAL Date: 2 July 2011 22:23 Subject: Re: [Tutor] Algorithm for sequence matching To: Walter Prins ya sorry I forgot to include 11 . i want the answer to be [11,23,45,21] On Sun, Jul 3, 2011 at 2:46 AM, Walter

Re: [Tutor] Algorithm for sequence matching

2011-07-02 Thread Walter Prins
Hi Ankur, On 2 July 2011 21:30, ANKUR AGGARWAL wrote: > Hey > I am looking for an algo for the largest sequence search in the two list. > > Example : list a accepts some say 'm' numbers. list b accept says 'n' > numbers. I want to look for the largest same sequence between the two list > and the

Re: [Tutor] Algorithm for sequence matching

2011-07-02 Thread bob gailer
On 7/2/2011 4:30 PM, ANKUR AGGARWAL wrote: Hey I am looking for an algo for the largest sequence search in the two list. Example : list a accepts some say 'm' numbers. list b accept says 'n' numbers. I want to look for the largest same sequence between the two list and then display it. I tried

Re: [Tutor] Algorithm for combination analysis suggestion.

2010-02-12 Thread Gerard Flanagan
Matthew Matson wrote: Hi Tutors, I am looking for the proper approach regarding the analysis of a dictionary of combinations I have. What I need to do is read from a supplied text file that has a unique ID and that unique ID's associated combination of elements. So let's say I have the fol

Re: [Tutor] Algorithm for combination analysis suggestion.

2010-02-11 Thread Matthew Matson
I will see if I can code up a sample of what I am trying to do. Thanks again. > Date: Thu, 11 Feb 2010 15:21:51 -0500 > Subject: Re: [Tutor] Algorithm for combination analysis suggestion. > From: ken...@tds.net > To: gtx...@hotmail.com > CC: tutor@python.org > > On Thu,

Re: [Tutor] Algorithm for combination analysis suggestion.

2010-02-11 Thread Kent Johnson
On Thu, Feb 11, 2010 at 1:59 PM, Matthew Matson wrote: > > Hi Tutors, > > I am looking for the proper approach regarding the analysis of a dictionary > of combinations I have. > > What I need to do is read from a supplied text file that has a unique ID and > that unique ID's associated combination

Re: [Tutor] Algorithm

2009-08-25 Thread kreglet
Wayne, Kent, Alan, and Mac Thank you for all the help and suggestions . Wayne and Kent, Both your solutions work great. The extra comments you gave on the code that I tried will help reduce the line count and make the code more readable in the rest of the project. Apparently, I still have a lo

Re: [Tutor] Algorithm

2009-08-25 Thread Kent Johnson
On Tue, Aug 25, 2009 at 9:55 PM, Wayne wrote: > I just did a quick test and this code seems to work correctly: > def countletters(word): >     lettercount = {} >     for letter in word: >         lettercount[letter] = lettercount.get(letter, 0) + 1 >     return lettercount > def comparewords(cmpwor

Re: [Tutor] Algorithm

2009-08-25 Thread Wayne
On Tue, Aug 25, 2009 at 2:14 PM, kreglet wrote: > > Wayne, > I appreciate your patience with me. I still can't get this to work: > > > from operator import itemgetter > class testwords: > def __init__(self): >self.lettercount={} >

Re: [Tutor] Algorithm

2009-08-25 Thread Kent Johnson
On Tue, Aug 25, 2009 at 5:03 PM, kreglet wrote: > > Hello Kent, > > Yes I would like to see your implementation. It seems to work but I get > error at the end. > > concat=''.join > > mainword="python" > cmpword="pot" >  # sort the letters in the target word; for example 'python' becomes > 'hnopty'

Re: [Tutor] Algorithm

2009-08-25 Thread kreglet
Hello Kent, Yes I would like to see your implementation. It seems to work but I get error at the end. concat=''.join mainword="python" cmpword="pot" # sort the letters in the target word; for example 'python' becomes 'hnopty' tmplst=[] for letters in mainword: tmplst.append(letters) t

Re: [Tutor] Algorithm

2009-08-25 Thread kreglet
Wayne, I appreciate your patience with me. I still can't get this to work: from operator import itemgetter class testwords: def __init__(self): self.lettercount={} self.inword=False self.main

Re: [Tutor] Algorithm

2009-08-25 Thread Wayne
On Mon, Aug 24, 2009 at 8:58 PM, kreglet wrote: > > Wayne, > > > def myfunc(cmpword, mainword): > > for letter in cmpword: > > if mainword.gets(letter): > > if cmpword[letter] >mainword[letter]: > > return False > > else: > > return False > > I tried your f

Re: [Tutor] Algorithm

2009-08-25 Thread Kent Johnson
On Sun, Aug 23, 2009 at 6:06 PM, kreglet wrote: > > Hello, > >  The problem that I am having is writing an algorithm for finding all the > possible words from a given word. For example: python > > from "python" you can make the words pot, top, hop, not etc. There are few > examples for making anagr

Re: [Tutor] Algorithm

2009-08-24 Thread kreglet
Wayne, > def myfunc(cmpword, mainword): > for letter in cmpword: > if mainword.gets(letter): > if cmpword[letter] >mainword[letter]: > return False > else: > return False I tried your function and couldn't get it to work. It threw an error in the line "if

Re: [Tutor] Algorithm

2009-08-24 Thread Alan Gauld
"kreglet" wrote The reason I used print sorted is that using just print throws a syntax error: print (lettercount.iteritems(), key=itemgetter(1)) ---> error print lettercount.iteritems(), key=itemgetter(1) ---> error print sorted(lettercount.iteritems(), key=itemgetter(1)) ---> works I don't

Re: [Tutor] Algorithm

2009-08-24 Thread Wayne
On Mon, Aug 24, 2009 at 10:48 AM, kreglet wrote: > > Wayne, > > The reason I used print sorted is that using just print throws a syntax > error: > > print (lettercount.iteritems(), key=itemgetter(1)) ---> error > print lettercount.iteritems(), key=itemgetter(1) ---> error > print sorted(lettercou

Re: [Tutor] Algorithm

2009-08-24 Thread kreglet
Hello Mac, Thanks for the tip. I was aware of an and considered using it. I decided not to use it unless I have no other choice. Although it does exactly what I am after: a) I don't want to use any dependencies other than Python's built in modules b) You hit it right in the nose when you

Re: [Tutor] Algorithm

2009-08-24 Thread kreglet
Wayne, The reason I used print sorted is that using just print throws a syntax error: print (lettercount.iteritems(), key=itemgetter(1)) ---> error print lettercount.iteritems(), key=itemgetter(1) ---> error print sorted(lettercount.iteritems(), key=itemgetter(1)) ---> works I don't know why

Re: [Tutor] Algorithm

2009-08-24 Thread Mac Ryan
On Sun, 2009-08-23 at 15:06 -0700, kreglet wrote: > Hello, > > The problem that I am having is writing an algorithm for finding all the > possible words from a given word. For example: python > > from "python" you can make the words pot, top, hop, not etc. There are few > examples for making an

Re: [Tutor] Algorithm

2009-08-24 Thread Wayne
On Sun, Aug 23, 2009 at 10:01 PM, kreglet wrote: > > Alan, > > Thanks for the reply. This is not homework, it is a hobby. I am 44 years > old. I was using Visual Basic, but recently decided to switch to Linux and > have no intentions of going back to windows. Python seems like a good > computer

Re: [Tutor] Algorithm

2009-08-24 Thread kreglet
Alan, Thanks for the reply. This is not homework, it is a hobby. I am 44 years old. I was using Visual Basic, but recently decided to switch to Linux and have no intentions of going back to windows. Python seems like a good computer language. I read somewhere the the best way to learn it was to

Re: [Tutor] Algorithm

2009-08-23 Thread Alan Gauld
"kreglet" wrote The problem that I am having is writing an algorithm for finding all the possible words from a given word. For example: python This sounds a lot like a homework. We don't give direct help on homeworks but will try to point you in the right direction. It helps if you tell/sho