previndexinfonext

code guessing, round #68 (completed)

started at ; stage 2 at ; ended at

specification

welcome back and happy new year! for the return of code guessing you must decipher a substitution cipher. submissions may be written in any language.

a substitution cipher is one that replaces each symbol (usually Latin letter) of the plaintext with another, fixed, one; as the same unit is always replaced with the same thing, this type of cipher is very easy to crack using a variety of methods, such as frequency analysis.

this problem is plainly statistical. without assuming what type of text has been ciphered, it is impossible to solve with any reliability. you may assume anything you like, but if you are uncreative, "English text written with only ASCII letters" is a good starting-off point.

your challenge, given text ciphered with a substitution cipher, is to find what the plaintext likely was (or to find the substitution table). as any language is allowed, there is no fixed API.

results

  1. 👑 essaie +5 -2 = 3
    1. ponydork
    2. minecalftree
    3. kimapr (was Moja)
    4. Moja (was Dolphy)
    5. oleander
    6. Dolphy (was kimapr)
    7. olive
    8. Makefile_dot_in
  2. oleander +5 -3 = 2
    1. ponydork
    2. minecalftree
    3. Dolphy (was Moja)
    4. olive (was Dolphy)
    5. kimapr
    6. essaie
    7. Moja (was olive)
    8. Makefile_dot_in
  3. Moja +3 -1 = 2
    1. ponydork
    2. oleander (was minecalftree)
    3. kimapr (was Dolphy)
    4. minecalftree (was oleander)
    5. Makefile_dot_in (was kimapr)
    6. essaie
    7. olive
    8. Dolphy (was Makefile_dot_in)
  4. olive +4 -4 = 0
    1. Makefile_dot_in (was ponydork)
    2. minecalftree
    3. essaie (was Moja)
    4. Dolphy
    5. oleander
    6. kimapr
    7. Moja (was essaie)
    8. ponydork (was Makefile_dot_in)
  5. minecalftree +3 -3 = 0
    1. essaie (was ponydork)
    2. Moja
    3. kimapr (was Dolphy)
    4. oleander
    5. Makefile_dot_in (was kimapr)
    6. Dolphy (was essaie)
    7. olive
    8. ponydork (was Makefile_dot_in)
  6. kimapr +2 -2 = 0
    1. Makefile_dot_in (was ponydork)
    2. essaie (was minecalftree)
    3. ponydork (was Moja)
    4. Dolphy
    5. Moja (was oleander)
    6. minecalftree (was essaie)
    7. olive
    8. oleander (was Makefile_dot_in)
  7. Dolphy +1 -2 = -1
    1. essaie (was ponydork)
    2. ponydork (was minecalftree)
    3. oleander (was Moja)
    4. minecalftree (was oleander)
    5. olive (was kimapr)
    6. Moja (was essaie)
    7. kimapr (was olive)
    8. Makefile_dot_in
  8. ponydork +0 -3 = -3
    1. essaie (was minecalftree)
    2. Dolphy (was Moja)
    3. Moja (was Dolphy)
    4. olive (was oleander)
    5. Makefile_dot_in (was kimapr)
    6. kimapr (was essaie)
    7. minecalftree (was olive)
    8. oleander (was Makefile_dot_in)
  9. Makefile_dot_in +0 -3 = -3
    1. essaie (was ponydork)
    2. kimapr (was minecalftree)
    3. ponydork (was Moja)
    4. olive (was Dolphy)
    5. Dolphy (was oleander)
    6. minecalftree (was kimapr)
    7. oleander (was essaie)
    8. Moja (was olive)

entries

you can download all the entries

entry #1

written by ponydork
submitted at
0 likes

guesses
comments 3
jan Sana ¶

this provides inspiration like the house of plants


jan Sana ¶

*plants


jan Weno ¶

*botanical life


post a comment


subs.rb ASCII text, with very long lines (64293), with CRLF line terminators

entry #2

written by minecalftree
submitted at
0 likes

guesses
comments 0

post a comment


CG68.8xp TI-83+ Graphing Calculator (program)
CG68.txt 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
:Input "ENTER CIPHERTEXT ",Str1
:DelVar [A]{2,29->dim([A]
:length(Str1->L
:DelVar [B]{1,Ans->dim([B]
:While L>1
:inString("EARIOTNSLCUDPMHGBFYWKVXZJQ .,",sub(Str1,1,1->[B](1,L
:[A](1,Ans)+1->[A](1,Ans
:L-1->L
:sub(Str1,2,Ans)->Str1
:End
:inString("EARIOTNSLCUDPMHGBFYWKVXZJQ .,",Str1->[B](1,1
:[A](1,Ans)+1->[A](1,Ans
:Repeat L=30
:L->[A](2,L
:L+1->L
:End
:1->L
:Repeat L=26
:L+1->L
:Ans->H
:[A](1,Ans->N
:1->C
:Repeat C>H
:int((C+(H-C)/2->E
:If N>[A](1,[A](2,Ans:Then
:E-1->H
:Else
:E+1->C
:End:End
:L->C
:Repeat E>=C
:C-1->C
:[A](2,Ans->[A](2,Ans+1
:End
:L->[A](2,E
:End
:dim([B]
:Ans(2)->L
:1->C
:While C<30
:If [A](2,C)=[B](1,L
:C->H
:C+1->C
:End
:sub("EARIOTNSLCUDPMHGBFYWKVXZJQ .,",H,1->Str1
:While L>1
:L-1->L
:1->C
:While C<30
:If [A](2,C)=[B](1,L
:C->H
:C+1->C
:End
:sub("EARIOTNSLCUDPMHGBFYWKVXZJQ .,",H,1
:Str1+Ans->Str1
:End
:0->L
:Repeat L>=int(length(Str1)/26)+1
:Disp sub(Str1,26L+1,min(26,length(Str1)-26L
:L+1->L
:End

entry #3

written by Moja
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)

entry #4

written by Dolphy
submitted at
0 likes

guesses
comments 0

post a comment


make cg great again.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
def get_permutation_data(s):
    out_str = ''
    out_table = {}
    i = 0
    for c in s:
        if c not in out_table.keys():
            out_table[c] = i
            i += 1
        out_str = out_str + str(out_table[c])

    return out_str, out_table

def entry(text, all_words):
    text = text.lower()
    words = text.split()
    table = entry_helper(words, all_words, {})
    if table is None:
        return None
    inv_table = {v: k for k, v in table.items()}
    inv_table = {ord(k): ord(v) for k, v in inv_table.items()}
    return text.translate(inv_table)

def entry_helper(words, all_words, table):
    if len(words) == 0:
        return table

    word = words[0]
    rest = words[1:]
    word_id, word_mapping = get_permutation_data(word)
    word_inv = {v: k for k, v in word_mapping.items()}

    for w in all_words:
        if len(w) != len(word):
            continue

        w_id, w_mapping = get_permutation_data(w)
        if w_id == word_id:
            w_inv = {v: k for k, v in w_mapping.items()}
            new_mapping = {}
            for i in range(len(w_inv.keys())):
                new_mapping[w_inv[i]] = word_inv[i]

            for k, v in new_mapping.items():
                if k in table.keys():
                    if table[k] != v:
                        break
                else:
                    if v in table.values():
                        break
            else:
                old_table = table.copy()
                for k, v in new_mapping.items():
                    table[k] = v
                result = entry_helper(rest, all_words, table)
                if result is not None:
                    return result
                table = old_table
            
    return None

entry #5

written by oleander
submitted at
0 likes

guesses
comments 0

post a comment


week68.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
#this code doesnt actually work 😇

cm = 'Uif rvjdl cspxo gpy kvnqt pwfs uif mbaz eph.'

wlf = open('wordlist.txt', 'r')
wl = wlf.read().split('\n')
wlf.close()

abc='abcdefghijklmnopqrstuvwxyz'    
punct=['!','.','-',',',';','?','\n','\t']

wld={}
cfd={i:1 for i in abc}
for i in wl:
    for c in i:
        if not c.lower() in abc:
            break
    else:
        if len(i) in wld: wld[len(i)].append(i.lower())
        else: wld[len(i)]=[i.lower()]
        for c in i:
            cfd[c]+=1

cm=cm.lower()
for i in punct: cm=cm.replace(i, '')

cms = set(list(cm.replace(' ','')))
cml = cm.split(' ')



fwd={i:{j:0 for j in abc} for i in cms}

for w in cml:
    for p in wld[len(w)]:
        cd = {}
        for c in range(0, len(w)):
            if w[c] in cd:
                if cd[w[c]]==p[c]:
                    continue
                else:
                    break
            else:
                cd[w[c]]=p[c]
        else:
            for j in cd:
                fwd[j][cd[j]]+=1

iwd={i:'a' for i in cms}
for i in cms:
    for j in fwd[i]:
        if (fwd[i][j]/cfd[j])>(fwd[i][iwd[i]]/cfd[iwd[i]]):
        #if (fwd[i][j])>(fwd[i][iwd[i]]):
            iwd[i]=j

ncm=list(cm.lower())
for i in range(0,len(ncm)):
    if ncm[i] in iwd:
        ncm[i]=iwd[ncm[i]]

ncm = ''.join(ncm)
print(ncm)

entry #6

written by kimapr
submitted at
1 like

guesses
comments 3
cdr sa ¶

epIc me jumpscare


jan Sana ¶

does this contain truth


kimapr known at the time as [author of #6] replying to jan Sana ¶

merely pleasing false statements


post a comment


Makefile 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
none:
	# do nothing

CODEGUESS = \
	codeguess-unpacked/1 \
	codeguess-unpacked/2 \
	codeguess-unpacked/3 \
	codeguess-unpacked/4 \
	codeguess-unpacked/5 \
	codeguess-unpacked/6 \
	codeguess-unpacked/7 \
	codeguess-unpacked/8 \
	codeguess-unpacked/9 \
	codeguess-unpacked/10 \
	codeguess-unpacked/11 \
	codeguess-unpacked/12 \
	codeguess-unpacked/13 \
	codeguess-unpacked/14 \
	codeguess-unpacked/15 \
	codeguess-unpacked/16 \
	codeguess-unpacked/17 \
	codeguess-unpacked/18 \
	codeguess-unpacked/19 \
	codeguess-unpacked/20 \
	codeguess-unpacked/21 \
	codeguess-unpacked/22 \
	codeguess-unpacked/23 \
	codeguess-unpacked/24 \
	codeguess-unpacked/25 \
	codeguess-unpacked/26 \
	codeguess-unpacked/27 \
	codeguess-unpacked/28 \
	codeguess-unpacked/29 \
	codeguess-unpacked/30 \
	codeguess-unpacked/31 \
	codeguess-unpacked/32 \
	codeguess-unpacked/33 \
	codeguess-unpacked/34 \
	codeguess-unpacked/35 \
	codeguess-unpacked/36 \
	codeguess-unpacked/37 \
	codeguess-unpacked/38 \
	codeguess-unpacked/39 \
	codeguess-unpacked/40 \
	codeguess-unpacked/41 \
	codeguess-unpacked/42 \
	codeguess-unpacked/43 \
	codeguess-unpacked/44 \
	codeguess-unpacked/45 \
	codeguess-unpacked/46 \
	codeguess-unpacked/47 \
	codeguess-unpacked/48 \
	codeguess-unpacked/49 \
	codeguess-unpacked/50 \
	codeguess-unpacked/51 \
	codeguess-unpacked/52 \
	codeguess-unpacked/53 \
	codeguess-unpacked/54 \
	codeguess-unpacked/55 \
	codeguess-unpacked/56 \
	codeguess-unpacked/57 \
	codeguess-unpacked/58 \
	codeguess-unpacked/59 \
	codeguess-unpacked/60 \
	codeguess-unpacked/61 \
	codeguess-unpacked/62 \
	codeguess-unpacked/63 \
	codeguess-unpacked/64 \
	codeguess-unpacked/65 \
	codeguess-unpacked/66 \
	codeguess-unpacked/67 \

codeguess/%.tar.bz2:
	@mkdir -p codeguess
	@echo fetching $@
	@while ! curl --retry-all-errors --retry 1000000 -sS https://codeguessing.gay/$*.tar.bz2 > codeguess/$*.tar.bz2; do :; done
	@echo fetched $@

codeguess-unpacked/%: codeguess/%.tar.bz2
	@mkdir -p codeguess-unpacked
	cd codeguess-unpacked && tar xf ../codeguess/$*.tar.bz2

codeguess-all: $(CODEGUESS)

models.h: analyzer.scm $(CODEGUESS)
	ratio(){ echo | awk "{ a=$$(cat "$$@"|wc -c); b=$$(cat "$$@"|gzip|wc -c); print a/b }"; }; \
	find $(CODEGUESS) -name '.git' -prune -o -type f -print | while read line; do \
	if [ "$$(du -b "$$line" | grep -oE ^[0-9]\*)" -le 16384 ] && \
	[ $$(echo|awk "{ n=$$(ratio "$$line")>3?1:0; print n; }") = 1 ]; then \
	printf '%s\n' "$$line"; fi; done | \
	( echo 'static const struct model models[] = {'; \
	while read line; do printf '%s\n' "$$(wc -c "$$line")" >&2; \
	guile analyzer.scm < "$$line"; done; echo '};' ) > models.h

decipher: decipher.c models.h
	$(CC) -O3 decipher.c -o decipher
analyzer.scm 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
(import (rnrs (6)))
((lambda (fd-in fd-out)
   (define freq (make-vector 256 0))
   (letrec ((loop (lambda ()
                    (define char (get-u8 fd-in))
                    (if (not (eof-object? char))
                      (begin
                        (vector-set!
                          freq
                          char
                          (+ 1 (vector-ref freq char)))
                        (loop))))))
     (loop))
   (letrec ((loop (lambda (i)
                    (if (< i (vector-length freq))
                      (begin
                        (vector-set! freq i (cons i (vector-ref freq i)))
                        (loop (+ i 1)))))))
     (loop 0))
   (vector-sort!
     (lambda (sa ba) (> (cdr sa) (cdr ba)))
     freq)
   (define total
     (letrec ((loop (lambda (i c)
                      (if (< i (vector-length freq))
                        (loop (+ i 1) (+ c (cdr (vector-ref freq i))))
                        c))))
       (loop 0 0)))
   (if (> total 0)
     (letrec ((loop (lambda (i)
                      (if (< i (vector-length freq))
                        ((lambda ()
                           (define elem (vector-ref freq i))
                           (vector-set!
                             freq
                             i
                             (cons (car elem)
                                   (exact->inexact (/ (cdr elem) total))))
                           (loop (+ i 1))))))))
       (loop 0)))
   (put-string
     fd-out
     "\t(struct model) {\n\t\t.items = {\n")
   (letrec ((loop (lambda (i)
                    (if (< i (vector-length freq))
                      ((lambda ()
                         (define char (car (vector-ref freq i)))
                         (define ratio (cdr (vector-ref freq i)))
                         (put-string
                           fd-out
                           (string-append
                             "\t\t\t(struct char_freq) { .who = "
                             (if (and (<= 32 char) (> 127 char))
                               (let ((char (integer->char char)))
                                 (string-append
                                   "'"
                                   (if (or (eq? #\' char) (eq? #\\ char))
                                     "\\"
                                     "")
                                   (make-string 1 char)
                                   "'"))
                               (number->string char))
                             ", .when = "
                             (number->string ratio)
                             " },\n"))
                         (loop (+ i 1))))))))
     (loop 0))
   (put-string fd-out "\t\t}\n\t},\n"))
 (standard-input-port)
 (current-output-port))
decipher.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
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>

struct char_freq {
	char who;
	double when;
};

struct model {
	struct char_freq items[256];
};

#include "models.h"

#define lenof(obj) (sizeof(obj) / sizeof(*(obj)))

void halt_and_catch() {
	fprintf(stderr, "critical error occurred. please leave the building immediately\n");
	exit(1);
}

char *readfile(FILE *file, size_t *size) {
	int cap = 16;
	char *buf = malloc(cap);
	if (!buf) return NULL;
	int count = 0, c;
	while ((c=fgetc(file))!=EOF) {
		count++;
		if (count > cap) {
			char *buf_ = buf;
			if (!(buf = realloc(buf, (cap *= 2)))) {
				free(buf_);
				return NULL;
			}
		}
		buf[count-1] = c;
	}
	char *buf_ = buf;
	if (!(buf = realloc(buf, count))) {
		free(buf_);
		return NULL;
	}
	*size = count;
	return buf;
}

int sort_model_cb(const void *a_, const void *b_) {
	const struct char_freq *a = a_;
	const struct char_freq *b = b_;
	double diff = b->when - a->when;
	return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
}

void sort_model(struct model *model) {
	qsort(model->items, 256, sizeof(*model->items), sort_model_cb);
}

double cmp_model(struct model *a, struct model *b) {
	double accum = 0;
	for (int i = 0; i < 256; i++) {
		double diff = (a->items[i].when - b->items[i].when);
		accum += diff * diff;
	}
	return accum;
}

void merge_model(const struct model *a, double a_weight, const struct model *b, struct model *out) {
	if (a_weight == 0) {
		*out = *b;
		return;
	}
	struct model b_raw;
	for (int i = 0; i < 256; i++) {
		b_raw.items[(unsigned char)b->items[i].who] = b->items[i];
	}
	for (int i = 0; i < 256; i++) {
		out->items[i] = (struct char_freq) {
			.who = a->items[i].who, .when =
				(a->items[i].when
				 + b_raw.items[(unsigned char)a->items[i].who].when)
				 / (a_weight+1)
		};
	}
	sort_model(out);
}

int analyze_buffer(const char *str, size_t size) {
	size_t freqs[256] = {0};
	for (int i = 0; i < size; i++) {
		freqs[(unsigned char)str[i]]++;
	}
	struct model model;
	for (int i = 0; i < 256; i++) {
		model.items[i] = (struct char_freq) {
			.who = i, .when = ((double)freqs[i])/size,
		};
	}
	sort_model(&model);
	double bestest_score = 1.0/0.0;
	struct model bestest_model;
	for (int d = 0 ;; d++) {
		double best_model_score = 1.0/0.0;
		struct model best_model;
		struct model new_model;
		for (int i = 0; i < lenof(models); i++) {
			merge_model(&bestest_model, d, &models[i], &new_model);
			double score = cmp_model(&model, &new_model);
			if (score < best_model_score) {
				best_model_score = score;
				best_model = new_model;
			}
		}
		if (best_model_score >= bestest_score) {
			break;
		}
		bestest_score = best_model_score;
		bestest_model = best_model;
	}
	char map[256];
	for (int i = 0; i < 256; i++) {
		map[(unsigned char)model.items[i].who] = bestest_model.items[i].who;
	}
	for (int i = 0; i < size; i++) {
		fputc(map[(unsigned char)str[i]], stdout);
	}
	return 0;
}

int analyze_file(FILE *file) {
	size_t size;
	char *data = readfile(file, &size);
	if (!(data && !analyze_buffer(data, size))) {
		return 1;
	}
	return 0;
}

int main(int argc, char **argv) {
	FILE *file = stdin;
	if(argc > 1) {
		file = fopen(argv[1], "rb");
		if (!file) {
			halt_and_catch();
		}
	}
	if (analyze_file(file)) {
		halt_and_catch();
	}
	return 0;
}

entry #7

written by essaie
submitted at
0 likes

guesses
comments 3
cdr sa ¶

epIc me jumpscare


soweli sike Amo ¶

anonymous function


essaie ¶

\I did the sculpting by hand :pleading_face:


post a comment


Ine.txt 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
hm'rahim z rmhicamqymawcahrarsgg mzhwyoaeq iayogtrmayooar
fcrayz ayrsgg mzhwyo.aHaywmvyoosawyi'mamqhiuatbayitmq zar
sgg mzhwyoati .a qq.ahm'raqyzfamtaf rwzhp .a...hrakqkactt
fatza xho?as yqavqamqym'raitmaqteak zbtzgyiw aetzur.akztp
ypos,apvmamqymaft ri'mag yiamqymavrhicaWag yirastvafti'ma
qyx amtaetzzsayptvmak zbtzgyiw .ahm'rag gtzhnymhti.aitaey
sayztvifahm.amq akthimahramqymao yzihicayisaoyicvyc a x i
mvyoosaz dvhz raztm ag gtzhnymhtiatbahmraxtwypvoyzs;amqhr
ahraviyxthfypo .ahiaJykyi r amqymag gtzhnymhtiahiwovf rau
yijh.aeqymafhfastvag yi?ait,afvf ,aHafti'm.ae ooagsakthim
ahramqymaymamq a ifatbamq afysastvaqyx amtauiteaeqyma ywq
aetzfag yirayifaqteamtaezhm ahmar kyzym os.amq z 'raita"z
vo ".ahmayiitsrag artagvwq.aqykksa2025amtastvamtt!.ayisey
sratiamtamq apyfai eratiamq abhzrmafysatbamq as yz!ahrima
hma lwhmhic?.aeq z ahrayimhbyaeq z ae ai  famq g?.aqggaha
ghcqmauiteaeqymamtaftaiteaybm za lygr.artamqymramq acttfa
i erahc.amyre oooaeyhmahabtzctmamtayruahbamq z rayisakymm
 ziahiamq az yfhicratbauyijhamqymaghcqmaq okag .ahab  oao
hu ar yzwqhicamqhicraypmamqhrapvmahgayortaybzyhfahmfap ar
kthohicagsr obartahfu?astvaqyx amtag  mayifartwhyohn aehm
qai eakkoaeq iastvayz ahiayafhbb z imawtvimzs.aQykksa2025
ayifaqykksaphzmqfysaGtjy!aHmarmyifrabtzaitmaryb abtzaetzu
,artamqhicraohu aitmae yzhicastvzar ymp omahbastvayz ayam
ylhafzhx za mw.aMq ae prhm ajvrmamqhiurastvayz aqtofhicay
au savktiamykkhicartastvaqyx amtawohwuatvmrhf .aWqymahram
qymayarmywutx zbote.wtgaz b z iw ?.aMq ayimhctooyzuaHauit
eaetvofachx ayarhoosaz rktir .aHfuahbayisptfsa or aitmhw 
famqhrapvmamq ar zx zahwtiarmtkk fawqyichic.aTuysaeqymaHa
eyractiiyaezhm ahra lywmosaeqyma rtptmaryhf.ahri'mahmavrv
yoosaitayzcra->akzhimaq okaehmqayooamq aboycrayifarmvbb.a
eqsayz astvafthicamqhr.astv'z aitmamq aptm.ahamqtvcqmamq 
achmawtgghmaqyrq rae z ajvrmaktohrqabtzayar wtif.aeqyma i
wtfhicahramqhrag yimamtap ?ahm'rauhifatbahim z rmhic.amtf
ysahao yzi famq z 'rayaqyru ooaivwo yzaghrrho akywuyc .aM
q r apzym rarvz aftap ax zm .avgihutrayz astva xho?aHaeti
f zahbahawtvofawqttr amtap oh x amqymagsaKtohrq-rk yuhica
bzh ifrayz afhz wmosaz rktirhpo abtzayooaKtohrqaoyicvyc a
m lmahiamq a"etzof".aQhagyu .aMqym'rag !.aOtx amqhrayihgy
or:a[rqhgk].aStvag te f.actatiayaFYM aehmqag atiaMV RFYSa
ymayaWTBB  aRQTKaeti'mastvaKO YR !aqvqaeqymaeyrahm?a o g 
imrawyiawtimyhia,ayifaeqho astvawyia rwyk ahmagtrmatbamq 
amhg ahgajvrmaoyns.a o g imrawyimawtimyhiayamypartaohu .a
hmrarvk za yrsamtajvrmahir zmamq azyeaxyov raq z .aeqhwqa
gyu raptmraohu amq r axvoi zypo ahacv rr?ahbastvaeyimamta
u  kamq aHKatbastvzar zx zaqhff i.aq sas'yoo!aHajvrmactma
q z abztgamq arvpz ffhm.aottuhicabtzahmaymg,amq z aeyraya
rmvfsatbagtitohicvyoar wtifyzsarwqttoayc farmvf imraeq z 
ati acztvkaeyrachx iayiaIae  uawtvzr a(8?)ahiayar wtifaoy
icvyc ,ayifayar wtifacztvkaeyrachx iaya2ae  uawtvzr ahiam
tuhaktiyamq iayiaI-2ae  uawtvzr ahiamq aryg ar wtifaoyicv
yc .ar wtifacztvkarwtz faeysaqhcq zatiar wtifaoyicvyc ayr
r rrg imr.ax zsawtto!aHaeyramzshicamtajthiamq awtgkho zra
yifahim zkz m zrafhrwtzfayrae ooayramqhrati abztgamq aehu
h,apvmamq hzaohiuar  gramtaitaotic zaetzu.aFt rayisti aq 
z aqyx ahm?.aHafti'maohu amq aehif.aHaftabhifamqhrawvm .a
habzh fao apzyhiamzshicamtavif zrmyifamq aphchbsatk zymtz
.aHaftaehrqamq z aeyrayaeysamtapz yuafteiayawvrmtgapotwu.
coca.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
 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
# MonoalphabetIc substItutIon cIpher solver by Stazarzxy
# Usage: python3 coca.py <fIlename>

(lambda                         L :(lambda Z,y,
                            w,T :( lambda C,E,_ :(
                        lambda A,X:(lambda K,z:(lambda
                       B:L(lambda f,l,D,k,b,i,j:(lambda
                     F:(lambda N:(lambda G,u,v:f(f,l,G,u,
                    v,i,j+1)if i+j<len(Z)-1 else f(f,l,G,u
                  ,v,i+1,0)if i<len(Z)-1 else print(z(C,u)))
                 (F if N<b else D,w(k,j,j+i)if N<b else k,min
                (N,b)))(X(F)))(T(w(T(w(D,j,j+i)),j,j+i))),L,B,
               K,X(B),1,0))((lambda s :( lambda g :( lambda f:(
              lambda n:[[n.get(r+c,0)for(j,c)in enumerate(Z)]for
             (i,r) in enumerate(Z)])({d:f[d]/max(f.values())for d
            in f}))({d:g.count(d)for d in set(g)}))([s[i:i+2]for i
            in range(len(s)-1)            ]))(z(A,K))))((lambda k:k
           +[c for c in Z                    if not c in k])((lambda
          v:L(lambda m,                          l,S,h:S if h<2 else
          L(lambda g,l                            ,s,d,o:o+s+d if not
         s or not d                                 else g(g,l,s[1:],d
         ,o+[s[0]])                                  if A.count(s[0])>
        A .count(                                      d[0])else g(g,l,
        s,d[1:],                                        o+[d[0]]),L,m(m
        ,l,S[:h                                          //2],h//2),m(m,
        l,S[h//                                          2:],h-h//2),[]),
        L,v,len                                           (v)))(list(set(
       A)) )) ,                                            lambda s,k:"".
       join(Z[                                              k.index(c)] if
       c in k                                               else c for c in
       s)))(                                                " ".join("".join
      (c for                                                 c in" ".join (C.
      split                                                   ()) if c in Z ).
      split                                                   ()),lambda D:sum
      (sum(                                                    abs(D[i][j]-E[i]
      [j]                                                       )for j in range
       (                                                         len(E[0])))for
                                                                 i in range(len(
                                                                  E)))))(open(y .
                                                                  argv[1]).read().
                                                                  lower(),[[0,0.09,
                                                                  .879,00.526,0.331
                                                                   ,.244,0.107,0.36,
                                                                    0.307,.073,.129,
                                                                    .125,0.166,0.09,
                                                                     .189,.301,.179,
                                                                     0.102,.061,.124,
                                                                    0.227,.024,0.036,
                                                                   0.037,0,0.004,.004
                                                                  ],[1,0.074,.08,.121
                                                                 ,.021,.043,0.2,0.166
                                                                ,.011,.305,0.157,.084
                                                               ,.048,0.002,.062,0.015
                                                              ,.026,0.014,0.049,0.024
                                                             ,0.006,0.043,0.004,0.001
                                                            ,0.015,.003,.002],[0.465 ,
                                                            0.119, 0.022,0.052, 0.178,
                                                           .092,.002,.037,0.858,0.041,
                                                           0,.014,.004,.022,.001,0.013
                                                          ,0.001,0,0.023,0,0,0,0,0,0,0,
                                                         0],[ 0.017 ,0.013 ,0.204,0.005,
                                                        0.002, 0.075, 0.44, 0.128, 0.02,
                                                       0.146, 0.054, 0.158, 0.048, 0.019,
                                                      0.056,0.014,0.013,0.024,0.056,0.018,
                                                     .037 ,0.05,0.028,0, 0.001,0, 0.003],[
                                                     0.215, 0.006, 0.074,.01,0.037, 0.013,
                                                    0.192,0.039,0.003,0.208,  0.045,0.039,
                                                   0.011, 0.194,0.081,0.06,    0.216,0.008,
                                                  0.004, 0.025,0.01,0.024,     0.015,0.001,
                                                 0.001,0, 0.001 ],[0.005,       0.055,0.167
                                                ,0.022 ,0.052, 0, 0.332 ,       .164,0,.051,
                                                0.059,0.077,0.061,0.001,        .064,0,0.035,
                                               0.038,0,.009,.007,0.034,          0.008,0.001,
                                              0.003,.001,0.002],[.385 ,          0.107,0.139,
                                             0.034,0.087, 0.031,0.009,           .056,0.004,0,
                                            0.354,0.006,0.041,0.008,0             ,0.001,0.004
                                           ,0.145,0.016,0,0.001,0.002             ,0.008,0.001,
                                           0,0.001,0],[0.475, 0.154,               0.134,0.078,
                                          0.069,0.048 ,.003, 0.047,                .098, 0.010,
                                         0.001,0.009, 0.012,0.029,                  0.006,0.008,
                                        0.001,0.001, 0.004, 0.03 ,                  .001,0,0.004
                                       ,0,0,0.001,0],[0.187,0.71,                    0.036,0.249,
                                       0.106,0.184,0.001,0.002,0,                    .017,0,0.001,
                                      0,0.016,0.001 ,0, .001 ,0,                     0.024,0,.001,
                                     0,0,0,0,0,0],[0.271 ,0.259,                      0.044,0.073,
                                    0.089,0.092, 0.027, 0.049 ,                       0.001,0.012,
                                   0.066,.009,0.009,.021,0.015                        ,0.001,0.004,
                                  0.009,.028,.004,0.002,0.011,                         0.011,0,0,0,
                                 0],[.639,0.087,0,0.035,0.039                          ,0.051,0.006,
                                .023,0,.019,.004,.005,0,0.011                          ,0.003,0.003,
                                0.001,.006,.006,0,0,.002,0,0,                           0,0,0],[.166,
                               0.119,.019,.063,0.082,.064,0,                            0.02,0,0.001,
                              0.056,0.141,0.001,0.007,0.002,                            0.002,0.009,0,
                             0.047,0.002,0,0.007,0.004,0,0,                             .0,.0],[0.005,
                            0.068,0.031,0.06,0.08,0.025,0,                               0,0.086,0.014
                           ,0,0.015,0.01,0.014,0,0.0,0,0,                                0.003,0,0.0,0,
                           0.019,0.0,0.0,0.001,0],[0.042,                                .01,.075,0.01,
                          0.001,0.011, 0.086, 0.073,0.0,                                  0.072, 0.014,
                         0.044,  0.019, 0.0, 0.011,0.0,                                   0.002,0.022,0,
                        0.033,0.01,0.0,0.001,0.0,0.0,0                                    ,.001],[0.118,
                       0.127,0,0.08,0.051,0.037,0.001,                                     0.011,0,0.003,
                      0,0.0,0.001,0.013,0.011,0,.001,                                      0,0.025,0.015,
                     0.012,0.,.0,0.,.0,0.,.0],[.041,                                       0.07,0.0,0.072                                             ,.039
                    ,0.084,.016,0.004,0.084 ,0.005,                                         0.0,0.003,0.0,                                            .0,0.0,
                    0.0,0.0,0.0,0.001,0.0,0.0,0.0,                                          0.0,0.0,0.0,0.0                                           ,0.0],[
                   0.228,0.036,0.016,0.028,0.097,                                           .033,0.0,0.001,0                                          ,0.031,
                  0.0,0.011,0.0,0.011,0.0 , 0.0,                                             0.022,0.0,0.001,                                        .0,0.00,
                 0.0 , 0.0 , 0.0,0.0,0.0,0.0],[                                               .112,.043,0.002,                                       .03,.048
                ,0.02,0.004,0.014,0.05, 0.024,                                                 0.002,0.008,0.0,                                    .006,.002,
                0.0,0.0 ,0.003,0.003,0.0,0.0,                                                  .0,0.,.0,0.0,0.0,                                  0.0],[0.27,
               0.035,0.001,0.001,0.034,0.009,                                                   0.001,0.013 ,0.0,                                .002,0,.002,
              0.0,0.0,0.001,0.0,0.0,0.0,0.0,                                                    .004,0.002,0.0,0.0,                              0.0,0.0,0.0,
             0.0],[0.027,0.059,0.013,0.032,                                                      0.037,0.014,.0,.005                            ,0.015,0.045,
            0.0,.033,0.,0.011,0.0,0.0,0.0,                                                       .0,0.001,0.013,0.0,0.,                         0.0,0.0,0.0,
           0.,.0],[.007,0.121,.002,0.019,                                                         0.028,0.014,0.001,0.005                     ,0.,0.028,.0,
          0.026,0,0.041,0,0,0,0,0.024,0,                                                          .002,0,0,0.001,0,0,0],[0.001              ,0.142,0,0.018,
         0.007,0.029,0,0,0,0,0,0,0,0,0,                                                            0,0,0,0,0,0,0,0,0,0,0,0],[0.036,0.05,0,.001,0.002,0.027
        ,0.013,0.006,0,0,0,0.001,0,0,0,                                                            0,0,0,0,0,0,0,0,0,0,0,0],[0,0.016,0,0.005,0.01,0.002,0,
        0.0,0.0,0.0,0.0,0.0,0.0,0.011,                                                              .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.003,0.002,0.005,0.002,0.000,                                                                0.002,0.0,0.0,0.0,0.0,0.0,0.0,0.002,0.0,0.0,0.0,0.0,
      0.0,0.0,0.003,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.011,0.0,0.0,                                                                    0.0,0.0,0.0,0.00,00.0,0.0,0.0,0.0,0.0,0.0,0.0],[
    .001,0.005,0,0.003,0.001,0.003,                                                                     0,0,0,0.001,0,0.,0,0,0,0,0,0,0,0.0,0,0,0,0,0,0,
    0.001]],y.setrecursionlimit(3400)))(                                                                 " etaoinshrdlcumwfgypbvkjxqz",__import__("sys"
   ),lambda M,i,j:M[:min(j,i)]+[M[max(i,j)]]+M                                                             [min(i,j)+1:max(i,j)]+[M[min(j,i)]]+M[max(
  j,i)+1:]if i-j else M,lambda M:[[M[i][j]for i                                                              in range(len(M))]for j in range(len(M[0
                                                                                                                ]))]))(lambda f,l,*n:f(f,l,*n))

entry #8

written by olive
submitted at
0 likes

guesses
comments 3
louna ¶

Hello Olive, I hope this message finds you well. My name is Louna, and I would like to sell you snake oil. Best Regards, Louna


olive replying to louna ¶

Heyo Louna, thank you, I'm doing well :) How goes you? Unfortunately I don't know any be-scaled friends, so I have no use for snake oil. Do you sell products for furred or mechanical people?


louna ¶

Hello Olive, Actually, reconcidering everything i think money based economics is kinda cringe and we could instead do mutual aid. I can make you robot motor oil from potatos if that helps - please do reach out if there is anything else you would need. Best regarsd, Louna


post a comment


submersible.lua 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
-- assume newlines are not begarbed

-- todo: utf8it

local freqs = {}
local file = io.open((arg[1] or "eso-off-topic.trim.txt"), "r")
for line in file:lines() do
	for c in line:gmatch(".") do
		freqs[c] = (freqs[c] or 0) + 1	
	end
end
file:close()

local lines = {}
local gecs = {}
for line in io.stdin:lines() do
	lines[#lines+1] = line
	for c in line:gmatch(".") do
		gecs[c] = (gecs[c] or 0) + 1
	end
end
io.stdin:close()

-- this is awful but no time
local function sorteet(m)
	local nl = {}
	for k,v in pairs(m) do
		nl[#nl+1] = {k,v}
	end
	table.sort(nl, function(a,b)
		return a[2] > b[2]
	end)
	local ln = {}
	for k,v in pairs(nl) do
		ln[#ln+1] = v[1]
	end
	return ln
end

local frome = sorteet(freqs)
local toe = sorteet(gecs)

local map = {}
for i,v in ipairs(frome) do
	map[v] = toe[i]
end

for i, line in ipairs(lines) do
	io.write(line:gsub(".", function(c) return map[c] end))
	io.write("\n")
end

entry #9

written by Makefile_dot_in
submitted at
0 likes

guesses
comments 0

post a comment


c.st Unicode text, UTF-8 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
#!/home/olus2000/programy/smalltalk-3.2/gst

Object subclass: CipherCracker [
    | corpusBag inputBag count tbl |
    <comment: 'I crack subtitution ciphers ^_^'>

    CipherCracker class >> new [
        | r |
        r := super new.
        r init.
        ^r
    ]
    
    init [
        <category: 'initialization'>
        corpusBag := Bag new.
        inputBag := Bag new.
        count := 0.
    ]

    learn: corpus [
        <category: 'processing'>
        <comment: 'I update the cracker to expect text similar to the one provided.'>
        corpus do: [:c | c isLetter ifTrue: [corpusBag add: c asLowercase]].
    ]

    prescan: input [
        <category: 'processing'>
        <comment: 'I learn the frequency of letters in the input.'>
        input do: [:c | c isLetter ifTrue: [inputBag add: c asLowercase]].
    ]

    beforeCrack [
        <category: 'processing'>
        tbl := LookupTable new.
        inputBag sortedByCount
            with: corpusBag sortedByCount
            do: [:i :c | tbl at: i value put: c value].
    ]

    crack: string [
        <category: 'processing'>
        <comment: 'I cracka da string.'>
        count := count + 1.
        ^(string collect: [:c | c isUppercase
                              ifTrue: [(tbl at: c asLowercase ifAbsent: [c asLowercase]) asUppercase]
                              ifFalse: [tbl at: c ifAbsent: [c]]
                          ]) asString
    ]

    stats [
        <category: 'statistics'>
        ^'BORN TO SPAM
WORLD IS A MJAU
鬼神 Love Em All %1
I am l​ouna ^_^
' % { count }
    ]    
]

Dictionary extend [
    at: key ifAbsent: absent ifPresent: present [
        present value: (self at: key ifAbsent: [^absent value])
    ]
]
FileStream class extend [
    withOpen: fn mode: m do: block [
        | f |
        f := self open: fn mode: m.
        [block value: f] ensure: [f close].
    ]

    withOpen: fn1 mode: m1 and: fn2 mode: m2 do: block [
        | f1 f2 |
        f1 := self open: fn1 mode: m1.
        f2 := self open: fn2 mode: m2.
        [block value: f1 value: f2] ensure: [f1 close. f2 close].
    ]
]

Object subclass: Program [
    | input output corpus |

    arguments := LookupTable new
                 at: $c put: #corpus:;
                 at: $i put: #input:;
                 at: $o put: #output:;
                 yourself.
   
    corpus: filename [corpus := filename]
    input:  filename [input  := filename]
    output: filename [output := filename]

    run [
        | err cracker |
        err := false.
        Smalltalk arguments: '-c: -i: -o:'
                  do: [:name :arg | arguments
                                  at: name
                                  ifAbsent: [err := true]
                                  ifPresent: [:sel | self perform: sel with: arg].
                      ]
                  ifError: [^self usage].
        err ifTrue: [^self usage].
        corpus ifNil: [^self usage].
        input ifNil: [^self usage].
        output ifNil: [^self usage].
        
        cracker := CipherCracker new.
        FileStream withOpen: corpus
                   mode: FileStream read
                   do: [:f | f linesDo: [:l | cracker learn: l]].

        FileStream withOpen: input
                   mode: FileStream read
                   and: output
                   mode: FileStream write
                   do: [:in :out |
                        in linesDo: [:line | cracker prescan: line].
                        cracker beforeCrack.
                        in reset.
                        in linesDo: [:line | out << (cracker crack: line); nl]
                       ].
        cracker stats displayNl.
    ]

    usage [
        FileStream stderr << 'cracker.st -c CORPUS -i INPUT -o OUTPUT'; nl.
        ObjectMemory quit: 2
    ]
]

Program new run