C, 358 바이트
(코드는 3 줄 밖에 없지만 가독성을 위해 3 줄을 나누었습니다.)
#define x putchar
#define y random()
c,n;main(){char*s[26]={"QS","HNV","FVX","EFSX","DRW","CDGR","FHTV","BGJY","KOU","HKNU",
"IJLM","KO","KN","BJM","ILP","OO","AW","EFT","ADWZ","GRY","IJY","BCG","ESQ","CDZ","HTU",
"SX"};while((c=getchar())>0){if(y%10>0&&x(c))continue;if(isalpha(c)&&y%3<1){n=(c&31)-1;
x(s[n][y%strlen(s[n])]|(c&32));continue;}if (y&1)x(x(c));}}
시작 부분의 문자열 배열은 알파벳의 각 문자에 대해 가능한 인접 키를 나열합니다. random()%1
이동 문자를 선택할 때 계산을 피하기 위해 "O"( "P"에 인접)를 두 배로 늘려야했습니다.
시운전 :
$ echo "This is some correct text. It is too correct. Please un-correctify it." |./a.out
This is some cofrect teext. It is too correct.. Plleaase un-correctify it..
최신 정보:
다음은 동일한 소스 코드의 확장 및 주석 처리 된 버전입니다.
#include <stdio.h>
#include <string.h>
/* ^^ These should be included, but the code compiles without them */
int c,n;
void main() {
/* Adjacent keys for each letter of the alphabet (A, B, C, ..., Z): */
char *s[26] = { "QS","HNV","FVX","EFSX","DRW","CDGR","FHTV","BGJY","KOU","HKNU",
"IJLM","KO","KN","BJM","ILP","OO","AW","EFT","ADWZ","GRY","IJY",
"BCG","ESQ","CDZ","HTU","SX" };
/* Fetch input until null character or EOF reached */
while ((c=getchar())>0) {
/* For 90% of the time, just echo the character unchanged */
if (random()%10>0 && putchar(c)) continue;
/* If it's a letter of the alphabet, shift with 33% probability */
if (isalpha(c) && random()%3<1) {
/* Calculate offset to adjacent keys data */
n=(c&31)-1;
/* Choose a random adjacent key, and change to lower case if needed */
putchar(s[n][random()%strlen(s[n])]|(c&32));
continue;
}
/* If we reach this point, either we didn't fetch an alphabet character, or */
/* we did but chose not to shift it. Either way, we now need to either repeat */
/* the character or delete it, with 50% probability for each. */
/* This repeats the character by printing the return value from putchar() */
if (random()&1) putchar(putchar(c));
/* To delete the character, we don't have to do anything. */
}
}