Refactor output

This commit is contained in:
David Doblas Jiménez 2023-08-28 18:34:37 +02:00
parent 4a960cf1ad
commit 39d820cca2

View File

@ -1,26 +1,30 @@
using Base: String
#= #=
Created on 22 Jul 2021 Created on 22 Jul 2021
@author: David Doblas Jiménez @author: David Doblas Jiménez
@email: daviddoji@pm.me @email: daviddoji@pm.me
Solution for Problem 13 of Project Euler Solution for Problem 013 of Project Euler
https://projecteuler.net/problem=13 =# https://projecteuler.net/problem=13
=#
using BenchmarkTools using BenchmarkTools
using DoubleFloats using DoubleFloats
function Problem13() function Problem013()
#= #=
Work out the first ten digits of the sum of the following one-hundred Work out the first ten digits of the sum of the following one-hundred
50-digit numbers =# 50-digit numbers
=#
return string(sum(parse.(BigInt, split(read("files/Problem13.txt", String), "\n")))[1])[1:10]
# return string(sum(parse.(BigInt, readlines("files/Problem13.txt"))))[1:10]
# return string(mapreduce(x->parse.(BigInt,x), +, readlines("files/Problem13.txt")))[1:10]
return string(sum(parse.(BigInt, readlines("../files/Problem13.txt"))))[1:10]
end end
println("Time to evaluate Problem $(lpad(13, 3, "0")):") println("Took:")
@btime Problem13() @btime Problem013()
println("") println("")
println("Result for Problem $(lpad(13, 3, "0")): ", Problem13()) println("Result for Problem $(lpad(13, 3, "0")): ", Problem013())