Skip to content

Commit

Permalink
All test pass, needed to include a function and better regex
Browse files Browse the repository at this point in the history
  • Loading branch information
brittLiban committed Nov 9, 2024
1 parent 6d23c68 commit b057378
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
24 changes: 0 additions & 24 deletions archive/j/julia/LongestWord.jl

This file was deleted.

16 changes: 16 additions & 0 deletions archive/j/julia/longest-word.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function longest_word_length(text::String)
# Split on exactly the specified whitespace characters: space, tab, newline, carriage return
words = split(text, r"[ \t\n\r]+")

# Find the maximum length of the words array
return maximum(length.(words))
end

# Command-line argument handling
if length(ARGS) == 0 || strip(ARGS[1]) == ""
println("Usage: please provide a string")
exit(1)
end

input_string = ARGS[1]
println(longest_word_length(input_string))

0 comments on commit b057378

Please sign in to comment.