-
Notifications
You must be signed in to change notification settings - Fork 31
RST CheatSheet
Benjamin Smith edited this page Jan 22, 2019
·
4 revisions
Contents
Bold text
Italic text
-
- Item 1
-
- sub item
-
- four space indentation
-
- enumerated sub sub item
- another sub sub item
-
- Item 2
-
-
- non-enumerated sub items
-
- Enumerated sub sub item
-
- Bullet 1
-
- Bullet 2
-
- Sub bullet 1
- Sub bullet 2
Col1 | Col2 | Col3 |
---|---|---|
item | item | item |
item | item | item |
item | item | item |
def centroid_index(arr):
"""
:param arr: list(int)
:return: first occurring index, i, of arr for which
sum(arr[:i]) == sum(arr[i:]) or None if it does not exist.
"""
s = sum(arr)
c, i = 0, 0
while i < len(arr):
c += arr[i]
s -= arr[i]
if c - arr[i] == s:
return i
i += 1
def test_centroid_index():
assert(centroid_index([1, 2, 3, 4, 3, 2, 1]) == 3)
assert(centroid_index([1, 1, -1]) == 0)
assert(centroid_index([1, 2, 3]) is None)
/**
* deploys and registers tokens on contract
* The object consists of:
* 1.) contract to register account
* 2.) owner of contract
* 3.) number of tokens to be registered
*/
const registerTokens = async function(contract, token_owner, numTokens) {
console.log("Registering %d tokens to %s", numTokens, token_owner)
const res = []
const owner = await contract.owner()
for (let i = 0; i < numTokens; i++) {
const token = await ERC20Mintable.new({ from: token_owner })
res.push(token)
await contract.addToken(token.address, { from: owner })
}
return res
}
Custom Footer! Sweet!