Aurora Wednesday 18:30
Home > Aurora Wednesday 18:30 (Page 5)
Question:
When moving, ants form rows so that each ant except the first is behind another ant. It is not widely known what happens when two rows of ants moving in opposite directions run into each other in a passage too narrow for both rows to...
Question:
Rory is playing with an array A consisting of N integer elements indexed from 1 to N and a positive integer M. Rory will perform Q operations. Each operation is either type 1 or type 2.
Type 1 operation is in the form 1 l r x. You should add x to each element in A[l], A[l + 1],...
Question 1:
You take part in a competition and get good score. So you decide to add it to your resume. However, the released results only include the average rank for each of the attained scores. You think that might not be enough information, and want...
Question:
Today in gym class, your class decided to play dodgeball, and Jack is selected as one of the team captains! N students are lined up in a row, waiting to be put on teams. Jack is allowed to pick multiple students as long as they are adjacent...
Question:
Ken is working for the secret agency. He is going to send a secret message that encodes UPPERCASE words by shifting their letters forward.
Shifting a letter by S positions means to go forward S letters in the alphabet. For example, shifting B by S = 3 positions gives E. However, sometimes...
Question:
Being able to send encoded messages during World War II was very important to the Allies. The messages were always sent after being encoded with a known password. Having a fixed password was of course insecure, thus there was a need to change it frequently....
Before the invention of book-printing, it was very hard to make a copy of a book. All the contents had to be re-written by hand by so called scribers. The scriber had been given a book and after several months he finished its copy. One...
Question 1:
The hailstone sequence starting at a positive integer n is generated by following two simple rules. If n is even, the next number in the sequence is n/2. If n is odd, the next number in the sequence is 3*n+1. Repeating this process, we generate the hailstone sequence. Write a recursive function hailstone(n) which prints the...
Question 1:
Use recursion to write a function divides_all that consumes a list of positive integers seq and a positive integer factor. Your function should produce True if every item in seq is a multiple of factor and False otherwise. The helper function is_multiple has been provided for you.
Question 2:
Use recursion to write a function reverse that consumes a list seq and produces a new...
Question 1:
Use recursion to write a function has_digit that consumes a string and produces True if the string contains a digit (0 through 9) and False otherwise.
Hints:
Make sure that you have a base case.
Make sure to use the function on a shorter string.
Before calling the function,...