Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Stuck_Zipper
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> first = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- List<int> second = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- List<int> firstIndex = new List<int>();
- List<int> secondIndex = new List<int>();
- for (int i = 0; i < first.Count; i++)
- {
- secondIndex.Add(first[i]);
- for (int j = secondIndex.Count - 1; j >= 0; j--)
- {
- if (Math.Abs(first[i]).ToString().Length > Math.Abs(secondIndex[j]).ToString().Length)
- {
- secondIndex.Remove(first[i]);
- }
- else if (Math.Abs(first[i]).ToString().Length < Math.Abs(secondIndex[j]).ToString().Length)
- {
- secondIndex.Remove(secondIndex[j]);
- }
- }
- }
- for (int i = 0; i < second.Count; i++)
- {
- firstIndex.Add(second[i]);
- for (int j = firstIndex.Count - 1; j >= 0; j--)
- {
- if (Math.Abs(second[i]).ToString().Length > Math.Abs(firstIndex[j]).ToString().Length)
- {
- firstIndex.Remove(second[i]);
- }
- else if (Math.Abs(second[i]).ToString().Length < Math.Abs(firstIndex[j]).ToString().Length)
- {
- firstIndex.Remove(firstIndex[j]);
- }
- }
- }
- for (int i = 0; i < firstIndex.Count; i++)
- {
- for (int j = 0; j < secondIndex.Count; j++)
- {
- if (Math.Abs(firstIndex[i]).ToString().Length > Math.Abs(secondIndex[i]).ToString().Length)
- {
- firstIndex.Remove(firstIndex[i]);
- }
- else if (Math.Abs(secondIndex[i]).ToString().Length > Math.Abs(firstIndex[i]).ToString().Length)
- {
- secondIndex.Remove(secondIndex[i]);
- }
- }
- }
- int maxCount = Math.Max(firstIndex.Count, secondIndex.Count);
- List<int> zipped = new List<int>();
- for (int i = 0; i <= maxCount; i++)
- {
- if (i < firstIndex.Count)
- {
- zipped.Add(firstIndex[i]);
- }
- if (i < secondIndex.Count)
- {
- zipped.Add(secondIndex[i]);
- }
- }
- Console.WriteLine(string.Join(" ", zipped));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement