- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
3 Posted Topics
[code=python] def wordReplace(sentList, wordDict): find = lambda searchList, elem: [[i for i, x in enumerate(searchList) if x == e] for e in elem] wordList = list(wordDict) wordInd = find(sentList,wordList) for i in wordList: for k in range(len(wordInd)): for j in wordInd[k]: sentList[j] = wordDict[i] return "".join(sentList) [/code] This is probably …
Okay, I will help you out. First off, have you heard of the rational root theorem? If you have just use that if not here is an explanation. Given an arbitrary polynomial, the possible roots of that polynomial are +/- p/q where p is an integer factor of the constant …
1 is not prime: [code=python] def isPrime(n): if n == 1: return 0 else: for x in range(2,int(n**0.5)+1): if n%x == 0: return 0 return 1 [/code] Here is a shorter primeList: [code=python]primeList = lambda n: set([i for i in range(2,n)]) ^ set([i for i in range(2,n) for x in …
The End.
wallars