From: ·············@gmail.com
Subject: Lisp problem to solve
Date: 
Message-ID: <ee26faa3-109a-4c51-b029-7f877460e3b8@n20g2000hsh.googlegroups.com>
You are given a list of transactions along with the
profits from the transactions. Write code that will return the
transaction with the maximum profit. If many transactions have the
same and maximusm profit, the code can return any of these. For
example,
given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
return T3.


I am looking for code or pseudocode.

From: Chris Russell
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <f8f8bf92-74d3-4439-a3a5-52ed0650af1b@y43g2000hsy.googlegroups.com>
On 20 Nov, 14:48, ·············@gmail.com wrote:
> You are given a list of transactions along with the
> profits from the transactions. Write code that will return the
> transaction with the maximum profit. If many transactions have the
> same and maximusm profit, the code can return any of these. For
> example,
> given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> return T3.
>
> I am looking for code or pseudocode.

(lambda(x)(third x));I have confirmed type correctness and program
passes all test cases.
From: ·············@gmail.com
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <74ec7d94-4b05-4239-b456-159c915f9ac3@y43g2000hsy.googlegroups.com>
On Nov 20, 9:24 am, Chris Russell <·····················@gmail.com>
wrote:
> On 20 Nov, 14:48, ·············@gmail.com wrote:
>
> > You are given a list of transactions along with the
> > profits from the transactions. Write code that will return the
> > transaction with the maximum profit. If many transactions have the
> > same and maximusm profit, the code can return any of these. For
> > example,
> > given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> > return T3.
>
> > I am looking for code or pseudocode.
>
> (lambda(x)(third x));I have confirmed type correctness and program
> passes all test cases.

That would work but not what im looking for...
From: Ken Tilton
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <gIV0j.9$QY3.6@newsfe10.lga>
Chris Russell wrote:
> On 20 Nov, 14:48, ·············@gmail.com wrote:
> 
>>You are given a list of transactions along with the
>>profits from the transactions. Write code that will return the
>>transaction with the maximum profit. If many transactions have the
>>same and maximusm profit, the code can return any of these. For
>>example,
>>given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
>>return T3.
>>
>>I am looking for code or pseudocode.
> 
> 
> (lambda(x)(third x));I have confirmed type correctness and program
> passes all test cases.

You either meant #'caaddr or we'll to see your implementation of EQL s.t:

     (eql '(t3 188) 't3) -> t

hth,kxo

-- 
http://www.theoryyalgebra.com/

"In the morning, hear the Way;
  in the evening, die content!"
                     -- Confucius
From: Slobodan Blazeski
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <85ae7541-0373-4a85-8ebd-9bdafbcbc6a5@i12g2000prf.googlegroups.com>
On Nov 20, 3:48 pm, ·············@gmail.com wrote:
> You are given a list of transactions along with the
> profits from the transactions. Write code that will return the
> transaction with the maximum profit. If many transactions have the
> same and maximusm profit, the code can return any of these. For
> example,
> given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> return T3.
>
> I am looking for code or pseudocode.

You're looking for trouble, your teacher is probably reading this
newsgroup:
ITER> (defun max-profit (transactions)
	(iter (for elt in transactions)
	      (finding (car elt) maximizing (cadr elt))))
