[Solved] Accept Input from a Website (Hackerrank)

Hello,

I’m going through the Hackerrank 30 Days of Code, and have a problem that I couldn’t find the answer to. In the challenges, it often has you accept an input (I’m assuming a text file). My question is, how would you code something simple as print “Hello, World.” and a given input? Below is the code I tried

## Print "Hello, World."

println("Hello, World.")

## Print Hackerrank input

println(STDIN)

This gives an output of “Hello, World.” and apparently nothing else. Since it can process the script and let me know that I have the wrong answer, I’m assuming that it’s something wrong with using STDIN (which, to my knowledge, is for interactive user inputs). I couldn’t find the appropriate function within the documentation. Any advice, or guidance on where to look, would be greatly appreciated.

Use readline.

julia> answer = readline();
Hello!

julia> answer
"Hello!"
2 Likes

Thank you! That did indeed work. Marking the title as solved.