哥&寂寞,,[Python]代码fr


[Python]代码

from itertools import product, permutationsli=[[u"哥",u"烟",u"寂寞"], [u"是",u"不是"]]t=[x+y for x,y in product(*[[i for i in permutations(j)] for j in li])]print "\n".join([i[0]+u"抽的"+i[3]+i[1]+","+i[4]+i[2] for i in  t])#out:#哥抽的是烟,不是寂寞#哥抽的不是烟,是寂寞#哥抽的是寂寞,不是烟#哥抽的不是寂寞,是烟#烟抽的是哥,不是寂寞#烟抽的不是哥,是寂寞#烟抽的是寂寞,不是哥#烟抽的不是寂寞,是哥#寂寞抽的是哥,不是烟#寂寞抽的不是哥,是烟#寂寞抽的是烟,不是哥#寂寞抽的不是烟,是哥

[Mathematica]代码

typing[str_, sec_: 0.05] :=  With[{len = StringLength@str},   Dynamic[t = Clock[{0, len, 1}, len*sec];    Style[StringTake[str, t], Hue[t/len]]]   ];list = Join @@@    Tuples[Permutations /@ {{"红薯", "野鬼", "宏哥"}, {"不是", "是"}}];str = (#[[1]] <> "喜欢的" <> #[[4]] <> #[[2]] <>        ", " <> #[[5]] <> #[[3]] <> "\n" &) /@ list // StringJoin;typing[str] 

typing.gif

imgs/asCode/22230350_Oq4r.jpg

评论关闭