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
// Wikipedia: a way of coloring the vertices of a graph such that no two | |
// adjacent vertices share the same color; this is called a vertex coloring. | |
// Similarly, an edge coloring assigns a color to each edge so that no two adjacent | |
// edges share the same color, and a face coloring of a planar graph assigns a color to | |
// each face or region so that no two faces that share a boundary have the same color. | |
// In NP-complete | |
boolean mcolor(int i, int m, int n, bool [][] W, int [] vcolor, int n) | |
{ | |
// i: last colored vertex | |
// m: number of colors |
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
// From Wikipedia: Prim's algorithm is a greedy algorithm that | |
// finds a minimum spanning tree for a connected weighted undirected graph. | |
// This means it finds a subset of the edges that forms a tree that | |
// includes every vertex, where the total weight of all the edges in the tree is minimized. | |
void Prim(int n, int[][] W, int[] nearest) | |
{ | |
int[]distance | |
for( i = 1; i<=n; i++) | |
{ |
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
// From Wikipedia: For a given source vertex (node) in the graph, Dijkstra's algorithm finds the | |
// path with lowest cost (i.e. the shortest path) between that vertex and every other vertex. | |
void Dijkstra(int n, int [][] W, int source, int[] touch, int[] distance, int[totalCost]) | |
{ | |
int [] length | |
for(int i = 1; i<=n; i++) | |
{ | |
touch[i] = source | |
length[i] = W[source][i] | |
} |
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
// The eight queens puzzle is the problem of placing eight chess queens on an 8?8 | |
// chessboard so that no two queens attack each other. Thus, a solution requires that no two | |
// queens share the same row, column, or diagonal. The eight queens puzzle is an example of the more general | |
// n-queens problem of placing n queens on an n?n chessboard, | |
// where solutions exist for all natural numbers n with the exception of 2 and 3.[ | |
boolean promising (int i, int[] col) { | |
for (j=1; j<i; j++) { | |
if (col[i] == col[j]) { | |
return false; | |
} |
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
// Wikipedia: a graph analysis algorithm for finding shortest paths in a weighted graph | |
// (with positive or negative edge weights) and also for finding transitive closure of a | |
// relation R. A single execution of the algorithm will find the lengths (summed weights) | |
// of the shortest paths between all pairs of vertices, though it does not return details | |
// of the paths themselves. The algorithm is an example of dynamic programming. | |
public void floyd(int n, int[][] W, int[][] P, int[][] D) | |
{ | |
D = W; | |
for (int i = 0; i<n; i++) |
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
-(void) retrieveFromInternet { | |
NSURLRequest * request = [NSURLRequest requestWithURL: [self feedUrl]]; | |
NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; | |
NSString * pageSource = [[NSString alloc] initWithData: data encoding:NSUTF8StringEncoding]; | |
// NSLog(@"%@", pageSource); | |
[self setNewsStories: [self getHeadersAndSnippetsFromSource: pageSource]]; | |
} | |
- (NSArray *) getHeadersAndSnippetsFromSource: (NSString *) pageSource { | |
NSArray * feedItems = [pageSource componentsSeparatedByString:@"<item>"]; | |
NSMutableArray * titlesAndSnippets = [[NSMutableArray alloc]init]; |
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
// AddViewController- has fields where data is entered. | |
AddViewController.h | |
@protocol AddDelegate <NSObject> | |
-(void) saveMySeconds: (int) seconds andTitle: (NSString*)activity; | |
@end | |
//AddViewController.m | |
#pragma mark text field delegate method | |
-(BOOL)textFieldShouldReturn:(UITextField *)textField { // dismiss keyboard on return. | |
[textField resignFirstResponder]; | |
return YES; |
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
tell application "BBEdit" to set theFile to file of document 1 | |
tell application "Finder" to set theFolder to (container of file theFile) as alias | |
set theUnixPath to POSIX path of theFolder | |
tell application "iTerm" | |
activate | |
set myTerm to (make new terminal) | |
tell myTerm | |
launch session "Default" | |
set _session to current session | |
end tell |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>_className</key> | |
<string>PHXCardDAVSource</string> | |
<key>disabled</key> | |
<false/> | |
<key>homeInfo</key> |
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
### Keybase proof | |
I hereby claim: | |
* I am imightbewrong on github. | |
* I am njlash (https://keybase.io/njlash) on keybase. | |
* I have a public key whose fingerprint is 80C8 96A0 DBDB 120D ED97 C719 E99E 79CB E34C 6588 | |
To claim this, I am signing this object: |
OlderNewer