Skip to content

Instantly share code, notes, and snippets.

@cjblomqvist
Created January 13, 2016 12:01
Show Gist options
  • Save cjblomqvist/f36718588a7001d0562f to your computer and use it in GitHub Desktop.
Save cjblomqvist/f36718588a7001d0562f to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ITHS1._3
{
class Program
{
static void Main(string[] args)
{
List<int> a = new List<int>() { 1,3,5};
List<int> b = new List<int>() { 2, 4, 6, 8 };
List<int> newList = Zip(a, b);
newList.ForEach(item => Console.Write(item));
Console.WriteLine();
}
public static List<int> Zip(List<int> l1, List<int> l2)
{
List<int> newList = new List<int>();
int max = l1.Count;
if(l2.Count > max)
{
max = l2.Count;
}
for(int i = 0; i < max; i++)
{
if(i < l1.Count)
{
newList.Add(l1[i]);
}
if (i < l2.Count)
{
newList.Add(l2[i]);
}
}
return newList;
}
class ZipList<T>
{
public List<T> l { get; set; }
public ZipList(List<T> l)
{
this.l = l;
}
public static List<T> operator +(ZipList<T> a, ZipList<T> b)
{
// Zip code here
return null;
}
public static List<T> operator -(ZipList<T> a, ZipList<T> b)
{
// Unzip code here
return null;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment