Skip to content

Commit

Permalink
Add Julia implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ruippeixotog committed Aug 17, 2024
1 parent 73d31ba commit 65e1b22
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions julia/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DOCKER_IMAGE=julia:1.10.4
RUN_CMD='julia quicksort.jl'
12 changes: 12 additions & 0 deletions julia/quicksort.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function quicksort(arr)
if length(arr) == 0
return []
end
pivot = pop!(arr)
return vcat(quicksort(arr[arr .< pivot]), pivot, quicksort(arr[arr .>= pivot]))
end

readline()
arr = collect(parse.(Int, eachsplit(readline(), " ")))
sorted = quicksort(arr)
println(join(sorted, " "))

0 comments on commit 65e1b22

Please sign in to comment.