all stats

Kaylynn's stats

guessed the most

namecorrect guessesgames togetherratio

were guessed the most by

namecorrect guessesgames togetherratio
LyricLy240.500
IFcoltransG040.000
quintopia040.000

entries

round #4

guesses
comments 0

post a comment


c9.py ASCII text, with CRLF line terminators
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
(
    ( __import__ ( "forbiddenfruit" ) . curse ( tuple, "then", lambda a, f: f ( *a ) ), )
    . then ( lambda _: (
        __import__ ( "collections" ) . Counter,
        __import__ ( "operator" ) . eq,
        __import__ ( "sys" ) . modules,
    ) )
    . then ( lambda count, eq, mods: (
        lambda a, b: ( eq (
            count ( str.replace ( ( str.lower ( a ) ), " ", "" ) ),
            count ( str.replace ( ( str.lower ( b ) ), " ", "" ) ),
        ) ), )
        . then ( lambda entry: ( ( mods [ __name__ ] ), ) 
            . then ( lambda mod: ( ( setattr ( mod, "entry", entry ) ), ) ) )
    )
)

round #3

guesses
comments 0

post a comment


kaylynn.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
 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
import itertools
import re

from collections import namedtuple


class Maybe:
    class _Base:
        def __matmul__(self, other):
            return type(self) == type(other) or type(self) == other

        def __neg__(self):
            return self.remaining

        def wrap(self, value):
            new = self.__class__(**self._asdict())
            if new @ Maybe.Just:
                new.result = value

            return new

    class Just(_Base, namedtuple("Just", "result remaining")):
        ...

    class Nothing(_Base, namedtuple("Nothing", "remaining")):
        ...

    class Skip(_Base, namedtuple("Skip", "remaining")):
        ...


class Combinator:
    def __init__(self, parser):
        self.parser = parser

    def __call__(self, *args, **kwargs):
        return self.parser(*args, **kwargs)

    def __gt__(self, other):
        if not isinstance(other, tuple):
            other = (other,)

        return self(*other)


def combinator(func):
    return Combinator(func)


@combinator
def first_success(*parsers):
    def inner(input_text):
        for parser in parsers:
            result = parser(input_text)
            if result @ Maybe.Just:
                return result

        return Maybe.Nothing(input_text)

    return inner


@combinator
def at_least(parser, times):
    def inner(input_text):
        results = []

        def recursive_parse(text):
            result = parser(text)
            if result @ Maybe.Just or result @ Maybe.Skip:
                if result @ Maybe.Just:
                    results.append(result.result)

                return recursive_parse(-result)
            else:
                # haskell ternary is cooler
                return Maybe.Just(tuple(results), -result) if len(results) >= times else Maybe.Nothing(-result)

        return recursive_parse(input_text)

    return inner


@combinator
def at_least_zero(parser):
    return at_least(parser, 0)


@combinator
def at_least_once(parser):
    return at_least(parser, 1)


@combinator
def apply(*parsers):
    def inner(input_text):
        results = []

        text = input_text
        for parser in parsers:
            result = parser(text)
            if result @ Maybe.Nothing:
                return Maybe.Nothing(input_text)
            else:
                if result @ Maybe.Just:
                    results.append(result.result)

            text = -result

        return Maybe.Just(tuple(results), text)

    return inner


@combinator
def separated(parser, separator):
    def inner(input_text):
        results = []
        cycle = itertools.cycle([(True, parser), (False, separator)])
        text = input_text
        for (should_keep, cycle_parser) in cycle:
            result = cycle_parser(text)
            if result @ Maybe.Just:
                if should_keep:
                    results.append(result.result)
            else:
                return Maybe.Just(tuple(results), text)

            text = -result

    return inner


@combinator
def ws(parser):
    def inner(input_text):
        return parser(input_text.lstrip())

    return inner


@combinator
def tag(text):
    def inner(input_text):
        return Maybe.Just(text, input_text[len(text):]) if input_text.startswith(text) else Maybe.Nothing(input_text)

    return inner


@combinator
def regex(pattern):
    def inner(input_text):
        if (match := re.match(pattern, input_text)):
            return Maybe.Just(match, input_text[len(match[0]):])
        else:
            return Maybe.Nothing(input_text)

    return inner


