Simple Programming Problems
Simple Programming Problems
13.Write a function that computes the list of the first 100 Fibonacci
numbers.
14.Write a function that takes a number and returns a list of its digits.
15.Write functions that add, subtract, and multiply two numbers in
their digit-list representation (and return a new digit list). If youre
ambitious you can implement Karatsuba multiplication. Try different
bases. What is the best base if you care about speed? If you
couldnt completely solve the prime number exercise above due to
the lack of large numbers in your language, you can now use your
own library for this task.
16.Implement the following sorting algorithms: Selection sort, Insertion
sort, Merge sort, Quick sort, Stooge Sort. Check Wikipedia for
descriptions.
17.Implement binary search.
18.Write a function that takes a list of strings an prints them, one per
line, in a rectangular frame. For example the list ["Hello", "World",
"in", "a", "frame"] gets printed as:
19.*********
20.* Hello *
21.* World *
22.* in
23.* a
24.* frame *
*********
25.Write function that translates a text to Pig Latin and back. English is
translated to Pig Latin by taking the first letter of every word,
moving it to the end of the word and adding ay. The quick brown
fox becomes Hetay uickqay rownbay oxfay.
Intermediate
1. Write a program that outputs all possibilities to put + or - or nothing
between the numbers 1,2,,9 (in this order) such that the result is
100. For example 1 + 2 + 3 - 4 + 5 + 6 + 78 + 9 = 100.
2. Write a program that takes the duration of a year (in fractional
days) for an imaginary planet as an input and produces a leap-year
rule that minimizes the difference to the planets solar year.