Skip to content

Instantly share code, notes, and snippets.

View ymnk's full-sized avatar

Atsuhiko Yamanaka ymnk

View GitHub Profile
object RomanNumerals{
class RomanNumeralsException extends Exception
private val rn="IVXLCDM ".toList
def apply(n:Int):String={
type LS = List[String]
def n2ivx(n:Int, i:String, v:String, x:String):String = n match{
case 4 => i+v
/**
Copyright (c) 2009 ymnk, JCraft,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:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
import scala.io.Source
/**
* http://www.facebook.com/jobs_puzzles/index.php?puzzle_id=7
*/
object HoppityHop{
def main(arg:Array[String]){
val line = Source.fromFile(arg(0)).getLine(1)
// val Array(n) = line.split(" ").filter(_.length!=0)
@ymnk
ymnk / README
Created January 29, 2009 02:22 — forked from hsak/beep.scala
This program is a 2D shooting game written in Scala by
@h_sakurai(http://twitter.com/h_sakurai),
and has been originally hosted at https://gist.github.com/46448 .
@ymnk(http://twitter.com/ymnk) has slightly modified that code
to run it on scala 2.8 with sbt.
$ sbt
> run
import swing._
import swing.event._
/**
* http://d.hatena.ne.jp/xibbar/20081203#1228294818
*/
object SimpleGui1B extends SimpleGUIApplication {
def top = new MainFrame {
title = "SimpleGui1B"
contents = new Button {
/*
Copyright (c) 2008 ymnk, JCraft,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:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
/*
Copyright (c) 2008 ymnk, JCraft,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:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
import java.net.{InetAddress, Socket, InetSocketAddress}
import java.io._
import scala.collection.mutable._
import scala.io.Source
import scala.concurrent.ops.spawn
/**
* This program expects to be comipled with ARCFour.scala[1] .
* [1] http://gist.github.com/28462
*/
class ARCFour{
private var x:Int = _
private var y:Int = _
private val state = new Array[Int](256)
def decrypt(src:Array[Byte], off:Int, length:Int):Array[Byte]={
encrypt(src, off, length)
}
def decrypt(src:Array[Byte], soff:Int,
/*
* ftdop2.scala
* Functional Top Down Operator Precedence
*/
package ftdop2
import scala.util.matching.Regex
import scala.collection.mutable.HashMap
object main {
def main(argv:Array[String]) {