#K65572. AlphaLang List Evaluator

    ID: 32227 Type: Default 1000ms 256MiB

AlphaLang List Evaluator

AlphaLang List Evaluator

You are given an expression written in AlphaLang which supports operations on lists. There are three built-in functions:

  • repeat(list, n): Repeats the list n times.
  • merge(list1, list2): Merges two lists by alternating elements. If one list is longer, the remaining elements are appended.
  • slice(list, a, b): Extracts a sublist starting at index a and ending before index b. (In mathematical notation: $$L[a:b]$$.)

The expression may combine these functions in a nested manner. Your task is to evaluate the given expression and print out the resulting list in the standard list format.

inputFormat

The input consists of a single line read from stdin representing an AlphaLang expression. The expression can use nested operations. For example:

slice(repeat([0, 1], 5), 2, 8)

All function names are case-insensitive, and spaces may appear arbitrarily.

outputFormat

Print the resulting list to stdout in the standard Python list format. For example:

[0, 1, 0, 1, 0, 1]
## sample
repeat([1, 2], 3)
[1, 2, 1, 2, 1, 2]