Midterm Practice Problems

These sample problems are maybe slightly harder than the problem that will appear on the actual midterm. Enjoy!

1. Reverse: Input a string. Print that string in reverse order. For example:

    ? Hello!
!olleH

2. Palindrome Check: Input a string. Print "yes" if that string is a "palindrome" (reads exactly the same backwards and forward). The palindrome must be exact, including spaces and capitalization. For example:

    ? AMANAPLANACANALPANAMA
yes


but

    ? ABLEWASIEREISAWELBOW
no

3. Digit Sum: Find the smallest positive integer whose digits add up to 23. The second smallest positive integer whose digits add up to 23 is 689.

4. Digit Product: Find the smallest positive integer whose digits multiply together to yield 567. The second smallest such number is 979.

5. Solve the first two problems at http://projecteuler.net.