This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static string Caesar(string value, int shift) | |
| { | |
| char[] buffer = value.ToCharArray(); | |
| for (int i = 0; i < buffer.Length; i++) | |
| { | |
| // Letter. | |
| char letter = buffer[i]; | |
| // Add shift to all. | |
| letter = (char)(letter + shift); | |
| // Subtract 26 on overflow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AtbashTable | |
| { | |
| /// <summary> | |
| /// Lookup table to shift characters. | |
| /// </summary> | |
| char[] _shift = new char[char.MaxValue]; | |
| /// <summary> | |
| /// Generates the lookup table. | |
| /// </summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static int Fibonacci(int n) | |
| { | |
| int a = 0; | |
| int b = 1; | |
| // In N steps compute Fibonacci sequence iteratively. | |
| for (int i = 0; i < n; i++) | |
| { | |
| int temp = a; | |
| a = b; | |
| b = temp + b; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static bool IsPalindrome(string value) | |
| { | |
| int min = 0; | |
| int max = value.Length - 1; | |
| while (true) | |
| { | |
| if (min > max) | |
| { | |
| return true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void Shuffle<T>(T[] array) | |
| { | |
| var random = _random; | |
| for (int i = array.Length; i > 1; i--) | |
| { | |
| // Pick random element to swap. | |
| int j = random.Next(i); // 0 <= j <= i-1 | |
| // Swap. | |
| T tmp = array[j]; | |
| array[j] = array[i - 1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Dijkstra | |
| { | |
| private int rank = 0; | |
| private int[,] L; | |
| private int[] C; | |
| public int[] D; | |
| private int trank = 0; | |
| public Dijkstra(int paramRank,int [,]paramArray) | |
| { | |
| L = new int[paramRank, paramRank]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static double NextGaussianDouble(this Random r) | |
| { | |
| double U, u, v, S; | |
| do | |
| { | |
| u = 2.0 * r.NextDouble() - 1.0; | |
| v = 2.0 * r.NextDouble() - 1.0; | |
| S = u * u + v * v; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| namespace SampleApp | |
| { | |
| internal class Program | |
| { | |
| private static void Main() | |
| { | |
| List<double> data = new List<double> {1, 2, 3, 4, 5, 6}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Linq; | |
| using NUnit.Framework; | |
| [TestFixture] | |
| public class Levenshtein { | |
| public static int EditDistance (string original, string modified) | |
| { | |
| if (original == modified) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function buildApiRequest() { | |
| var address = $('#street1').value.replace(/ /gi, '+') + ',+'; | |
| address += $('#city').value.replace(/ /gi, '+') + ',+'; | |
| return 'http://maps.googleapis.com/maps/api/geocode/json?address=' + address + $('#state').value + '&sensor=false'; | |
| } |