Skip to main content
Commonmark migration
Source Link

#Emulate the Professor's typing

Emulate the Professor's typing

#Emulate the Professor's typing

Emulate the Professor's typing

Tweeted twitter.com/#!/StackCodeGolf/status/522192541589180417
Source Link
laurencevs
  • 1.6k
  • 12
  • 23

Emulate the Professor's typing

#Emulate the Professor's typing

Background

Unfortunately, the Professor is not able to use his keyboard properly: whenever he is meant to use the Shift key, he presses Caps Lock once before typing, and doesn't bother to correct himself. If there are two or more keys in a row that require Shift, he presses Caps Lock before the first one and does nothing before the others.

As his secretary, I want to replicate this effect so that people think that he is the one replying to his emails, not me. He knows his typing looks stupid, but he doesn't care.

Task

Write a program that takes STDIN or file input of some text, and then outputs that text as if it had been typed by the Professor.

This is code golf, and standard loopholes are not allowed.

Keyboard layout

Default: ` 1 2 3 4 5 6 7 8 9 0 - = q w e r t y u i o p [ ] a s d f g h j k l ; ' # \ z x c v b n m , . / With shift: ¬ ! " £ $ % ^ & * ( ) _ + Q W E R T Y U I O P { } A S D F G H J K L : @ ~ | Z X C V B N M < > ? With caps lock: ` 1 2 3 4 5 6 7 8 9 0 - = Q W E R T Y U I O P [ ] A S D F G H J K L ; ' # \ Z X C V B N M , . / 

Example input / output

(The CapsLock line is just there for your understanding, and should not be outputted in your program)

Input: abc ** def ! (ghijkl) mnop Output: abc 88 DEF 1 9GHIJKL0 mnop CapsLock: * * * * (* means Caps Lock was pressed before this character) Input: print("Hello, World!"); sys.exit() Output: print92HELLO, world120; SYS.EXIT90 CapsLock: * * * * Input: !ABC!abc!ABC!abc!x!y!z Output: 1ABC1ABC1abc1abc1X1y1Z CapsLock: * * * * *