oops my solution was wrong... should be: >./ 13 ([: */ "."0) \ n
filtering is still faster timespacex '>./ 13 ([: */ "."0) \ n' 0.00725632 43008 >./ ([: */ "."0)"1 (#~ ( 13 = '0' i.~ ])"1) 13,\ n 23514624000 timespacex ' >./ ([: */ "."0)"1 (#~ ( 13 = ''0'' i.~ ])"1) 13,\ n' 0.00241984 44672 ----- Original Message ----- From: 'Pascal Jasmin' via Programming <[email protected]> To: "[email protected]" <[email protected]> Cc: Sent: Thursday, July 3, 2014 7:35:15 PM Subject: Re: [Jprogramming] Project Euler Problem 8 a similar solution that avoids making an intermediate list: >./ 13 */@:". \ n regarding avoiding those items that contain a 0, for the problem at hand, I would guess it isn't necessary since a 0 ensures that the product cannot be maximum, and I would guess it slows things down. But if you must, then your original approach seems right. (#~ ( 13 = '0' i.~ ])"1) 13,\ 40{. n 7316717653133 6249192251196 2491922511967 4919225119674 9192251196744 1922511967442 9225119674426 2251196744265 2511967442657 5119674426574 1196744265747 1967442657474 9674426574742 6744265747423 7442657474235 >./ */@:"."1 (#~ ( 13 = '0' i.~ ])"1) 13,\ n timespacex ' >./ 13 */@:". \ n' 0.00128096 31872 timespacex ' >./ */@:"."1 (#~ ( 13 = ''0'' i.~ ])"1) 13,\ n' 0.00065632 33792 turns out I was wrong and it is faster to filter out the 0s! ----- Original Message ----- From: mvillarino <[email protected]> To: [email protected] Cc: Sent: Thursday, July 3, 2014 6:18:10 PM Subject: [Jprogramming] Project Euler Problem 8 I came to this solution, which happens to be a transliteration of the problem's formulation: >./ */"1 ".items"1(13,\number) where «numero» is the string with the number's digits (one thousand). Please note I'm no programmer, and I'm learning a little J with no other intent than just for curiosity. Before proceeding into another Problem, I would like to modify the solution above in order to avoid multiplying groups that contain noughts. With iteration it would be something like instead of ".items"1 (13,\number), build the table ignoring _increasing some counter that refers to position_ those subarrays that contains a zero and the next few rows, where few is 13 minus the position of the last zero counted, until the end of number is reached. Is something alike that expressible with J? Can you give me some hints? Best regards, Marce ---------------------------------------------------------------------- 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
