Example #1
0
def main():
  grid = parse(sys.stdin.readlines())

  after100 = nth(iterate(animate, grid), 100)
  print('part1: ', count_on(after100))

  after100 = nth(iterate(pipe(animate, turn_edges), grid), 100)
  print('part1: ', count_on(after100))
Example #2
0
def main():
    grid = parse(sys.stdin.readlines())

    after100 = nth(iterate(animate, grid), 100)
    print('part1: ', count_on(after100))

    after100 = nth(iterate(pipe(animate, turn_edges), grid), 100)
    print('part1: ', count_on(after100))
Example #3
0
def solver():
    """
    By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see
    that the 6th prime is 13.

    What is the 10 001st prime number?
    """
    assert nth(iter_primes(), 6-1) == 13
    return nth(iter_primes(), 10001-1)
Example #4
0
File: day03.py Project: aah/advent
def carry_distance(index: int) -> int:
    """Find the carry distance from a square to the access port.

    >>> carry_distance(1)
    0
    >>> carry_distance(12)
    3
    >>> carry_distance(23)
    2
    >>> carry_distance(1024)
    31
    """
    return manhattan_distance(ORIGIN, nth(spiral(), index - 1))
Example #5
0
def code(row, col):
    return nth(iterate(next_code, 20151125), ns(row, col))
Example #6
0
def main():
  n = sys.stdin.readline().strip()

  part1 = nth(iterate(las, n), 40)
  print "part 1: ", len(part1)
  print "part 2: ", len(nth(iterate(las, part1), 10))
Example #7
0
def code(row, col):
  return nth(iterate(next_code, 20151125), ns(row, col))
Example #8
0
def getvalue(value, **rest):
  return nth(0,value)
Example #9
0
    def _dataget(url,u):
      def _data(d):
	def _value(v):
	  return v['value'] if v.has_key('value') else []
	return _value(d['data']) if d.has_key('data') else []
      return nth(0,_data(conngen(conn=makeconn(url),url=url,method='GET',headers={'Accept':'application/json'})))
Example #10
0
def main():
    n = sys.stdin.readline().strip()

    part1 = nth(iterate(las, n), 40)
    print "part 1: ", len(part1)
    print "part 2: ", len(nth(iterate(las, part1), 10))