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.
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.
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...
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
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
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
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
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
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.
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
"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
·············@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
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
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
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.
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
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
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/
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 :)
·············@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
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
:)
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
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
·············@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
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) |______________|