all stats

Moja's stats

guessed the most

namecorrect guessesgames togetherratio
olus2000450.800
moshikoi240.500
chirk250.400
kimapr270.286
ponydork140.250
essaie150.200
LyricLy160.167
Dolphy170.143
yui050.000

were guessed the most by

namecorrect guessesgames togetherratio
Dolphy470.571
essaie250.400
moshikoi140.250
yui150.200
LyricLy160.167
kimapr170.143
ponydork040.000
chirk040.000
olus2000050.000

entries

round #70

submitted at
0 likes

guesses
comments 0

post a comment


cg70bot.py ASCII text
 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
import requests
import random

server_url="https://codeguessing.gay/extra/game70"

def get_grid(s):
    r = s.get(server_url)
    return r.json()["grid"]

def get_move(cp, tp, bp):
    (cx, cy)=cp
    (tx, ty)=tp
    dx = [-1, 1][cx < tx]
    dy = [-1, 1][cy < ty]
    if cx != tx and bp != (cx + dx, cy) and cy != ty and bp != (cx, cy + dy):
        return random.choice([cx < tx, 2 + (cy < ty)])

    if cx != tx and bp != (cx + dx, cy):
        return cx < tx
    if cy != ty:
        if bp != (cx, cy + dy):
            return 2 + (cy < ty)
        return random.randrange(0, 2)
    return random.randrange(2, 4)

