Write a program that converts a temperature in Fahrenheit to Celsius.
Write a program that counts the number of vowels in a given string.
Write a program that outputs the Collatz sequence starting from a given number.
Write a function that returns true
if a given vector
contains duplicate
elements.
Write a function that simulates the roll of a given number of fair six-sided
dice, and returns a vector
of the numbers obtained.
Write a function that simulates the roll of a given number of fair six-sided
dice, and returns true
if at least two dice show the same number.
Next, write a program that simulates the above a given number of times, and outputs the proportion of times when at least two dice showed the same number.
Write a function that simulates a given number of fair coin flips, and returns the length of the longest run of heads.
Next, write a program that simulates the above a given number of times, and outputs the mean length of the longest run of heads.
Note: this problem was part of the 2017 Qualification Round for the Google Code Jam contest. Have a look at past contests for many more challenging problems!
Tatiana likes to keep things tidy. Her toys are sorted from smallest to largest, her pencils are sorted from shortest to longest and her computers from oldest to newest. One day, when practicing her counting skills, she noticed that some integers, when written in base 10 with no leading zeroes, have their digits sorted in non-decreasing order. Some examples of this are 8, 123, 555, and 224488. She decided to call these numbers tidy. Numbers that do not have this property, like 20, 321, 495 and 999990, are not tidy.
She just finished counting all positive integers in ascending order from 1 to N. What was the last tidy number she counted?