Q For Problems - Episode 13 - Project Euler #13

Hi everyone,

 

Please check out episode 13 of the Q For Problems video series.

 

 

This covers problem 13 from the Project Euler problem set.

[Project Euler - Problem 13](“https://projecteuler.net/problem=13” "“Project”)

We need to find the first 10 digits of the sum of 100 50-digit numbers.

 

Feel free to share your own solutions and ideas in the comments.

 

[Github Repo](“https://github.com/jkane17/qForProblems” "“Github”)

 

Thanks

This is great, thanks for sharing Jonathan! 

 

q) 10#string floor sum {“F”$“.” sv 0 10 _ x}each read0 `:p13.txt “5537376230” q)

or:

q) 10#string sum “J”$11#'read0 `:p13.txt “5537376230” q)

 

Nice one, this is a very short and simple solution to the problem. However, it may fail for the general case as we must consider all digits as there may be a cascading effect when adding. For example, consider

 

 

n:(9#enlist 50#“1”),enlist(49#“0”),“1”

 

The answer should be “1000000000”, but your solution will produce “9999999999” since it does not correctly add the lower digits.