Skip to content

Instantly share code, notes, and snippets.

@dillmo
dillmo / 10.cpp
Created February 21, 2014 15:33
C++ Homework Problem Set 2 solutions
/* Problem Set 2 Question 10 by Dillon Morse
* -----------------------------------------
* Write a program that converts Celsius temperatures to Fahrenheit
* temperatures.
*/
#include<iostream>
using namespace std;
double get_celsius() {
@dillmo
dillmo / 12.cpp
Created February 21, 2014 19:26
Solutions for C++ Problem Set 3
/* Problem Set 3 Question 12 solution by Dillon Morse
* --------------------------------------------------
* A bank charges $10 per month plus the following check fees for a commercial
* checking account:
*
* $0.10 each for fewer than 20 checks
* $0.08 each for 20-39 checks
* $0.06 each for 40-59 checks
* $0.04 each for 60 or more checks
*
@dillmo
dillmo / 3x3_tunnel.lua
Created February 22, 2014 15:22
A ComputerCraft program to dig a lit 3x3 tunnel
-- 3x3 Tunnel by dillmo --
--[[
This program creates a 3x3 lit-up tunnel for as far as you want. To run
this program, place your turtle on the bottom row of the middle column of
your tunnel wall. Then, place torches in the turtle's first inventory
slot and cobblestone is the second slot. Before running the program, be
sure to configure the program to meet your needs.
--]]
-- Configuration --
@dillmo
dillmo / make_branches.lua
Last active August 29, 2015 13:56
A ComputerCraft program to perforate tunnel walls with lit tunnels, in order to expose ores
--[[ Branch Miner by dillmo
----------------------
Begin by placing the turtle facing forward two blocks three blocks before
the next strip. If you have already started, this is at the end of the
last strip. Next, place torches in slot one of the turtle's inventory and
cobblestone in the second. Finally, specify your preferences in
Customization and run the program. The turtle will continue until it
reaches the end of your main tunnel.
--]]
@dillmo
dillmo / lab_4.cpp
Created March 7, 2014 19:59
Introduction to C++ Lab 4
/* Lab 4 Solution by Dillon Morse
* ------------------------------
* Generate four random number grades between 1 and 100. Then, drop the lowest
* grade and issue a letter grade, rounding up.
*/
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
@dillmo
dillmo / test_1_lab.cpp
Created March 21, 2014 18:40
Intro to C++ Test 1 Lab Solution
/* Dillon Morse - ASD Intro to C++ Test 1 Lab Solution
* ---------------------------------------------------
* Write a program that will input an arbitrary number of people who want to
* play on a soccer team. We will not accept more than 20 applicants.
*
* Now determine how many teams of 11 people on a side can we form?
*
* Full credit requires that you handle incorrect data.
*/
@dillmo
dillmo / 10.cpp
Created March 25, 2014 18:23
Intro to C++ Homework Problem Set 4 Solutions
/* Problem Set 4 Question 10 solution by Dillon Morse
* --------------------------------------------------
* Write a proram that uses nested loops to collect data and calculate the
* average rainfall over a period of years. The program should first ask for
* the number of years. The outer loop will iterate once for each year. The
* inner loops will iterate twelve times, once for each month. Each iteration
* of the inner loop will ask the user for the inches of rainfall for that
* month.
*
* After all iterations, the program should display the number of months, the
@dillmo
dillmo / solve_the_global_debt.cpp
Created March 29, 2014 00:03
Solve the Global Debt Code Challeng solution
#include<iostream>
#include<cstring>
#include<vector>
#include<sstream>
#include<cstdlib>
using namespace std;
int main() {
vector<string> input, countries, output;
@dillmo
dillmo / dwarves_and_coins.cpp
Created April 4, 2014 14:39
Solution to the Dwarves and Coins problem
/* Dwarves and Coins Solution by Dillon Morse
* ------------------------------------------
* Several (M) dwarves have found a goblin's chest with N gold coins and have
* to divide them. Due to ancient rules governing the allocation of loot to
* pirates in order of seniority, the oldest dwarf should get one coin more
* than the next oldest dwarf, and so on, so that the youngest dwarf gets M-1
* fewer coins than the oldest dwarf. Additionally, no dwarf has to pitch in
* any coins (ie no negative coins to any dwarfs)
*
* Help the dwarves to divide the coins in this way, or tell them that this is
@dillmo
dillmo / test_2_lab.cpp
Created April 8, 2014 19:05
Introduction to C++ Test 2 Lab solution
/* Introduction to C++ Test 2 Lab solution by Dillon Morse
* -------------------------------------------------------
* a) Write a program that will create a file that will contain
* the data values:
* 4 -9 7
* 1 -1 8
* 7 4 5
* 9 0 -3
* when your program completes.
*