2

私は Project Euler に取り組んでおり、問題 8に取り組んでおり、単純なブルート フォースを試みています。数字の連続する 5 桁をそれぞれ乗算し、結果のリストを作成し、より高い値を見つけます。

これは私が現在Jで書こうとしているコードです:

   n =: 731671765313x
   NB. 'n' will be the complete 1000-digits number

   itl =: (".@;"0@":)
   NB. 'itl' transform an integer in a list of his digit

   N =: itl n
   NB. just for short writing

   takeFive =: 5 {. ] }.~ 1 -~ [
   NB. this is a dyad, I get this code thanks to '13 : '5{.(x-1)}.y'
   NB. that take a starting index and it's applied to a list

N のすべてのインデックスに takeFive を使用するにはどうすればよいですか? 私は試した:

  (i.#N) takeFive N
|length error: takeFive
|   (i.#N)    takeFive N 

しかし、うまくいかず、その理由がわかりません。皆さん、ありがとうございました。

4

1 に答える 1