Algorithmic exercises

Here you can find five quick exercises which will help you to understand basics of programming: conditional instructions, loops, logical operators and variables. During evaluation mentor will ask you to draw a flowchart for one of your solutions.

Modulo

Write a program which prints the top 25 three-digit natural numbers divisible by 7 or by 9. Each number should be displayed in a separate line.

The greatest common divisor

Write a program which takes two numbers from a command line and prints the greatest common divisor of them.

Present participle form

In English, the present participle is formed by adding the suffix - ing to the infinite form: go -> going.

  • A simple set of heuristic rules can be given as follows:
  • If the verb ends in e , drop the e and add - ing (if not exception: be, see, flee, knee , etc. )
  • If the verb ends in ie , replace ie with y and add - ing
  • For words consisting of consonant-vowel-consonant, double the final letter before adding - ing
  • By default just add - ing

Write the script which takes infinitive verbs separated by one space as the command line arguments and displays their present participle form in separated lines.

Anagrams

Write the anagram recogniser that accepts a file name from the user provided as the command line argument of the script, reads each line of that file, and displays in separated lines those pairs of word which are anagrams.

You can use for testing this sample file: anagrams.csv