Skip to content

Instantly share code, notes, and snippets.

@bcrisp
Created December 13, 2013 03:37
Show Gist options
  • Save bcrisp/7939460 to your computer and use it in GitHub Desktop.
Save bcrisp/7939460 to your computer and use it in GitHub Desktop.
Unique Pairs Sketch of correctness: Case for single element: let an array of non-negative integers "val" have one element, such that the sole index is i = j = 0. If val[i] + val[j] = 100 (i.e. val[0] = 50) then output the values, otherwise return void. Proof by contradiction: let some value j < i result in val[j] + val[i] = 100. Now since i rang…
using System;
using System.Collections.Generic;
namespace gauss
{
class MainClass
{
public static void Main (string[] args)
{
int[] nums = new int[]{0, 1, 100, 99, 0, 10, 90, 30, 55, 33, 55, 75, 50, 51, 49, 50, 51, 49, 51};
List<int> myList = new List<int>();
for (int i = 0; i < nums.Length; i++) {
if(!myList.Contains(nums[i]))
{
myList.Add(nums[i]);
}
}
for (int i = 0; i < myList.Count; i++) {
for (int j = i; j < myList.Count; j++) {
if (myList[i] + myList[j] == 100)
Console.WriteLine(myList[i] + " " + myList[j]);
}
}
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment