Today I found one task, and of course decided to write it in J.

Task: find volume:
http://habr.habrastorage.org/post_images/0ca/4c0/046/0ca4c0046711fd9f8a743163a12f3c31.jpg

http://habr.habrastorage.org/post_images/539/fa1/294/539fa129413dc277e575798dc568337e.jpg

My solution is:
<pre>

w =: 0 5 3 5 1 2      NB. input

s =: >./\ - [         NB. fun to calculate "holes" from L to R

+/ (f w) <. f&.|. w   NB. find "holes" L->R, find holes R->L. find
minimum for each, sum.

</pre>


Q: standard: make it shorter.

-- 
Regards,
  Alexander.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to