Skip to content

Instantly share code, notes, and snippets.

@krikit
krikit / magic_trick.scala
Last active August 29, 2015 14:00
Google Code Jam 2014 Qualification Round A Magic Trick
object magic_trick extends App {
def solve(first_answer: Int, first_cards: List[List[Int]], second_answer: Int, second_cards: List[List[Int]]): String = {
val first_choice = first_cards(first_answer - 1)
val second_choice = second_cards(second_answer - 1)
val answer = (first_choice.toSet & second_choice.toSet).toList
answer match {
case head :: Nil => head.toString
case Nil => "Volunteer cheated!"
case head :: tail => "Bad magician!"
}
@krikit
krikit / cookie_clicker_alpha.scala
Last active August 29, 2015 14:00
Google Code Jam 2014 Qualification Round B Cookie Clicker Alpha
object ManageYourEnergy{
def getLocalList(E: Long, R: Long, v: List[Long]): List[Long] = v.take(((E - 1) / R + 1).toInt)
def solve(E: Long,R:Long,v: List[Long]): BigInt = {
def inner(currE: Long, localList:List[Long], r: BigInt=0): BigInt={
if(localList.isEmpty) r
else{
val spendE = currConsume(currE, E, R, getLocalList(E,R,localList))
inner(Math.min(currE - spendE + R,E), localList.tail, r + BigInt(spendE) * BigInt(localList.head))
}
import java.io.FileInputStream
import java.io.FileOutputStream
object SquareTiles extends App {
def solve(tiles: Array[Array[Char]]): Option[Array[Array[Char]]] = {
for (
r <- (0 until (tiles.length - 1));
c <- (0 until (tiles(r).length - 1))
) {
tiles(r)(c) match {
object RopeIntranet {
def main(args: Array[String]) {
val writer = new java.io.PrintWriter("a-large.out")
try {
process(io.Source.fromFile("A-large-practice.in").getLines)(writer.println)
} finally {
writer.flush()
writer.close()
}
}
@krikit
krikit / python3.py
Created July 25, 2018 13:19
code template for Python 3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
code template for Python 3
__author__ = 'Your Name (your.email@address.info)'
__copyright__ = 'No copyright, just copyleft!'
"""
@krikit
krikit / khaiii.py
Last active December 17, 2018 05:57
7b7862e332a4fbc3fb4f3af68ae38b2e6b6216e7
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
khaiii API module
__author__ = 'Jamie (jamie.lim@kakaocorp.com)'
__copyright__ = 'Copyright (C) 2018-, Kakao Corp. All rights reserved.'
"""
@krikit
krikit / regression_api_test.ipynb
Last active June 4, 2020 09:10
Regression API Test
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.