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 <string.h> | |
#include <ctype.h> | |
/** | |
* Caesar.c | |
* A program that encrypts messages using Caesar’s cipher. Your program must | |
* accept a single command-line argument: a non-negative integer. Let’s call it | |
* k for the sake of discussion. If your program is executed without any |
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 <string.h> | |
#include <ctype.h> | |
#include <math.h> | |
// calculates the number of digits in the card number | |
int getCardDigits(long long card_num) | |
{ | |
int card_digits = (int)log10(card_num) + 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
/** | |
* helpers.c | |
* | |
* Computer Science 50 | |
* Problem Set 3 | |
* | |
* Helper functions for Problem Set 3. | |
*/ | |
#include <cs50.h> |
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
/** | |
* helpers.c | |
* | |
* Computer Science 50 | |
* Problem Set 3 | |
* | |
* Helper functions for Problem Set 3. | |
*/ | |
#include <cs50.h> |
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
//n is the last index of the array | |
int arr_sum(int arr[], int n ) | |
{ | |
//base case | |
if (n == 0) | |
{ | |
return arr[0]; | |
} | |
return (arr[n] + arr_sum(arr,n-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
#include "stdio.h" | |
//n is the last index of the array | |
int arr_count(int count, int n) | |
{ | |
//base case | |
if (n == 0) | |
{ | |
return count; |
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> | |
/* [2016-06-13] Challenge #271 [Easy] Critical Hit | |
* http://bit.ly/1sLH0bn | |
* | |
* Critical hits work a bit differently in this RPG. If you roll the maximum value on a die, you | |
* get to roll the die again and add both dice rolls to get your final score. Critical hits can | |
* stack indefinitely -- a second max value means you get a third roll, and so on. With enough |
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
var userChoice = prompt("Do you choose rock, paper or scissors?"); | |
var computerChoice = Math.random(); | |
if (computerChoice < 0.34) { | |
computerChoice = "rock"; | |
} else if (computerChoice <= 0.67) { | |
computerChoice = "paper"; | |
} else { | |
computerChoice = "scissors"; | |
} console.log("Computer: " + computerChoice); |
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> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main (void) | |
{ | |
int tilecount[] = { 9, 2, 2, 4, 12, 2, 3, 2, 9, 1, 1, 4, 2, 6, 8, 2, 1, 6, | |
4, 6, 4, 2, 2, 1, 2, 1, 0, 0, 0, 0, 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
/** | |
* degree.c | |
* | |
* Reddit Daily Programmer Challenge #273 [EASY] | |
* Getting a degree | |
* | |
* https://www.reddit.com/r/dailyprogrammer/comments/4q35ip/20160627_challenge_273_easy_getting_a_degree/ | |
* | |
*/ | |
OlderNewer