Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jsp1611 on github.
  • I am jpoulton (https://keybase.io/jpoulton) on keybase.
  • I have a public key ASD83O5Y8gADmSAG8sdXcnHhwLEUhO5hzVP0hPfw0MUeeQo

To claim this, I am signing this object:

@jsp1611
jsp1611 / RemovingElements.java
Created June 30, 2019 12:34
Removing Elements CW Ex.
/**
* Remove every other element from an array.
*
* @author jon
*/
public class RemovingElements {
public static String[] remove(final String[] arr) {
final String[] rem = new String[arr.length % 2 == 0
? arr.length / 2
@jsp1611
jsp1611 / GoingToTheCinema.java
Created June 30, 2019 12:31
Going to the Cinema CW Ex
/**
* Going to the cinema.
*
* @author jon
*/
public class GoingToTheCinema {
public static int movie(final int card, final int ticket, final double perc) {
int visits = 0;
double systemA = 0;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.EnumSet;
import static java.nio.file.FileVisitOption.FOLLOW_LINKS;
import static java.nio.file.FileVisitResult.CONTINUE;
/**
* Recursively iterate over a file structure starting at some
package com.codenumb.vtd;
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import com.ximpleware.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@jsp1611
jsp1611 / exercise-1-11.scm
Last active October 16, 2015 11:57
Exercise 1.11 in SICP. First attempt is linear recursive.
;; Define a function f such that:
;; f(n) = n if n<3 and f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) if n> 3
;; This is the recursive implementation that doesn't scale well
(define (f n)
(if (< n 3)
n
(+ (f (- n 1))
(* 2 (f (- n 2)))
(* 3 (f (- n 3))))
)