Skip to content

Commit c53216f

Browse files
Merge pull request #55 from Hypercubers/leaderboard-tweaks
Leaderboard tweaks
2 parents 54a4fef + 6c8f346 commit c53216f

File tree

8 files changed

+140
-22
lines changed

8 files changed

+140
-22
lines changed

docs/javascripts/leaderboards.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
var shortList = document.getElementsByClassName("shorttime");
3+
var longList = document.getElementsByClassName("longtime");
4+
5+
function LongTime() {
6+
// switches to the long time format
7+
for (var i = 0; i < shortList.length; i++) {
8+
shortList[i].style.display = "none";
9+
longList[i].style.display = "block";
10+
}
11+
document.getElementById("long-time-format").classList.add("md-button--primary");
12+
document.getElementById("wca-time-format").classList.remove("md-button--primary");
13+
sessionStorage.setItem("timeFormat", "long");
14+
}
15+
16+
function ShortTime() {
17+
// switches to the short time format
18+
for (var i = 0; i < longList.length; i++) {
19+
longList[i].style.display = "none";
20+
shortList[i].style.display = "block";
21+
}
22+
document.getElementById("long-time-format").classList.remove("md-button--primary");
23+
document.getElementById("wca-time-format").classList.add("md-button--primary");
24+
sessionStorage.setItem("timeFormat", "short");
25+
26+
}
27+
28+
29+
30+
document.addEventListener("DOMContentLoaded", load);
31+
document.addEventListener("hashchange", load);
32+
33+
function load() {
34+
console.log("loaded thing");
35+
var format = sessionStorage.getItem("timeFormat");
36+
if (format == "short") {
37+
ShortTime();
38+
} else {
39+
LongTime();
40+
}
41+
}
42+
43+
load();
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Other Leaderboards
3+
---
4+
5+
# Other Leaderboards
6+
7+
8+
[Magic Cube 4D Hall of Fame](https://superliminal.com/cube/halloffame.htm)
9+
- The original Hall of Fame. New submissions are no longer accepted due to reaching 500 solvers.
10+
11+
[Magic Cube 4D Extended Records](http://wiki.superliminal.com/wiki/MC4D_Records)
12+
- Records for many other puzzles found in [MC4D](/software/magiccube4d.md).
13+
14+
[Magic Cube 5D Hall of Insanity](http://www.gravitation3d.com/magiccube5d/hallofinsanity.html)
15+
- List of everyone who has solved 2^5^-7^5^, and also FMC solutions.
16+
17+
[Magic Cube 7D Solvers](https://superliminal.com/andrey/mc7d/)
18+
- List of 6D and 7D solvers in MC7D.
19+
20+
[Magic 120 Cell Solvers](http://www.gravitation3d.com/magic120cell/index.html)
21+
- List of 120 cell solvers in M120C or MPU.
22+
23+
[MagicTile Klein Bottle challenge](http://roice3.org/magictile/mathologer/)
24+
- List of the first 100 people to solve the Klein Bottle Rubik's Cube from a [competition video](https://www.youtube.com/watch?v=DvZnh7-nslo) made by [Mathologer](https://www.youtube.com/@Mathologer).
25+
26+
[Speedsolving Wiki List of Unofficial World Records](https://www.speedsolving.com/wiki/index.php?title=List_of_Unofficial_World_Records#High_Dimensional_Puzzles)
27+
- List of a few speedsolving and FMC records.

leaderboards/generate_leaderboards.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,27 @@ def get_template(filename):
4040

4141
def format_time(duration) -> str: # duration: timedelta | int
4242
# duration can be timedelta (time) or int (movecount for fmc)
43+
44+
# gets the time in a short format (ex: 8:48:23.15)
45+
# converts duration into a string. Then it chops off leading 0's because a TimeDelta object has those for some reason
46+
shortTime = str(duration)
47+
if (shortTime.find(".") != -1): # if the string has a decimal point
48+
shortTime = shortTime[0:-4] # chop off the extra four 0's at the end if the time includes a non-integer number of seconds
49+
if (shortTime.find(".") == -1): # if the string does not have a decimal point, add ".00" to the end
50+
shortTime += ".00"
51+
52+
while shortTime[0:1] == "0": # while there are leading 0's to chop off
53+
shortTime = shortTime[1:len(shortTime)] # chop off leading 0
54+
if shortTime[0:1] == ":": # if next character is a colon
55+
shortTime = shortTime[1:len(shortTime)] # chop off colon
56+
57+
returnString = "<a class='shorttime'>" + shortTime + "</a><a class='longtime'>"
58+
59+
# code for geting time string in long format (ex: 8h 4m 32s 592ms)
4360
def unit(s):
4461
return f'<small>{s}</small>'
4562

63+
# this is if duration is actually FMC movecount, I think
4664
if isinstance(duration, int):
4765
return f"{duration:,}".replace(',', '\u2009')
4866

@@ -52,20 +70,27 @@ def unit(s):
5270

5371
minutes, seconds = divmod(seconds, 60)
5472
if minutes == 0:
55-
return f"{seconds}{unit('s')} {millis_str}"
73+
longTime = f"{seconds}{unit('s')} {millis_str}"
74+
return [longTime, shortTime]
5675
seconds_str = f"{seconds:02}{unit('s')}"
5776

5877
hours, minutes = divmod(int(minutes), 60)
5978
if hours == 0:
60-
return f"{minutes}{unit('m')} {seconds_str} {millis_str}"
79+
longTime = f"{minutes}{unit('m')} {seconds_str} {millis_str}"
80+
return [longTime, shortTime]
6181
minutes_str = f"{minutes:02}{unit('m')}"
6282

6383
days, hours = divmod(int(hours), 24)
6484
if days == 0:
65-
return f"{hours}{unit('h')} {minutes_str} {seconds_str} {millis_str}"
85+
longTime = f"{hours}{unit('h')} {minutes_str} {seconds_str} {millis_str}"
86+
return [longTime, shortTime]
6687
hours_str = f"{minutes:02}{unit('h')}"
6788

68-
return f"{days:,}{unit('d')} {hours_str} {minutes_str} {seconds_str} {millis_str}".replace(',', '\u2009')
89+
longTime = f"{days:,}{unit('d')} {hours_str} {minutes_str} {seconds_str} {millis_str}".replace(',', '\u2009')
90+
# return "<p class='shorttime'>" + shortTime + "</p><p class='longtime'>" + longTime + "</p>"
91+
# return returnString + longTime + "</a>"
92+
return [longTime, shortTime]
93+
6994

7095

7196
class Solve:
@@ -93,7 +118,7 @@ def __init__(self,
93118
formatted_time = format_time(self.time)
94119
self._cell_contents = {
95120
'date': self.date,
96-
'time': f'[{formatted_time}]({self.link})' if link else formatted_time,
121+
'time': f'<a class=\'longtime\' href={self.link}>{formatted_time[0]}</a><a style=\'display: none\' class=\'shorttime\' href={self.link}>{formatted_time[1]}</a>' if link else formatted_time,
97122
'event': self.event.name,
98123
'program': self.program,
99124
'solver': f'[{self.solver.name}]({self.solver.relative_file_path})',
@@ -104,12 +129,6 @@ def cell_contents(self, header):
104129
if self.rank is None:
105130
return ''
106131
emoji = ''
107-
# if 1 <= self.rank <= 3:
108-
# emoji = [
109-
# ':first_place: ',
110-
# ':second_place: ',
111-
# ':third_place: ',
112-
# ][self.rank-1]
113132
if self.rank == 1:
114133
emoji = ':trophy-gold-hypercube: '
115134
elif self.rank == 2:

leaderboards/templates/history.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ search:
55
---
66

77
# World Record History
8+
9+
<script src="/javascripts/leaderboards.js"></script>
10+
11+
??? note "View Options"
12+
| Time Format |
13+
| ------- |
14+
| <input type="button" id="long-time-format" class="md-button md-button--primary" value="Long (1m 00s 000ms)" onclick="LongTime()"/> |
15+
| <input type="button" id="wca-time-format" class="md-button" value="WCA (1:00.00)" onclick="ShortTime()"/> |

leaderboards/templates/leaderboards.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ search:
1010
<meta property="og:url" content="https://hypercubing.xyz/" />
1111
<meta property="og:image" content="https://assets.hypercubing.xyz/img/virt/mc4d_3x3x3x3.png" />
1212

13+
<script src="/javascripts/leaderboards.js"></script>
14+
1315
# Leaderboards
1416

15-
World record database for higher dimensional twisty puzzle speedsolving! Verification is done by the moderator team of the Hypercubers Discord. Please read the [submission rules](rules.md) carefully before submitting a request to add your time.
1617

17-
??? abstract "Other places that various records are kept:"
18-
- [Magic Cube 4D Hall of Fame](https://superliminal.com/cube/halloffame.htm)
19-
- [Magic Cube 4D Extended Records](http://wiki.superliminal.com/wiki/MC4D_Records)
20-
- [Magic Cube 5D Hall of Insanity](http://www.gravitation3d.com/magiccube5d/hallofinsanity.html)
21-
- [Magic Cube 7D Solvers](https://superliminal.com/andrey/mc7d/)
22-
- [Magic 120 Cell Solvers](http://www.gravitation3d.com/magic120cell/index.html)
23-
- [MagicTile Klein Bottle challenge](http://roice3.org/magictile/mathologer/)
24-
- [Speedsolving Wiki List of Unofficial World Records](https://www.speedsolving.com/wiki/index.php?title=List_of_Unofficial_World_Records#High_Dimensional_Puzzles)
18+
19+
20+
World record database for higher dimensional twisty puzzle speedsolving!
21+
2522

2623
[:material-format-list-numbered: Rules](https://hypercubing.xyz/leaderboards/rules/){{.md-button .md-button--primary}}
2724
[:material-plus-circle: Submit](https://forms.gle/Y7Vpi3pb8989Ay8W8){{.md-button .md-button--primary}}
2825

26+
??? note "View Options"
27+
| Time Format |
28+
| ------- |
29+
| <input type="button" id="long-time-format" class="md-button md-button--primary" value="Long (1m 00s 000ms)" onclick="LongTime()"/> |
30+
| <input type="button" id="wca-time-format" class="md-button" value="WCA (1:00.00)" onclick="ShortTime()"/> |
2931

30-
31-
Happy hypercubing!

leaderboards/templates/records.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ search:
55
---
66

77
# Current World Records :trophy-gold-hypercube:
8+
9+
<script src="/javascripts/leaderboards.js"></script>
10+
11+
??? note "View Options"
12+
| Time Format |
13+
| ------- |
14+
| <input type="button" id="long-time-format" class="md-button md-button--primary" value="Long (1m 00s 000ms)" onclick="LongTime()"/> |
15+
| <input type="button" id="wca-time-format" class="md-button" value="WCA (1:00.00)" onclick="ShortTime()"/> |

leaderboards/templates/solver.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@ title: {name}
33
search:
44
boost: 1
55
---
6+
7+
<script src="/javascripts/leaderboards.js"></script>
8+
9+
??? note "View Options"
10+
| Time Format |
11+
| ------- |
12+
| <input type="button" id="long-time-format" class="md-button md-button--primary" value="Long (1m 00s 000ms)" onclick="LongTime()"/> |
13+
| <input type="button" id="wca-time-format" class="md-button" value="WCA (1:00.00)" onclick="ShortTime()"/> |

leaderboards/test.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
date, link, time, program, solver, puzzle, format
2+
2048-01-01, 2xx_2XNxxfA, 12:08:16.71, HSC, rowan, hemimegaminx, single
3+
2048-01-02, 2xx_2XNxxfA, 3:21:22.23, M120C, vin, hemimegaminx, single
4+
2048-01-03, 2xx_2XNxxfA, 8:16.71, HSC, hactar, hemimegaminx, single
5+
2048-01-04, 2xx_2XNxxfA, 1.01, HSC, grant, hemimegaminx, single

0 commit comments

Comments
 (0)