Skip to content

Instantly share code, notes, and snippets.

@jakewilson801
jakewilson801 / gist:5552126
Created May 10, 2013 02:55
Job Interview Question Numbers are assigned to each letter of the alphabet, where a=1, b=2, ..., z=26. A word can then be encoded based on those numbers, so for example "apple" is encoded as "11616125". However, "11616125" can also be decoded to many other strings, such as "kfafay" (11 6 1 6 1 25) and "aafple" (1 1 6 16 12 5). Letters are never …
import java.util.ArrayList;
public class DecoderTree {
public static void main(String args[]) {
System.out.println(decode("2222"));
System.out.println(decode("105"));
System.out.println(decode("2175"));
System.out.println(decode("0000"));
}
@jakewilson801
jakewilson801 / gist:5552139
Last active December 17, 2015 04:39
An amazing command line built in c++ for an Operating Systems class in school
#include "wsh.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <map>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
@jakewilson801
jakewilson801 / gist:5552165
Created May 10, 2013 03:05
12 Days of christmas recursively had to do it.
import java.util.ArrayList;
import java.util.List;
public class Days {
public static void main(String args[]) {
List<String> days = new ArrayList<String>();
days.add(new String("A Partridge in a Pear Tree"));
@jakewilson801
jakewilson801 / gist:5552192
Created May 10, 2013 03:19
Some awesome graph code from school
//
// main.cpp
// Graph
//
// Created by Jacob Wilson on 4/11/12.
// Copyright (c) 2012 Weber State. All rights reserved.
//
#include <iostream>
#include <iomanip>
@jakewilson801
jakewilson801 / gist:5552201
Created May 10, 2013 03:22
Good ol sorting stuff from school
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
class ArraySort {
public:
ArraySort(int size);
@jakewilson801
jakewilson801 / gist:5552206
Created May 10, 2013 03:23
Good ol binary tree stuff
//
// main.cpp
// Trees
//
// Created by Jacob Wilson on 3/27/12.
// Copyright (c) 2012 Weber State. All rights reserved.
//
#include <iostream>
#include <string>
@jakewilson801
jakewilson801 / gist:5552207
Created May 10, 2013 03:24
Rollin my own hash map. College c++ style :)
//
// main.cpp
// HashMap
//
// Created by Jacob Wilson on 2/28/12.
// Copyright (c) 2012 Weber State. All rights reserved.
//
#include <iostream>
@jakewilson801
jakewilson801 / crap
Created July 11, 2013 04:47
My attempt and reading in a relation-database like file with id's
items = new ArrayList<Item>();
for(String s : lines){
String[] data = s.split("|");
items.add(new Item(Integer.parseInt(data[0]), data[1],data[2], new ArrayList<Item>()));
}
for(int i =0; i< lines.size(); i++){
String[] temp = lines.get(i).split("|");
List<Integer> ids = new ArrayList<Integer>();
String[] temp2 = temp[3].split(",");
@jakewilson801
jakewilson801 / test
Created September 11, 2013 03:50
I got 99 problems and a bit aint one
import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(String args[]) {
System.out.println(getC(2));
System.out.println(getC(3));
@jakewilson801
jakewilson801 / gist:7969095
Created December 15, 2013 04:58
How to parse json using GSON
public Summary summaryData;
AsyncHttpClient client = new AsyncHttpClient();
client.get("http://i.tv/getmesomesuperawesomedata", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
Type listType = new TypeToken<Summary>() {}.getType();
summaryData = (Summary) new Gson().fromJson(response, listType);
//now summary data will be in memory from a json string
//no more traversing json objects to get the data we need this call does all that magic