@combinator
def defer(name):
    return globals().get(name)


@combinator
def ignore(parser):
    def inner(input_text):
        result = parser(input_text)
        if result @ Maybe.Nothing:
            return result
        else:
            return Maybe.Skip(-result)

    return inner


@combinator
def flatten(parser):
    def inner(input_text):
        result = parser(input_text)
        if not result @ Maybe.Just:
            return result

        flattened = []

        def visit(item):
            if type(item) == Maybe.Just:
                item = item.result

            if isinstance(item, tuple):
                for subitem in item:
                    visit(subitem)
            else:
                flattened.append(item)

        visit(result)

        return Maybe.Just(tuple(flattened), -result)

    return inner


def transform(transform_func):
    @combinator
    def wrapped(parser):
        def inner(input_text):
            result = parser(input_text)
            if not result @ Maybe.Just:
                return result
            else:
                return transform_func(result.result)

        return inner

    return wrapped


class ASTNode:
    StructField = namedtuple("Field", "name type")
    Struct = namedtuple("Struct", "name fields")


class Transformer:
    @staticmethod
    def struct(tree):
        return ASTNode.Struct(
            tree[0].group(0),
            *(ASTNode.StructField(field_name.group(0), field_type.group(0))
              for field_name, field_type in zip(tree[1::2], tree[2::2])),
        )


INT = regex("[0-9]+")
FLOAT = apply(INT, tag("."), INT)
SEQUENCE = apply(
    tag("["),
    separated(
        defer("EXPR"),
        ws > tag(",")
    ),
    tag("]")
)
IDENT = regex("[a-zA-Z]+[a-zA-Z0-9]*")
ATTRIBUTE = apply(IDENT, at_least_zero > apply(tag("."), IDENT))
ASSIGNMENT = apply(ATTRIBUTE, ws > tag(":="), defer("EXPR"))

ADD = apply(defer("EXPR"), ws > tag("+"), defer("EXPR"))
SUB = apply(defer("EXPR"), ws > tag("-"), defer("EXPR"))
MUL = apply(defer("EXPR"), ws > tag("*"), defer("EXPR"))
DIV = apply(defer("EXPR"), ws > tag("/"), defer("EXPR"))

GENERIC_HEAD = apply(
    tag("<"),
    separated(
        first_success(
            defer("GENERIC_TYPE"),
            ATTRIBUTE
        ),
        ws > tag(",")
    ),
    tag(">"),
)

CALL_HEAD = apply(
    tag("("),
    separated(
        defer("EXPR"),
        ws > tag(",")
    ),
    tag(")"),
)

GENERIC_TYPE = apply(ATTRIBUTE, GENERIC_HEAD)
CALL = apply(
    ATTRIBUTE,
    at_least_once(
        first_success(ws > GENERIC_HEAD, ws > at_least_once(CALL_HEAD))
    )
)

FOR = apply(
    tag("foreach"),
    ws > IDENT,
    ws > tag("of"),
    ws > defer("EXPR"),
    ws > tag("{"),
    at_least_zero > apply(ws > defer("ITEM"), ws > tag(";")),
    ws > tag("}")
)

STRUCT = transform(Transformer.struct) > (
    flatten > apply(
        ignore > tag("struct"),
        ws > ATTRIBUTE,
        ignore > (ws > tag("{")),
        separated(
            apply(
                ws > IDENT,
                ignore > (ws > tag(":")),
                ws > first_success(GENERIC_TYPE, ATTRIBUTE)),
            ignore > (ws > tag(","))),
        ignore > (ws > tag("}"))
    )
)


result = STRUCT(r"struct example {a: b}")

def entry(left, right):
    return [
        [
            sum(
                a * b for a, b in zip(left_row, right_column)
            ) for right_column in zip(*right)
        ] for left_row in left
    ]

round #2

guesses
comments 0

post a comment


636797375184240640-kaylynn.py Unicode text, UTF-8 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
 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
def repeat(i, n):
    for _ in range(n): yield i

def do_n(functor, n):
    def do(func): return map(functor, repeat(func, n))
    return do

def call_n(n):
    def call(func): return do_n(lambda c: c(), n)(func)
    return call

def call_n_m(n, m):
    def call(func): return call_n(n)(lambda: [*call_n(m)(func)])
    return call

