Hey there's a use for your method. Investigate bogo sort.
Can you come up with a worse performer?
bogo bogo sort.
odometer6=: (4 $. $.)@($&1) NB. best performance
And, as a non-sequitor, here's my adventofcode.com/day/18 solution with
animation.
read=: 1!:1@:boxopen
frame=:0,.0,.~0,0,~]
GRID=: ('#'&=);._1 LF,read'input'
NB. (improvement for u of u;. (4&{ someverb +/)@,
f=: (1 1,:3) ((3 = +/ - 4&{) +. (4&{ *. 3 = +/))@:,;._3 frame
PART1=: +/,f^:100 GRID
stuck=: ((0;0);(0;_1);(_1;0);<(_1;_1))&(1:`[`]})
g=: (1 1,:3) ((3 = +/ - 4&{) +. (4&{ *. 3 = +/))@:,;._3 frame@:stuck
PART2=: +/,stuck g^:100 GRID
smoutput PART1 , PART2
NB. animation
load'viewmat'
FRAMES=: g^:(<101) GRID
VISIBLE_jviewmat_=:0
(' '&=`(,:&'0')}(":,.i.101))([:viewmat;~)"_1 FRAMES
NB. using imagemagick animate program, for example
NB. pushd ~/j64-804-user/temp
NB. animate ???.png
NB. popd
Date: Fri, 18 Dec 2015 12:58:49 +0000 (UTC)
From: "'Jon Hough' via Programming"<[email protected]>
To: Programming Forum<[email protected]>
Subject: [Jprogramming] Getting all pairs of integers up to some value
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
I've spent an hour on this, and am frustrated that I couldn't figure out a way
to do it (without using for_j or while).
I want to get all pairs ( pair order not important e.g. 2 3 is the same as 3 2)
of integers up to some value.
e.g. up to 4:
0 1
0 2
0 3
1 2
1 3
2 3
in frustration this is what I came up with (for the case of 10):
/:~ ~. /:~"1 (1000 # 2) ? 10
which works but is not a very good solution.
Any nice solutions?
Thanks,
Jon
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm