Oops, lost my 1 char indent in each function (addrow, view, diagonal) but 
should still copy/run…/Rob

> On 4 Oct 2019, at 11:23 pm, 'Rob Hodgkinson' via Programming 
> <[email protected]> wrote:
> 
> Hey R.E.
> 
> Nobody really picked this up, but I experimented for a little and produced 
> this code to produce the Wolfram 30 puzzle, thought it might be useful for 
> anyone wanting to explore.
> Turns out to be a nice use case for 3 u;._3 to extract length 3 subsets from 
> a list as in a tessellation …
> 
> The following can be pasted into a script (careful of quotes copying in here):
> 
> =====================================================================
> load 'viewmat'
> 
> NB. Wolfram’s 8 match cases for the existing row
> NB. NB. Convert each match case in base 2 (eg 1 1 1) to an integer (eg 7) as 
> this is then faster to look up in addrow
> cases=: #.8 3$1 1 1, 1 1 0, 1 0 1, 1 0 0, 0 1 1, 0 1 0, 0 0 1, 0 0 0
> value=: 0 0 0 1 1 1 1 0
> 
> addrow=: 3 : 0
> lastrow=. ,>_1 {. y
> NB. Calculate the #. of length 3 subarrays from the lastrow, then look up in 
> cases and return corresponding value to create newrow
> newrow=. value {~ cases i. 3 #.;._3] 0 0,lastrow,0 0
> y,<newrow
> )
> 
> view=:3 : 0
> (|.-i.1{.$ mat)|."0 1 mat=:>y
> )
> 
> diagonal =:3 : 0
> (<0 1)|: y NB. Return diagonal of matrix y
> )
> 
> smoutput 'To run for example ...'
> smoutput ' viewmat view addrow^:50 <1'
> =====================================================================
> 
> So the sample line above:
> 
>   viewmat view addrow^:50 <1
> 
> reproduces the graphic triangle shown in the first link you gave below …
> 
> I did not spend much time on analysing the centre column (which in my case as 
> I maintain each row as a list, may be found using diagonal as here;
> 
>   diagonal >addrow^:6 <1
> 1 1 0 1 1 1 0
> 
> Hope others find this useful.
> 
> @Cliff Reiter: maybe even scope to consider as another chaotic instance as 
> Woflram suggest…/Rob
> 
>> On 2 Oct 2019, at 6:49 pm, R.E. Boss <[email protected]> wrote:
>> 
>> This was submitted in math-fun
>> 
>> https://rule30prize.org
>> https://writings.stephenwolfram.com/2019/10/announcing-the-rule-30-prizes
>> 
>> 
>> R.E. Boss
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to