Skip to content

Commit de9369a

Browse files
committed
Add "Rock-paper-scissors-Spock-lizard" hole
1 parent 3459bfb commit de9369a

File tree

13 files changed

+93
-10
lines changed

13 files changed

+93
-10
lines changed

assets/build

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ GO
2626

2727
my ( %data, %paths );
2828

29-
for (<assets/*.{css,ico,js}>) {
29+
for ( (my $w = 'assets/twemoji.woff2'), <assets/*.{css,ico,js}> ) {
3030
say;
3131

3232
my $data = slurp($_);
@@ -45,11 +45,23 @@ GO
4545

4646
next;
4747
}
48+
elsif ( $_ eq 'twemoji.woff2' ) {
49+
$data{$name} = $data;
50+
my $path = $paths{$name} = '/assets/' . md5_base64($data) =~ y|+/|-_|r;
51+
52+
print $fh <<GO;
53+
case "$path":
54+
w.Write($name)
55+
GO
56+
57+
next;
58+
}
4859

4960
$data =~ s|/\* include ([^ ]+) +\*/|slurp("assets/includes/$1")|eg;
5061

5162
if (/\.css$/) {
5263
$data =~ s|svg\(([^#]+)(.+)\)|svg($1, $2)|eg;
64+
$data =~ s|twemojiWoff2|$paths{twemojiWoff2}|;
5365

5466
$data = run($data, 'csso');
5567
}

assets/common.css

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
@font-face {
2+
font-family: emoji;
3+
src: url('twemojiWoff2');
4+
unicode-range: U+2702, U+1F48E, U+1F4C4, U+1F596, U+1F98E;
5+
}
6+
17
body {
2-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
8+
font-family: emoji, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
39
font-size: 16px;
410
margin: 50px 0 0;
511
}
@@ -108,7 +114,7 @@ header nav img {
108114
pre,
109115
.CodeMirror,
110116
#hole table {
111-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
117+
font-family: emoji, 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
112118
}
113119

114120
select {
@@ -272,7 +278,10 @@ tr.me { background: #5cf }
272278
color: #fff;
273279
display: block;
274280
font-size: 26px;
281+
overflow: hidden;
275282
padding: 10px;
283+
text-overflow: ellipsis;
284+
white-space: nowrap;
276285
}
277286

278287
#home div > a:last-child {

assets/hole.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ aside > div {
1010
background: #fff;
1111
border: 2px solid #369;
1212
border-left: 0;
13-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
13+
font-family: emoji, 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
1414
height: 140px;
1515
overflow: auto;
1616
padding: 5px;
@@ -208,7 +208,8 @@ main nav a:nth-child(3):before {
208208
text-align: center;
209209
}
210210

211-
#alert a {
211+
#alert a,
212+
#preamble a {
212213
text-decoration: underline;
213214
}
214215

@@ -223,7 +224,7 @@ main nav a:nth-child(3):before {
223224
#arg span {
224225
background: #ddd;
225226
border-radius: 10px;
226-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
227+
font-family: emoji, 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
227228
line-height: 30px;
228229
padding: 3px 7px;
229230
white-space: pre;

assets/includes/codemirror.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
.CodeMirror {
44
/* Set height, width, borders, and global font properties here */
5-
font-family: monospace;
65
height: 300px;
76
color: black;
87
direction: ltr;

assets/twemoji.woff2

4.39 KB
Binary file not shown.

db.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ CREATE TYPE public.hole AS ENUM (
4444
'poker',
4545
'prime-numbers',
4646
'quine',
47+
'rock-paper-scissors-spock-lizard',
4748
'roman-to-arabic',
4849
'rule-110',
4950
'seven-segment',

holes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Gaming
2020
======
2121

2222
* Poker
23+
* Rock-paper-scissors-Spock-lizard
2324
* Sudoku
2425
* Ten-pin Bowling
2526

routes/render.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func Render(w http.ResponseWriter, r *http.Request, code int, name string, data
8282
"connect-src 'self';" +
8383
"default-src 'none';" +
8484
"form-action 'none';" +
85+
"font-src 'self';" +
8586
"frame-ancestors 'none';" +
8687
"img-src 'self' data: avatars.githubusercontent.com;" +
8788
"script-src 'self';" +
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package routes
2+
3+
import (
4+
"math/rand"
5+
"strings"
6+
)
7+
8+
var rockPaperScissorsSpockLizardGames = [...][2]string{
9+
{"💎💎", "Tie"},
10+
{"💎📄", "📄 covers 💎"},
11+
{"💎✂", "💎 crushes ✂"},
12+
{"💎🖖", "🖖 vaporizes 💎"},
13+
{"💎🦎", "💎 crushes 🦎"},
14+
{"📄💎", "📄 covers 💎"},
15+
{"📄📄", "Tie"},
16+
{"📄✂", "✂ cuts 📄"},
17+
{"📄🖖", "📄 disproves 🖖"},
18+
{"📄🦎", "🦎 eats 📄"},
19+
{"✂💎", "💎 crushes ✂"},
20+
{"✂📄", "✂ cuts 📄"},
21+
{"✂✂", "Tie"},
22+
{"✂🖖", "🖖 smashes ✂"},
23+
{"✂🦎", "✂ decapitates 🦎"},
24+
{"🖖💎", "🖖 vaporizes 💎"},
25+
{"🖖📄", "📄 disproves 🖖"},
26+
{"🖖✂", "🖖 smashes ✂"},
27+
{"🖖🖖", "Tie"},
28+
{"🖖🦎", "🦎 poisons 🖖"},
29+
{"🦎💎", "💎 crushes 🦎"},
30+
{"🦎📄", "🦎 eats 📄"},
31+
{"🦎✂", "✂ decapitates 🦎"},
32+
{"🦎🖖", "🦎 poisons 🖖"},
33+
{"🦎🦎", "Tie"},
34+
}
35+
36+
func rockPaperScissorsSpockLizard() ([]string, string) {
37+
args := make([]string, len(rockPaperScissorsSpockLizardGames))
38+
outs := make([]string, len(rockPaperScissorsSpockLizardGames))
39+
40+
for i, game := range rockPaperScissorsSpockLizardGames {
41+
args[i] = game[0]
42+
outs[i] = game[1]
43+
}
44+
45+
// Shuffle
46+
for i := range args {
47+
j := rand.Intn(i + 1)
48+
args[i], args[j] = args[j], args[i]
49+
outs[i], outs[j] = outs[j], outs[i]
50+
}
51+
52+
return args, strings.Join(outs, "\n")
53+
}

routes/solution.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ func solution(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
5050
args, out.Exp = poker()
5151
case "quine":
5252
out.Exp = in.Code
53+
case "rock-paper-scissors-spock-lizard":
54+
args, out.Exp = rockPaperScissorsSpockLizard()
5355
case "seven-segment":
5456
args = make([]string, 1)
5557
args[0], out.Exp = sevenSegment()

0 commit comments

Comments
 (0)