diff --git a/layouts/index.html b/layouts/index.html
index ea23988b0..7ae47925e 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -60,6 +60,7 @@
🕰 Recent Puzzles
Puzzle |
Turns |
Score |
+ Percentile |
{{ range first 5 $wordles }}
@@ -68,6 +69,7 @@ 🕰 Recent Puzzles
{{ index .Params.puzzles 0 }} |
{{ partialCached "guess-count.html" . .File.Path }}{{- cond (eq .Params.state.hardMode true) "*" "" -}} |
{{ partialCached "puzzle-score.html" . .File.Path }} |
+ {{ (partialCached "puzzle-score-percentile.html" . .File.Path) | lang.FormatNumber 1 }}% |
{{ end }}
diff --git a/layouts/partials/puzzle-score-percentile.html b/layouts/partials/puzzle-score-percentile.html
new file mode 100644
index 000000000..32f4d59ee
--- /dev/null
+++ b/layouts/partials/puzzle-score-percentile.html
@@ -0,0 +1,18 @@
+{{ $score := partialCached "puzzle-score.html" . .File.Path }}
+{{ $wordles := where .Site.RegularPages "Section" "w" }}
+{{ $total := len $wordles }}
+{{ $less := 0 }}
+{{ $equal := 0 }}
+{{ range $puzzle := $wordles }}
+ {{ $otherScore := partialCached "puzzle-score.html" $puzzle $puzzle.File.Path }}
+ {{ if lt $otherScore $score }}
+ {{ $less = add $less 1 }}
+ {{ else if eq $otherScore $score }}
+ {{ $equal = add $equal 1 }}
+ {{ end }}
+{{ end }}
+{{ $percentile := 0.0 }}
+{{ if gt $total 0 }}
+ {{ $percentile = mul (div (float (add $less $equal)) $total) 100 }}
+{{ end }}
+{{ return $percentile }}
diff --git a/layouts/w/single.html b/layouts/w/single.html
index 2a02ad78f..438ac8476 100644
--- a/layouts/w/single.html
+++ b/layouts/w/single.html
@@ -268,7 +268,10 @@ {{.Title}}
- Puzzle Score: {{ partialCached "puzzle-score.html" . .File.Path }}
+ {{ $puzzleScore := partialCached "puzzle-score.html" . .File.Path }}
+ {{ $puzzlePercentile := partialCached "puzzle-score-percentile.html" . .File.Path }}
+ Puzzle Score: {{ $puzzleScore }}
+ (Percentile: {{ $puzzlePercentile | lang.FormatNumber 1 }}%)
{{ partialCached "puzzle-score-detail.html" . .File.Path }}