This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final static String PATTERN_COLOR_REGEXP = "(<color=(.+?)>)(.+?)(</color>)"; | |
private final static Pattern PATTERN_COLOR = Pattern.compile(PATTERN_COLOR_REGEXP); | |
private final static String PATTERN_BOLD_REGEXP = "(<b>)(.+?)(</b>)"; | |
private final static Pattern PATTERN_BOLD = Pattern.compile(PATTERN_BOLD_REGEXP); | |
private final static String PATTERN_UNDERLINE_REGEXP = "(<u>)(.+?)(</u>)"; | |
private final static Pattern PATTERN_UNDERLINE = Pattern.compile(PATTERN_UNDERLINE_REGEXP); | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Euler5 { | |
def isPrime(num: Int) = { | |
(2 until num).forall(num % _ != 0) | |
} | |
/** | |
* 숫자 n의 unique한 소인수 집합 | |
* @param num | |
* @param fractions | |
* @return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Euler9 { | |
def getPitagorasWithSum1000(): (Int, Int, Int) = { | |
//if c > a > b then a > 1000/3 and a < 1000/2 | |
for (a <- 333 to 499; b <- (500 - a to a - 1) if a * a + b * b == (1000 - a - b) * (1000 - a - b)) { | |
return (a, b, 1000 - a - b) | |
} | |
return (0, 0, 0) | |
} | |
def calcMult() = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Euler8 { | |
val rawData = "73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557668966489504452445231617318564030987111217223831136222989342338030813533627661428280644448664523874930358907296290491560440772390713810515859307960866701724271218839987979087922749219016997208880937766572733300105336788122023542180975125454059475224352584907711670556013604839586446706324415722155397536978179778461740649551492908625693219784686224828397224137565705605749026140797296865241453510047482166370484403199890008895243450658541227588666881164271714799244429282308634656748139191231628245861786645835912456652947654568284891288314260769004224219022671055626321111109370544217506941658960408071984038509624554443629812309878799272442849091888458015616609791913387549920052406368991256071760605886116467109405077541002256983155200055935729725716362695618826704282524836008232575304207 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Euler7 { | |
val primeStream: Stream[Int] = 2 #:: 3 #:: primeStream.tail.map(m => nextPrime(m)) | |
def nthPrime(index: Int) = primeStream(index - 1) | |
def isPrime(num: Int) = { | |
(2 until num).forall(num % _ != 0) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Euler6 { | |
def squareSum(maxNum:Int) = (1 to maxNum).map( num => num * num).sum | |
def sumSquare(maxNum:Int) = { | |
val sum = (maxNum * (maxNum+1) /2) | |
sum * sum | |
} | |
def diff(maxNum:Int) = Math.abs(squareSum(maxNum) - sumSquare(maxNum)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Euler4 { | |
def findMaxPalindrome():Int = { | |
for (i <- (1 to 9).reverse; j <- (0 to 9).reverse; k <- (0 to 9).reverse) { | |
val num = 100001 * i + 10010 * j + 1100 * k | |
for (k <- (100 to Math.sqrt(num).toInt).reverse if num % k == 0 && num / k < 1000) { | |
return num | |
} | |
} | |
return 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Euler3 { | |
/** | |
* prime 여부 | |
* @param num | |
* @return | |
*/ | |
def isPrimeLong(num: Long): Boolean = { | |
var index = 2L | |
while (index < num) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Euler2 { | |
/** | |
* max 이하의 짝수 피보나치 수열 합 | |
* @param op1 | |
* @param op2 | |
* @param max | |
* @param sum | |
* @return | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Euler1 { | |
/** | |
* 1 부터 maxVal 미만의 수 중 3 또는 5의 배수의 합 | |
* @param maxVal | |
* @return | |
*/ | |
def getMultipleOf3Or5(maxVal: Int) = { | |
(0 /: (1 until maxVal).filter((arg: Int) => (arg % 3 == 0 || arg % 5 == 0)))(_ + _) | |
} |