Skip to content

Instantly share code, notes, and snippets.

@thedeagler
thedeagler / fogcreek.js
Created February 17, 2016 20:08
Fog Creek Software posted a puzzle on their software developer jobs page which asks you to crack a poor hashing function.
// Originally found at: http://www.fogcreek.com/jobs/dev/
/*
========================================
Prompt
========================================
*/
// Find a 9 letter string of characters that contains only the letters
var values = 'acdegilmnoprstuw';
// such that badHash(the_string) is
@thedeagler
thedeagler / Array+Rotated.swift
Created April 26, 2019 22:37
Swift Array extension which creates a new 2d array, rotated 90 degrees clockwise from the original
extension Array where Element: Collection {
typealias InnerElement = Element.Element
/// Rotates a 2d array clockwise such that the nth column becomes the nth row. Rows which have
/// fewer elements than the longest row will be padded with nil to make a full, rectangular
/// matrix prior to rotation
///
/// - Returns: A rectangular matrix where the contents are rotated 90 degrees clockwise. Nil is
/// used as padding for rows/columns with fewer eleemnts than the max.
func rotatedClockwise() -> [[InnerElement?]] {