jweinst1
11/3/2016 - 7:24 AM

questions vrsion without answers

questions vrsion without answers

#Generator practice

#FizzBuzz Generator
"""
Implement a generator such that on each next() call, it yields the next
number in the FizzBuzz sequence. If a number is divisble by 3, it yields fizz,
if it's divisible by 5, it yields bizz, and if it's divisible by both, it yields fizzbuzz. Otherwise yields the number

   next(f)
=> 1
   next(f)
=> 2
   next(f)
=> 'Fizz'
   next(f)
=> 4
   next(f)
=> 'Buzz'
   next(f)
=> 'Fizz'
   next(f)
=> 7
   next(f)
=> 8
   next(f)
=> 'Fizz'
   next(f)
=> 'Buzz'
"""

def fizz_buzz():
	pass
		
#Generator that utilizes a function and arguments to continously call it recursively
def applier(func, start, inc):
	pass
		
		
		
#Challenge Problem: Growing Trees
#Implement a generator that starts with a binary tree with a value of 0. 
#In every subsequent two children, nodes with a value one greater than the previous are made.
#In each yield statement, the entire tree is yielded.
"""
   a = grow_trees()
=> None
   next(a)
=> (None)<--[0]-->(None)
   next(a)
=> ((None)<--[1]-->(None))<--[0]-->((None)<--[1]-->(None))
   next(a)
=> (((None)<--[2]-->(None))<--[1]-->((None)<--[2]-->(None)))<--[0]-->(((None)<--[2]-->(None))<--[1]-->((None)<--[2]-->(None)))
   next(a)
=> ((((None)<--[3]-->(None))<--[2]-->((None)<--[3]-->(None)))<--[1]-->(((None)<--[3]-->(None))<--[2]-->((None)<--[3]-->(None))))<--[0]-->((((None)<--[3]-->(None))<--[2]-->((None)<--[3]-->(None)))<--[1]-->(((None)<--[3]-->(None))<--[2]-->((None)<--[3]-->(None))))
"""
class bnode:
	
	def __init__(self, val, left=None, right=None):
		self.val = val
		self.left = left
		self.right = right
	def __repr__(self):
		return "({0})<--[{1}]-->({2})".format(self.left, self.val, self.right)
		
def grow_trees():
	pass