MAX-PROFIT
ITER> (max-profit '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
T3


Slobodan
From: ·············@gmail.com
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <e7550b55-2eea-40bd-8d19-9be4aab6d67e@b32g2000hsa.googlegroups.com>
On Nov 20, 9:50 am, Slobodan Blazeski <·················@gmail.com>
wrote:
> On Nov 20, 3:48 pm, ·············@gmail.com wrote:
>
> > You are given a list of transactions along with the
> > profits from the transactions. Write code that will return the
> > transaction with the maximum profit. If many transactions have the
> > same and maximusm profit, the code can return any of these. For
> > example,
> > given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> > return T3.
>
> > I am looking for code or pseudocode.
>
> You're looking for trouble, your teacher is probably reading this
> newsgroup:
> ITER> (defun max-profit (transactions)
>         (iter (for elt in transactions)
>               (finding (car elt) maximizing (cadr elt))))
> MAX-PROFIT
> ITER> (max-profit '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
> T3
>
> Slobodan

Thanks it doesnt matter if he is
From: Slobodan Blazeski
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <0ef0c5ae-c145-487b-a02c-feadc8650aa7@b15g2000hsa.googlegroups.com>
On Nov 20, 4:54 pm, ·············@gmail.com wrote:
> On Nov 20, 9:50 am, Slobodan Blazeski <·················@gmail.com>
> wrote:
>
>
>
> > On Nov 20, 3:48 pm, ·············@gmail.com wrote:
>
> > > You are given a list of transactions along with the
> > > profits from the transactions. Write code that will return the
> > > transaction with the maximum profit. If many transactions have the
> > > same and maximusm profit, the code can return any of these. For
> > > example,
> > > given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> > > return T3.
>
> > > I am looking for code or pseudocode.
>
> > You're looking for trouble, your teacher is probably reading this
> > newsgroup:
> > ITER> (defun max-profit (transactions)
> >         (iter (for elt in transactions)
> >               (finding (car elt) maximizing (cadr elt))))
> > MAX-PROFIT
> > ITER> (max-profit '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
> > T3
>
> > Slobodan
>
> Thanks it doesnt matter if he is
I hope that you know what you're doing.
What kind of course  are these coming from anyway? Lisp only?  AI
introduction ? Learning lisp with half-dozen of other languages?

Slobodan
From: ·············@gmail.com
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <97b3da11-b837-4b4b-a7dd-9f0958c4ae0b@f3g2000hsg.googlegroups.com>
On Nov 20, 10:12 am, Slobodan Blazeski <·················@gmail.com>
wrote:
> On Nov 20, 4:54 pm, ·············@gmail.com wrote:
>
> > On Nov 20, 9:50 am, Slobodan Blazeski <·················@gmail.com>
> > wrote:
>
> > > On Nov 20, 3:48 pm, ·············@gmail.com wrote:
>
> > > > You are given a list of transactions along with the
> > > > profits from the transactions. Write code that will return the
> > > > transaction with the maximum profit. If many transactions have the
> > > > same and maximusm profit, the code can return any of these. For
> > > > example,
> > > > given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> > > > return T3.
>
> > > > I am looking for code or pseudocode.
>
> > > You're looking for trouble, your teacher is probably reading this
> > > newsgroup:
> > > ITER> (defun max-profit (transactions)
> > >         (iter (for elt in transactions)
> > >               (finding (car elt) maximizing (cadr elt))))
> > > MAX-PROFIT
> > > ITER> (max-profit '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
> > > T3
>
> > > Slobodan
>
> > Thanks it doesnt matter if he is
>
> I hope that you know what you're doing.
> What kind of course  are these coming from anyway? Lisp only?  AI
> introduction ? Learning lisp with half-dozen of other languages?
>
> Slobodan

Learning lisp with half-dozen of other languages
From: ·············@gmail.com
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <b4f52cf2-e3c3-4900-8f2f-d0697d99c419@p69g2000hsa.googlegroups.com>
On Nov 20, 10:12 am, Slobodan Blazeski <·················@gmail.com>
wrote:
> On Nov 20, 4:54 pm, ·············@gmail.com wrote:
>
> > On Nov 20, 9:50 am, Slobodan Blazeski <·················@gmail.com>
> > wrote:
>
> > > On Nov 20, 3:48 pm, ·············@gmail.com wrote:
>
> > > > You are given a list of transactions along with the
> > > > profits from the transactions. Write code that will return the
> > > > transaction with the maximum profit. If many transactions have the
> > > > same and maximusm profit, the code can return any of these. For
> > > > example,
> > > > given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> > > > return T3.
>
> > > > I am looking for code or pseudocode.
>
> > > You're looking for trouble, your teacher is probably reading this
> > > newsgroup:
> > > ITER> (defun max-profit (transactions)
> > >         (iter (for elt in transactions)
> > >               (finding (car elt) maximizing (cadr elt))))
> > > MAX-PROFIT
> > > ITER> (max-profit '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
> > > T3
>
> > > Slobodan
>
> > Thanks it doesnt matter if he is
>
> I hope that you know what you're doing.
> What kind of course  are these coming from anyway? Lisp only?  AI
> introduction ? Learning lisp with half-dozen of other languages?
>
> Slobodan

I just want to see how the code works, then learn from the code. Lisp
is so foreign to me.
From: Slobodan Blazeski
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <46475b81-39c9-4b91-9e48-c3615193d2b3@e4g2000hsg.googlegroups.com>
On Nov 20, 5:25 pm, ·············@gmail.com wrote:
> On Nov 20, 10:12 am, Slobodan Blazeski <·················@gmail.com>
> wrote:
>
>
>
> > On Nov 20, 4:54 pm, ·············@gmail.com wrote:
>
> > > On Nov 20, 9:50 am, Slobodan Blazeski <·················@gmail.com>
> > > wrote:
>
> > > > On Nov 20, 3:48 pm, ·············@gmail.com wrote:
>
> > > > > You are given a list of transactions along with the
> > > > > profits from the transactions. Write code that will return the
> > > > > transaction with the maximum profit. If many transactions have the
> > > > > same and maximusm profit, the code can return any of these. For
> > > > > example,
> > > > > given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> > > > > return T3.
>
> > > > > I am looking for code or pseudocode.
>
> > > > You're looking for trouble, your teacher is probably reading this
> > > > newsgroup:
> > > > ITER> (defun max-profit (transactions)
> > > >         (iter (for elt in transactions)
> > > >               (finding (car elt) maximizing (cadr elt))))
> > > > MAX-PROFIT
> > > > ITER> (max-profit '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
> > > > T3
>
> > > > Slobodan
>
> > > Thanks it doesnt matter if he is
>
> > I hope that you know what you're doing.
> > What kind of course  are these coming from anyway? Lisp only?  AI
> > introduction ? Learning lisp with half-dozen of other languages?
>
> > Slobodan
>
> I just want to see how the code works, then learn from the code. Lisp
> is so foreign to me.

Please accept my condolences. Courses like those are one of the reason
students hate lisp from the bottom of their souls. In my country
students learn lisp together with half-dozen other languages and
introduction to AI. And they *learn* to program lisp in pen & paper.
Once they pass that course they never want to hear about the damn AI
dinosaur who doesn't even have a proper ide. In the end they end up
with java.
If you want to learn lisp get yourself a nice ide (whichever you want,
any will do):
http://www.franz.com/downloads/allegrodownload.lhtml
http://www.lispworks.com/downloads/index.html
http://www.gigamonkeys.com/lispbox/

and a good book :
http://www.cs.cmu.edu/~dst/LispBook/
http://www.gigamonkeys.com/book/
or a video:
http://www.franz.com/services/classes/download.lhtml

Here's some more solution:
Iterative with dolist:
(defun max-profit (transaction)
              (let ((max (car transaction)))
                (dolist (elt transaction (car max))
                  (if (> (cadr elt) (cadr max))
                      (setq max elt)))))

Recursive with cond:
(defun max-profit (transaction &optional max)
              (cond ((endp transaction) (car max))
                    ((null max)
                     (setq max (car transaction))
                     (max-profit (cdr transaction) max))
                    ((> (cadar transaction) (cadr max))
                     (setq max (car transaction))
                     (max-profit (cdr transaction) max))
                    (t (max-profit (cdr transaction) max))))


Slobodan
From: Andreas Thiele
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <fhvqig$ohu$03$1@news.t-online.com>
"Slobodan Blazeski" <·················@gmail.com> schrieb im Newsbeitrag 
·········································@e4g2000hsg.googlegroups.com...
> On Nov 20, 5:25 pm, ·············@gmail.com wrote:
>> On Nov 20, 10:12 am, Slobodan Blazeski <·················@gmail.com>
>> wrote:
>>
>>
>>
>> > On Nov 20, 4:54 pm, ·············@gmail.com wrote:
>>
>> > > On Nov 20, 9:50 am, Slobodan Blazeski <·················@gmail.com>
>> > > wrote:
>>
>> > > > On Nov 20, 3:48 pm, ·············@gmail.com wrote:
>>
>> > > > > You are given a list of transactions along with the
>> > > > > profits from the transactions. Write code that will return the
>> > > > > transaction with the maximum profit. If many transactions have the
>> > > > > same and maximusm profit, the code can return any of these. For
>> > > > > example,
>> > > > > given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
>> > > > > return T3.
>>
>> > > > > I am looking for code or pseudocode.
>>
>> > > > You're looking for trouble, your teacher is probably reading this
>> > > > newsgroup:
>> > > > ITER> (defun max-profit (transactions)
>> > > >         (iter (for elt in transactions)
>> > > >               (finding (car elt) maximizing (cadr elt))))
>> > > > MAX-PROFIT
>> > > > ITER> (max-profit '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
>> > > > T3
>>
>> > > > Slobodan
>>
>> > > Thanks it doesnt matter if he is
>>
>> > I hope that you know what you're doing.
>> > What kind of course  are these coming from anyway? Lisp only?  AI
>> > introduction ? Learning lisp with half-dozen of other languages?
>>
>> > Slobodan
>>
>> I just want to see how the code works, then learn from the code. Lisp
>> is so foreign to me.
>
> Please accept my condolences. Courses like those are one of the reason
> students hate lisp from the bottom of their souls. In my country
> students learn lisp together with half-dozen other languages and
> introduction to AI. And they *learn* to program lisp in pen & paper.
> Once they pass that course they never want to hear about the damn AI
> dinosaur who doesn't even have a proper ide. In the end they end up
> with java.
> ...

I'd second this. Have a close look at lisp.

You'll loose a lot when you miss to learn this language (like I did
during study).

Andreas

P.S. of course you need to now other languages as well or you
can not judge the power of lisp
From: Ken Tilton
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <FPV0j.10$QY3.6@newsfe10.lga>
·············@gmail.com wrote:
> On Nov 20, 10:12 am, Slobodan Blazeski <·················@gmail.com>
> wrote:
> 
>>On Nov 20, 4:54 pm, ·············@gmail.com wrote:
>>
>>
>>>On Nov 20, 9:50 am, Slobodan Blazeski <·················@gmail.com>
>>>wrote:
>>
>>>>On Nov 20, 3:48 pm, ·············@gmail.com wrote:
>>
>>>>>You are given a list of transactions along with the
>>>>>profits from the transactions. Write code that will return the
>>>>>transaction with the maximum profit. If many transactions have the
>>>>>same and maximusm profit, the code can return any of these. For
>>>>>example,
>>>>>given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
>>>>>return T3.
>>
>>>>>I am looking for code or pseudocode.
>>
>>>>You're looking for trouble, your teacher is probably reading this
>>>>newsgroup:
>>>>ITER> (defun max-profit (transactions)
>>>>        (iter (for elt in transactions)
>>>>              (finding (car elt) maximizing (cadr elt))))
>>>>MAX-PROFIT
>>>>ITER> (max-profit '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
>>>>T3
>>
>>>>Slobodan
>>
>>>Thanks it doesnt matter if he is
>>
>>I hope that you know what you're doing.
>>What kind of course  are these coming from anyway? Lisp only?  AI
>>introduction ? Learning lisp with half-dozen of other languages?
>>
>>Slobodan
> 
> 
> I just want to see how the code works, then learn from the code. Lisp
> is so foreign to me.

Actually, no, it is not, unless of course all code is foreign to you 
because you have never programmed before. If you have, you are just a 
terribly sad case running crying to usenet cuz lisp is your latest 
monster under the bed or in the closet or wherever you keep your 
monsters. Lisp is foreign the way driving on the other side of the road 
is foreign as in not at all because it's one bit and one bit doth not a 
foreigner make.

hth,kxo

-- 
http://www.theoryyalgebra.com/

"In the morning, hear the Way;
  in the evening, die content!"
                     -- Confucius
From: Mark Tarver
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <fec922a1-8b54-499d-8180-856b90492bdb@l1g2000hsa.googlegroups.com>
On 20 Nov, 14:48, ·············@gmail.com wrote:
> You are given a list of transactions along with the
> profits from the transactions. Write code that will return the
> transaction with the maximum profit. If many transactions have the
> same and maximusm profit, the code can return any of these. For
> example,
> given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> return T3.
>
> I am looking for code or pseudocode.

(SETQ *LIST* '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))

Shortest solution is 1 line.

(FIRST (FIRST (SORT *LIST* (FUNCTION (LAMBDA (X Y) (> (SECOND X)
(SECOND Y)))))))

Mark
From: John Thingstad
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <op.t135acd3ut4oq5@pandora.alfanett.no>
P� Tue, 20 Nov 2007 23:59:24 +0100, skrev Mark Tarver  
<··········@ukonline.co.uk>:

> On 20 Nov, 14:48, ·············@gmail.com wrote:
>> You are given a list of transactions along with the
>> profits from the transactions. Write code that will return the
>> transaction with the maximum profit. If many transactions have the
>> same and maximusm profit, the code can return any of these. For
>> example,
>> given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
>> return T3.
>>
>> I am looking for code or pseudocode.
>
> (SETQ *LIST* '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
>
> Shortest solution is 1 line.
>
> (FIRST (FIRST (SORT *LIST* (FUNCTION (LAMBDA (X Y) (> (SECOND X)
> (SECOND Y)))))))
>
> Mark
>

or (caar (sort *list* #'> :key #'second))

--------------
John Thingstad
From: Chris Russell
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <ee70d356-d311-429d-9a19-538d8d9f3ccf@y43g2000hsy.googlegroups.com>
On 20 Nov, 23:09, "John Thingstad" <·······@online.no> wrote:
> På Tue, 20 Nov 2007 23:59:24 +0100, skrev Mark Tarver
> <··········@ukonline.co.uk>:
>
>
>
> > On 20 Nov, 14:48, ·············@gmail.com wrote:
> >> You are given a list of transactions along with the
> >> profits from the transactions. Write code that will return the
> >> transaction with the maximum profit. If many transactions have the
> >> same and maximusm profit, the code can return any of these. For
> >> example,
> >> given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> >> return T3.
>
> >> I am looking for code or pseudocode.
>
> > (SETQ *LIST* '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
>
> > Shortest solution is 1 line.
>
> > (FIRST (FIRST (SORT *LIST* (FUNCTION (LAMBDA (X Y) (> (SECOND X)
> > (SECOND Y)))))))
>
> > Mark
>
> or (caar (sort *list* #'> :key #'second))
>
> --------------
> John Thingstad

If you guys must help him, at least tell him to use reduce.

(first (reduce (lambda(a b) (if (> (second a) (second b)) a b))
              '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66))))

It's O(n), side effect free, and shouldn't cons.
From: Slobodan Blazeski
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <1164fc32-e5da-4ccd-8238-fc250987ec83@d50g2000hsf.googlegroups.com>
On Nov 21, 2:32 am, Chris Russell <·····················@gmail.com>
wrote:
> On 20 Nov, 23:09, "John Thingstad" <·······@online.no> wrote:
>
>
>
> > På Tue, 20 Nov 2007 23:59:24 +0100, skrev Mark Tarver
> > <··········@ukonline.co.uk>:
>
> > > On 20 Nov, 14:48, ·············@gmail.com wrote:
> > >> You are given a list of transactions along with the
> > >> profits from the transactions. Write code that will return the
> > >> transaction with the maximum profit. If many transactions have the
> > >> same and maximusm profit, the code can return any of these. For
> > >> example,
> > >> given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> > >> return T3.
>
> > >> I am looking for code or pseudocode.
>
> > > (SETQ *LIST* '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
>
> > > Shortest solution is 1 line.
>
> > > (FIRST (FIRST (SORT *LIST* (FUNCTION (LAMBDA (X Y) (> (SECOND X)
> > > (SECOND Y)))))))
>
> > > Mark
>
> > or (caar (sort *list* #'> :key #'second))
>
> > --------------
> > John Thingstad
>
> If you guys must help him, at least tell him to use reduce.
>
> (first (reduce (lambda(a b) (if (> (second a) (second b)) a b))
>               '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66))))
>
> It's O(n), side effect free, and shouldn't cons.


Nice catch Chris, reduce is what I was looking for yesterday but got
too lazy and wrote ugly code.

Slobodan
From: Maciej Katafiasz
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <fhussb$m99$1@news.net.uni-c.dk>
Den Tue, 20 Nov 2007 06:48:45 -0800 skrev ryan.dufrasne:

> You are given a list of transactions along with the profits from the
> transactions. Write code that will return the transaction with the
> maximum profit. If many transactions have the same and maximusm profit,
> the code can return any of these. For example,
> given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> return T3.
> 
> 
> I am looking for code or pseudocode.

Homeworks go to alt.education.homeworks.

HTH,
Maciej
From: Rainer Joswig
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <joswig-2A0B54.15544620112007@news-europe.giganews.com>
In article 
<····································@n20g2000hsh.googlegroups.com>,
 ·············@gmail.com wrote:

> You are given a list of transactions along with the
> profits from the transactions. Write code that will return the
> transaction with the maximum profit. If many transactions have the
> same and maximusm profit, the code can return any of these. For
> example,
> given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> return T3.
> 
> 
> I am looking for code or pseudocode.

Looks like homework to me. When I solve it for you,
how will you explain that to your teacher?
Will I get your points?

-- 
http://lispm.dyndns.org/
From: ·············@gmail.com
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <d162af1a-1c57-4cf6-940d-f22cd8827042@p69g2000hsa.googlegroups.com>
On Nov 20, 8:54 am, Rainer Joswig <······@lisp.de> wrote:
> In article
> <····································@n20g2000hsh.googlegroups.com>,
>
>  ·············@gmail.com wrote:
> > You are given a list of transactions along with the
> > profits from the transactions. Write code that will return the
> > transaction with the maximum profit. If many transactions have the
> > same and maximusm profit, the code can return any of these. For
> > example,
> > given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> > return T3.
>
> > I am looking for code or pseudocode.
>
> Looks like homework to me. When I solve it for you,
> how will you explain that to your teacher?
> Will I get your points?
>
> --http://lispm.dyndns.org/

Sure you can have my points :)
From: Ken Tilton
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <TsD0j.999$TW5.650@newsfe09.lga>
·············@gmail.com wrote:
> On Nov 20, 8:54 am, Rainer Joswig <······@lisp.de> wrote:
> 
>>In article
>><····································@n20g2000hsh.googlegroups.com>,
>>
>> ·············@gmail.com wrote:
>>
>>>You are given a list of transactions along with the
>>>profits from the transactions. Write code that will return the
>>>transaction with the maximum profit. If many transactions have the
>>>same and maximusm profit, the code can return any of these. For
>>>example,
>>>given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
>>>return T3.
>>
>>>I am looking for code or pseudocode.
>>
>>Looks like homework to me. When I solve it for you,
>>how will you explain that to your teacher?
>>Will I get your points?
>>
>>--http://lispm.dyndns.org/
> 
> 
> Sure you can have my points :)

https://www4.uwm.edu/uits/help/

hth, kenny

ps. couldn't find a link to the ethics board at your school. Got that? :) k

-- 
http://www.theoryyalgebra.com/

"In the morning, hear the Way;
  in the evening, die content!"
                     -- Confucius
From: ·············@gmail.com
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <6127afa0-6ce5-4309-89df-5c1c99016f3b@b32g2000hsa.googlegroups.com>
On Nov 20, 9:56 am, Ken Tilton <···········@optonline.net> wrote:
> ·············@gmail.com wrote:
> > On Nov 20, 8:54 am, Rainer Joswig <······@lisp.de> wrote:
>
> >>In article
> >><····································@n20g2000hsh.googlegroups.com>,
>
> >> ·············@gmail.com wrote:
>
> >>>You are given a list of transactions along with the
> >>>profits from the transactions. Write code that will return the
> >>>transaction with the maximum profit. If many transactions have the
> >>>same and maximusm profit, the code can return any of these. For
> >>>example,
> >>>given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> >>>return T3.
>
> >>>I am looking for code or pseudocode.
>
> >>Looks like homework to me. When I solve it for you,
> >>how will you explain that to your teacher?
> >>Will I get your points?
>
> >>--http://lispm.dyndns.org/
>
> > Sure you can have my points :)
>
> https://www4.uwm.edu/uits/help/
>
> hth, kenny
>
> ps. couldn't find a link to the ethics board at your school. Got that? :) k
>
> --http://www.theoryyalgebra.com/
>
> "In the morning, hear the Way;
>   in the evening, die content!"
>                      -- Confucius

:)
From: Ross Lonstein
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <m2r6ijwv5f.fsf@pobox.com>
You might be looking to hit him with this...
 http://www.uwm.edu/Dept/OSL/DOS/conduct.html
and this
 http://www4.uwm.edu/Acad_Aff/policy/academicmisconduct.cfm

- Ross
From: Ken Tilton
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <UG01j.820$QY3.83@newsfe10.lga>
Ross Lonstein wrote:
> You might be looking to hit him with this...
>  http://www.uwm.edu/Dept/OSL/DOS/conduct.html
> and this
>  http://www4.uwm.edu/Acad_Aff/policy/academicmisconduct.cfm

Bingo!

"Academic misconduct is an act in which a student seeks to claim credit 
for the work or efforts of another without authorization or citation, ..."

Doh!

We may be in trouble, too:

"...or assists other students in any of these acts."

Actually, it would be kinda cool adding that 
expelled-from-schools-not-attended notch to my belt of dubious academic 
achievements.

"Prohibited conduct includes ... collaborating with others in work to be 
presented, contrary to the stated rules of the course; submitting a 
paper or assignment as one's own work when a part or all of the paper or 
assignment is the work of another; submitting a paper or assignment that 
contains ideas or research of others without appropriately identifying 
the sources of those ideas;.."

Doh! Doh! Doh!

kt

-- 
http://www.theoryyalgebra.com/

"In the morning, hear the Way;
  in the evening, die content!"
                     -- Confucius
From: D Herring
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <gM6dnYSnQPVNGt7anZ2dnUVZ_hWdnZ2d@comcast.com>
·············@gmail.com wrote:
> You are given a list of transactions along with the
> profits from the transactions. Write code that will return the
> transaction with the maximum profit. If many transactions have the
> same and maximusm profit, the code can return any of these. For
> example,
> given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> return T3.
> 
> 
> I am looking for code or pseudocode.

Untested:
(defun fun-or-profit (list)
   (let ((max 0)
         (pair nil))
     (dolist (p list)
       (when (> (cadr p) max)
          (setf pair p)))
     pair))

You should be able to easily fix the problem.

- Daniel
From: Timofei Shatrov
Subject: Re: Lisp problem to solve
Date: 
Message-ID: <47440aec.3243503@news.readfreenews.net>
On Tue, 20 Nov 2007 06:48:45 -0800 (PST), ·············@gmail.com tried to
confuse everyone with this message:

>You are given a list of transactions along with the
>profits from the transactions. Write code that will return the
>transaction with the maximum profit. If many transactions have the
>same and maximusm profit, the code can return any of these. For
>example,
>given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
>return T3.
>

;;Just kidding. OP should ignore this solution.

(require 'clsql)
(defparameter *av-pairs* '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
(clsql:connect ....) ;;Insert your database specification
(clsql:enable-sql-reader-syntax)

(clsql:create-table [transactions] 
     '(([transaction] (varchar 20))
       ([profit] integer)))

(clsql:insert-records [transactions] :av-pairs *av-pairs*)

(defun find-max-transaction ()
   (caar (clsql:select [transaction] 
                       :from [transactions]
                       :order-by [profit]
                       :limit 1)))

 


-- 
|Don't believe this - you're not worthless              ,gr---------.ru
|It's us against millions and we can't take them all... |  ue     il   |
|But we can take them on!                               |     @ma      |
|                       (A Wilhelm Scream - The Rip)    |______________|