Product of subset of numbers in python -


I am going through a project over, and I'm stuck on this question.

I am posting my code with comments, so everyone can follow my thinking and see where I went wrong. All suggestions are appreciated :)

  # series needs to find the largest product in import time # The code initially brings time. From time to time () # code creates Start time list = [] # I go multipules is # 'takes \ Grid and converted into a large number of "Num =' \ 73l67l7653l3306249l9225ll9674426574742355349l94934 \ 969835203l27745063262395783l80l698480l86947885l843 \ 8586l560789ll294949545950l73795833l9528532088055ll \ L2540698747l585238630507l5693290963295227443043557 \ 66896648950445244523l6l73l8564030987lll2l722383ll3 \ 62229893423380308l353362766l4282806444486645238749 \ 30358907296290491560440772390713810515859307960866 \ 70172427121883998797908792274921901699720888093776 \ 65727333001053367881220235421809751254540594752243 \ store I am going to 52584907711670556013604839586446706324415722155397 \ 53697817977846174064955149290862569321978468622482 \ 83972241375657056057490261407972968652414 Initially 535100474 \ 82166370484403199890008895243450658541227588666881 \ 16 427l7l4799244429282308634656748l39l9l23l62824586 \ 17866458359124566529476545682848912883142607690042 \ 24219022671055626321111109370544217506941658960408 \ 07198403850962455444362981230987879927244284909188 \ 84580156166097919133875499200524063689912560717606 \ 05886116467109405077541002256983155200055935729725 \ 71636269561882670428252483600823257530420752963450 'I range (0, 1000, 1) for i = 0 # ticker: # large blocks of length number 1000 hold_num = integer (Number [i]) * int (num [i + 1]) * int (num [i + 2]) # im made number of consecutive numbers ... this subset list. Appleend (hold_num) # storage productsI = + 1 print max (list) in the list # Find the maximum number of product in the archived list  

I get this error:

  traceback ( Most recent call final): File "/ Users /robertdefilippi/Documents/Python/Euler/8eu.py", in line 37, & lt; Module & gt; Hold_num = int (num [i + 1]) * int (num [i + 2]) index error: out of string index range [end in 0.0s with exit code] 1  

Any suggestions on what I'm doing wrong?

When you are <0> for category (0, 1000, 1) , To reach 999, num [i + 1] and num [i + 2] should be outside limit.

You have to use the category (0,998,1) instead which can be shorter on the boundary (998) and by doing so, i will increase and start from 0. You do not need to do i + = 1 or i = 0 .


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -