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
package moba_teams | |
import java.io.BufferedReader | |
import java.io.InputStreamReader | |
import java.io.FileInputStream | |
import java.util.ArrayList | |
import komino.Bone | |
import komino.format | |
import komino.deque | |
import java.io.File |
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
import os | |
import time | |
filename = "/home/username/.macromedia/Flash_Player/Logs/flashlog.txt" | |
old_size= os.path.getsize(filename) | |
while True: | |
time.sleep(1) | |
new_size = os.path.getsize(filename) | |
if old_size != new_size: | |
f = open(filename) |
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
def decode(key: Seq[Char], bytes: Array[Byte]): String = new String(bytes.indices.map(i => bytes(i) ^ key(i % key.length)).map(_.toByte).toArray, "latin1") | |
val bytes = Source.fromFile("Code.hs.enc", "latin1").mkString.getBytes("latin1") | |
val res = bytes.sliding(5, 1).map(decode("impor", _)).filter(decode(_, bytes).contains("main")).toList.headOption.map(decode(_, bytes)) | |
println(res.getOrElse("Solution not found")) |
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
import io.Source | |
object Stars { | |
type Point = Array[Int] | |
type Tree = Array[Array[Array[List[Point]]]] | |
def main(args:Array[String]) { | |
val start:Long = System.nanoTime() | |
val coords = Source.fromFile("stars.dat").getLines().map(s => s.split("\\s+").map(_.toInt)).toArray | |
var minDistance = Long.MaxValue |
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
val map:Map[String, Object] = Map("word" -> "complex") | |
val str:String = "scala is so complex" | |
val index:Int = str indexOf map("word") | |
println(""""%s" indexOf "%s" = %d""".format(str, map("word"), index)) | |
------------------------------ | |
"scala is so complex" indexOf "complex" = -1 |
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
(defn solve [input] | |
(let [neighbours (fn [[y x]] | |
(filter #(not= % [y x]) (for [i (range -1 2) j (range -1 2)] [(+ y i) (+ x j)]))) | |
isLive (fn [[y x]] | |
(and (>= y 0) (< y (count input)) (>= x 0) (< x (count (input y))) | |
(not= (nth (input y) x) \space))) | |
shouldLive (fn [p] | |
(let [liveNeighbours (count (filter isLive (neighbours p)))] | |
(or (= liveNeighbours 3) (and (isLive p) (= liveNeighbours 2)))))] | |
(map |
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
data class Rect(val left:Float, val right:Float, val height:Float) | |
data class Mark(val rect:Rect, val value:Float, val isFinish:Boolean) | |
fun calcSquare(data:List<Rect>):Float { | |
if (data.isEmpty()) { | |
return .0f | |
} | |
val marks = arrayListOf<Mark>() | |
for (rect in data) { |
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
fun luckyTicketsCount():Int { | |
fun digits(i:Int) = arrayOf( | |
i % 10, | |
(i / 10) % 10, | |
(i / 100) % 10, | |
(i / 1000) % 10, | |
(i / 10000) % 10, | |
(i / 100000) % 10 | |
) | |
fun isLucky(i:Int):Boolean { |
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
package core | |
import co.paralleluniverse.actors.ActorRef | |
import co.paralleluniverse.actors.ActorRegistry | |
import co.paralleluniverse.fibers.Suspendable | |
import co.paralleluniverse.kotlin.Actor | |
import co.paralleluniverse.kotlin.register | |
import co.paralleluniverse.kotlin.spawn | |
import co.paralleluniverse.strands.Strand | |
import java.util.* |
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
((d:Seq[(String, Int)]) => | |
println(d.map(t => t._1 + " " + t._2).mkString("\n") + "\n\nВиноват " + | |
(if (d.map(_._1).take(5).contains("Вевелония")) "Ганс Шмуцихь" else "Вольфганг Кунстштюк"))) | |
(Source.fromFile("/home/scrum/data.txt").getLines().map(_.split(":")).flatMap(as => as(1).split(",").map(_.trim) | |
.map((_, as(0)))).toArray.groupBy(_._1).mapValues(_.length).toSeq | |
.sortWith((a, b) => if (a._2.compareTo(b._2) == 0) a._1.compareTo(b._1) < 0 else a._2.compareTo(b._2) > 0)) | |
Output: | |
Россия 10 |
OlderNewer