Advertisement
Guest User

Untitled

a guest
Dec 4th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.61 KB | None | 0 0
  1. ##############
  2. ### DAY 04 ###
  3. ##############
  4. ### part 1
  5. using ProgressMeter
  6. pb = ProgressMeter.Progress(595730-136760, dt=1, barglyphs=BarGlyphs("[=> ]"), barlen=50, color=:yellow)
  7. passwords = []
  8. for i in 136760:595730
  9.     # i = 136760
  10.     # println(i)
  11.     i_split = parse.(Int64, convert(Array{String,1}, split(string(i), "")))
  12.     i_test1 = i_split[1:(end-1)] .<= i_split[2:end]
  13.     i_test2 = i_split[1:(end-1)] .== i_split[2:end]
  14.     if (sum(i_test1) == length(i_test1)) & (sum(i_test2) > 0)
  15.         push!(passwords, i)
  16.     end
  17.     ProgressMeter.update!(pb, i-136760)
  18. end
  19. solution_d4p1 = length(passwords)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement