I see Brian Schott and RE Boss have already posted something.
Sorry if this duplicates.
Please note, first, that your output might not be quite right,
as, for example. the triple 8 9 10 evaluates as 990. There
should, I think, be only 120 unique base-10 triple values,
but your example has 720 unique such values.
Anyway, assuming you do want to improve from your example, the
following works in JQt 903 beta-d under Windows 10:
timer'# PanDigT =: 3 <@(10 & #.) \"1 ] 1000 {. PanDigS'
+----------+----+
|0.00799561|1000|
+----------+----+
5{.PanDigT
+---+---+---+---+---+---+---+----+
|123|234|345|456|567|678|789|900 |
+---+---+---+---+---+---+---+----+
|123|234|345|456|567|678|790|909 |
+---+---+---+---+---+---+---+----+
|123|234|345|456|567|679|798|990 |
+---+---+---+---+---+---+---+----+
|123|234|345|456|567|679|800|1008|
+---+---+---+---+---+---+---+----+
|123|234|345|456|567|680|808|1089|
+---+---+---+---+---+---+---+----+
timer'# PanDigT =: 3 (10 & #.) \"1 ] PanDigS' NB. do all, unboxed
+------+-------+
|28.954|3628800|
+------+-------+
<"0 ] 5 {.PanDigT NB. boxing afterwards
+---+---+---+---+---+---+---+----+
|123|234|345|456|567|678|789|900 |
+---+---+---+---+---+---+---+----+
|123|234|345|456|567|678|790|909 |
+---+---+---+---+---+---+---+----+
|123|234|345|456|567|679|798|990 |
+---+---+---+---+---+---+---+----+
|123|234|345|456|567|679|800|1008|
+---+---+---+---+---+---+---+----+
|123|234|345|456|567|680|808|1089|
+---+---+---+---+---+---+---+----+
timer'# PanDigT =: 3 <@(10 & #.) \"1 ] PanDigS' NB. do all, boxed
+------+-------+
|29.139|3628800|
+------+-------+
BUT - I risked the following - eventually managing to break with
Jbreak.bat :
timer'#PanDigT =: 10 #. each 3 <\"1 PanDigS' NB. do base ten after
boxing
|break: timer
| #PanDigT=:10 #.each 3<\"1 PanDigS
I forget what the would be the unix family's equivalent for jbreak.bat
It was apparently taking for ever, and using a load of memory; Windows
Task Manager
reported over 10 GB of memory, while Resouce Monitor showed ~10 GB
"Private"
and ~22GB "Commit"
It seems, unsurprisingly perhaps, that boxing the 10-tuples to triples
creates a
very large object.
So - you _might_ find that
PanDigT =: 3 <@(10 & #.) \"1 PanDigS
I'm not sure of the syntax for base and box, and don't have them to
hand in my set-up,
so leave replacing 10 & #. and < to you! (Brian's shown where to find them!)
I noticed that there's a lot of redundancy, in that triples are
repeated many times.
This code works in J902 and J903, though I haven't put in checks for
edge cases.
pandigs =: {{ (perm y) { 1 + i.y }} NB. set up the y-ples
NB. eg
NB. PanDigS =: pandigs 10
NB. evaluate the x-tuples, x = 3 by default
pandigt =: {{)v
3 pandigt y
:
tuplesz =. x
s =. pandigs y
sets =. ''
tuples =. 0$~ 0, tuplesz
out =. 0$~0,~ #s
for_ix. tuplesz ,\ i. y do.
utix =. ~. tix =. ix {"1 s
if. +/ todo =. utix -.@e. tuples do.
utix =. todo# utix
tuplevals =. y #. ~. utix
tuples =. tuples, utix
sets =. sets, tuplevals
end.
lux =. tuples i. tix
out =. out,. lux { sets
end.
}}
timer'#q =. pandigt 10' NB. somewhat faster, but not fast!
+-----+-------+
|6.439|3628800|
+-----+-------+
If you worked on digits 0 to 9 rather than 1 to 10, it would be
easier to set up the look-up table!
Any help?
Mike
On 07/02/2021 11:32, Francesco Pedulla' wrote:
The following piece of code does not work on Ubuntu 20.04.
load 'primitives'
perm =: i.@! A. i.
PanDigS =: (perm 10) from (1 + i.10)
PanDigT =: 10 base"1 each 3 box\"1 PanDigS
The effect is variable: crash of the J interpreter, freeze of the Qt
interface or even of the whole system. It shows up both on J807 and J902.
The dataset is quite large:
7!:5 <'PanDigS'
5.36871e8
and the process crashes (or the system freezes) after several seconds.
Hence, I suspect an issue with memory management.
Any idea or suggestion on how to bypass the problem?
Thanks,
Francesco
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm