Skip to content

RST CheatSheet

Benjamin Smith edited this page Jan 22, 2019 · 4 revisions

Document Title

Bold text

Italic text

  1. Item 1
    1. sub item
    2. four space indentation
      1. enumerated sub sub item
      2. another sub sub item
  2. Item 2
    • non-enumerated sub items
      1. 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
  1. Google's HomePage
  2. dFusion Specificaion
  3. specific Function in smart contract
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
}