Re: [Jprogramming] regex on binary string

2015-12-22 Thread Ryan Eckbo
Great, thanks! On 23 Dec 2015, at 14:29, Raul Miller wrote: > Two reasons. > > One is that by default regex assumes utf8 and a. is not utf8. To > disable that, you need to go: > rxutf8 0 > > The other is that the regex implementation we are using assumes C > strings, which are null terminated. S

Re: [Jprogramming] regex on binary string

2015-12-22 Thread Raul Miller
Two reasons. One is that by default regex assumes utf8 and a. is not utf8. To disable that, you need to go: rxutf8 0 The other is that the regex implementation we are using assumes C strings, which are null terminated. So you need to get rid of any nulls if you want regex to go past them.

[Jprogramming] regex on binary string

2015-12-22 Thread Ryan Eckbo
Why doesn't regex work on binary? e.g. load'regex' 'a' rxmatch a. _1 0 'a' rxmatch AlphaNum_j_ 26 1 -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] advent 22

2015-12-22 Thread Henry Rich
I didn't want to try to analyze this problem, because the question will arise of when to stop protecting yourself and go for the kill (also the question of what part 2 will bring). I just coded a solution that checks all the possibilities. I can have high confidence that it will give the righ

[Jprogramming] advent 22

2015-12-22 Thread 'Pascal Jasmin' via Programming
instead of solving this I made tools to interactively test the choice of spells. These are hard coded to my boss damage of 8 and boss hp of 55. mana =: +/@:{~ turnskill =: (6 %~ 55 - 4 2 0 +/@:{~ 3 4 -.~ ]) turnsdie =: 9 %~ 50 - 0 _2 0 _21 0 +/@:{~ ] turnsdie1 =: 8 %~ 50 - 0 _2 0 _21 0 +/

Re: [Jprogramming] Magic squares

2015-12-22 Thread Moon S
±1 or ±½ of course :) Sorry didn't read all, just saw that -n/2 ... 0 ... n/2. For odd n it's i:<.-:n i:<.-:5 _2 _1 0 1 2 On Tue, Dec 22, 2015 at 8:20 PM, Moon S wrote: > > NB. Creat a rotation vector from -n/2 ... 0 ... n/2 > > Try i: -: y > > On Tue, Dec 22, 2015 at 7:50 PM, Richard Donova

Re: [Jprogramming] Magic squares

2015-12-22 Thread Moon S
> NB. Creat a rotation vector from -n/2 ... 0 ... n/2 Try i: -: y On Tue, Dec 22, 2015 at 7:50 PM, Richard Donovan wrote: > Thanks Thomas, works very well! > > > From: tmcguir...@gmail.com > > Date: Tue, 22 Dec 2015 12:14:31 -0500 > > To: programm...@jsoftware.com > > Subject: Re: [Jprogramming

Re: [Jprogramming] Magic squares

2015-12-22 Thread Richard Donovan
Thanks Thomas, works very well! > From: tmcguir...@gmail.com > Date: Tue, 22 Dec 2015 12:14:31 -0500 > To: programm...@jsoftware.com > Subject: Re: [Jprogramming] Magic squares > > I haven't tried this in a while but here is one method from an APL book > transcribed into J > > NB. Magic Squares

Re: [Jprogramming] Magic squares

2015-12-22 Thread Thomas McGuire
I haven't tried this in a while but here is one method from an APL book transcribed into J NB. Magic Squares the APL/J way NB. From APL An Interactive Approach by Gilman and Rose NB. NB. Problem 19 page 177 NB. NB. A magic square of order n made up of the integers from NB. 1 through n. NB. NB.

[Jprogramming] Magic squares

2015-12-22 Thread Richard Donovan
Is there a J routine to construct magic squares of side n? Thanks in advance. -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Genetic algorithms?

2015-12-22 Thread 'Jon Hough' via Programming
Another remark, I just ran the (original) algorithm again, for 20 cities, 100 chromosomes, and modifying distances so 0,1,2,...,18,19 is the minimum path, for 500 iterations. the "minimal" path found was 18 19 1 0 16 5 6 13 14 15 10 9 8 17 12 11 4 2 3 7 which is not too bad, all things conside

Re: [Jprogramming] Genetic algorithms?

2015-12-22 Thread 'Jon Hough' via Programming
Thanks, Raul. It's a good point. This hasn't been validated at all. I suppose the lazy way to validate would be to force a single path to be minimal: modifydistance =: 3 : 0 'from to distance' =. y if. to = >: from do. distance =. 1 elseif. distance < 10 do. distance =. 10 end. from, to, distanc