There is frequently performance degradation on a straight port of an
algorithm from a compiled language to J.  However, two advantages that J
brings are 1) a different outlook on the problem, sometimes allowng a new
and different algorithm, and 2) a quick way to try different methods and
algorithms.

You say your solution took 4.5 seconds in Python.  How many times did you
run this program and how long did it take you to get working code?  These
are the constraints you have to balance for real problems.  How quickly a
program runs is often an example of measuring the wrong thing.  For example,
for a single run, if your 4.5-second Python solution took 10 minutes to
write and your 60-second J version took 4 minutes to write, your
total-time-to-solution was twice as fast in J.  Of course, YMMV - it depends
on how proficient you are with each tool and what sort of problems you
typically solve.

On Mon, Dec 14, 2009 at 8:26 PM, miridian <[email protected]> wrote:

> Thank you to everybody for the comments.
>
> I already solved the problem 161 some months ago but I didn't keep my
> solution. I did it as a dynamic programming solution in C/C++ or Python
> if I remember correctly.
>
> Some days ago I was looking at the solutions present in the forum and
> decided to re-implement the C++ solution of stijn263 in Python
> (it tooks 4.5 secondsin Python) and then in J.
>
> I know that J should be used the J-way but was just for fun.
> :-)
>
> I almost never used amended array before.
> I supposed to have a performance comparable with that of the Python
> implementation but it seems that the current implementation of amend
> make the porting of some traditional algorithms to J quite difficult.
> :-/
>
>
> MfG
>
> Luca Masini
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to