Skip to content

Instantly share code, notes, and snippets.

@Koitaro
Created August 21, 2012 17:46
Show Gist options
  • Select an option

  • Save Koitaro/3417801 to your computer and use it in GitHub Desktop.

Select an option

Save Koitaro/3417801 to your computer and use it in GitHub Desktop.
R: Project Euler 70-79
2 + (1000000-5) %/% 7 * 3
library(partitions)
P(100)
library(igraph)
g <- graph.empty() + vertices(0:9)
for (line in strsplit(readLines("keylog.txt"), "")) {
n <- as.numeric(line) + 1
g <- g + edges(c(n[1], n[2], n[2], n[3]))
}
vs <- numeric(0)
for (v in V(g)) {
if (length(neighbors(g, v, mode="all")) == 0) vs <- c(vs, v)
}
g <- g - vertices(vs)
V(g)[topological.sort(g)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment