#P7869. Determine the Source System of a Text File

    ID: 21054 Type: Default 1000ms 256MiB

Determine the Source System of a Text File

Determine the Source System of a Text File

This problem is about identifying the operating system used to create a text file based on its newline escape sequences. In different systems, newlines are represented differently:

  • Windows uses the escape sequence \(\verb!\r\n!\)
  • Linux uses the escape sequence \(\verb!\n!\)
  • Mac uses the escape sequence \(\verb!\r!\)

You are given a non-empty text file (as a string) that contains only alphanumeric characters (both uppercase and lowercase), underscores, spaces, and newline escape sequences. The file was written on a single system so that the newline is represented by exactly one of the above patterns. Your task is to determine which system was used. Output windows if the file contains the Windows newline, linux if it contains the Linux newline, and mac if it contains the Mac newline.

Hint: Since the Windows format contains the substring \r\n (which includes both \r and \n), be sure to check for it before checking for the individual characters.

inputFormat

The input consists of a single string (possibly spanning multiple lines) representing the converted text file. All newline characters in the original file have been replaced by one of these explicit escape sequences: \r\n (Windows), \n (Linux), or \r (Mac).

outputFormat

Output a single line containing one of the strings: windows, linux, or mac, corresponding to the detected newline escape sequence in the input.

sample

Line1\r\nLine2\r\nLine3
windows