Skip to content

Instantly share code, notes, and snippets.

View Iboatwright's full-sized avatar

Ivan Boatwright Iboatwright

View GitHub Profile
@Iboatwright
Iboatwright / U4_L6.py
Last active March 22, 2016 15:53
Codecademy Python Unit 4 Lesson 6
def hotel_cost(nights):
return 140*nights
def plane_ride_cost(city):
if city == "Charlotte":
return 183
elif city == "Tampa":
return 220
elif city == "Pittsburgh":
return 222
@Iboatwright
Iboatwright / IBoatwright_U4_L6.py
Last active March 22, 2016 15:54
Codecademy Python Unit 4 Lesson 6 - my solution
def hotel_cost(nights):
return 140 * nights
def plane_ride_cost(city):
costs = {"Charlotte": 183,"Tampa": 220, "Pittsburgh": 222, "Los Angeles": 475}
return costs[city]
def rental_car_cost(days):
if days >= 7:
return days * 40 - 50
// from: http://www.cplusplus.com/forum/beginner/13044/#msg62827
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
//----------------------------------------------------------------------------
template <typename T>
struct input_t
@Iboatwright
Iboatwright / struct_testing.cpp
Last active March 16, 2017 22:48
testing some ideas for using a struct to handle arrays
#include <iostream>
using namespace std;
struct test_t {
int arr_sz = 2;
int* arr;
int var = 7;
};
@Iboatwright
Iboatwright / heap_test.cpp
Created March 17, 2017 23:55
testing new[] and destroy[] with struct ptr
#include <iostream>
struct equation_t
{
int coeffsCount = 3;
double coeffs[coeffsCount] = {};
int rootsCount = 2;
double roots[rootsCount] = {};
bool rootsExist = false;
};
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
using namespace std;
//Function prototypes
void getValidInput(double &, char);
void readCoeffs(double [], int);
#include <iostream>
#include <unistd.h>
using namespace std;
int main(int argc, char* argv[]) {
int pid = getpid(); // parent's process id
int numberOfChildren = 4;
void fun(int[][4], int, int, int&, int&);
int main(){
int arr[][4] = {{1,2,-3,4},{5,6,-3}};
int row, col;
fun(arr, sizeof(arr)/sizeof(int), sizeof(arr[0])/sizeof(int), row, col);
return 0;
}
@Iboatwright
Iboatwright / midterm_3_prep.md
Last active December 20, 2017 20:01
COP3003 Exam 3 study notes

COP3003 Exam 3 Study Note

Topics covered

Ordered by date introduced 3. chapter 20: Generic Classes and Methods

  • There is nothing in the study guide directly on generics
  • Likely it will be a part of something else, but not the focus
  1. chapter 16: Collections (Interface Collections, Class Collections)
  • Lists - Ordered by insertion, duplicates allowed
  • Sets - not ordered, only uniques
  • Maps - not ordered, key-value association
@Iboatwright
Iboatwright / Rotate.java
Created February 25, 2018 21:40
Java snippet for displaying 2D arrays and for rotating them.
/*
This is for displaying 2D arrays and for rotating them.
*/
public class Rotate {
public static void parr(int[][] arr){
System.out.println();
for (int i = 0; i < arr.length; i++) {
for (int j:arr[i]) {
System.out.printf("%-3d ", j);
}