Skip to content

Instantly share code, notes, and snippets.

View jasongorman's full-sized avatar

Jason Gorman jasongorman

View GitHub Profile
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');
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.
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.
const assert = require('assert');
function CD(artist, title, stock) {
this.stock = stock;
this.getStock = function () {
return this.stock;
};
this.buy = function () {
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) {
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) {
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}};
}
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;
import unittest
from parameterized import parameterized
PAPER = "paper"
SCISSORS = "scissors"
ROCK = "rock"
DRAW = 0
PLAYER_ONE_WINS = 1
PLAYER_TWO_WINS = 2
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())