ShareMyScreen/ProjectEuler/0008
Jump to navigation
Jump to search
Find the thirteen adjacent digits in the 1000-digit number that have the greatest product.
NB. cap the fork NB. │ take the greatest one NB. │ │ overlappingly, take the product over every 13 items NB. │ │ │ cap the fork NB. │ │ │ │ convert every atom to a noun, given the shape, it'll result in a list NB. │ │ │ │ │ use the numbers as indices to take from the alphabet noun, getting a column of chars NB. │ │ │ │ │ │ ravel items to a new dimension NB. │ │ │ │ │ │ │ from the list of numbers, copy once where XORing with 10, a newline in decimal ASCII, is true (thus getting a list of decimal digits only) NB. │ │ │ │ │ │ │ │ convert the string to the corresponding decimal ASCII values by taking their index within the ASCII alphabet noun NB. │ │ │ │ │ │ │ │ │ the 1000-digit number as it appears on the site, selected ([: >./ 13(*/)\ [:, "."0 @ {&a. @ ,. @ (10&~:#]) @ I.~&a.)shell'xclip -o'
alternatively,
NB.expand scientific notation since this solution gives it as such NB.│ cap the fork NB.│ │ take the greatest one NB.│ │ │ overlappingly, take the product over every 13 items NB.│ │ │ │ cap the fork NB.│ │ │ │ │ copy each list member once where not infinity NB.│ │ │ │ │ │ convert ever list member, digit, to a number, substituting with infinity where impossible, newline NB.│ │ │ │ │ │ │ the 1000-digit number as it appears on the site, selected x: ([: >./ 13(*/)\ [: (_&~: # ]) (_&"."0) )shell'xclip -o'