Skip to content

Instantly share code, notes, and snippets.

@kazua
kazua / fileSearch.java
Last active December 17, 2015 03:59
ファイル検索
//write kazua
import java.io.File;
import java.util.*;
public class fileSearch {
private List<String> getFiles(String path) {
List<String> pl = new ArrayList<String>();
File file = new File(path);
if (!file.isDirectory()) file = file.getParentFile();
@kazua
kazua / unZipCreatePs.java
Created April 29, 2013 13:52
解凍用プログラム(階層・パスワード付加対応)hishidamaさんユーティリティ使用
//write kazua
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Enumeration;
import jp.hishidama.zip.ZipEntry;
import jp.hishidama.zip.ZipFile;
public class unZipCreatePs {
@kazua
kazua / zipCreatePs.java
Created April 29, 2013 13:50
圧縮用プログラム(階層・パスワード付加対応)hishidamaさんユーティリティ使用
//write kazua
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import jp.hishidama.zip.ZipEntry;
import jp.hishidama.zip.ZipOutputStream;
@kazua
kazua / unZipCreate.java
Last active December 16, 2015 18:20
解凍用プログラム(階層対応)
//write kazua
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Enumeration;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
public class unZipCreate {
@kazua
kazua / zipCreate.java
Last active December 16, 2015 14:59
圧縮用プログラム(階層対応)
//write kazua
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;
@kazua
kazua / poker_handofcard.scala
Last active December 16, 2015 09:29
ポーカーの手役判定
//write kazua
object poker_handofcard {
def pack[A](ls : List[A]) : List[List[A]] = {
if (ls.isEmpty) List(Nil)
else {
val (hdele, elsele) = ls.span(_ == ls.head)
if (elsele == Nil) List(hdele)
else hdele :: pack(elsele)
}
@kazua
kazua / daydiff.scala
Created April 4, 2013 11:15
年月日の全ての数字が異なる年月日のリスト生成
//write kazua
//年月日の中に同じ数値が現れない年月日のリスト
import java.util.Calendar
import java.text.SimpleDateFormat
object daydiff {
def sdf = new SimpleDateFormat("yyyyMd")
def daydiff(stday : Calendar, edday : Calendar, acl : List[String]) : List[String] = stday match {
case s if s.compareTo(edday) > 0 => acl.reverse
@kazua
kazua / worldproblem1_7.scala
Last active December 15, 2015 15:49
世界で闘うプログラマ本の1-7
//write Kazua
import scala.collection.mutable._
object worldproblem1_7 {
def ZeroUpdate(tgt : Array[Array[Int]]) = {
val rowbol = Map[Int, Int]()
val colbol = Map[Int, Int]()
for (i <- 0 until tgt.size) {
@kazua
kazua / worldproblem1_5.scala
Last active December 15, 2015 11:39
世界で闘うプログラマ本の1-5
//write Kazua
object worldproblem1_5 {
def ZipStr(tgt : String, zip : String = "", acl : String = "", bktgt : String = "") : String = tgt match {
case t if t.size == 0 => acl + zip.take(1) + zip.length
case t => acl match {
case a if a.length > 0 && a.length >= bktgt.length => bktgt
case a => zip match {
case z if z == "" => ZipStr(t.tail, z + t.head, a, t)
case z if z.head == t.head => ZipStr(t.tail, z + t.head, a, bktgt)
@kazua
kazua / worldproblem1_3.scala
Created March 23, 2013 10:53
世界で闘うプログラマ本の1-3
//write Kazua
object worldproblem1_3 {
def PermutationsCheck(chkstr1 : String, chkstr2 : String) : Boolean = {
if (chkstr1.length != chkstr2.length) return false
val chgchkstr1 = chkstr1.toList.sortWith((o1, o2) => o1.toString.compareToIgnoreCase(o2.toString) < 0).mkString
val chgchkstr2 = chkstr2.toList.sortWith((o1, o2) => o1.toString.compareToIgnoreCase(o2.toString) < 0).mkString
chgchkstr1.equals(chgchkstr2)