Skip to content

Instantly share code, notes, and snippets.

@nbervar21
Last active December 6, 2018 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbervar21/2f34381e9f8e5edc0dbd2610c5474303 to your computer and use it in GitHub Desktop.
Save nbervar21/2f34381e9f8e5edc0dbd2610c5474303 to your computer and use it in GitHub Desktop.
caesar_oneline.c - compact caesar cipher in c
#include <cs50.h> // caesar_oneline.c by Nick "the one-line god" Bervar
#include <stdio.h>
int main(int c, char *v[])
{
for (char i = ((c == 2) ? 0 : ((printf("Usage: ./caesar k\n") * 0) + INT_MAX)), *p = (c == 2) ? get_string("plaintext: ") : ""; p[(int)i] != '\0'; i += ((int)i == INT_MAX) ? 0 : ((printf("%s%c%s", (i < 1) ? "ciphertext: " : "", ((p[(int)i] >= 'A' && p[(int)i] <= 'Z') || (p[(int)i] >= 'a' && p[(int)i] <= 'z')) ? (p[(int)i] - ((p[(int)i] - 'A') % ('a' - 'A'))) + ((((p[(int)i] - 'A') % ('a' - 'A')) + atoi(v[c == 2 ? 1 : 0])) % 26) : p[(int)i], (p[(int)i + 1] != '\0') ? "" : "\n") * 0) + 1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment