让我们解析和处理键语言!给定一系列键盘按键和/或特殊键的输入,编写一个程序,功能等,当根据以下键盘处理了所有操作时,该产品就会输出产品:
+-------------------------------------------------------+
| ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | - | + | |
| ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | _ | = |Del|
+-------------------------------------------------------+
|TAB| q | w | e | r | t | y | u | i | o | p | [ | ] | \ |
| | Q | W | E | R | T | Y | U | I | O | P | { | } | | |
+-------------------------------------------------------+
|CAPS | a | s | d | f | g | h | j | k | l | ; | ' | RET |
| | A | S | D | F | G | H | J | K | L | : | " | |
+-------------------------------------------------------+
| SHIFT | z | x | c | v | b | n | m | , | . | / | SHIFT |
| | Z | X | C | V | B | N | M | < | > | ? | |
+-------------------------------------------------------+
| |
| SPACEBAR |
+-------------------------------------------------------+
的按键时输出实际的字符不包括空白的和是能够通过其他键将被称为“字符键”所修饰,并且那些修改其他密钥或输出空格将被称为“特殊键”的输出。字母字符键(将在输入中显示为大写字母)可以用Shift
或进行修改Caps Lock
以产生大写字母,而其余字符键仅可以用进行修改Shift
以产生其替代字符。因此A
,在输入中对应于a A
字符键,其正常输出为a
,而使用Shift
或Caps Lock
键可获得的修改后的输出为A
。另一方面,/
对应于/ ?
字符键的,只有此时间才具有的正常输出/
和的修改输出。?
Shift
规则
输入将始终是由一系列字符键和特殊键组成的字符串。输入字符串映射的完整特殊键(即,保证它们在输入中的格式)及其对应的动作/输出如下:
<DEL> -> Delete the previous character (including whitespace). If called when string is empty, nothing happens. If called 2 or more times in a row, 2 consecutive deletes happen. For instance, "RE<DEL><DEL>" should return an empty string ("") and also "R<RET><DEL><DEL>E" should return just "E".
<CAPS> -> Enable Caps Lock until <CAPS> appears again, upon which it is disabled, although it is not guaranteed to be disabled by the end of the input. Enabling this only modifies the upcoming alphabet keys resulting in them outputting only uppercase letters. For instance, "<CAPS>RE<CAPS>" results in the output "RE", but <CAPS>.<CAPS> would still result in a ".".
<RET> -> Add a new line.
<SPC> -> Add a single blank space.
<TAB> -> Add 4 spaces.
<SHFT> -> Shift is held down resulting in the alternate character of the upcoming keypress to be output, after which the key is released. For instance, "<SHFT>A" results in the output "A", "<SHFT>1" results in the output "!", and "<SHFT>1234" results in the output "!234" as only the first upcoming keypress is modified and nothing else. It is guaranteed that a character key will succeed a <SHFT>. Therefore, <SHFT><SPC> is not a possible input.
空字符串也可以作为输入,但输出应为空。
- 禁止使用任何直接解决此问题的内置方法。
- 禁止使用标准漏洞。
测试用例
以格式显示,Actual String Input -> Actual String Output
后面有一些解释。
1<SHFT>2<TAB><CAPS>R.KAP.<SPC><SHFT>123 -> 1@ R.KAP. !23
1
在1
没有切换的情况下按下键时输出,然后按住Shift2
键并按下键以产生@
输出。然后释放Shift键并按下Tab键,从而产生4个间隔的缩进。跟进,大写锁定键被按下,在这之后R
,.
,K
,A
,P
,和.
键按下,导致输出R.KAP.
。最后,单个空间被输出,接着移位导致!23
被输出时1
,2
和3
在末端键被按下。<SHFT>ABCDEFG<SHFT>HIJK<SHFT>1<SHFT>2<SHFT>3<SHFT>4567890 -> AbcdefgHijk!@#$567890
按住Shift键的同时,按住键
A
不放,结果是输出,A
然后按下键bcdefg
时输出B-G
。然后,再次按下Shift键,然后再按下该键,其后H
输出为H
,然后按下ijk
该I-K
键时。最后,将1-4
全部修改换档键被每次按键导致输出之前压住!@#$
由结束了567890
当5-0
重新按键。<CAPS>THIS<SPC>IS<SPC>IN<SPC>ALL<SPC>CAPS<CAPS><SPC>NOW<SPC>THIS<SPC>IS<SPC>IN<SPC>ALL<SPC>LOWERCASE -> THIS IS IN ALL CAPS now this is in all lowercase
<TAB><SPC><TAB><SHFT>1 -> !
<CAPS>WWW<CAPS>.CODEGOLF.STACKEXCHANGE<SHFT>.COM -> WWW.codegolf.stackexchange>com
PROGRAMMING<CAPS><SPC>IS<SPC><CAPS>AWESOME -> programming IS awesome
<DEL><RET><DEL><RET><DEL> -> "" (Empty String)
开始时按Delete键,此后什么也没有发生。然后,按回车键将产生新行,在再次按退格键后将其删除。最后,重复相同的序列(换行后跟退格键)。毕竟,输出是一个空字符串。
<SHFT>HI<SPC>HOW<SPC>ARE<SPC>YOU<SHFT>/<RET><SHFT>I<SPC><SHFT>AM<SPC>O<DEL><SHFT>GOOD<SHFT>1 -> Hi how are you?\nI Am Good!
<SHFT>,<CAPS>RET<CAPS><SHFT>. -> <RET>
该字符串
<RET>
应为实际的字符串输出。因此,这应该不是输出新行。<CAPS>67890,.;'[]<CAPS> -> 67890,.;'[]
<CAPS><SHFT>A -> A
RE<DEL><DEL> -> "" (Empty String)
U<RET><DEL><DEL>I -> i
<DEL><DEL><DEL>5<DEL> -> "" (Empty string)
"" (Empty String) -> "" (Empty String)
这是 高尔夫 因此以字节为单位的最短代码将获胜!
AbcdefgHijk!@#$567890
?同样,在测试8中,<SHFT>
它位于字符串的末尾,但是规则指出:“保证字符键将在<SHFT>之后。”