def get_pos(thing, grid):
    idx = grid.find(thing)
    return (idx % 16, idx // 16)

def get_positions(grid):
    cp = get_pos("@", grid)
    tp = get_pos("+", grid)
    bp = get_pos("*", grid)
    return (cp, tp, bp)

def make_move_local(cp, move):
    (dx, dy) = [(-1, 0), (1, 0), (0, -1), (0, 1)][move]
    return (cp[0]+dx, cp[1]+dy)

def make_move_remote(s, move):
    move=["left", "right", "up", "down"][move]
    r = s.post(server_url, headers={"Content-Type": "application/json"}, json={"dir": move})
    return r.json()["grid"]

def make_move(s, grid):
    (cp, tp, bp) = get_positions(grid)
    while cp != tp:
        move = get_move(cp, tp, bp)
        cp = make_move_local(cp, move)
        make_move_remote(s, move)


def main():
    with requests.Session() as s:
        s.cookies = requests.utils.add_dict_to_cookiejar(s.cookies, {"session": ""})

        while True:
            grid=get_grid(s)
            print(grid)
            make_move(s, grid)

main()

round #69

submitted at
2 likes

guesses
comments 0

post a comment


cg.py ASCII text, with CRLF line terminators
 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
from math import pi, e, sqrt
import sys

max_float = sys.float_info.max
phi = (1. + sqrt(5))/2

ops = [
    (lambda x,y:x+y, "+", lambda x,y: True),
    (lambda x,y:x-y, "-", lambda x,y: True),
    (lambda x,y:x*y, "*", lambda x,y: True),
    (lambda x,y:x/y, "/", lambda x,y: y!=0.),
    (lambda x,y:x**y, "^", lambda x,y: x>0. and (y <= 1. or x <= max_float**(1/y))),
]

consts = [
    (1., "1"),
    (pi, "pi"),
    (e, "e"),
    (phi, "phi"),
]

num_symbols = len(ops)+len(consts)

def decode_op(number):
    global ops, num_symbols
    num_consts = len(consts)
    assert number%num_symbols >= num_consts
    (op, sop, cond) = ops[number%num_symbols-num_consts]
    return (op, sop, cond, number//num_symbols)

def decode_expr(number):
    global num_symbols, consts
    digit=number%num_symbols
    if digit < len(consts):
        (value, strep)=consts[digit]
        return (value, strep, number//num_symbols)
    (op, sop, cond, number)=decode_op(number)
    (l, sl, number)=decode_expr(number)
    if l is None:
        return (None, None, number)
    (r, sr, number)=decode_expr(number)
    if r is None or not cond(l, r): 
        return (None, None, number)
    return (op(l, r), f"{sl} {sr} {sop}", number)

inp = float(input("Enter number: "))
best_diff = float("inf")
current = 0

while best_diff > 0.:
    (number, strep, _) = decode_expr(current)
    if number is None:
        current += 1
        continue
    diff = abs(inp-number)
    if diff < best_diff:
        print(f"{strep} = {number}, (difference = {diff})")
        best_diff = diff
    current += 1

round #68

submitted at
0 likes

guesses
comments 0

post a comment


cg.py ASCII text, with CRLF line terminators
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
inp=input("enter text: ")
d=dict()
for i in inp:
    if not i.isalpha(): continue
    d.setdefault(i, 0)
    d[i]+=1

l=sorted(list(d.items()), key=lambda x: x[1])
l=["unknown"]*(26-len(l))+[i[0] for i in l]
print("letter -- possible match")

for i,j in zip(l, "zjqxkvbpgwyfmculdhrsnioate"):
    print(i, "--", j)

round #64

submitted at
1 like

guesses
comments 0

post a comment


dir las
description.txt ASCII text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
syntactically minimal lambda calculus

` = application
\ = abstraction
a-z = variables

variables are single character, and do not appear near their lambdas. 
Instead, a variable's position in the alphabet determines which lambda it refers to, 
starting from the topmost lambda with a, the second topmost being b, and so on.
(basically a reverse De Bruijn indexing. or De Bruijn levels 
(according to https://en.wikipedia.org/wiki/De_Bruijn_index#Alternatives_to_de_Bruijn_indices))

That's enough info, good luck trying to implement it!
las.lc ASCII text
1
2
3
4
`\```````\\\\\\\``a`\`\`jj\`i\``jjk\\``j\\``l\\`````hkm\``n\\`````hmp\```gdk`iq\
```gck`ine```gcke\```gbk`ile```gbkee``fbe\\`bc\\`b`bc\\`b`b`bc\\c\\\\``dbc\\\\\`
`eb\\``gcd``\\\\``c``bde``bed``\\\\`c``bde`\\\``cbd\\\```b\\`f`ec\d\e\``b\\\e\\c
\\``bcb\\`a`a`a`a`a`ab

round #62

submitted at
0 likes

guesses
comments 0

post a comment


62.py ASCII text
 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
import sys

def is_digit(c): return c in '0123456789'

lines=[]
fname=sys.argv[1]

open(fname, 'a').close()

with open(fname, "r+") as f:
    lines = f.readlines()

    print("> ", end='')
    sys.stdout.flush()
    for line in sys.stdin:
        line=line.lstrip()
        if line.rstrip() in ["quit", "q", "exit"]: break
        i=0
        while i<len(line) and is_digit(line[i]): i+=1
        loc=int(line[:i])-1
        line = line[i:].lstrip()
        if len(line)==0 or line[0] not in "ei":
            print(loc+1, "|", lines[loc])
        elif line[0] == 'e':
            lines[loc] = line[1:]
        elif line[0] == 'i':
            lines = lines[:loc] + [line[1:]] + lines[loc:]
        print("> ", end='')
        sys.stdout.flush()

    f.seek(0)
    f.writelines(lines)
    f.flush()

round #57

submitted at
2 likes

guesses
comments 0

post a comment


cg57.py ASCII text
 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
## Python Version 3.9.7
## There was no `golfing' tomfoolery involved.
## Forsake your place in   clementine  heaven.
## For eso-limes guessed a puzzle   is solved.
## Please keep handy the metaphorical  heaven
## (That  rose  out  of   Shakespeare's  hand)
## While d(r)iving into this  serpent's  land:
## https://www.gutenberg.org/cache/epub/100/pg100.txt


import random # We will be using random for **spIkiness** :D

def generate_markov_chain(data, len_ctx): # Self-explanatory.
    res = {}
    for i in range(len_ctx, len(data)):
        window=data[i-len_ctx:i]
        res.setdefault(window, {})
        res[window].setdefault(data[i], 0)
        res[window][data[i]] += 1

    for prev_chars, next_chars in res.items():
        res[prev_chars] = list(next_chars.items()), sum(next_chars.values())

    return res

def generate_next_ch(markov_chain): # Self-explanatory.
    prob, total = markov_chain
    c = random.randrange(total)
    for i, p in prob:
        if c < p: return i
        c-=p
    return

def generate_text(markov_chain, prompt, len_gen_text): # Self-explanatory.
    lookback = len(list(markov_chain.keys())[0])
    if len(prompt) < lookback: 
        return "Error: prompt not long enough"

    for i in range(len(prompt), len_gen_text+1):
        ctx = prompt[i-lookback:i]
        if ctx not in markov_chain:
            return f"Error: prompt '{ctx}' wasn't found *inside* Markov"

        c = generate_next_ch(markov_chain[ctx])
        if c is None: break
        prompt += c
    return prompt

with open("corpus.txt", mode="r", encoding="utf-8") as file:
    m=generate_markov_chain(file.read(), 5)
    file.close()

    while True:
        t=generate_text(m, input(), 2000)
        print(t)

round #56

submitted at
0 likes

guesses
comments 0

post a comment


lyric.c ASCII text
  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
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef enum {
    LIT,
    CAT,
    OR,
    NONE,
    END
} Tag;

typedef struct Ast Ast;

typedef union {
    char ch;
    Ast *children;
} Data;

struct Ast {
    Tag tag;
    Data data;
};

Ast create_lit(char c) {
    return (Ast){
        .tag = LIT,
        .data = 
            (Data){.ch = c}
        };
}

Ast create_seq(Ast* c, Tag tag) {
    return (Ast){
        .tag = tag,
        .data = 
            (Data){.children = c}
        };
}

void cleanup(Ast ast) {
    if (ast.tag != CAT || ast.tag != OR) return;
    
    Ast* children = ast.data.children;

    for (int i=0;children[i].tag != END; i++) {
        cleanup(children[i]);
    }

    free(ast.data.children);
}

void init(Ast *seq, int len, int cap) {
    Ast end = {END, (Data){ .children =  NULL}};
    for (int i=len; i < cap; i++) seq[i]=end;
}

void* expect_nonnull(void* ptr) {
    if (ptr == NULL) {
        fprintf(stderr, "Oh no, it looks like I got too hungry for yo computer... *smacks lips*\n");
        exit(EXIT_FAILURE);
    }
    return ptr;
}

int ensure_nuf_space(void** vec, int required_cap, int cap, int size) {
    while (required_cap >= cap) {
        cap*=2;
    }
    *vec = expect_nonnull(realloc(*vec, cap*size));
    return cap;
}

int parse(char*, Ast*);

int parse_next(char* input, Ast* ret) {
    if (input[0] == '(') {
        int c=0, i=1;
        for(; input[i] != ')' || c != 0; i++) {
            switch (input[i]) {
                case '(':
                    c++;
                    break;
                case ')':
                    c--;
                    break;
                case '\\':
                    i++;
                    break;
            }
        }

        input[i]=0;
        parse(&input[1], ret);
        input[i]=')';
        return i+1;
    }
    int offset = input[0]=='\\';
    *ret = create_lit(input[offset]);
    return offset + 1;
}

int parse(char* input, Ast* ret) {
    Ast end = create_seq(NULL, END);

    int len = 0, cap = 10, len2 = 0, cap2 = 10;
    Ast* seq = expect_nonnull(malloc(sizeof(Ast)*cap));

    Ast* ptr = expect_nonnull(malloc(sizeof(Ast)*cap2));
    seq[len++] = create_seq(ptr, CAT);

    int i=0;

    while (input[i]) {
        if (input[i] == '|') {
            seq[len-1].data.children[len2] = end;
            cap = ensure_nuf_space(&seq, len+2, cap, sizeof(Ast));
            i++;
            len2=0;
            cap2=10;
            Ast* ptr = expect_nonnull(malloc(sizeof(Ast)*cap2));
            seq[len++] = create_seq(ptr, CAT);
            continue;
        }
        
        Ast** currp = &seq[len-1].data.children;
        
        if (input[i] == '*') {
            cleanup((*currp)[--len2]);
            (*currp)[len2]=end;
            i++;
            continue;
        }

        cap2 = ensure_nuf_space(currp, len2+2, cap2, sizeof(Ast));

        Ast* curr = *currp;

        if (input[i] == '[') {
            curr[len2++]=create_seq(NULL, NONE);
            i+=2;
            continue;
        }

        i += parse_next(&input[i], &curr[len2++]);
    }

    seq[len-1].data.children[len2]=end;
    seq[len] = end;

    *ret = len == 1 ? seq[0] : create_seq(seq, OR);

    return i;
}

char* create_example(Ast ast) {
    switch (ast.tag) {
        case NONE:
        {
            return NULL;
        }
        case LIT:
        {
            char* a = expect_nonnull(malloc(sizeof(char)*2));
            a[0] = ast.data.ch;
            a[1] = 0;
            return a;
        }
        case OR:
        {
            Ast* children = ast.data.children;

            for (int i = 0; children[i].tag != END; i++) {
                char* segment = create_example(children[i]);
                if (segment != NULL) return segment;
            }

            return NULL;
        }
        case CAT:
        {
            int len = 0, cap = 10;
            char* res = expect_nonnull(malloc(sizeof(char)*cap));
            
            Ast* children = ast.data.children;

            for (int i = 0; children[i].tag != END; i++) {
                char* segment = create_example(children[i]);

                if (segment == NULL) {
                    free(res);
                    return NULL;
                }
                
                int l = strlen(segment);
                cap = ensure_nuf_space(&res, len+l+1, cap, sizeof(char));
                strcpy(&res[len], segment);
                len+=l;
            }

            res[len] = 0;
            return res;
        }
        case END: {}
    }
    return NULL;
}

int main(int argc, char *argv[]) {
    int cap=8, len=0;
    char* input=expect_nonnull(malloc(sizeof(char)*cap));

    while (1) {
        printf(">> ");
        fflush(stdout);

        char c;
        while ((c=getchar()) != '\n') {
            if (c==EOF) {
                free(input);
                return EXIT_SUCCESS;
            }
            cap = ensure_nuf_space(&input, len+2, cap, sizeof(char));
            input[len++]=c;
        }

        input[len]=0;

        Ast ast;

        parse(input, &ast);

        char* ex = create_example(ast);

        if (ex != NULL) {
            printf("%s\n", ex);
            free(ex);
        } else printf(":(\n");

        cleanup(ast);
        fflush(stdout);
    }
}