Difference between revisions of "Programming performance/Apter K"

From HaskellWiki
Jump to navigation Jump to search
(Two new solutions)
 
(3 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
See http://www.nsl.com/k/gspc/gspc.k as I do not have permission to copy the source code herein.
 
See http://www.nsl.com/k/gspc/gspc.k as I do not have permission to copy the source code herein.
   
[Note added by sa, the author of the original:
+
Note added by sa, the author of the original:
   
 
The original solution has been replaced by two contributions from the K mailing list.
 
The original solution has been replaced by two contributions from the K mailing list.
   
 
No time estimates were given, but I'd expect something in the 10-30 minute range.
Solution 1:
 
   
  +
Both solutions yield final cash = 13754.98
c:10000.;h:p:();
 
d:|*(" F";" ")0:1_0:`gspc.txt
 
c+/h*{$[~0.97<y%x;[c-:m:.1*c;h,:m%y;p,:y];#i:&~1.06>y%p;[c+:y*+/h i;h[i]:p[i]:0n]];y}/d
 
 
Solution 2:
 
 
x:|1_*(" F";" ")0:`gspc.txt
 
f:{$[y;[b[z]+:(.1*x)%z;.9*x];[z*:+/b p@:&~z<1.06*p:!b;b::p_b;x+z]]}
 
g:{b!:b::0#0.0;(last[x]*+/b)+f/[1e4;~.97<%':x;x]}
 
g x
 
 
No time estimates were given, but i'd expect something in the 10-30 minute range.]
 

Latest revision as of 10:50, 12 March 2007

Prepare yourself...

Precise details are not known about how long it took to write this. Anecdotal evidence says 15 minutes, based on an e-mail conversation with an author's acquaintance.

Code

See http://www.nsl.com/k/gspc/gspc.k as I do not have permission to copy the source code herein.

Note added by sa, the author of the original:

The original solution has been replaced by two contributions from the K mailing list.

No time estimates were given, but I'd expect something in the 10-30 minute range.

Both solutions yield final cash = 13754.98