CHALLENGES

Back to home page
  • Mth to last element

    Sponsoring Company:

    Challenge Description:

    Write a program which determines the Mth to the last element in a list.

    Input sample:

    The first argument is a path to a file. The file contains the series of space delimited characters followed by an integer. The integer represents an index in the list (1-based), one per line.

    For example:

    a b c d 4 e f g h 2

    Output sample:

    Print to stdout the Mth element from the end of the list, one per line. If the index is larger than the number of elements in the list, ignore that input.

    For example:

    a g
Login to submit solution