Skip to content

Instantly share code, notes, and snippets.

View fupfin's full-sized avatar

Sungchul Park fupfin

  • Woowahan Bros.
  • Seoul, South Korea
View GitHub Profile
@fupfin
fupfin / .editorconfig
Last active January 27, 2024 05:08
My default coding style
# top-most EditorConfig file
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
tab_width=8
@fupfin
fupfin / AbstractPathFinder.java
Created September 17, 2012 15:17
코딩 인터뷰 완전 분석 215쪽 문제 18.10 풀이
package org.fupfin.insight.evnet2b;
import java.util.LinkedList;
import java.util.List;
import org.fupfin.insight.evnet2b.WordGraphBuilder.WordGraph;
public abstract class AbstractPathFinder implements PathFinder {
protected WordGraph graph;
import java.util.Arrays;
public class HashCodeFunctions
{
private final static short DEFAULT_PRIME_NUMBER = 31;
private HashCodeFunctions()
{
throw new AssertionError("Could not be instantiated.");
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples</groupId>
<artifactId>myfirstspring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<!-- Generic properties -->
@fupfin
fupfin / Problem2.scala
Last active December 16, 2015 18:39
오일러 프로젝트 문제 2: http://euler.synap.co.kr/prob_detail.php?id=2 피보나치 수열의 각 항은 바로 앞의 항 두 개를 더한 것이 됩니다. 1과 2로 시작하는 경우 이 수열은 아래와 같습니다. 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... 짝수이면서 4백만 이하인 모든 항을 더하면 얼마가 됩니까?
package com.fupfin.euler.problem2
import scala.collection.immutable.Stream._
import scala.collection.GenIterable
object Problem2 {
def fib(max: Int): Stream[Int] = 1 #:: 2 #:: fib(1, 2, max)
private def fib(v1:Int, v2:Int, max:Int): Stream[Int] = if(v1 + v2 <= max) (v1 + v2) #:: fib(v2, v1 + v2, max) else Empty
def sum(that:GenIterable[Int], p: Int => Boolean): Int = {
@fupfin
fupfin / FactorialZeroTailCounter.java
Created September 7, 2012 17:53
‘코딩 인터뷰 완전 분석 210쪽 17.3 변형 문제 풀이’
package org.fupfin.insight.event2a;
public interface FactorialZeroTailCounter {
/**
* n!의 결과에서 뒷부분 0의 개수와 그 앞자리 수의 수를 반환한다.
* @param n 팩토리얼을 계산하려는 수
* @return 끝자리 0의 개수와 그 앞자리 수
*/
public Result count(int n);
@fupfin
fupfin / SetPartitioner.java
Created September 7, 2012 10:57
‘문제로 풀어보는 알고리즘 149쪽 문제 3.c 풀이’
package org.fupfin.insight.event1b;
import java.util.Arrays;
import java.util.concurrent.RecursiveAction;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ForkJoinPool;
public class SetPartitioner {
@fupfin
fupfin / AbstractArrayRotator.java
Created September 7, 2012 10:22
‘문제로 풀어보는 알고리즘 0.3 생각해보기 풀이’
package org.fupfin.insight.event1;
import java.lang.reflect.Array;
public abstract class AbstractArrayRotator<T> implements ArrayRotator<T>{
@Override
public T[] rotateRight(T[] source, int step) {
if(isValidArguments(source, step))
throw new IllegalArgumentException("step value have to be not negative number : " + step);
@fupfin
fupfin / Tuples.java
Created April 4, 2012 07:52
Scala's tuple implmentation for Java
package fupfin;
public class Tuples {
private Tuples() {}
public static <T1, T2> Tuple2<T1, T2> tuple(T1 v1, T2 v2) {
return new Tuple2<T1, T2>(v1, v2);
}
@fupfin
fupfin / Option.java
Created October 5, 2011 06:52
java version of scala Option
package fupfin;
import java.util.NoSuchElementException;
/**
* A base class of simple value container that represents optional values. You can
* use subclass Some<A> for some existent values or None for non existent values.
* This is java version of scala Option class.
*
* @author fupfin@gmail.com