Re: [Jprogramming] Genetic algorithms?

2015-12-19 Thread 'Jon Hough' via Programming
I created a toy genetic algorithm program to solve the traveling salesman problem for a randomly generated graph (cities with distances). It's not written in very J-like code unfortunately. It also seems pretty slow, possibly due to lots of in-place assignments. Anyway, it might interest you. N

Re: [Jprogramming] Advent 19

2015-12-19 Thread Henry Rich
I think you were lucky. I don't see any sure-fire way of applying changes in an order that is guaranteed to run to completion. In general, recursion is required, methinks. In the same way, my version doesn't show that there is a solution; it just finds the length of the solution if there is

Re: [Jprogramming] Advent 19

2015-12-19 Thread 'Pascal Jasmin' via Programming
Was a lot of time for me too. Most of it guessing on insertion order. In the end, taking the last match in the molecule on each iteration is what worked. (Though it turns out that some other patterns work too) Even harder to notice than your substitution pattern math is why reverse order or

Re: [Jprogramming] Advent 19

2015-12-19 Thread Henry Rich
After an OBSCENE amount of thought, consumed by worries about recursions, I found the easy solution to part 2. The more I worked on part 2 the less I liked it, because in the end the solution is in an analysis of the data rather than the algorithm. But I was pleased with part 1. Spoiler...

Re: [Jprogramming] win10 edge

2015-12-19 Thread Jose Mario Quintana
Eric, I just realized that I might be able to make my Kindle/J relationship more pleasurable by writing a couple of menus with some items calling some of the Simple Project (SP) utilities following the example shown in the IDE help section. I was glad to notice that while crtl+. is used to advance

Re: [Jprogramming] Advent 19

2015-12-19 Thread 'Pascal Jasmin' via Programming
replying to other message as it uses definitions there, a7 =. ((0 { ]) ,&< 1 Y)"1 (\: (# * 1 + 4 * +/@((;: 'Ar')&e.) + 2 * +/@((;: 'Ar Rn Y' )&e.))@(1&{::"1 )) a2 =.(0 Y ; [: <@(isupper <;. 1 ] ) 1 Y )"1 a =. > cutLF wdclippaste '' NB. just keys mostly useless sorting, and simpler a2 wou

[Jprogramming] an E. based delete/replace function

2015-12-19 Thread 'Pascal Jasmin' via Programming
haven't finished latest advent prob, but felt I needed a more flexible replace function Y =: (&{::)(@:]) X =: (&{::)(@:[) M=:@:] T=:(&{)(>@) R =: (&}.) M comments placed on following line to escape line breaks. blank lines are line breaks if it messes up. delitem =: ;@:((1 X {. ]) ; (0 X + 1