Skip to content

Instantly share code, notes, and snippets.

@giuniu
giuniu / PythagoraSwitch.scala
Created December 13, 2011 22:50
原始ピタゴラス数探索ロジック:Scala版
import math._
object PythagoraSwitch {
def main(args: Array[String]): Unit = {
val max = Integer.parseInt(args(0))
val start = System.nanoTime()
/*
val result = for (
c <- 3 to max by 2;
@giuniu
giuniu / PythagoraSwitch2.java
Created December 12, 2011 17:55
原始ピタゴラス数探索ロジック:一般項導出編
import java.util.ArrayList;
import java.util.List;
public class PythagoraSwitch2 {
/**
* @param args
*/
public static void main(String[] args) {
final int MAX = Integer.parseInt(args[0]);
@giuniu
giuniu / PythagoraSwitch.java
Created December 12, 2011 17:54
原始ピタゴラス数探索ロジック:しらみつぶし編
import java.util.ArrayList;
import java.util.List;
public class PythagoraSwitch {
public static void main(String[] args) {
final int MAX = Integer.parseInt(args[0]);
long start = System.nanoTime();
List<PythagorasNum> result = new ArrayList<>();
for (int c = 3; c <= MAX; c += 2) {
@giuniu
giuniu / SortWordsJ.java
Created December 10, 2011 09:54
ダブり文字列並べ替えロジック Java版
package exercise;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedSet;
import java.util.TreeSet;
public class SortWordsJ {
@giuniu
giuniu / SortWords.scala
Created December 9, 2011 14:46
ダブり文字列並べ替えロジック Scala版
object SortWords {
def main(args: Array[String]): Unit = {
val list = args.toList sort (_ > _)
val foldList = (List((1, list.head)) /: list.tail) {
case (x, y) if (x.head._2 == y) => (x.head._1 + 1, x.head._2) :: x.tail
case (x, y) => (1, y) :: x
}
val result = foldList sort ((a, b) => a._1 > b._1 || a._1 == b._1 && a._2 < b._2) map (_._2)
println(result)
@giuniu
giuniu / Exercise.java
Created December 8, 2011 13:24
最大公約数が最も大きい組み合わせを見つける(Java版)
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
public class Exercise {
public static void main(String[] args) {
List<Integer> nums = new ArrayList<>();
for (String str : args)
@giuniu
giuniu / Gistテスト
Created June 6, 2011 09:27
Gistのテストをしてみるよ。
コレが中身。