在这个挑战中,给出一份来自Pac-Man的鬼魂列表,您必须输出哪些鬼魂丢失了。你必须用尽可能少的字节来完成它。
输入将由一个字符串或列表组成,该字符串或列表将包含一个数字鬼,其中可能包括:
然而,输入也可能包括Pac-Man (带有标点符号)。因此,列表中项目的最大数量将是5个,按任何顺序排列。可以假定列表中没有无效的项。
输出将由字符串或列表组成。这将包括所有不在输入中的鬼魂,按任何顺序排列。然而,如果Pac-Man在输入中,所有的鬼魂都会被认为是失踪的(因为他吃了它们)。
input: Clyde
output: Blinky, Inky, Pinky
alternate output: Inky, Pinky, Blinky
or one of the other 4 permutations
input: Clyde, Blinky # or however you delimit it
output: Inky, Pinky
alt: Pinky, Inky
input: Pac-Man, Clyde
Output: Blinky, Inky, Pinky, Clyde
or you could output one of the other 23 permutations
input:[null]
Output: Blinky, Inky, Pinky, Clyde
or you could output one of the other 23 permutations这是个合作伙伴,所以越低越好。
发布于 2016-07-19 12:15:36
lambda s:[x for x in['Blinky','Inky','Pinky','Clyde']if(x in s)<1or'-'in s]输入是一个逗号分隔的字符串,输出将是一个列表.
发布于 2016-07-19 02:10:53
将一个以空结尾的字符串数组传递给f(),它将打印出缺少的名称.
*a[]={"Blinky","Inky","Pinky","Clyde",0},**s,**r,n;f(int**p){for(r=p;*p;)r=strcmp(*p++,"Pac-Man")?r:a+4;for(s=a;*s;++s){for(p=r,n=1;n&&*p;)n=strcmp(*s,*p++);n&&puts(*s);}}试试看。
发布于 2016-07-19 04:33:20
import Data.List
p l=(if elem"Pac-Man"l then id else(\\l))["Blinky","Inky","Pinky","Clyde"]输入是字符串的列表。它根据"Pac-Man“的存在来决定是按原样使用列表,还是根据”Pac-Man“的存在进行列表差异。
为了更多的乐趣,这里没有宠物男:
import Data.List
(["Blinky","Inky","Pinky","Clyde"]\\)很快就会改进这个答案,很晚才这么做。
https://codegolf.stackexchange.com/questions/85737
复制相似问题