### 2017-02-13 HW

posted Feb 13, 2017, 6:42 AM by Samuel Konstantinovich   [ updated Feb 14, 2017, 6:26 AM ]
 Today's Homework:     Complete Codingbat set3 (hailstone)OLD HOMEWORK REMINDER: (I will not remind you in the future to keep up with codingbat)To avoid penalties and understand the work we are doing next, you MUST complete ALL codingbat problems assigned. This includes the following currently:1) Warmup-1:    make10,    sleep_in,    monkey_trouble,    diff21,        parrot_trouble,    makes10,    near_hundred,    pos_neg2) Logic-1:  sorta_sum,      near_ten,      love63) Logic-2:  lone_sum,      lucky_sum,    no_teen_sum4) Custom Problems: *edit* you can access set2 any way you want. It works both ways.http://codingbat.com/home/konstans@stuy.edu/set1http://codingbat.com/home/konstans@stuy.edu/set2http://codingbat.com/home/konstans@stuy.edu/set3  * this is new as of today *Goal: Generating a sequence with a loop.The hailstone sequence starts at any natural number, and always terminates with the value 1.To generate the sequence you follow a simple set of rules:if n = 1 : doneif n is even: the next number is n / 2if n is odd: the next number is 3 * n + 1So hailstone sequences starting with the first 6 values:12 1 3 10 5 16 8 4 2 14 2 15 16 8 4 2 16 3 10 5 16 8 4 2 1...Write a function printHail(n) that will print the hailstone sequence (on one line for readability)You can print with a comma at the end of the line to prevent the new line from printinge.g.print 5,print 6outputs:5 6Normally we don't print out things, instead we return them. We know the starting/ending number of each sequence, so that isn't a useful thing to return. Something we cannot predict is the length of the sequence!Write a function that calculates the length of a hailstone sequence that starts with n: (look at the example sequences above to see why!) n ->  hailLen(n)1 -> 12 -> 23 -> 84 -> 35 -> 66 -> 9...