討論串[閒聊] 自學練習
共 5 篇文章
內容預覽:
突然想到. 這第二題沒有阻止我有intersection. return list(set(lst1).intersection(set(lst2))). 這樣好像就行了. 把def的名字改掉就好. 回到第三題抽插的部分. # Write a function called "flatten" th
(還有993個字)
內容預覽:
早上起來去超市邊買邊想. 想不出來. 我一開始的想法是,我先找出所有這個數字會有的因數. 再從因數裡面挑出是質數的部分,並從最小的質數2開始除. 一直重覆到2不能除,然後在用下一個質數去除,除到不能除. 但這個想法太暴力了,而且我自己寫了幾行真的寫不出來. 只好看答案. def factorPrim
(還有1776個字)
內容預覽:
Write a function called "factorPrime" that takes an integer as input, and. returns the prime factorization of the input.. factorPrime(120); # returns
(還有280個字)
內容預覽:
def has_33(lst):. result = False. lst1 = [3, 3]. for i in range(0, len(lst) - 1):. if lst[i : i + 2] == lst1:. result = True. return result. 這個我看的教學影片
(還有36個字)
內容預覽:
# Given a list of ints, return True if the list contains a 3 next to a 3.. 想法是,33要連接在一起,所以檢查在lst裡面如果有3的話,後一個是不是也是3. def has_33(lst):. for index in ran
(還有1025個字)