This repository has been archived by the owner on Jan 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
coverage.Rmd
97 lines (78 loc) · 2.2 KB
/
coverage.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
title: "Coverage"
output: html_document
---
```{r setup, include=FALSE}
library(printr)
knitr::opts_chunk$set(echo = FALSE)
```
```{r init}
coverage <- function() {
fileNames <- list.files(pattern="euler[0-9]{4}[.][a-zA-Z]+",recursive=T)
truncatedNames <- gsub("/euler[0-9]{4}", "", fileNames)
rawSolvedProblems <- unlist(strsplit(truncatedNames, split="[.]"))
solvedProblems <- matrix(FALSE, nrow=length(rawSolvedProblems)/2, ncol=2)
solvedProblems[,1] <- rawSolvedProblems[seq(2,length(rawSolvedProblems),by=2)]
solvedProblems[,2] <- rawSolvedProblems[seq(1,length(rawSolvedProblems),by=2)]
usedLanguages <- sort(unique(solvedProblems[,1]))
problemNrs <- unique(solvedProblems[,2])
solvedStateMatrix <- matrix(data=FALSE,nrow=length(usedLanguages),ncol=length(problemNrs))
rownames(solvedStateMatrix) <- usedLanguages
colnames(solvedStateMatrix) <- problemNrs
solvedStateMatrix[solvedProblems] <- TRUE
solvedStateMatrix
}
summary.coverage <- function(x) {
mostFrequent <- max(x)
mostFrequentName <- names(which(x == mostFrequent, x))
result <- structure(
.Data=list(
rawData=x,
data=data.frame(factor(names(x)), x),
max=mostFrequent,
maxName=mostFrequentName
)
)
result
}
coverageMat <- coverage()
langStats <- summary.coverage(rowSums(coverageMat))
problemStats <- summary.coverage(colSums(coverageMat))
w <- writeLines
```
## General
```{r general1}
foo <- coverageMat
foo[foo==T] <- "✔"
foo[foo==F] <- "✘"
t(foo)
```
```{r general2}
texts <- c("Total languages used:", "Total problems solved:")
values <- c(nrow(coverageMat), ncol(coverageMat))
as.matrix(paste(texts, values))
```
## Language Statistics
### Data:
```{r languages1}
as.matrix(t(langStats$rawData))
```
```{r languages2}
plot(langStats$data)
```
### Most used language(s):
```{r languages3}
as.matrix(paste(langStats$maxName, "with", langStats$max, "solved problems"))
```
## Problems Statistics
### Data:
```{r problems1}
problemStats$rawData
```
```{r problems2}
plot(problemStats$data)
```
### Most solved problem(s):
```{r problems3}
as.matrix(paste(problemStats$maxName, "with", problemStats$max, "solutions"))
```