Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Gorman jasongorman

View GitHub Profile
View rover_test.js
describe('Mars Rover', () => {
[
{facing: 'N', endsFacing: 'E'},
{facing: 'E', endsFacing: 'S'},
{facing: 'S', endsFacing: 'W'},
{facing: 'W', endsFacing: 'N'}
].forEach(({facing, endsFacing}) => {
it('turns right from ${facing} to ${endsFacing}', () => {
let rover = {facing: facing};
rover = exec(rover, 'R');
View basket_test.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. BASKET-TEST.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
COPY 'total_params.cpy'.
COPY 'test_context.cpy'.
01 expected PIC 9(04)V9(2).
PROCEDURE DIVISION.
MAIN-PROCEDURE.
View sqrt.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. SQRT.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 prev PIC 9(08)V9(12) VALUE ZEROES.
LINKAGE SECTION.
01 num PIC 9(08)V9(12).
01 root PIC 9(08)V9(12) VALUE ZEROES.
View cd_warehouse_test.js
const assert = require('assert');
function CD(artist, title, stock) {
this.stock = stock;
this.getStock = function () {
return this.stock;
};
this.buy = function () {
View cd_warehouse_test.js
const assert = require('assert');
function Warehouse(catalogue) {
this.catalogue = catalogue;
this.getCd = function (artist, title) {
return this.catalogue.find((cd) => cd.artist == artist && cd.title == title);
};
this.buyCd = function (artist, title, catalogue) {
View cd_warehouse_test.js
const assert = require('assert');
function Warehouse(catalogue) {
this.catalogue = catalogue;
this.getCd = function (artist, title) {
return this.catalogue.find((cd) => cd.artist == artist && cd.title == title);
}
this.updatedCatalogue = function (cd, boughtCd) {
View cd_warehouse_test.js
function buyCd(artist, title, catalogue) {
const cd = catalogue.find((cd => cd.artist == artist && cd.title == title));
return {...catalogue, [catalogue.indexOf(cd)] : {...cd, stock: cd.stock-1}};
}
View TrainMotion.java
package com.codemanship.xmastrain;
public class TrainMotion {
private static final int SECONDS_PER_HOUR = 3600;
private static final int METRES_PER_KM = 1000;
private final double acceleration;
private final double topSpeed;
private double velocity;
private double distance;
private final Sensor sensor;
View rockpaperscissors_test.py
import unittest
from parameterized import parameterized
PAPER = "paper"
SCISSORS = "scissors"
ROCK = "rock"
DRAW = 0
PLAYER_ONE_WINS = 1
PLAYER_TWO_WINS = 2
View rental.py
class Rental(object):
def __init__(self, customer, imdbID, pricer):
self._customer = customer
self._movie = pricer.price(imdbID)
def __str__(self):
return "Movie Rental - customer: " + self._customer \
+ ". Movie => title: " + self._movie.get_title() \
+ ", price: £" + str(self._movie.get_price())
You can’t perform that action at this time.