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> | |
/** | |
* Vigenere.c | |
* | |
* A program that encrypts messages using Vigenère’s cipher. This program | |
* must accept a single command-line argument: a keyword, k, composed entirely |
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
// Normal | |
const bubbleSort = function(array) { | |
let swaps; | |
do { | |
swaps = false; | |
for (let i = 0; i < array.length - 1; i++) { | |
if (array[i] > array[i + 1]) { | |
let temp = array[i + 1]; | |
array[i + 1] = array[i]; | |
array[i] = temp; |
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
// Setup | |
mocha.setup('bdd'); | |
chai.should(); | |
chai.config.includeStack = false; | |
const assert = chai.assert; | |
describe('addTwoNumbers', () => { | |
it('Adds two positive numbers', function() { | |
assert.equal(addTwoNumbers(10, 2), 12); |
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
/** | |
* fifteen.c | |
* | |
* Computer Science 50 | |
* Problem Set 3 | |
* | |
* Implements Game of Fifteen (generalized to d x d). | |
* | |
* Usage: fifteen d | |
* |
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
// Copyright 2013 Soundslice LLC. License: BSD. | |
/* HTML example: **************** | |
<figure class="vid"> | |
<video preload> | |
<source src="/videos/help/playhead.mp4" type="video/mp4"> | |
<source src="/videos/help/playhead.webm" type="video/webm"> | |
</video> | |
<p>To move the playhead, click in the timeline or drag the playhead’s diamond.</p> |
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
// Copyright 2013 Soundslice LLC. License: BSD. | |
/* HTML example: **************** | |
<figure class="vid"> | |
<video preload> | |
<source src="/videos/help/playhead.mp4" type="video/mp4"> | |
<source src="/videos/help/playhead.webm" type="video/webm"> | |
</video> | |
<p>To move the playhead, click in the timeline or drag the playhead’s diamond.</p> |
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> | |
// function that returns the number of 16oz bottles used | |
int getBottles(int time, int showerflow) | |
{ | |
return (time * showerflow)/16; | |
} | |
int main(void) |
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
// array to reduce | |
// combine is a function that will do something to the current value and the current element | |
// current is either the start provided or 0 if nothing is provided? | |
function reduce(array, combine, start) { | |
var current = start || 0; | |
for (var i = 0; i < array.length; i++) | |
current = combine(current, array[i]); | |
return current; | |
} |
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 bankAccount = prompt("How much money is in your bank account?"); | |
var spendingLimit = prompt("What is the max amount mof money do you wish to spend?") | |
var phonePrice = 100, accessoryPrice = 20, taxRate = 0.06, cost = 0; | |
function finalCheckout(amt) { | |
amt = amt + (amt * taxRate); | |
if (amt < bankAccount) | |
console.log("You can afford this!"); | |
else |
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
// | |
// server.c | |
// | |
// Computer Science 50 | |
// Problem Set 6 | |
// | |
// feature test macro requirements | |
#define _GNU_SOURCE | |
#define _XOPEN_SOURCE 700 |