人力资源机是专门为程序员设计的神游戏
目录
(14)最大化室——jumpIfNegative指令
一,关卡1-5
(1)收发室——输入输出指令
-- HUMAN RESOURCE MACHINE PROGRAM --
INBOX
OUTBOX
INBOX
OUTBOX
INBOX
OUTBOX
(2)繁忙的收发室——jump指令
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
OUTBOX
INBOX
OUTBOX
JUMP a
(3)复印楼层——copyfrom指令
-- HUMAN RESOURCE MACHINE PROGRAM --
COPYFROM 4
OUTBOX
COPYFROM 0
OUTBOX
COPYFROM 3
OUTBOX
(4)解扰码器——copyto指令
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
INBOX
OUTBOX
COPYFROM 0
OUTBOX
JUMP a
(5)咖啡时间
二,关卡6-14
(6)多雨之夏——add指令
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
INBOX
ADD 0
OUTBOX
JUMP a
(7)零之杀手——jumpIfZero指令
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
b:
INBOX
JUMPZ b
OUTBOX
JUMP a
(8)三倍扩大室
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
ADD 0
ADD 0
OUTBOX
JUMP a
(9)保护零行动
-- HUMAN RESOURCE MACHINE PROGRAM --
JUMP b
a:
OUTBOX
b:
c:
INBOX
JUMPZ a
JUMP c
(10)八倍扩大器套件
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
ADD 0
COPYTO 0
ADD 0
COPYTO 0
ADD 0
OUTBOX
JUMP a
(11)Sub走廊——sub指令
文字描述不对,其实是先out第2个减第1个,再out第1个减第2个。
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
INBOX
COPYTO 1
SUB 0
OUTBOX
COPYFROM 0
SUB 1
OUTBOX
JUMP a
(12)四十倍扩大器
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
ADD 0
COPYTO 1
ADD 1
ADD 0
COPYTO 0
ADD 0
COPYTO 0
ADD 0
COPYTO 0
ADD 0
OUTBOX
JUMP a
(13)平等化室——注释
-- HUMAN RESOURCE MACHINE PROGRAM --
JUMP b
a:
COPYFROM 0
OUTBOX
b:
c:
INBOX
COPYTO 0
INBOX
SUB 0
JUMPZ a
JUMP c
(14)最大化室——jumpIfNegative指令
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
INBOX
SUB 0
JUMPN b
ADD 0
JUMP c
b:
COPYFROM 0
c:
OUTBOX
JUMP a
三,关卡15-19
(15)员工斗志的注入
(16)绝对正能量
-- HUMAN RESOURCE MACHINE PROGRAM --
JUMP c
a:
COPYTO 0
SUB 0
SUB 0
b:
OUTBOX
c:
INBOX
JUMPN a
JUMP b
(17)VIP休息室
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
b:
INBOX
JUMPN d
INBOX
JUMPN e
c:
COPYFROM 4
OUTBOX
JUMP b
d:
INBOX
JUMPN c
e:
COPYFROM 5
OUTBOX
JUMP a
(18)公休海滩天堂
(19)倒计时——bump+指令、bump-指令
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
b:
JUMPN d
c:
OUTBOX
BUMPDN 0
JUMPN a
JUMP c
d:
OUTBOX
BUMPUP 0
JUMP b
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
b:
JUMPN d
c:
OUTBOX
BUMPDN 0
JUMPN a
JUMP c
d:
e:
OUTBOX
BUMPUP 0
JUMPN e
JUMP b
四,关卡20-28
(20)乘法研讨会
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
INBOX
COPYTO 1
b:
BUMPDN 0
JUMPN c
COPYFROM 1
ADD 9
COPYTO 9
JUMP b
c:
COPYFROM 9
OUTBOX
BUMPUP 0
COPYTO 9
JUMP a
-- HUMAN RESOURCE MACHINE PROGRAM --
COPYFROM 9
COPYTO 8
COPYTO 7
BUMPU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D+vZujZh/zzHI+
wzAKRsEoGBYAAB6VGOg;
(21)以零结尾的求和——内联函数
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
COPYFROM 5
COPYTO 4
b:
INBOX
JUMPZ c
ADD 4
COPYTO 4
JUMP b
c:
COPYFROM 4
OUTBOX
JUMP a
采用内联函数,利用代码空间换取执行效率:
-- HUMAN RESOURCE MACHINE PROGRAM --
INBOX
COPYTO 4
INBOX
JUMPZ b
ADD 4
COPYTO 4
INBOX
JUMPZ a
ADD 4
COPYTO 4
a:
b:
c:
d:
e:
f:
g:
h:
COPYFROM 4
i:
OUTBOX
INBOX
JUMPZ i
COPYTO 4
INBOX
JUMPZ h
ADD 4
COPYTO 4
INBOX
JUMPZ g
ADD 4
COPYTO 4
INBOX
JUMPZ f
ADD 4
COPYTO 4
INBOX
JUMPZ e
ADD 4
COPYTO 4
INBOX
JUMPZ d
ADD 4
COPYTO 4
INBOX
JUMPZ c
(22)斐波那契参观者
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
COPYFROM 9
COPYTO 0
BUMPUP 0
COPYTO 1
INBOX
COPYTO 8
b:
COPYFROM 8
SUB 0
JUMPN a
COPYFROM 0
OUTBOX
COPYFROM 1
ADD 0
COPYTO 2
COPYFROM 1
COPYTO 0
COPYFROM 2
COPYTO 1
JUMP b
(23)最小的数字
-- HUMAN RESOURCE MACHINE PROGRAM --
JUMP b
a:
COPYFROM 0
OUTBOX
b:
INBOX
COPYTO 0
c:
d:
INBOX
JUMPZ a
SUB 0
JUMPN e
JUMP c
e:
ADD 0
COPYTO 0
JUMP d
(24)模运算模块
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
INBOX
COPYTO 1
COPYFROM 0
b:
JUMPN c
SUB 1
JUMP b
c:
ADD 1
OUTBOX
JUMP a
(25)累加的倒计时
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
JUMPZ d
COPYTO 0
COPYTO 4
b:
BUMPDN 0
JUMPZ c
ADD 4
COPYTO 4
JUMP b
c:
COPYFROM 4
d:
OUTBOX
JUMP a
(26)小小的除法
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
INBOX
COPYTO 1
COPYFROM 9
COPYTO 8
b:
COPYFROM 0
SUB 1
JUMPN c
COPYTO 0
BUMPUP 8
JUMP b
c:
COPYFROM 8
OUTBOX
JUMP a
(27)深夜石油
(28)三排序
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 0
INBOX
COPYTO 1
INBOX
COPYTO 2
COPYTO 7
SUB 1
JUMPN b
COPYFROM 1
COPYTO 2
COPYFROM 7
COPYTO 1
b:
COPYFROM 2
COPYTO 7
SUB 0
JUMPN c
COPYFROM 0
COPYTO 2
COPYFROM 7
COPYTO 0
c:
COPYFROM 2
OUTBOX
COPYFROM 1
SUB 0
JUMPN d
COPYFROM 0
OUTBOX
COPYFROM 1
JUMP e
d:
COPYFROM 1
OUTBOX
COPYFROM 0
e:
OUTBOX
JUMP a
五,关卡29-33
(29)仓库楼层——指针
这一关开始引入指针的概念。
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 12
COPYFROM [12]
OUTBOX
JUMP a
(30)串存储楼层——字符运算
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 24
b:
COPYFROM [24]
JUMPZ a
OUTBOX
BUMPUP 24
JUMP b
可以发现,这里字符和整数是完全分开的概念,并不像c语言中,字符的本质也是整数,char就是整型。
这里的字符可以参与2种运算,一是2个字符相减,得到的值和c语言中字符相减的值相同,二是和0比较大小,结果恒为大于0,但字符不能加减整数。
(31)串的反转
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
b:
INBOX
COPYTO [14]
JUMPZ c
BUMPUP 14
JUMP b
c:
d:
BUMPDN 14
JUMPZ e
COPYFROM [14]
OUTBOX
JUMP d
e:
COPYFROM [14]
OUTBOX
JUMP a
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
b:
BUMPUP 14
INBOX
COPYTO [14]
JUMPZ c
JUMP b
c:
d:
BUMPDN 14
JUMPZ a
COPYFROM [14]
OUTBOX
JUMP d
(32)库存报告
-- HUMAN RESOURCE MACHINE PROGRAM --
JUMP b
a:
COPYFROM 19
OUTBOX
b:
COPYFROM 14
COPYTO 19
COPYTO 18
INBOX
COPYTO 15
c:
COPYFROM [18]
JUMPZ a
SUB 15
JUMPZ d
JUMP e
d:
BUMPUP 19
e:
BUMPUP 18
JUMP c
DEFINE LABEL 14
eJwTZ2BgCCu8lXkrXzYnLu9o4Yoshta8jPmzz2bIbmTP9tn9P1f0UHFRxJFd1aKH3jT071Vr5tgp1vl4
7scu3j6+ntxyvp4lBZO6jFK2d2TGcjYV+lyv2eKXXXowvDq/NI1hFIyCUTDoAQDzSyn9;
DEFINE LABEL 18
eJyTZmBgmOWjVWrtM7vxicf7ZUAuw0f/S6YgujvTPYYpUS36RNyaeP0Y2ZzNUWZ1IVHO7ReiD87hiluz
5Gl85qLZyT+m8md8rvbMks1pzrEO3pv3R7U6f7rSrfw1Uv9zV7j+z80t/14weZJfyZolDKNgFIyCQQcA
8m4uQg;
DEFINE LABEL 19
eJwzYGBgeOOa6tzrKph83fHcUj3XgAmT/EvTbkRc8w+JyowVim7KF4p+PPdr5J/1QKUM3wsEk6vzm/If
5WyZ3JyjtsAxd+damfxb60SKpq9pqHRfeL6+rXNRy5KC/a3T01ubX/c8aV6ytbZt7/FJXXpXcnvazoHM
YF92K/Pd9NSza2bsPS4/d8nW5uWS09eud26fu9WsTnK7c3vF9i2TK7bfWhe9Tel0xfYN+4J3Nm3h3Gu0
8sxx3r53l/orsq6Y1S251rV4yTWl0wyjYBSMAooAAGbUYJY;
(33)王五哪儿去了
六,关卡34-42
(34)元音焚化炉
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
b:
INBOX
COPYTO 7
COPYFROM 5
COPYTO 6
c:
COPYFROM [6]
JUMPZ d
SUB 7
JUMPZ b
BUMPUP 6
JUMP c
d:
COPYFROM 7
OUTBOX
JUMP a
(35)删除重复项
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
b:
INBOX
COPYTO 12
COPYFROM 14
COPYTO 13
c:
BUMPDN 13
JUMPN d
COPYFROM [13]
SUB 12
JUMPZ b
JUMP c
d:
COPYFROM 12
COPYTO [14]
OUTBOX
BUMPUP 14
JUMP a
(36)字母饼干
-- HUMAN RESOURCE MACHINE PROGRAM --
COPYFROM 23
COPYTO 21
COPYFROM 24
COPYTO 22
a:
INBOX
JUMPZ b
COPYTO [23]
BUMPUP 23
JUMP a
b:
c:
INBOX
JUMPZ e
COPYTO [24]
BUMPUP 24
JUMP c
d:
COPYFROM [21]
OUTBOX
BUMPUP 21
SUB 23
JUMPZ k
BUMPUP 22
SUB 24
JUMPZ l
e:
COPYFROM [21]
SUB [22]
JUMPZ d
JUMPN g
f:
COPYFROM [22]
OUTBOX
BUMPUP 22
SUB 24
JUMPZ j
JUMP f
g:
h:
COPYFROM [21]
OUTBOX
BUMPUP 21
SUB 23
JUMPZ i
JUMP h
i:
j:
k:
l:
(37)拾荒者之链
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
b:
COPYTO 7
COPYFROM [7]
OUTBOX
BUMPUP 7
COPYFROM [7]
JUMPN a
JUMP b
(38)数位炸弹
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
COPYFROM 9
COPYTO 8
COPYTO 7
INBOX
COPYTO 4
b:
COPYFROM 4
SUB 11
JUMPN c
COPYTO 4
BUMPUP 8
JUMP b
c:
ADD 11
COPYTO 4
COPYFROM 8
JUMPZ d
OUTBOX
d:
e:
COPYFROM 4
SUB 10
JUMPN f
COPYTO 4
BUMPUP 7
JUMP e
f:
ADD 10
COPYTO 4
COPYFROM 7
ADD 8
JUMPZ g
SUB 8
OUTBOX
g:
COPYFROM 4
OUTBOX
JUMP a
DEFINE LABEL 9
eJyTZGBgMCw+GD6jwChlQe6Gykc5j+cuyC1dPaPg84H3xalnNcteX8xoqjq6vptjp0df4uZ/E9cs+Tal
cKLwNOf2i9Nkc6ZPYYmKnSQZ5NHH47m/da/t+XozS8maCKvnZYqOC3K/BzzKqQtlGAWjYBQMWgAAvxww
jw;
DEFINE LABEL 10
eJwTZ2BgaItncFCP1yotjA64CuQynCqdH1adz9Aal7dl8v/cP+tl8jl2bi28tN+w+PMBzbLPBzbVPd8u
1/Z+WW7PyW6Pvv4Kj773iXw988OudF7zZ2zl8ayoee1+v/KaP8MoGAWjYNADABGJKrI;
DEFINE LABEL 11
eJwzZGBgYPSKsNJzvXcCyGRITDRKWR3bX1EY/bqnMJpl/urYkFVMiX/Wf0r7s746P2SVW7n7wrlVdbP0
Gto6M5rM6hhbd2Ywts4PW9RyzX9Vo7OTZM1eW5GivbaPchQdy1L1vBITrYNXx3bF+cS+TwSZL74gJuTu
3EcRa2bszBCe5l02fQpDa+jUmJlrZrxfVjfXaOXVBeeW/l8xf/b7dXr9pza0dR7afKlq7tbSNLutB8Pd
Nl3zN1zH41m9aoXriqUrXCcv1PMSX3DNn2EUjIJRQDYAAFqEWek;
(39)重设坐标
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 5
COPYFROM 14
COPYTO 6
b:
COPYFROM 5
SUB 15
JUMPN c
COPYTO 5
BUMPUP 6
JUMP b
c:
COPYFROM 5
OUTBOX
COPYFROM 6
OUTBOX
JUMP a
(40)质数工厂
方法一:列举所有可能的质数
-- HUMAN RESOURCE MACHINE PROGRAM --
COPYFROM 24
COPYTO 0
BUMPUP 0
BUMPUP 0
COPYTO 1
BUMPUP 1
ADD 0
COPYTO 2
ADD 0
COPYTO 3
ADD 0
ADD 0
COPYTO 4
ADD 0
COPYTO 5
ADD 0
ADD 0
COPYTO 6
ADD 0
COPYTO 7
a:
COPYFROM 24
COPYTO 23
INBOX
COPYTO 22
b:
COPYFROM 24
COPYTO 19
BUMPDN 22
JUMPZ a
BUMPUP 22
COPYTO 21
c:
COPYFROM 22
JUMPZ e
JUMPN d
SUB [23]
COPYTO 22
BUMPUP 19
JUMP c
d:
BUMPUP 23
COPYFROM 21
JUMP f
e:
COPYFROM [23]
OUTBOX
COPYFROM 19
f:
COPYTO 22
JUMP b
指令多执行慢,光是枚举2-19这些质数就花了20个指令。
方法二:只列举幂指数可能大于1的质数,即2和3,其他质数最多只会出现一次。
-- HUMAN RESOURCE MACHINE PROGRAM --
COPYFROM 24
COPYTO 2
COPYTO 0
BUMPUP 0
COPYTO 21
BUMPUP 0
COPYTO 1
BUMPUP 1
a:
BUMPDN 21
JUMPZ b
BUMPUP 21
OUTBOX
b:
COPYFROM 24
COPYTO 23
INBOX
c:
d:
COPYTO 22
COPYTO 21
COPYFROM 24
COPYTO 19
e:
COPYFROM 22
JUMPZ g
JUMPN f
SUB [23]
COPYTO 22
BUMPUP 19
JUMP e
f:
BUMPUP 23
COPYFROM [23]
JUMPZ a
COPYFROM 21
JUMP c
g:
COPYFROM [23]
OUTBOX
COPYFROM 19
JUMP d
(41)排序楼层
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
COPYFROM 24
COPYTO 20
b:
INBOX
JUMPZ c
COPYTO [20]
BUMPUP 20
JUMP b
c:
BUMPDN 20
JUMPZ h
d:
COPYFROM 24
COPYTO 21
e:
COPYFROM [20]
COPYTO 17
SUB [21]
JUMPN f
COPYFROM [21]
COPYTO [20]
COPYFROM 17
COPYTO [21]
f:
BUMPUP 21
SUB 20
JUMPZ g
ADD 20
JUMP e
g:
h:
i:
COPYFROM [20]
OUTBOX
BUMPDN 20
JUMPZ i
JUMPN a
JUMP d
(42)程序结束。恭喜。
宇宙的终极答案,就是42
这里收录了每一关解法:
http://atesgoral.github.io/hrm-solutions/">http://atesgoral.github.io/hrm-solutions/