Answers:
Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:s 1 l 1 r.Pickup a passenger going to Sunny Skies Park.Go to Sunny Skies Park:n 1 l 1 l 1 r.[a]Go to Heisenberg's:n 1 r 1 r 3 r.Pickup a passenger going to Cyclone.Go to Go More:n 1 l 3 l 3 l.Go to Starchild Numerology:e 2 r.62 is waiting at Starchild Numerology.Pickup a passenger going to Cyclone.Go to Cyclone:e 1 l 2 r.Pickup a passenger going to What's The Difference.Pickup a passenger going to Divide and Conquer.Pickup a passenger going to Divide and Conquer.Go to Divide and Conquer:n 2 r 2 r 1 r.Pickup a passenger going to Trunkers.Go to Trunkers:e 1 r 3 r 1 l.Pickup a passenger going to Multiplication Station.Go to Cyclone:w 2 r.Pickup a passenger going to Multiplication Station.Go to Multiplication Station:s 1 l 2 r 4 l.Pickup a passenger going to What's The Difference.Go to What's The Difference:n 2 l 1 r 3 l.Pickup a passenger going to Addition Alley.Go to Starchild Numerology:e 1 r 3 l 2 r.1 is waiting at Starchild Numerology.63 is waiting at Starchild Numerology.Pickup a passenger going to Addition Alley.Pickup a passenger going to The Underground.Go to Addition Alley:e 1 l 2 r 3 r 1 r.Pickup a passenger going to Joyless Park.Go to Writer's Depot:n 1 l 1 l.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789- is waiting at Writer's Depot.Pickup a passenger going to Chop Suey.Go to Joyless Park:n 3 r 2 r 2 l.Go to Chop Suey:w 1 r 1 r 1 l.[b]Pickup a passenger going to Narrow Path Park.Go to Narrow Path Park:n 1 l 1 r 1 l.Go to The Underground:e 1 r.Switch to plan "c" if no one is waiting.Pickup a passenger going to The Underground.Go to Fueler Up:s.Go to Chop Suey:n 3 r 1 l.Switch to plan "b".[c]Go to Joyless Park:n 1 r.Pickup a passenger going to The Underground.Go to Narrow Path Park:w 1 r 3 l.[d]Pickup a passenger going to KonKat's.Go to KonKat's:e 1 r.Pickup a passenger going to KonKat's.Go to The Underground:s.Switch to plan "e" if no one is waiting.Pickup a passenger going to The Underground.Go to Fueler Up:s.Go to Narrow Path Park:n 4 l.Switch to plan "d".[e]Go to KonKat's:n.Pickup a passenger going to Riverview Bridge.Go to Riverview Bridge:n 1 l.Go to Narrow Path Park:e 1 l 1 r.Pickup a passenger going to Post Office.Go to Post Office:e 1 r 4 r 1 l.Go to Sunny Skies Park:s 1 r 1 l 1 r.Pickup a passenger going to The Underground.Go to The Underground:n 1 r 1 r 2 r.Switch to plan "f" if no one is waiting.Pickup a passenger going to Sunny Skies Park.Go to Sunny Skies Park:n 3 l 2 l 1 l.Switch to plan "a".[f]
出租车是超级不是为此而做的,但是你可以做到!我将尝试解释未高尔夫版本下的情况。
Go to Post Office: west 1st left 1st right 1st left.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: south 1st left 1st right.
Pickup a passenger going to Sunny Skies Park.
Go to Sunny Skies Park: north 1st left 1st left 1st right.
[a]
Go to Heisenberg's: north 1st right 1st right 3rd right.
Pickup a passenger going to Cyclone.
Go to Go More: north 1st left 3rd left 3rd left.
Go to Starchild Numerology: east 2nd right.
62 is waiting at Starchild Numerology.
Pickup a passenger going to Cyclone.
Go to Cyclone: east 1st left 2nd right.
Pickup a passenger going to What's The Difference.
Pickup a passenger going to Divide and Conquer.
Pickup a passenger going to Divide and Conquer.
Go to Divide and Conquer: north 2nd right 2nd right 1st right.
Pickup a passenger going to Trunkers.
Go to Trunkers: east 1st right 3rd right 1st left.
Pickup a passenger going to Multiplication Station.
Go to Cyclone: west 2nd right.
Pickup a passenger going to Multiplication Station.
Go to Multiplication Station: south 1st left 2nd right 4th left.
Pickup a passenger going to What's The Difference.
Go to What's The Difference: north 2nd left 1st right 3rd left.
Pickup a passenger going to Addition Alley.
Go to Starchild Numerology: east 1st right 3rd left 2nd right.
1 is waiting at Starchild Numerology.
63 is waiting at Starchild Numerology.
Pickup a passenger going to Addition Alley.
Pickup a passenger going to The Underground.
Go to Addition Alley: east 1st left 2nd right 3rd right 1st right.
Pickup a passenger going to Joyless Park.
Go to Writer's Depot: north 1st left 1st left.
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789- is waiting at Writer's Depot.
Pickup a passenger going to Chop Suey.
Go to Joyless Park: north 3rd right 2nd right 2nd left.
Go to Chop Suey: west 1st right 1st right 1st left.
[b]
Pickup a passenger going to Narrow Path Park.
Go to Narrow Path Park: north 1st left 1st right 1st left.
Go to The Underground: east 1st right.
Switch to plan "c" if no one is waiting.
Pickup a passenger going to The Underground.
Go to Fueler Up: south.
Go to Chop Suey: north 3rd right 1st left.
Switch to plan "b".
[c]
Go to Joyless Park: north 1st right.
Pickup a passenger going to The Underground.
Go to Narrow Path Park: west 1st right 3rd left.
[d]
Pickup a passenger going to KonKat's.
Go to KonKat's: east 1st right.
Pickup a passenger going to KonKat's.
Go to The Underground: south.
Switch to plan "e" if no one is waiting.
Pickup a passenger going to The Underground.
Go to Fueler Up: south.
Go to Narrow Path Park: north 4th left.
Switch to plan "d".
[e]
Go to KonKat's: north.
Pickup a passenger going to Riverview Bridge.
Go to Riverview Bridge: north 1st left.
Go to Narrow Path Park: east 1st left 1st right.
Pickup a passenger going to Post Office.
Go to Post Office: east 1st right 4th right 1st left.
Go to Sunny Skies Park: south 1st right 1st left 1st right.
Pickup a passenger going to The Underground.
Go to The Underground: north 1st right 1st right 2nd right.
Switch to plan "f" if no one is waiting.
Pickup a passenger going to Sunny Skies Park.
Go to Sunny Skies Park: north 3rd left 2nd left 1st left.
Switch to plan "a".
[f]
开始:获取标准输入
将标准输入值转换为文本,将其转换为数字,然后将其粘贴到某处等待。
计划A第1部分:获取一个随机整数1-62
获取一个随机整数,然后获取62
一个数字。同时复制随机整数和,62
因为稍后我们将需要它们。你只能携带一下子让我们结了3名乘客rand
,rand
和62
。(另外62
,直到我们回来会等各地。)转到鸿沟rand
通过62
和截断结果得到一个整数。返回以获取的另一个副本,62
并将其乘以除法中的截断的整数。最后,从的第一个副本中减去乘积rand
。这给我们一个0-61的数字。现在我们必须返回到拾取a 1
并将其添加到结果中以获得数字1-62。是的,所有这么多的文本行都只是mod(rand(),62)+1
。
计划第2部分:创建一个字符数组,从中选择
包含所有有效字符的字符串,以及一个我们不需要的末尾的字符串(稍后会详细介绍)。在63
我们拿起前面的比赛这个字符串的长度。将其交给Chop Suey,将其分解成单独的乘客。
方案B:移动数组,以便我们可以一个
一个地选择一个字符,然后将每个字符移到Narrow Path Park。这是唯一可用的堆栈,也是避免剩余乘客进入的唯一方法。Townsburg中的其他所有内容都是FIFO,因此我必须回过头来,在整个循环的每次迭代中清除所有乘客。这样,我可以将它们留在公园,每次都会被63个新角色推开。一开始很A
可能永远也无法逃脱。
计划C:准备选择角色
这实际上只是计划D中不需要的几站。重新放置出租车以进行准备。
计划d:获取所有我们的字符不希望
与反转“阵列”的第一个字符开始(这是我们不希望的第63个字符),继续拿起和连接字符作为我们从结果倒计时mod
功能在计划A中。一旦您达到零,下一个字符就是您想要的那个。
计划E:淹没您不想要的那些,并返回所选的那个。
“在河景桥下车的[P]冒犯者似乎总是从侧面跌落到河里...”好吧,这摆脱了那连串的失败者。去接下一个字符并将其发送到标准输出。最后,让我们检查到目前为止已经打印了多少个字符。回到Sunny Skyes,获取我们很久以前留下的stdin值。减去一,如果结果大于零,则将其发回以等待,然后从计划A重新开始。
code-bowling
并已被修订。code-golf
我能找到的最长答案是原始的Brain-Flak提交的有关基本quine挑战的信息。它的大小为9.5 * 10 ^ 580字节。最长的电流答案,我发现是在一元黄金测试仪:1.65 * 10 ^ 56个字节。
rand()%74
应该是rand()%75
&&putchar(i)
代替三进制运算符来进一步减小大小。
n->{for(int t;n-->0;t*=Math.random(),System.out.printf("%c",t+=t>9?t>35?61:55:48))t=62;}
移植@ 2501的C答案为 -9个字节,因此请确保也对他进行投票!
旧答案,97个字节
n->{for(int t;n-->0;t*=Math.random(),System.out.printf("%c",t>9?(t<36?65:97)+t%26:48+t%10))t=62;}
说明:
n->{ // Method with integer parameter and String return-type
for(int t; // Temp integer
n-->0 // Loop the input amount of times:
; // After every iteration:
t*=Math.random(), // Set `t` to a random integer in the range [0,62)
System.out.printf("%c", // Print as character:
t+= // The random integer, after we've added:
t>9? // If the random integer is larger than 9:
t>35? // If the random integer is larger than 35:
61 // Add 61
: // Else:
55 // Add 55
: // Else:
48)) // Add 48
t=62;} // (Re)set `t` to 62 for the random
n->{for(int t;n-->0;t*=Math.random(),System.out.printf("%c",...))t=62;}
// Similar as above
t>9? // If the random integer is larger than 9:
(t<36? // If the random integer is smaller than 36:
65 // Start with 65 ('A')
: // Else:
97) // Start with 97 ('a')
+t%26 // And add the random integer modulo-26
: // Else:
48 // Start with 48 ('0')
+t%10) // And add the random integer modulo-10
((}#`""*:48vn58nR|65vn91nR,aC|97vn123nR,aCAsH1AaL#aC*;bR))
这是一个子程序,它以整数作为输入并返回随机字符串。
(( subroutine
} make b, e, g active
#` e = input (from +)
""* store an empty string in +
: what follows is the block to prepend a random char to +
48vn58nR| generate range(48..58) and place in g (need b and e for next step)
65vn91nR generate range(65..91) in b
,aC| move g to e, concatenate b and e, and move the result to g
97vn123nR generate range(97..123) in b
,aC move g to e, concatenate b and e, keeping the result in b
AsH shuffle the array of candidate ASCII codes stored in b
1AaL equivalent to 0aAwR - get the first element wrapped in an array
#aC retrieve + and prepend the randomly generated character
* store back into +
;bR repeat this block e times, where e has been set to the input
)) output is given via +
((}#`""*:48vn58nR|65vn91nR,aC|97vn123nR,aCAsH1AaL#aC*;bR))
。
-4感谢Andrei Odegov-转换为char数组而不是循环创建char数组。
-join[char[]](65..90+97..122+48..57|random -C "$args")
生成1..2+4..5 = 1,2,4,5
所有可接受的字符代码范围,然后$args
使用随机选择元素数量random -Count
-将生成的元素循环遍历使用|%{}
并转换为[char]
s,[char[]]
-将其转换为字符数组-然后将整个对象封装在方括号中,并将-join
ed在一起。
PS C:\users\sweeneyc\Desktop> .\grstr.ps1 5
oaCE5
PS C:\users\sweeneyc\Desktop> .\grstr.ps1 10
UReh6McG7D
PS C:\users\sweeneyc\Desktop> .\grstr.ps1 30
t1YrhZf5egyzqnPlWUKV3cEoIudMTs
对于输入0无效Get-Random
,因为该-Count
参数仅接受大于1的数字。
-join[char[]](65..90+97..122+48..57|random -C "$args")
intToUtf8(sample(c(65:90,97:122,48:57),scan(),T))
说明:
scan()
c(65:90,97:122,48:57)
sample(c(65:90,97:122,48:57),scan(),T)
intToUtf8
这几乎像反向高尔夫球!在字节数上大获成功,确保将使用所有三组字符的全部范围。
f=n=>n--?btoa(String.fromCharCode(Math.random()*248))[0]+f(n):""
f=n=>n--?btoa(String.fromCharCode(Math.random()*248))[0]+f(n):""
i.addEventListener("input",_=>o.innerText=f(+i.value))
<input id=i type=number><pre id=o>
[0-5w-z]
专门生成字符。
btoa(String.fromCharCode(Math.random()*248))[0]
统一覆盖整个范围。
toString
然后编码),以确保可以返回所有3组字符的全部范围。
014589ABEFIJMNQRUVYZcdghklopstwx
并且不是统一的)。
/w9u"Uz;r
\0.rdao"ki@/t&
这种布局已经比我原来的布局(32字节)好很多,但是我确定它不是最佳的……
/ Reflect to SE. Switch to Ordinal.
The IP now bounces diagonally up and down through the code.
09 Append 0 and 9 to an (implicit) empty string to create "09".
r Range expansion, turns the string into "0123456789".
"az" Push this string.
r Range expansion, turns it into the lower-case alphabet.
i Read all input as a string.
/ Reflect to E. Switch to Cardinal.
t Implicitly convert the input string to the integer value N it
contains and decrement it.
& Run the next command N-1 times.
The IP wraps around to the first column.
\ Reflect to NE. Switch to Ordinal. (This is not a command.)
w Push the current IP address to the return address stack N-1
times. This starts a loop whose body will run N times.
. Duplicate the lower-case alphabet.
u Convert it to upper case.
d Push the concatenation of all values on the stack. This pushes
a single string with digits, lower-case and upper-case alphabet.
U Random choice. Pick a character from this string uniformly at random.
o Print it.
; Discard the upper-case alphabet, because it will be regenerated
in the next loop iteration (and if we leave it, then upper-case
letters will become more and more likely as the output grows).
k As long as there is still an address on the return address stack,
jump back to that address (i.e. to the w). Once the return address
stack has been depleted, this does nothing and the loop is exited.
@ Terminate the program.
import random as r,string as s;lambda x:''.join(r.sample(s.printable[:62]*x,x))
+4字节(未考虑重复)
-4个字节(感谢@Rod的使用建议printable[:62]
)
(s.letters+s.digits)*x
代替s.letters+s.digits
`r.sample(...)`[2::5]
,而不是''.join(r.sample(...))
保存字节(只蟒蛇2),(s.letters+s.digits)*x
可以切换到s.printable[:62]*x
保存4个字节
printable
,无法[2::5]
上班(也许我做错了吗?)
~JfH
~J - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
f - cominbations(^, length=input)
H - random.choice(^)
MemoryError
LaORCz.AZ.J,t
a is cmdline arg; t is 10; z is lcase alphabet; AZ is ucase (implicit)
La Do the following, a times:
O Output (without newline)
RC random choice from:
z Lowercase letters
.AZ concatenated with uppercase letters
.J,t concatenated with range(10) joined into a string