This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
int isLower(char chr) {return chr >= 'a' && chr <= 'z';} | |
int isUpper(char chr) {return chr >= 'A' && chr <= 'Z';} | |
int isAlpha(char chr) {return isUpper(chr) || isLower(chr);} | |
char toLower(char chr) {return isUpper(chr) ? chr - ('A' - 'a') : chr;} | |
char toUpper(char chr) {return isLower(chr) ? chr + ('A' - 'a') : chr;} | |
int fib(int n) {return n < 2 ? n ? fib(n - 1) + fib(n - 2);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define EMPTY -1 | |
// translate human-readable coordinates to char indexes on board | |
int translateRow[4] = {EMPTY, 22, 42, 62}; | |
int translateCol[4] = {EMPTY, 0, 2, 4}; | |
char currentPiece[2] = "OX"; | |
// ---- translateWinConditions explanation ---- | |
// 9 is for the squares on the board, as follows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// credit.c by Nick Bervar (2019) | |
#include <stdio.h> | |
#include <cs50.h> | |
#include <math.h> | |
int main(void) | |
{ | |
long long c = 0, t = 0; | |
for (; c < 1; c = get_long_long("Number: ")); | |
for (int i = 1, q = c; l = log10(c); i < l; i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mario.c by Nick Bervar (2019) | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int c, char *v[]) | |
{ | |
for (int i = 1, s = c > 1 ? atoi(v[1]) : 6, g = c > 2 ? atoi(v[2]) : 2; i <= s; i++) | |
{ | |
for (int j = 1, m = g + (s * 2); j <= m + 1; j += (printf(j < m + 1 ? ((j <= s - i || j > s + g + i || (j > s && j <= s + g)) ? " " : "#") : "\n") * 0) + 1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original version - passes check50 and style50 | |
#include <cs50.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <ctype.h> | |
#define 👌 int | |
#define 🔒 "Usage: ./caesar k\n" | |
#define 🍑 strlen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// chess.c by Nick Bervar | |
#include <cs50.h> | |
#include <stdio.h> | |
// only used for printBox, temporary | |
#include <string.h> | |
// ============================== | |
// === preprocessor constants === | |
// ============================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//🙂🔫 | |
#include <stdio.h> | |
#include <cs50.h> | |
#include <math.h> | |
#define 👌 int | |
#define 🍐 1 | |
#define 🔒 "Number: " | |
#define 🍑 10 |