Skip to content
Prev Previous commit
Next Next commit
Cleaned up C# source files
Removed trailing whitespace, changed line endings from CRLF to LF and removed the UTF-8 BOM
  • Loading branch information
Butt4cak3 committed Jun 9, 2018
commit 9483eb07b39ce2c9a52f84cf66cc4dae7473904f
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
// submitted by Julian Schacher (jspp) with great help by gustorn
using System;
using System.Collections.Generic;
namespace JarvisMarch
{
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("JarvisMarch");
// Example list of points.
// The points are represented by vectors here, but that doesn't really matter.
var points = new List<Vector>()
{
new Vector(1, 3),
new Vector(2, 4),
new Vector(4, 0),
new Vector(1, 0),
new Vector(0, 2),
new Vector(2, 2),
new Vector(3, 4),
new Vector(3, 1),
};
var jarvisMarch = new JarvisMarch();
var giftWrap = jarvisMarch.Run(points);
// Print the points of the gift wrap.
foreach (var point in giftWrap)
System.Console.WriteLine($"{point.x}, {point.y}");
}
}
}
// submitted by Julian Schacher (jspp) with great help by gustorn
using System;
using System.Collections.Generic;

namespace JarvisMarch
{
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("JarvisMarch");
// Example list of points.
// The points are represented by vectors here, but that doesn't really matter.
var points = new List<Vector>()
{
new Vector(1, 3),
new Vector(2, 4),
new Vector(4, 0),
new Vector(1, 0),
new Vector(0, 2),
new Vector(2, 2),
new Vector(3, 4),
new Vector(3, 1),
};
var jarvisMarch = new JarvisMarch();
var giftWrap = jarvisMarch.Run(points);

// Print the points of the gift wrap.
foreach (var point in giftWrap)
System.Console.WriteLine($"{point.x}, {point.y}");
}
}
}
48 changes: 24 additions & 24 deletions chapters/data_compression/huffman/code/cs/Program.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
// submitted by Julian Schacher (jspp), thanks to gustorn for the help
using System.Collections;
using System.Collections.Generic;
namespace HuffmanCoding
{
class Program
{
static void Main(string[] args)
{
var huffmanCoding = new HuffmanCoding();
var result = huffmanCoding.Encode("bibbity bobbity");
// The bitStrings are just strings and provide no compression. Look in HuffmanCoding.cs for explanation.
// Print dictionary.
foreach (var entry in result.Dictionary)
System.Console.WriteLine($"{entry.Key} {entry.Value}");
// Print BitString.
System.Console.WriteLine($"{result.BitString} count: {result.BitString.Length}");
var originalString = huffmanCoding.Decode(result);
System.Console.WriteLine(originalString);
}
}
// submitted by Julian Schacher (jspp), thanks to gustorn for the help
using System.Collections;
using System.Collections.Generic;

namespace HuffmanCoding
{
class Program
{
static void Main(string[] args)
{
var huffmanCoding = new HuffmanCoding();

var result = huffmanCoding.Encode("bibbity bobbity");
// The bitStrings are just strings and provide no compression. Look in HuffmanCoding.cs for explanation.
// Print dictionary.
foreach (var entry in result.Dictionary)
System.Console.WriteLine($"{entry.Key} {entry.Value}");
// Print BitString.
System.Console.WriteLine($"{result.BitString} count: {result.BitString.Length}");

var originalString = huffmanCoding.Decode(result);
System.Console.WriteLine(originalString);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// submitted by Julian Schacher (jspp) with great help by gustorn and Marius Becker
// submitted by Julian Schacher (jspp) with great help by gustorn and Marius Becker
using System.Collections.Generic;

namespace StableMarriageProblem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;

namespace StableMarriageProblem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// submitted by Julian Schacher (jspp) with great help by gustorn and Marius Becker
// submitted by Julian Schacher (jspp) with great help by gustorn and Marius Becker
using System.Collections.Generic;

namespace StableMarriageProblem
Expand Down
134 changes: 67 additions & 67 deletions chapters/decision_problems/stable_marriage/code/cs/Program.cs
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
// submitted by Julian Schacher (jspp) with great help by gustorn and Marius Becker
using System;
using System.Collections.Generic;
namespace StableMarriageProblem
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("GaleShapleyAlgorithm");
// Using men and women as an example.
var men = new List<Man>()
{
new Man("A"),
new Man("B"),
new Man("C"),
new Man("D"),
new Man("E")
};
var women = new List<Woman>()
{
new Woman("F"),
new Woman("G"),
new Woman("H"),
new Woman("I"),
new Woman("J"),
};
var random = new Random();
foreach (var man in men)
{
man.Choices = new List<Woman>(women).Shuffle(random);
Console.WriteLine(man.Name + ":");
foreach (var choice in man.Choices)
Console.Write(choice.Name);
Console.WriteLine();
}
foreach (var woman in women)
{
woman.Choices = new List<Man>(men).Shuffle(random);
Console.WriteLine(woman.Name + ":");
foreach (var choice in woman.Choices)
Console.Write(choice.Name);
Console.WriteLine();
}
GaleShapleyAlgorithm<Woman, Man>.RunGaleShapleyAlgorithm(women, men);
foreach (var woman in women)
{
Console.WriteLine(woman.Name + " : " + woman?.Partner.Name);
}
}
}
public class Man : Person<Man, Woman>
{
public Man(string name) : base(name) { }
}
public class Woman : Person<Woman, Man>
{
public Woman(string name) : base(name) { }
}
}
// submitted by Julian Schacher (jspp) with great help by gustorn and Marius Becker
using System;
using System.Collections.Generic;

namespace StableMarriageProblem
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("GaleShapleyAlgorithm");
// Using men and women as an example.
var men = new List<Man>()
{
new Man("A"),
new Man("B"),
new Man("C"),
new Man("D"),
new Man("E")
};
var women = new List<Woman>()
{
new Woman("F"),
new Woman("G"),
new Woman("H"),
new Woman("I"),
new Woman("J"),
};

var random = new Random();

foreach (var man in men)
{
man.Choices = new List<Woman>(women).Shuffle(random);
Console.WriteLine(man.Name + ":");
foreach (var choice in man.Choices)
Console.Write(choice.Name);
Console.WriteLine();
}
foreach (var woman in women)
{
woman.Choices = new List<Man>(men).Shuffle(random);
Console.WriteLine(woman.Name + ":");
foreach (var choice in woman.Choices)
Console.Write(choice.Name);
Console.WriteLine();
}

GaleShapleyAlgorithm<Woman, Man>.RunGaleShapleyAlgorithm(women, men);

foreach (var woman in women)
{
Console.WriteLine(woman.Name + " : " + woman?.Partner.Name);
}
}
}

public class Man : Person<Man, Woman>
{
public Man(string name) : base(name) { }
}

public class Woman : Person<Woman, Man>
{
public Woman(string name) : base(name) { }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// submitted by Julian Schacher (jspp)
// submitted by Julian Schacher (jspp)
using System;

namespace EuclideanAlgorithm
Expand Down
36 changes: 18 additions & 18 deletions chapters/euclidean_algorithm/code/cs/EuclideanAlgorithm/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// submitted by Julian Schacher (jspp)
using System;
namespace EuclideanAlgorithm
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("EuclideanAlgorithm");
int check = EuclideanAlgorithm.EuclidMod(64 * 67, 64 * 81);
int check2 = EuclideanAlgorithm.EuclidSub(128 * 12, 128 * 77);
Console.WriteLine(check);
Console.WriteLine(check2);
}
}
}
// submitted by Julian Schacher (jspp)
using System;

namespace EuclideanAlgorithm
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("EuclideanAlgorithm");
int check = EuclideanAlgorithm.EuclidMod(64 * 67, 64 * 81);
int check2 = EuclideanAlgorithm.EuclidSub(128 * 12, 128 * 77);

Console.WriteLine(check);
Console.WriteLine(check2);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// submitted by Julian Schacher (jspp)
// submitted by Julian Schacher (jspp)
namespace EuclideanAlgorithmMdAdditional
{
public class EuclideanAlgorithmMdAdditional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// submitted by Julian Schacher (jspp)
using System;
namespace EuclideanAlgorithmMdAdditional
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("EuclideanAlgorithmMdAdditional");
int checkMdAdditional = EuclideanAlgorithmMdAdditional.EuclidMod(64 * 67, 64 * 81);
int checkMdAdditional2 = EuclideanAlgorithmMdAdditional.EuclidSub(128 * 12, 128 * 77);
Console.WriteLine(checkMdAdditional);
Console.WriteLine(checkMdAdditional2);
}
}
}
// submitted by Julian Schacher (jspp)
using System;

namespace EuclideanAlgorithmMdAdditional
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("EuclideanAlgorithmMdAdditional");
int checkMdAdditional = EuclideanAlgorithmMdAdditional.EuclidMod(64 * 67, 64 * 81);
int checkMdAdditional2 = EuclideanAlgorithmMdAdditional.EuclidSub(128 * 12, 128 * 77);

Console.WriteLine(checkMdAdditional);
Console.WriteLine(checkMdAdditional2);
}
}
}
2 changes: 1 addition & 1 deletion chapters/sorting_searching/bogo/code/cs/BogoSort.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// submitted by Julian Schacher (jspp)
// submitted by Julian Schacher (jspp)
using System;
using System.Collections.Generic;

Expand Down
Loading