Instantly share code, notes, and snippets.

# Jason Sperskejasonsperske

Block or report user

### Report or block jasonsperske

Hide content and notifications from this user.

• Sort options
Last active May 26, 2019
Like my WADParser.py but for Duke Nukem 3D MAP files
View GRPParser.py
 #!/usr/bin/env python3 import struct import re import io from collections import namedtuple GrpFileDefinition = namedtuple('GrpFileDefinition', 'name size') Line = namedtuple('Line', 'a b is_one_sided')
Last active Dec 23, 2018
An Amazon Technical interview question I received this year. Write a function that when given a map (a 2-dimensional grid where 1 is a walk-able square, 0 is an impassable square and 9 is the destination) and starting at the top left (x:0, y:0) finds the shortest path to the destination
View Examples.java
 import java.util.Arrays; public class Examples { public static void main(String ... args) { Solution s = new Solution(); System.out.print("Example problem: "); System.out.println(s.shortest(3, 3, Arrays.asList( Arrays.asList(1, 0, 0),
Last active Dec 20, 2018
 MIT License Copyright (c) 2018 Jason Sperske Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Last active Feb 3, 2018
Another Google technical interview question that left me stumped. "Write an algorithm that counts the number of ways you can paint a fence with N posts using K colors such that no more than 2 adjacent fence posts are painted with the same color". Here is a recursive approach:
View FencePainter.js
 var paint = function (posts, colors, display) { var painter = function (posts, colors, fence, count, display) { var color, total = count; if (posts === 0) { //Would you like to see them? Pass a display function if(display) { display(fence); } return 1; } else {
Created Nov 20, 2017
HueSegments
View hue.js
 //An example of this can be seen at https://jsfiddle.net/uLzwv8mx/ function HueSegments(steps) { var segments = [] var step var increment = 200/steps for(step = 0; step < steps; step++) { segments.push("hsla("+(Math.floor(increment*step))+", 100%, "+(step % 2 == 0 ? "75" : "50")+"%, 1)") } return segments }
Created Nov 1, 2017
Setting a deep JSON property with one call, a answer to a question on StackOverflow that was deleted before I could post it https://stackoverflow.com/questions/47064851/read-or-init-js-variable-to-avoid-cannot-read-property-of-undefined#47064851
View deepSet.js
 function deepSet(keys, defaultValue) { var keyNames = keys.split('.') var out = defaultValue var temp var size = keyNames.length var i for (i = size - 1; i >= 0; i--) { temp = out out = {}
Created Sep 28, 2017
InstallCert.java Posted at 22:28 Oct 09, 2006 by Andreas Sterbenz
View InstallCert.java
 /* * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. *
Created Sep 6, 2017
View keybase.md

### Keybase proof

I hereby claim:

• I am jasonsperske on github.
• I am sperske (https://keybase.io/sperske) on keybase.
• I have a public key ASDulU5JtSD8n6FbUOUc-Ew2aEepk77hUZO8-pUPKWGyJAo

To claim this, I am signing this object:

Last active Jul 12, 2017
Find the deepest left most node in a binary tree (and it's depth). A working demo can be found at: http://jsfiddle.net/YfLx6/5/
View deepestNode.js
 var Node = function(name, left, right) { this.name = name; this.left = left; this.right = right; }, findDeepest = function(node, depth) { var left, right, depth = depth || 0; if(typeof node !== 'undefined') { left = findDeepest(node.left, depth+1); right = findDeepest(node.right, depth+1);
Created Jun 21, 2017
Get Location Information
View index.html
 GeoLocation Diagnostics
You can’t perform that action at this time.