Skip to content

Instantly share code, notes, and snippets.

@cwu159
Created September 17, 2018 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwu159/6ceee5f051cff583406bb4a634c6e948 to your computer and use it in GitHub Desktop.
Save cwu159/6ceee5f051cff583406bb4a634c6e948 to your computer and use it in GitHub Desktop.
using DataStructures
println("Periodic Table Practice \t made by Charlie Wu, 2018 \t using JuliaLang")
user_input = ""
elements = Dict{String, String}()
if length(ARGS) > 0
load_file = open(ARGS[1])
else
load_file = open("elements.txt")
end
lines = readlines(load_file)
for line in lines
parts = split(line, " ")
elements[parts[1]] = parts[2]
end
while lowercase(user_input) != "quit"
current_element = rand(elements)
println(current_element[1])
global user_input
user_input = readline(stdin)
if lowercase(user_input) == current_element[2]
println("Correct!")
else
println("Incorrect.")
end
println("-"^10)
end
println("Thanks for using Periodic Table Practice!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment