|
21 | 21 | module Prob0070 |
22 | 22 |
|
23 | 23 | import Primes: prevprime, primes |
24 | | -import DataStructures: PriorityQueue, enqueue!, peek |
| 24 | +import DataStructures: PriorityQueue |
25 | 25 |
|
26 | 26 | LIMIT = 10 ^ 7 - 1 |
27 | 27 |
|
@@ -93,26 +93,26 @@ function solve_0070() |
93 | 93 | # initial data for pruning: |
94 | 94 | # n = 87109 = 11 * 7919, phi(87109) = 79180 |
95 | 95 | pq = PriorityQueue{Vector{Tuple{Int, Int}}, Float64}() |
96 | | - enqueue!(pq, [(11, 1), (7919, 1)] => (87109 / 79180) ) |
| 96 | + push!(pq, [(11, 1), (7919, 1)] => (87109 / 79180) ) |
97 | 97 |
|
98 | 98 | for p in reverse(primes(11, isqrt(LIMIT))) |
99 | 99 | # pruning: end of search |
100 | | - if get_ratio([(p, 1)]) > peek(pq)[2] |
| 100 | + if get_ratio([(p, 1)]) > first(pq)[2] |
101 | 101 | break |
102 | 102 | end |
103 | 103 |
|
104 | 104 | for pf_lst in Channel{Vector{Tuple{Int, Int}}}(c -> pf_generator(c, (p, prevprime(LIMIT ÷ p)))) |
105 | 105 | # pruning: skip to the next prime smaller than 'p' |
106 | | - if get_ratio(pf_lst[1:min(length(pf_lst), 2)]) > peek(pq)[2] |
| 106 | + if get_ratio(pf_lst[1:min(length(pf_lst), 2)]) > first(pq)[2] |
107 | 107 | break |
108 | 108 | end |
109 | 109 |
|
110 | 110 | if is_perm(prod(pf_lst), phi(pf_lst)) == true |
111 | | - enqueue!(pq, pf_lst => get_ratio(pf_lst)) |
| 111 | + push!(pq, pf_lst => get_ratio(pf_lst)) |
112 | 112 | end |
113 | 113 | end |
114 | 114 | end |
115 | | - prod(peek(pq)[1]) |
| 115 | + prod(first(pq)[1]) |
116 | 116 | end |
117 | 117 |
|
118 | 118 | end #module |
|
0 commit comments