1. Assume an input file of the following format is provided:

    N
    i_1
    i_2
    ...
    i_N
    

    N is the number of integers below in the file. i_1…i_N are the integers.

    Write a program that reads the integers from the file and writes them in a new file. The output file must contain the number of integers first, then odd integers in the same order as in the input file, and then even integers in the same order as in the output file.

    Example:

    Input:

    5
    4
    3
    5
    2
    9
    

    Output:

    5
    3
    5
    9
    4
    2
    
  2. Implement a program that creates a file that contains all prime numbers up to a given n.

    Consider implementing the sieve of Eratosthenes.

    Example. For n = 10

    2
    3
    5
    7
    11
    13
    17
    19
    23
    29
    31
    
  3. Assume the number of rows n and the number of columns m are given.

    Write a program that writes a rectangular grid with n rows and m columns to a file.

    Example. For n = 4 and m = 5.

    ┌──┬──┬──┬──┬──┐
    │  │  │  │  │  │
    ├──┼──┼──┼──┼──┤
    │  │  │  │  │  │
    ├──┼──┼──┼──┼──┤
    │  │  │  │  │  │
    ├──┼──┼──┼──┼──┤
    │  │  │  │  │  │
    └──┴──┴──┴──┴──┘
    
  4. Write a program that reads a text from a file and prints the number of words in the text. The words are separated by following characters: space (‘ ‘) or new line (‘\n’) or tab (‘\t’) or a combination of these.

    Example. For the text

    Hello! I love programming!
       
    Twinkle
         Twinkle
             Little star
    

    the output is 8.