20
4
Your challenge is to read a "password" from the keyboard / standard input.
Challenge:
- Read a string
s
invisibly. - For each of the characters in
s
, print a characterc
. - In realtime.
Rules:
- You must print
c
in realtime. As soon as the user enters a character you must displayc
. c
must be constant, i.e. it must be the same character.c
can be any visible character (i.e. it cannot be a newline, space, tab, or unprintable).c
can't be based ons
, i.e.c
must be defined/constant befores
is read.c
must be the same every time the program is run.c
can be one of the characters ins
if by accident, as long as all other rules are followed.- None of the characters of
s
may appear on the screen,c
excepted (see previous rule). - You may use any reasonable methods of input and output as long as all other rules are followed.
- You may assume that the length of
s
is never longer than the terminal/graphical window width. - If using a terminal, your program should terminate after a newline or EOF is entered.
Example:
If s
was password01
and c
was *
, the output would look something like:
Winner:
The shortest submission in each language wins.
Is python with
tkinter
allowed for our custom input field (like the one in HTML), such that the program does not terminate when enter is pressed, but when you close theEntry
's Window (X on Windows andcmd
+W
on mac)? – Mr. Xcoder – 2017-06-09T16:35:56.017@Mr.Xcoder Yes, that's valid. – MD XF – 2017-06-09T16:36:26.110
Can we use Ctrl+J to represent a literal newline in the terminal? Alternatively, can we use Ctrl+Z instead of enter? – Conor O'Brien – 2017-06-09T16:43:54.757
@ConorO'Brien Clarifying how input should end in the terminal. – MD XF – 2017-06-09T16:44:20.247
You cannot enter EOF, as EOF isn't a character. Should our program finish when EOF is encountered (i.e., when the input stream ends), or when the user presses a certain key combo? – Dennis – 2017-06-10T19:33:43.750
Also, your own answer finishes when Ctrl-C is pressed. Is that allowed? – Dennis – 2017-06-10T19:54:32.847
2What should happen if the user presses backspace? – zdimension – 2017-06-10T20:51:04.073
Aren't rules 4, 5, 6, and 7 covered by rule 2? – Esolanging Fruit – 2017-06-13T08:14:09.797
what characters can typed? special characters !?/$, Alt Shift Ctrl etc.? – phil294 – 2017-06-13T11:49:57.100