19
0
At runtime, keep prompting for a line of input until the user input is not the name of an existing file or directory or other file system item, relative to the current working directory. Then return/print that last inputted filename. You may assume that all user inputs will be valid filenames.
Pseudo-code 1
myform = new form("GUI")
myform.mytxt = new editfield("")
myform.ok = new button("OK")
repeat
waitfor(myform.ok,"click")
until not filesystem.exists(myform.mytxt.content)
return(myform.mytxt.content)
Pseudo-code 2
LET TEXT = "."
WHILE HASFILE(TEXT) DO
TEXT = PROMPT("")
ENDWHILE
RETURN TEXT
Examples of user input which will cause re-prompting when on TIO:
.
..
.env.tio
/
/bin/[
/lost+found
Examples of user input which will return when on TIO:
...
env.tio
../../bin/]
/lost/found
I'm fairly new to code golf here and can't seem to find any information on what counts as a solution. Do I need to include the main() function for languages that require it in a program, or can that be part of the header? Can import statements be a part of the header in TIO, or do they need to be part of the code and count against the byte count? For example, I have this solution: https://goo.gl/8RWNgu but not sure if it the bytes would be legitimate.
– Makotosan – 2018-03-16T15:33:53.5072
@Makotosan Both functions and full programs are fine, although in the case of functions they need to be reusable. Imports generally need to be included in the byte count.
– Martin Ender – 2018-03-16T15:41:20.270