Question 1: Assume that you are given the results of 5 games of rock-paper-scissors. The outcomes are given to you on separate pieces of paper; each piece says either 'A' if the first person won, or 'B' if his opponent won.
Write an algorithm, in English, for finding out who won the best out of 5 games (person A or person B).
Question 2: What is wrong with the given algorithm for sorting a deck of cards (considering the fundamental properties of algorithms)?
a) Put the cards together into a pile.
b) For each card in the pile: Turn it face up.
c) Sort the cards.
Question 3: Write a detailed explanation of a function which takes in an integer as an argument, then prints out the squares of all positive integers whose squares are less than the input. (The squares are 1, 4, 9, 16, ... If the input was 5, it would print 1, 4. If the input was 10, it would print 1, 4, 9.)
Question 4: Write down a pseudocode algorithm to print the numbers from 1 to 10, and then from 10 to 1, by using exactly one loop.
Question 5: The function contains() takes a food as an argument and states you whether the pizza contains that food. Tomas is allergic to peanuts, tuna, and onions but strangely, eating peanuts and onions altogether is fine for him. Write a condition which finds out whether the pizza is safe for him to eat.