This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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?]] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |