Задача 5.* Tear List in Half от курса Programming Fundamentals 2017 Extended
Здравейте, може ли някой да ми даде идея как да въвеждам всеки път на дадена позиция елементите от втория лист? Ето го кода: http://pastebin.com/PkT8kjui . Прикачвам и условието. Благодаря предварително.
1. * Tear List in Half
You will receive a list of integers on the first input line (space-separated). Your task is to separate the list into two parts and perform the following operations:
Assume you have the following initial list: |
|
Split the list into 2 equal parts and stack the right half on top of the left half: |
|
Place each digit of the upper list elements on either side of the lower list: |
|
After you perform the operations, print the resulting list on the console.
Constraints
The count of the input list elements will always be even and the elements will always be between 10 and 99.
Examples
Input |
Output |
11 22 33 45 14 12 |
4 11 5 1 22 4 1 33 2 |
82 77 12 84 92 11 |
8 82 4 9 77 2 1 12 1 |
11 12 13 14 15 16 17 18 |
1 11 5 1 12 6 1 13 7 1 14 8 |
Hints
- There is a certain arithmetic progression which can help you solve this problem:
- Simulate the splitting list -> splitting numbers into digits -> inserting to the left and right of the element action several times and pay attention to the indices you are inserting the numbers into.
- Do this several times and you will find the progression by yourself.
- It is the key to seeing at which index you need to insert the elements each time and it works no matter how many elements the list has as long as you follow it.
Благодаря !