CS110 Project 1 (PicoBot and HMMM) Swami Iyer Problem 1. (PicoBot: Empty Room Coverage) Write a PicoBot program empty_room.pb with rules that...
Hi, will any of you guys be able to do this hw? and please show step by step. thank you!
CS110 Project 1 (PicoBot and HMMM) Swami Iyer Problem 1. (PicoBot: Empty Room Coverage) Write a PicoBot program empty_room.pb with rules that instruct the bot tocover the entirety of an empty rectangular room. Your program should work regardless of how big the room is and regardlessof where the bot starts.$ python picobot . py -e env1 . txt < empty_room . pb...Coverage reached ! Problem 2. (Squared Distance) Write an HMMM program squared_distance.hmmm that takes four numbers x1 , y1 , x2 , y2 representing the coordinates of two points on a plane and prints the approximate squared Euclidean distance between the two,calculated as (x1 − x2 )2 + (y1 − y2 )2 .$ python hmmmSimulator . py -f s q u a r e d _ d i s t a n c e . b -n32-1525 Problem 3. (Sum of Ints) Write an HMMM program sum_of_ints.hmmm that takes a nonnegative integer n as input and printsthe sum 1 + 2 + 3 + · · · + (n − 1) + n.$ python hmmmSimulator . py -f sum_of_ints . b -n1005050 Problem 4. (Primality Testing) Write an HMMM program primality.hmmm that takes an integer n > √2 as input and prints1 if n is prime, and 0 otherwise. Hint: a number n is prime if it is not divisible by any number i ∈ [2, n].$ python hmmmSimulator . py -f primality . b -n311$ python hmmmSimulator . py -f primality . b -n350 Problem 5. (Euclid’s Algorithm, Iterative Approach) Write an HMMM program gcd_iter.hmmm that takes two nonnegativeintegers x and y as input and prints their greatest common divisor, calculated iteratively using Euclid’s Algorithm: if ydivides x, the gcd of x and y is y; otherwise, the gcd of x and y is the same as the gcd of y and x mod y, ie, in the nextiteration y takes the place of x and x mod y takes the place of y.$ python hmmmSimulator . py -f gcd_iter . b -n54246$ python hmmmSimulator . py -f gcd_iter . b -n22451 Problem 6. (Euclid’s Algorithm, Recursive Approach) Write an HMMM program gcd_rec.hmmm that takes two nonnegativeintegers x and y as input and prints their greatest common divisor (gcd), calculated recursively using Euclid’s Algorithm:(gcd(y, x mod y) if y 6= 0, andgcd(x, y) =xif y = 0. 1 of 2 CS110 Project 1 (PicoBot and HMMM) Swami Iyer $ python hmmmSimulator . py -f gcd_rec . b -n54246$ python hmmmSimulator . py -f gcd_rec . b -n22451 Files to Submit1. empty_room.pb2. squared_distance.hmmm3. sum_of_ints.hmmm4. primality.hmmm5. gcd_iter.hmmm6. gcd_rec.hmmm7. report.txt Before you submit:• Make sure your programs meet the input and output specifications by running the following command on theterminal:$ python run_tests . py [ < problems >] where the optional argument <problems> lists the numbers of the problems you want to test; all the problems aretested if no argument is given.• Make sure your report doesn’t exceed 400 lines, doesn’t contain spelling mistakes, and doesn’t contain lines thatexceed 80 characters. 2 of 2
Show more