This style guide is based on C# and Unity conventions.
This file contains 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 class Distance | |
{ | |
public static double Levenshtein(string source, string target) | |
{ | |
if (source.Length == 0) | |
return target.Length; | |
if (target.Length == 0) | |
return source.Length; |
This file contains 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
// hard-code that the item will always have children | |
hasChildren: true | |
// map the hasChildren property to the hasSubordinates field, serialized from the server | |
hasChildren: "hasSubordinates" | |
// compute whether the given item will have children | |
hasChildren: function(item) { | |
return item.hasEmployees && item.relatedDepartment; | |
} |
This file contains 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 class RSQLog | |
{ | |
private int[] A; | |
private int[,] sparseTable; | |
private int[] logTable; | |
public RSQLog(int[] A) | |
{ | |
this.PrecomputeSparseTable(A); | |
} |
This file contains 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 class RMQLog | |
{ | |
private int[] A; | |
private int[,] sparseTable; | |
private int[] logTable; | |
public RMQLog(int[] A) | |
{ | |
this.PrecomputeSparseTable(A); | |
} |
This file contains 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
/* | |
Solves both Range Minimum Query & Lowest Common Ancestor | |
in O(n) space & O(1) query time following Farach-Colton and Bender's algorithm. | |
Reference: https://www.ics.uci.edu/~eppstein/261/BenFar-LCA-00.pdf | |
*/ | |
using System.Collections.Generic; | |
using System.Linq; | |
public class RMQLin | |
{ |
This file contains 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
protected void Application_Start(object sender, EventArgs e) | |
{ | |
Bootstrapper.Initialized += this.BootstrapperInitializedHook; | |
} |
This file contains 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
/* | |
S -> aAe | |
A -> bAd | c | |
*/ | |
const parse = (() => { | |
let tokens; | |
let pos = 0; | |
const peek = () => tokens[pos]; | |
const eat = token => { |
This file contains 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
#!/bin/sh | |
cs_files="$(git diff --name-only --cached --diff-filter=d | grep -E '\.cs$')" | |
if [ -n "$cs_files" ]; then | |
cs_files_seperated_by_comma="$(echo $cs_files | tr ' ' ,)" | |
dotnet format --workspace <Project-Root> --files $cs_files_seperated_by_comma | |
git add $cs_files | |
fi |
OlderNewer