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
#include <stdio.h> | |
#define N 9 | |
#define B 3 //square root of N | |
int canBePlaced(int board[], int pos, int x) | |
{ | |
int row=pos/N; | |
int col=pos%N; | |
int i, j, topLeft; |
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
0 | 0 | 0 | 0 | 0 | 0 | 7 | 0 | 0 | 0 | 0 | 0 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 4 | |
0 | 0 | 10 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
0 | 0 | 0 | 0 | 5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 4 | 0 | |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 0 | 0 | |
0 | 0 | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | |
0 | 0 | 0 | 0 | 0 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | |
9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
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
data = Import["https://gist.github.com/taroyabuki/4749183/raw/ffc84dbc4a3499ddef4a8c4f689b56c2948225bd/clustering_test_data.csv"]; | |
(* This returns no result *) | |
FindClusters[data, DistanceFunction -> CosineDistance, | |
Method -> {"Agglomerate", "Linkage" -> "Complete"}] | |
(* Shuffled data can be clustered. *) | |
FindClusters[RandomSample@data, DistanceFunction -> CosineDistance, | |
Method -> {"Agglomerate", "Linkage" -> "Complete"}] |
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
install.packages("RCurl") | |
install.packages("lsa") | |
library(RCurl) | |
url <- getURL("https://gist.github.com/taroyabuki/4749183/raw/ffc84dbc4a3499ddef4a8c4f689b56c2948225bd/clustering_test_data.csv", ssl.verifypeer = F) | |
data <- read.csv(textConnection(url), header = F) | |
library(lsa) | |
d <- dist(1 - cosine(t(as.matrix(data)))) | |
hr <- hclust(d, method = "complete") |
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
samples <- data.frame( | |
x = c(3, 7, 10), | |
y = c(7, 1, 8), | |
row.names = c("A", "B", "C")) | |
plot(samples, type = "n") | |
text(samples[,1], samples[,2], row.names(samples)) | |
d <- dist(samples) |
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
Needs["HierarchicalClustering`"] | |
data = Import["https://gist.github.com/taroyabuki/4749183/raw/ffc84dbc4a3499ddef4a8c4f689b56c2948225bd/clustering_test_data.csv"]; | |
clusters = Agglomerate[data, DistanceFunction -> CosineDistance, Linkage -> "Complete"]; | |
On[Assert]; | |
Assert[Length@ClusterFlatten@clusters == Length@data] | |
{Length@ClusterFlatten@clusters, Length@data} |
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
0.07832604499879574 | 0. | 0. | 0. | 0.2170723815877265 | 0. | 0. | 0. | 0. | 0. | 0. | 0. | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0. | 0. | 0. | 0. | 0. | 0.6432675209026769 | 0. | 0. | 0. | 0. | 0. | 0. | |
0. | 0. | 0. | 0. | 0. | 0. | 0. | 0. | 0.5601120336112039 | 0. | 0. | 0. | |
0. | 0. | 0. | 0. | 0. | 0. | 0. | 0. | 0. | 0. | 0.20965696734438366 | 0.24253562503633297 | |
0. | 0. | 0.5312532024908597 | 0.23791547571544325 | 0. | 0. | 0. | 0. | 0. | 0. | 0. | 0. | |
0. | 0.15961737689352443 | 0. | 0.15861031714362883 | 0. | 0. | 0. | 0. | 0. | 0. | 0. | 0. | |
0. | 0. | 0. | 0. | 0. | 0.5360562674188974 | 0. | 0. | 0. | 0. | 0. | 0. | |
0. | 0. | 0. | 0. | 0. | 0. | 0. | 0. | 0.42008402520840293 | 0. | 0. | 0. | |
0. | 0. | 0. | 0.4758309514308865 | 0. | 0. | 0. | 0. | 0. | 0. | 0. | 0. | |
0.15665208999759148 | 0.15961737689352443 | 0. | 0. | 0. | 0. | 0. | 0. | 0. | 0. | 0.20965696734438366 | 0.48507125007266594 |
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
<?php | |
session_start(); | |
$oauth = new OAuth($_SESSION['consumer_key'], $_SESSION['consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI); | |
if (substr(PHP_OS, 0, 3) == 'WIN') { | |
$caPath = 'C:/xampp/perl/vendor/lib/Mozilla/CA/'; | |
$caInfo = "${caPath}cacert.pem"; | |
$oauth->setCAPath($caPath, $caInfo); | |
} |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Twitter OAuth Post</title> | |
</head> | |
<body> | |
<?php | |
session_start(); |
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
<?php | |
session_start(); | |
session_destroy(); | |
?> | |
<!doctype html> | |
<html> | |
<head> | |
<title>Logout</title> | |
</head> | |
<body> |