previndexinfo

code guessing, round #91 (completed)

started at ; stage 2 at ; ended at

specification

we found round 11 too hard, so we made it easier. let's encrypt data. submissions may be written in any language.

the definition of an "encryption algorithm" is pretty lax, so all you have to do is make sure that your algorithm:

have fun! as any language is allowed, there is no fixed API.

results

  1. 🅿️ essaie +3 -1 = 2
    1. Olek Sabak
    2. oleander
    3. seshoumara
  2. oleander +3 -1 = 2
    1. Olek Sabak
    2. seshoumara
    3. essaie
  3. Olek Sabak +1 -3 = -2
    1. essaie (was oleander)
    2. seshoumara
    3. oleander (was essaie)
  4. seshoumara +1 -3 = -2
    1. Olek Sabak
    2. essaie (was oleander)
    3. oleander (was essaie)

entries

you can download all the entries

entry #1

written by Olek Sabak
submitted at
0 likes

guesses
comments 0

post a comment


lzw.factor 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
! Copyright (C) 2025 Aleksander "olus2000" Sabak.
! See https://factorcode.org/license.txt for BSD license.
USING: accessors assocs byte-arrays io io.encodings.binary
io.streams.byte-array kernel math sequences ;
IN: lzw


! Encoding

<PRIVATE

CONSTANT: dict-limit 0x10000

TUPLE: encoder-tree index next ;

: <encoder-tree> ( index -- tree ) H{ } clone encoder-tree boa ;

: <encoder-root> ( -- root )
  f 256 <iota> dup [ <encoder-tree> ] map H{ } zip-as
  encoder-tree boa ;

: next? ( tree byte -- tree? ) swap next>> at ; inline

: write2 ( u16 -- ) 256 /mod write1 write1 ;

: encode-step ( root size node byte -- root size node' )
  2dup next? [ 2nip ]
  [ [ [ 1 + ] [ <encoder-tree> ] bi ] 2dip
    [ swap [ index>> write2 ] [ next>> set-at ] bi ] keep
    overd next? ] if* ;

PRIVATE>

: write-lzw ( -- )
  <encoder-root> 256 over [ read1 ]
  [ encode-step over dict-limit >
    [ [ 2drop <encoder-root> 256 over ] dip index>> next? ]
    when ] while* index>> [ write2 ] when* 2drop ;

: >lzw ( bytes -- encoded )
  binary [ binary [ write-lzw ] with-byte-writer ]
  with-byte-reader ;


! Decoding

<PRIVATE

: <decoder-dict> ( -- dict ) 256 <iota> [ 1byte-array ] map ;

: read2 ( -- u16? )
  read1 read1 2dup and [ 256 * + ] [ nip ] if ;

: init-decoder ( -- dict prev? )
  <decoder-dict> read2 dup [ over nth dup write ] when ;

: decode-step ( dict prev new -- dict' prev' )
  pick length over > [ pick nth ] [ drop dup dup first suffix ]
  if [ first suffix suffix ] keep dup write ;

PRIVATE>

: read-lzw ( -- )
  init-decoder [ read2 ]
  [ decode-step over length dict-limit >=
    [ 2drop init-decoder ] when ] while* 2drop ;

: lzw> ( encoded -- bytes )
  binary [ binary [ read-lzw ] with-byte-writer ]
  with-byte-reader ;

entry #2

written by oleander
submitted at
0 likes

guesses
comments 0

post a comment


crypter.py ASCII text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
def encrypt(data): #takes bytes object, returns bytes object
    c = b = 0
    o = b''
    for m in range(len(data) * 8):
        if (data[m // 8] >> (7 - (m % 8))) & 1 != b or c == 255:
            o += bytes([c])
            b = not b
            c = 0
        c += 1
    return o + bytes([c])

def decrypt(data): #takes bytes object, returns bytes object
    b = 0
    o = ''
    for c in data:
        o += str(int(b)) * c
        if not c == 255:
            b = not b
    
    return bytes([int(o[m:m + 8], 2) for m in range(0, len(o), 8)])

entry #3

written by seshoumara
submitted at
0 likes

guesses
comments 0

post a comment


rado.tm 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
#tape input: space, letters and '<' to mark end of input
|Uryyb Jbeyq<

0ANR0
0BOR0
0CPR0
0DQR0
0ERR0
0FSR0
0GTR0
0HUR0
0IVR0
0JWR0
0KXR0
0LYR0
0MZR0
0NAR0
0OBR0
0PCR0
0QDR0
0RER0
0SFR0
0TGR0
0UHR0
0VIR0
0WJR0
0XKR0
0YLR0
0ZMR0
0anR0
0boR0
0cpR0
0dqR0
0erR0
0fsR0
0gtR0
0huR0
0ivR0
0jwR0
0kxR0
0lyR0
0mzR0
0naR0
0obR0
0pcR0
0qdR0
0reR0
0sfR0
0tgR0
0uhR0
0viR0
0wjR0
0xkR0
0ylR0
0zmR0
0  R0
0<< $

entry #4

written by essaie
submitted at
0 likes

guesses
comments 0

post a comment


555770128705257502-shouharuka.py ASCII text
1
2
encrypt = lambda en, crypt: crypt + en
decrypt = lambda de, crypt: de.split(crypt)[1]