ed is the standard text editor on Unix systems. Your goal is to write an ed clone.


Write a program that reads an input stream and for every received end of line character, print ? followed by a end of line character.

  • The communication has to interactive. Means the program needs to output as soon as possible and has to accept more input after that.
  • There are no input lines that are longer than 105 characters + end of line character
  • You can choose which character or sequence you use as end of line character, as long as it does not contain any alphanumerical characters nor the ? character.
  • The program should not output anything else.

Shortest code wins.

Example Python Script

#/usr/bin/env python3

import sys

for line in sys.stdin:
  • 11
    \$\begingroup\$ How is this an ed clone? It doesn't seem to edit files. \$\endgroup\$
    – Wheat Wizard
    Commented Jan 7, 2022 at 22:12
  • \$\begingroup\$ @WheatWizard It is a joke. Because ed returns ? for almost every input. \$\endgroup\$ Commented Jan 10, 2022 at 11:41

5 Answers 5


Nibbles, 2 bytes


That's 4 nibbles at half a byte each in the binary form.

@ is the first line of input but auto maps all lines if there's more input after the first line.

Despite the simplicity of this problem I must thank it for making me make sure Nibbles is properly lazy enough to do interactive IO right. There was an issue in that it adds a newline at termination unless your last character was a newline (to not double print newlines), but that wasn't being done lazy enough and so it wasn't interactive enough to satisfy this question. But I've fixed it in latest commit (you'll need latest unstable version of nibbles).


Charcoal, 5 bytes


Try it online! Link is to verbose version of code. Explanation:


Write a ? to the canvas, but don't print anything yet.


Repeatedly input lines until there is nothing left to input...

... dump the canvas with a trailing newline.

Clear the canvas so that nothing gets output at the end.

  • \$\begingroup\$ I upvoted that for respect. I like your answer. \$\endgroup\$
    – Fmbalbuena
    Commented Jan 8, 2022 at 1:01

Perl 5.28.1 (webperl) + -pl, 6 bytes


Try it online!


Ruby + -pl, 5 bytes


Try it online!


Python 3, 40 27 bytes

for i in open(0):print("?")

Try it online!

-13 thanks to @ovs

  • 1
    \$\begingroup\$ You can use open(0) instead of sys.stdin and get rid of the input \$\endgroup\$
    – ovs
    Commented Jan 7, 2022 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.