发布于 2020-02-29 00:27:49
发布于 2021-06-07 20:27:07
Go to Post Office:w 1 l 1 r 1 l.[A]A is waiting at Writer's Depot.A is waiting at Writer's Depot.Go to Writer's Depot:w 1 r 1 l 2 l.Pickup a passenger going to Post Office.Pickup a passenger going to Post Office.Go to Zoom Zoom:n.Go to Post Office:w 3 l 2 r 1 l.Switch to plan A.这是一个有趣的挑战,因为它既需要无限的加油,也需要足够的乘客来支付汽油的费用。如果乘客支付足够的费用来支付用于运输他们的汽油,以下几点就足够了:
Go to the Post Office: west 1st left, 1st right, 1st left.
[loop]
"A" is waiting at the Writer's Depot.
Go to Go More: west 1st right, 1st left, 1st left, 2nd right.
Go to the Writer's Depot: west 1st right.
Pickup a passenger going to the Post Office.
Go to the Post Office: north 1st right, 2nd right, 1st left.
Switch to plan "loop".然而,由于乘客不支付足够的费用,这会导致只有54*A,一旦我们的燃料用完了,这个项目就会崩溃。我们也可以去Zoom买燃料,在这里买更便宜,这样我们就可以买到79*A。幸运的是,一次接两名乘客解决了每次迭代收入不足的问题。代码可以通过删除不包含空格的字符串的引号和最小化说明来进一步提高。它看起来像这样:
Go to the Post Office: west 1st left, 1st right, 1st left.
[loop]
"A" is waiting at the Writer's Depot.
"A" is waiting at the Writer's Depot.
Go to the Writer's Depot: west 1st right, 1st left, 2nd left.
Pickup a passenger going to the Post Office.
Pickup another passenger going to the Post Office.
Go to Zoom Zoom: north.
Go to the Post Office: west 3rd left, 2nd right, 1st left.
Switch to plan "loop".在我意识到我可以和两位乘客一起去Zoom之前,我发现了以下321个字节的解决方案,这些解决方案在较短的解决方案…中没有使用过一些有趣的技巧
Go to Post Office:w 1 l 1 r 1 l.[A]"A"is waiting at Writer's Depot."A"is waiting at Writer's Depot."A"is waiting at Writer's Depot.Go to Writer's Depot:w 1 r 1 l 2 l.[B]Switch to plan C i.Pickup a passenger going to Post Office.Switch to plan B.[C]Go to Go More:s 1 l.Go to Post Office:e 1 l 1 r 1 r 1 l.Switch to plan A.Go to Post Office:w 1 l 1 r 1 l.[A]"AAA"is waiting at Writer's Depot.Go to Writer's Depot:w 1 r 1 l 2 l.Pickup a passenger going to Chop Suey.Go to Zoom Zoom:n.Go to Chop Suey:w 1 l 3 r.[B]Switch to plan C i.Pickup a passenger going to Post Office.Switch to plan B.[C]Go to Post Office:s 1 r 1 l 2 r 1 l.Switch to plan A.使用更多的Go来获取燃料,即使是最多三名乘客也不能给出足够的钱来无限地循环,所以我不得不更聪明地考虑它。如果我们能更快地接送乘客,并带他们走更长的路线,他们就会为此付出更多的费用。去作家的仓库之前,获得燃料的结果在70*A。如果我们用这条路线接送三名乘客,我们就可以无限地循环。
接送三名前往同一目的地的乘客比使用相同的代码三次更节省字节。使用Switch to plan "name" if noone is waiting,我们可以挑选一个单独的传递者,直到三个人都被选中为止。计划名称周围的引号是可选的,它被解释为if noone is waiting之后的任何单词。使用这个方法,我们得到了第一个321字节的解决方案,下面的代码是未使用的版本:
Go to Post Office: west 1st left, 1st right, 1st left.
[loop]
[Setup 3 * "A"]
"A" is waiting at Writer's Depot.
"A" is waiting at Writer's Depot.
"A" is waiting at Writer's Depot.
Go to Writer's Depot: west 1st right, 1st left, 2nd left.
[Pickup 3 * "A"]
[before pickup]
Switch to plan "after pickup" if noone is waiting.
Pickup a passenger going to Post Office.
Switch to plan "before pickup".
[after pickup]
[Get Gas]
Go to Go More: south 1st left.
[Print 3 * "A"]
Go to Post Office: east 1st left, 1st right, 1st right, 1st left.
Switch to plan "loop".但还有更多!设置三个不同的乘客来接车需要花费相当多的字节。如果我们将字符串"AAA"分开,我们可以消除设置乘客的两条线路,而代价是经过Chop。有了这个,我们就不需要费尽心思去参观更多的加油站了,加油机在我们的路线上,Zoom Zoom也很容易到达。看看燃油,它是最贵的,事实上,它太贵了,你甚至连三个乘客都得不到足够的钱!我们只能打印561*A,187个循环的三个乘客,但不是无限的,因为我们正在尝试。幸运的是,Zoom -最便宜的加油站--根本不需要额外的路由,采用这条路线可以让我们进入另一个无限循环。
Go to Post Office: west 1st left, 1st right, 1st left.
[loop]
[Setup 3 * "A"]
"AAA" is waiting at Writer's Depot.
Go to Writer's Depot: west 1st right, 1st left, 2nd left.
Pickup a passenger going to Chop Suey.
[Get gas]
Go to Zoom Zoom: north.
Go to Chop Suey: west 1st left, 3th right.
[Pickup 3 * "A"]
[before pickup]
Switch to plan "after pickup" if noone is waiting.
Pickup a passenger going to Post Office.
Switch to plan "before pickup".
[after pickup]
[Print 3 * "A"]
Go to Post Office: south 1st right, 1st left, 2nd right, 1st left.
Switch to plan "loop".遗憾的是,这不安全的任何字节,但这是我第二次得到两个答案与相同的字节数,我认为这是很酷的!(请参见这个DDoouubbllee挑战。)
我还意识到,当我即将发表的时候,所有没有空格的字符串都可以不用引号来编写。这使我的实际解决方案得到了更多的帮助,并且不再让321字节的解决方案保持相同的长度。即使如此,我仍然发表了这个解释,因为重复接送三个乘客是有用的,使用Chop很有趣:)
https://codegolf.stackexchange.com/questions/200306
复制相似问题