Skip to content

Instantly share code, notes, and snippets.

View UberMouse's full-sized avatar

Taylor Lodge UberMouse

View GitHub Profile
@UberMouse
UberMouse / about.md
Created November 18, 2011 22:56 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@UberMouse
UberMouse / gist:5711126
Last active December 18, 2015 02:29
Solves the Beautiful Strings CodeEval problem (Slightly modified version of the Facebook Hacker cup 2013 Hackathon)
Array("Good luck in the Facebook Hacker Cup this year!",
"Ignore punctuation, please :)",
"Sometimes test cases are hard to make up.",
"So I just go consult Professor Dalves")
.filter(_.length > 0)
.map(x => x.toLowerCase())
.map(x => "[^a-z]*".r replaceAllIn(x, ""))
.map(x => x.map(y => (x.count(_ == y), y)).sortWith(_._1 > _._1).distinct.map(_._1).toArray)
.map(process(_))
.map(_.map(x => x._1 * x._2))
@UberMouse
UberMouse / QueryBoard.scala
Created June 5, 2013 03:55
Initial version for CodeEval Query Board
def main(args:Array[String]) {
//val source = scala.io.Source.fromFile(args(0))
val matrix = (new Array[Int](256), new Array[Int](256))
Array("SetCol 32 20",
"SetRow 15 7",
"SetRow 16 31",
"QueryCol 32",
"SetCol 2 14",
"QueryRow 10",
@UberMouse
UberMouse / QueryBoard.scala
Created June 5, 2013 04:28
Finished version of CodeEval Query Board problem
object Main {
def main(args:Array[String]) {
//val source = scala.io.Source.fromFile(args(0))
val matrix = List.fill[Int](256, 256)(0)
Array("SetCol 32 20",
"SetRow 15 7",
"SetRow 16 31",
"QueryCol 32",
@UberMouse
UberMouse / FizzBuzzV1.scala
Created June 5, 2013 05:35
First FizzBuzz solution
/**
* Created by IntelliJ IDEA.
* User: UberMouse
* Date: 10/26/11
* Time: 12:50 PM
*/
object fizzbuzz {
def main(args: Array[String]) {
val source = scala.io.Source.fromFile(args(0))
val lines = source.getLines().filter(_.length > 0)
@UberMouse
UberMouse / FizzBuzzV2.scala
Created June 5, 2013 05:57
Slightly better version of FizzBuzz
object Main extends App {
val source = scala.io.Source.fromFile(args(0))
source.getLines
.filter(_.length > 0)
.map(_.split(" ").map(_.toInt))
.map(x => fizz(x(0), x(1), x(2)))
.foreach(println)
def fizz(a:Int, b:Int, n:Int) = {
def buzz(check:Int, fizz:Int, buzz:Int) = {
package nz.ubermouse.minecraft.classicserver.packets
import nz.ubermouse.minecraft.classicserver.{Client, Server}
import java.nio.ByteBuffer
import java.io.PrintStream
import nz.ubermouse.minecraft.classicserver.utils.Logger
/**
* Created with IntelliJ IDEA.
* User: UberMouse
object Main {
def main(args:Array[String]) {
val re = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?".r
val source = scala.io.Source.fromFile(args(0))
source.getLines
.filter(x => x.length > 0)
.map(x => re.findFirstIn(x) != None)
.foreach(println)
}
Array("Good luck in the Facebook Hacker Cup this year!",
"Ignore punctuation, please :)",
"Sometimes test cases are hard to make up.",
"So I just go consult Professor Dalves")
.filter(_.length > 0)
.map(process)
.foreach(println)
def process(line:String) = {
val cleanedLine = "[^a-z]*".r.replaceAllIn(line.toLowerCase, "")
public class Option<T>
{
public readonly T Value;
public bool HasValue
{
get {return Value != null;}
private set {}
}