Python简单题第四期
本帖最后由 沉默的人e 于 2020-7-19 15:15 编辑python简单题 第四期 (争取月更)
(你就不会弄一个统一的标题吗!!!)
{:7_128:}{:7_128:}{:7_128:}
前几期的题目过于简单(过于简单...)
为了让我的题目值那些鱼币,所以,简单题要略微增加难度.
(不过还是相信鱼油能做出来,毕竟是一个大一的学生,再难能难到哪里去)
不废话,上题:
Given a set of data composed of numbers, the permutation of the set of data needs to be output. Each arrangement method needs to be packed with [], and the result of the overall arrangement will be packed with [].
For example, to output the permutation of , your result should be [,]
It is not allowed to use built-in functions or import modules to complete this operation directly.
For example, if there is a module named a.py whose function b can return the permutation of data, the following statements are prohibited:
import a
a.b()
hints: the dataset which will be permutated should be gotten by using the input() function
这是力扣网上的题目,经过了简单的修改,呈现出来.题目不难,真的不难!以函数式编程方式书写程序最先给出答案,并且答案最简洁单纯的为最佳答案.本系列虽鱼币有所缩减但仍然不少,请大家加油,最佳答案者,获得25鱼币哦
def func(l):
rets = []
def fun2(chs, sz=[]):
if not chs:
rets.append(sz)
for c in chs:
szc = sz.copy()
chsc = chs.copy()
szc.append(c)
chsc.remove(c)
fun2(chsc, szc)
fun2(l)
return rets 这里有字符串型的,先凑合着,待会儿给完整版f = lambda chs, sz: print(sz) if chs == '' else
f("FishC", '') 实现全排列,你管这叫简单题?{:10_277:} 突然觉得当年我要是把我每月的大作业都按时po在论坛上是不是就能坐等答案了.......{:10_256:} 呃,忘了说时限了.
时限到8月10号之前.
八月十号当天我会选出最佳答案者
各位加油哦!
谁能翻译一下题目{:10_266:}
页:
[1]