def map_i(c):
    def do(func): return map(lambda i: [*map(func, i)], c)
    return do

def part(*a, **kw):
    def do(func): return lambda: func(*a, **kw)
    return do

def take_n(n):
    def do(i):
        for _ in range(n): yield next(i)
    return do

def label_i(i):
    idx = int()
    for itm in i: yield (idx := idx + 1, *itm)

def entry(flat_maze):
    (as_i) = iter(flat_maze)
    (maze) = [*call_n(10)(lambda: [*take_n(10)(as_i)])]
    (directions, solution) = call_n(2)(list)
    (visited, correct) = call_n(2)(lambda: [*call_n_m(10, 10)(bool)])
    (start_x, start_y), (end_x, end_y) = (
        start   := [0, 0],
        end     := [9, 9],
    )

    def solve(y, x):
        while (y, x) != (end_y, end_x):
            visited[y][x] = True
            solution.append((y, x))

            def do(*a):
                for func in a:
                    (y_, x_) = func()
                    if 0 <= y_ <= 9 and 0 <= x_ <= 9 and not maze[y_][x_] and not visited[y_][x_]: return (y_, x_)

                solution.pop()
                possible = solution[-1]
                solution.pop()
                return possible

            y, x = do(
                lambda: [y - 1, x    ],
                lambda: [y + 1, x    ],
                lambda: [y    , x - 1],
                lambda: [y    , x + 1],
            )

        solution.append((end_y, end_x))
        return solution

    def directions_l(d):
        for o1, o2 in zip(d, d[1:]):
            o = (
                o1[0] - o2[0],
                o1[1] - o2[1],
            )
            yield {
                (  1,  0 ): 1,
                (  0,  1 ): 2,
                ( -1,  0 ): 3,
                (  0, -1 ): 4,
            }[o]

    return [*directions_l(solve(0, 0))]

def tests():
    cases = [
        [
            0, 1, 0, 0, 0, 1, 0, 0, 0, 1,
            0, 1, 0, 1, 0, 1, 0, 1, 0, 0,
            0, 1, 0, 1, 0, 1, 0, 1, 1, 0,
            0, 1, 0, 1, 0, 1, 0, 1, 0, 0,
            0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
            0, 1, 0, 1, 0, 1, 0, 1, 0, 0,
            0, 1, 0, 1, 0, 1, 0, 1, 1, 0,
            0, 1, 0, 1, 0, 1, 0, 1, 0, 0,
            0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
            0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
        ],
        [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        ],
        [
            0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
            0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
            1, 1, 1, 0, 1, 1, 0, 0, 1, 0,
            0, 1, 1, 0, 0, 0, 1, 0, 0, 1,
            0, 0, 0, 0, 1, 0, 1, 1, 0, 0,
            1, 0, 0, 0, 0, 1, 0, 0, 0, 1,
            0, 0, 1, 1, 1, 0, 1, 0, 1, 0,
            1, 0, 0, 0, 1, 0, 1, 0, 0, 0,
            0, 0, 0, 0, 1, 0, 0, 1, 1, 1,
            1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
        ],
        [
            0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
            0, 0, 1, 0, 1, 0, 0, 0, 1, 0,
            0, 0, 1, 1, 0, 0, 1, 1, 1, 0,
            0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
            0, 1, 0, 0, 1, 0, 1, 0, 0, 0,
            0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
            0, 1, 0, 0, 0, 0, 1, 0, 1, 0,
            0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
            0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
            1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
        ],
    ]

    for case in cases:
        print_maze(case)
        print(entry(case))

def print_maze(maze):
    as_i = iter(maze)
    [*call_n(10)(lambda: print("".join("▓" if cell else "░" for cell in take_n(10)(as_i))))]

round #1

guesses
comments 0

post a comment


636797375184240640-kaylynn.py ASCII text, with CRLF line terminators
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from typing import List

# Sort a list of integers
def entry(data: List[str]):
    swap = False
    for i, (one, two) in enumerate(zip(data, data[1:])):
        if two > one:
            # Swaps items
            data[i], data[i + 1] = data[i + 1], data[i]
            swap = True
    # Checks if we need to recur
    if swap:
        return entry(data)
    else:
        return data.reverse() or data