This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
problemutils.jl
58 lines (54 loc) · 2.23 KB
/
problemutils.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Following the copyright laws of https://projecteuler.net, as stated on
# https://projecteuler.net/copyright, it is recommended that if we choose to use the content
# as it appears on the website (which this package does), then we should say something like,
# "The following problem is taken from Project Euler."
const src = "The following problem is taken from Project Euler"
# Following the copyright laws of https://projecteuler.net, as stated on
# https://projecteuler.net/copyright, "All other content, including the statistics made
# available to members, is subject to standard copyright laws and may not be published or
# shared elsewhere." Hence, the fields of the struct below are allowed since the contents
# they use are visible to anyone who can visit https://projecteuler.net, i.e., not just for
# members only.
struct Problem
source :: AbstractString
title :: AbstractString
published_on :: AbstractString
solved_by :: Integer
difficulty_rating :: AbstractString
content :: AbstractString
end
function Base.show(io::IO, ::MIME"text/plain", p::Problem)
problem_info = [
" Source: " => p.source,
" Problem Title: " => p.title,
" Published On: " => p.published_on,
" Solved By: " => p.solved_by,
"Difficulty Rating: " => p.difficulty_rating
]
println()
for info in problem_info
printstyled("│ ", bold=true, color=:cyan)
printstyled(info.first, color=:cyan, bold=true)
printstyled(info.second, '\n')
end
println()
printstyled("Problem", "\n≡≡≡≡≡≡≡≡≡≡\n", bold=true)
print(p.content)
return nothing
end
function question(ID::Integer)
problem_module = eval(Symbol("Problem$ID"))
p = Problem(
src,
problem_module.title,
problem_module.published_on,
problem_module.solved_by,
problem_module.difficulty_rating,
problem_module.content
)
return p
end
# The functions below will be implemented in a later release of this package, if it does not
# infringe on the copyright laws of https://projecteuler.net.
# function submit(ID::Integer, answer) end
# function check(ID::Integer, answer) end