-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Julia category #20
Comments
sounds good! 👍 i invited you to the org if you want to spearhead that or link to an existing persons repo. 🚀 |
I can try to set up some repos and ask some uni friends if they wanna try! |
I have the original code right here. """
Extremely naive implementation of the 1BRC task.
Credit: https://www.youtube.com/watch?v=utTaPW32gKY
"""
function process_data(filepath::String)
stats = Dict{String,Dict{String,Float32}}()
open(filepath) do f
for row in eachline(f)
city, temp_str = split(row, ';')
temp = parse(Float32, temp_str)
if haskey(stats, city)
city_stats = stats[city]
# ifelse is faster than min/max
city_stats["min"] = ifelse(temp < city_stats["min"], temp, city_stats["min"])
city_stats["max"] = ifelse(temp > city_stats["max"], temp, city_stats["max"])
city_stats["sum"] += temp
city_stats["count"] += 1
else
stats[city] = Dict("min" => temp, "max" => temp, "sum" => temp, "count" => 1)
end
end
end
return stats
end
function print_stats(stats)
for (city, city_stats) in stats
min_temp = city_stats["min"]
max_temp = city_stats["max"]
avg_temp = city_stats["sum"] / city_stats["count"]
println("$city: min=$min_temp, max=$max_temp, avg=$avg_temp")
end
end
if abspath(PROGRAM_FILE) == @__FILE__
filepath = length(ARGS) < 2 ? ARGS[2] : "data.txt"
process_data(filepath) |> print_stats
end I have yet to complete the more optimized one, but where do I go from here. Might have missed it in the docs! |
https://github.com/Jafagervik/1BRC Initial repo |
you can either add the repo as a link and host the competition/submissiosn under your username or add it to @1brc like the nodejs and bun stuff was added to this org. up to you 🤷♂️ do whatever you want lol |
Indeed! I too have been playing with a Julia implementation last couple of weeks. I came here looking to open an issue, and found that you already beat me to it! 😄 I think we can share some notes in this discussion. I will also go through the Julia Discourse to gather more feedback. |
Would be interesting to see what you could achieve with Julia for this challenge
The text was updated successfully, but these errors were encountered: