Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/data/jtr/hybrid.conf
Views: 11765
[List.HybridLeet:new]1int i, j;2int c, p;3int totrots;4int length;56/* Get the word length */7length = 0; while (word[length++]) ; --length;89/* Skip if this word length is out of bounds10This should not be necessary, but we'll leave it here to be defensive */11if (req_minlen > length || (req_maxlen && req_maxlen < length ))12{13hybrid_total = 0;14return;15}1617/* Calculate word rotations */1819word_rot_count=0; /* Number of letter positions we are rotating for this word */20totrots = 1; /* Number of total rotation iterations */2122i=0;23while (i < length)24{25/* is this letter one of our rotators? a,A, b,B etc*/26c = word[i];27j = 0;28while (j < rot_poslen)29{30p = rot_pos[j];31if (c == rot_chars[p] || c == rot_chars[p+1]) /* Is 'a' or 'A' for example */32{33word_rot_idx[word_rot_count] = i; /* Save off which letter position in the word we are rotating */34word_rot_pos[word_rot_count] = j; /* Save off the rotation position for this slot */35word_rotchars_pos[word_rot_count] = p; /* Save off the first letter position in the rotation */36word_rot_count++;3738/* Also, set the word to the first letter in the rotation so we ensure to go through all of them */39word[i] = rot_chars[p];4041/* And multiple number of total rotations by the number of rotations for this position */42totrots = totrots * rot_len[j];4344break;45}46j++;47}48i++;49}5051hybrid_total = totrots;5253/* Reset or counter for THIS word. */54word_rot_current = 0;5556[List.External:HybridLeet]5758/*59Static context60String lengths here are arbitrary, increase them if you increase the61size of the stuff in the init() procedure62*/6364int rot_chars[256]; /* All characters to rotate */65int rot_charslen; /* The length of the rot_chars buffer */6667int rot_len[26]; /* The number of characters to rotate through per letter */68int rot_pos[26]; /* The starting position of each letter group in the rot_chars string */69int rot_poslen; /* Length of rot_pos and rot_len arrays (both same size) */7071int word_rot_idx[128]; /* The positions in the current word that require rotations (index into word)*/72int word_rot_pos[128]; /* The rot_pos index for each letter position in the current word that we are rotating (index into rot_pos)*/73int word_rotchars_pos[128]; /* The current rot_chars index for each letter position in the current word that we are rotating (state of rotation, index into rot_chars)*/74int word_rot_count; /* The number of letters that we are rotating in the current word (size of word_rot_idx, word_rot_pos, and word_rotchars_pos) */7576int word_rot_current; /* The rotation number of the current word */7778void init()79{80int rci;81int ri;8283rot_charslen=0;84rci=0;85ri=0;8687/* a */88rot_pos[ri] = rci;89rot_chars[rci++] = 'a'; /* The first two chars are always the lower */90rot_chars[rci++] = 'A'; /* and upper case letters to rotate on */91rot_chars[rci++] = '4';92rot_chars[rci++] = '@';93rot_chars[rci++] = '8';94rot_len[ri] = (rci - rot_pos[ri]);95ri++;9697/* b */98rot_pos[ri] = rci;99rot_chars[rci++] = 'b';100rot_chars[rci++] = 'B';101rot_chars[rci++] = '8';102rot_len[ri] = (rci - rot_pos[ri]);103ri++;104105rot_pos[ri] = rci;106rot_chars[rci++] = 'c';107rot_chars[rci++] = 'C';108rot_len[ri] = (rci - rot_pos[ri]);109ri++;110111rot_pos[ri] = rci;112rot_chars[rci++] = 'd';113rot_chars[rci++] = 'D';114rot_len[ri] = (rci - rot_pos[ri]);115ri++;116117/* e */118rot_pos[ri] = rci;119rot_chars[rci++] = 'e';120rot_chars[rci++] = 'E';121rot_chars[rci++] = '3';122rot_len[ri] = (rci - rot_pos[ri]);123ri++;124125rot_pos[ri] = rci;126rot_chars[rci++] = 'f';127rot_chars[rci++] = 'F';128rot_len[ri] = (rci - rot_pos[ri]);129ri++;130131rot_pos[ri] = rci;132rot_chars[rci++] = 'g';133rot_chars[rci++] = 'G';134rot_len[ri] = (rci - rot_pos[ri]);135ri++;136137/* h */138rot_pos[ri] = rci;139rot_chars[rci++] = 'h';140rot_chars[rci++] = 'H';141rot_chars[rci++] = '#';142rot_len[ri] = (rci - rot_pos[ri]);143ri++;144145/* i */146rot_pos[ri] = rci;147rot_chars[rci++] = 'i';148rot_chars[rci++] = 'I';149rot_chars[rci++] = '1';150rot_chars[rci++] = '!';151rot_len[ri] = (rci - rot_pos[ri]);152ri++;153154rot_pos[ri] = rci;155rot_chars[rci++] = 'j';156rot_chars[rci++] = 'J';157rot_len[ri] = (rci - rot_pos[ri]);158ri++;159160rot_pos[ri] = rci;161rot_chars[rci++] = 'k';162rot_chars[rci++] = 'K';163rot_len[ri] = (rci - rot_pos[ri]);164ri++;165166/* l */167rot_pos[ri] = rci;168rot_chars[rci++] = 'l';169rot_chars[rci++] = 'L';170rot_chars[rci++] = '1';171rot_len[ri] = (rci - rot_pos[ri]);172ri++;173174rot_pos[ri] = rci;175rot_chars[rci++] = 'm';176rot_chars[rci++] = 'M';177rot_len[ri] = (rci - rot_pos[ri]);178ri++;179180rot_pos[ri] = rci;181rot_chars[rci++] = 'n';182rot_chars[rci++] = 'N';183rot_len[ri] = (rci - rot_pos[ri]);184ri++;185186/* o */187rot_pos[ri] = rci;188rot_chars[rci++] = 'o';189rot_chars[rci++] = 'O';190rot_chars[rci++] = '0';191rot_len[ri] = (rci - rot_pos[ri]);192ri++;193194rot_pos[ri] = rci;195rot_chars[rci++] = 'p';196rot_chars[rci++] = 'P';197rot_len[ri] = (rci - rot_pos[ri]);198ri++;199200rot_pos[ri] = rci;201rot_chars[rci++] = 'q';202rot_chars[rci++] = 'Q';203rot_len[ri] = (rci - rot_pos[ri]);204ri++;205206rot_pos[ri] = rci;207rot_chars[rci++] = 'r';208rot_chars[rci++] = 'R';209rot_len[ri] = (rci - rot_pos[ri]);210ri++;211212/* s */213rot_pos[ri] = rci;214rot_chars[rci++] = 's';215rot_chars[rci++] = 'S';216rot_chars[rci++] = '$';217rot_chars[rci++] = '5';218rot_len[ri] = (rci - rot_pos[ri]);219ri++;220221/* t */222rot_pos[ri] = rci;223rot_chars[rci++] = 't';224rot_chars[rci++] = 'T';225rot_chars[rci++] = '+';226rot_chars[rci++] = '7';227rot_len[ri] = (rci - rot_pos[ri]);228ri++;229230rot_pos[ri] = rci;231rot_chars[rci++] = 'u';232rot_chars[rci++] = 'U';233rot_len[ri] = (rci - rot_pos[ri]);234ri++;235236rot_pos[ri] = rci;237rot_chars[rci++] = 'v';238rot_chars[rci++] = 'V';239rot_len[ri] = (rci - rot_pos[ri]);240ri++;241242rot_pos[ri] = rci;243rot_chars[rci++] = 'w';244rot_chars[rci++] = 'W';245rot_len[ri] = (rci - rot_pos[ri]);246ri++;247248rot_pos[ri] = rci;249rot_chars[rci++] = 'x';250rot_chars[rci++] = 'X';251rot_len[ri] = (rci - rot_pos[ri]);252ri++;253254rot_pos[ri] = rci;255rot_chars[rci++] = 'y';256rot_chars[rci++] = 'Y';257rot_len[ri] = (rci - rot_pos[ri]);258ri++;259260rot_pos[ri] = rci;261rot_chars[rci++] = 'z';262rot_chars[rci++] = 'Z';263rot_len[ri] = (rci - rot_pos[ri]);264ri++;265266rot_charslen = rci;267rot_poslen = ri;268269}270271/* new word */272void new()273{274.include [List.HybridLeet:new]275}276277void next()278{279int i, j;280281/* If we have reached the maximum number of rotations, we're done */282if (word_rot_current == hybrid_total)283{284word[0] = 0;285return;286}287288/* set word[] to the next candidate */289i=0;290while (i < word_rot_count)291{292/* Replace letter in word with appropriate rotated letter fom rot_chars */293word[word_rot_idx[i]] = rot_chars[word_rotchars_pos[i]];294i++;295}296297/* Rotate the word_rotchars_pos */298i=0;299while (i < word_rot_count)300{301word_rotchars_pos[i]++;302303j = word_rot_pos[i];304if (word_rotchars_pos[i] != (rot_pos[j] + rot_len[j]))305{306/* No carry */307break;308}309310/* Rotation overflow, carry to next rotation */311word_rotchars_pos[i] = rot_pos[j];312313i++;314}315316word_rot_current++;317}318319/* Called when restoring an interrupted session */320void restore()321{322int wrc;323324.include [List.HybridLeet:new]325326/* Pick up the current iteration */327word_rot_current = hybrid_resume;328329/* Zoom the word_rotchars_pos to the hybrid_resume iteration */330i=0;331wrc = word_rot_current;332333while (i < word_rot_count)334{335j = word_rot_pos[i];336337/* Rotate this position */338word_rotchars_pos[i] = rot_pos[j] + (wrc % rot_len[j]);339wrc = wrc / rot_len[j];340341i++;342}343}344345346