You're going to replicate the 90's cup holder joke software.

Here's what's it did, and you have to do:

  • Display the message Do you need a cup holder?
  • If the user confirms, enter an infinite loop that keeps opening the CDROM drive.
  • If the user doesn't confirm, silently exit.

You may display the message using either a console message (confirmation is y, decline is n), or display a message window with the two options "Yes" and "No". You can assume the default (or most common) CDROM drive (D: on Windows, /cdrom on linux etc.). Standard loopholes (except built-ins) are forbidden. No additional input nor output may be involved. If your PC has no physical drive, or another "style" of tray, make sure the program is valid.

, so shortest program in bytes wins.

Trivia: The loop is there to prevent anyone from closing the drive. On desktop drives, the re-open command will be sent while the drive is closing, therefore staying open and not "spilling the coffee".


5 Answers 5


Bash, 115 69 68 66 bytes

This was written on Mac OS X but it should work on other BSD-based systems as well.

echo Do you need a cup holder?;sed 1q|grep y&&yes drutil\ eject|sh

We echo the prompt, get input with set 1q, and determine whether the user confirmed with grep y. If the user said y, we pipe the infinite output of yes with the string drutil eject to the shell, which will continuously eject the disk tray.

Saved 50 bytes thanks to Digital Trauma!

  • 1
    \$\begingroup\$ @DigitalTrauma You are the bash master! \$\endgroup\$
    – Alex A.
    Feb 3, 2016 at 1:04
  • \$\begingroup\$ Can you save bytes by replacing the sed and grep with read? \$\endgroup\$ Feb 3, 2016 at 7:09
  • \$\begingroup\$ Shouldn't it be drutil tray eject? \$\endgroup\$ Feb 3, 2016 at 7:48
  • \$\begingroup\$ @VoteToClose drutil eject is a synonym for drutil tray open. It works as expected. ;) \$\endgroup\$
    – Alex A.
    Feb 3, 2016 at 15:38
  • 1
    \$\begingroup\$ @CousinCocaine I was using read in a previous revision, but then I'd need an equality check, which makes it longer overall. You can take a look at the revision history to see what I mean. \$\endgroup\$
    – Alex A.
    Feb 3, 2016 at 15:40

Vitsy + Mac OSX bash, 55 bytes

'?redloh puc a deen uoy oD'ZWb2^/([1m]
<,'drutil eject'

Expects input as y or n. If it is n, it will execute line 2 (infinite loop with the shell command), otherwise, it will halt.


Python (3.5) 84 bytes

import os
i=input("Do you need a cup holder?")
while i=='y':os.system("eject cdrom")

On linux

edit: fix bytes count ;)

  • \$\begingroup\$ FYI: I noticed this because I'm using this script, which (among other things) adds a byte/char counter above blocks of code on PPCG. \$\endgroup\$
    – 3D1T0R
    Jun 8, 2018 at 21:02

AutoIt, 85 bytes

If MsgBox(4,0,"Do you need a cup holder?")=7 Then Exit
Until 0

No one will ever answer anything in AutoIt anyway :)


Python 3.5 on Windows 7, 135 Bytes

import ctypes
r=input('Do you need a cup holder?')
while r=='y':ctypes.windll.WINMM.mciSendStringW('set cdaudio door open',None,0,None)

Your Answer

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