path stringlengths 5 169 | owner stringlengths 2 34 | repo_id int64 1.49M 755M | is_fork bool 2
classes | languages_distribution stringlengths 16 1.68k ⌀ | content stringlengths 446 72k | issues float64 0 1.84k | main_language stringclasses 37
values | forks int64 0 5.77k | stars int64 0 46.8k | commit_sha stringlengths 40 40 | size int64 446 72.6k | name stringlengths 2 64 | license stringclasses 15
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
src/main/kotlin/day2/solver.kt | derekaspaulding | 317,756,568 | false | null | package day2
import java.io.File
fun parse(passwordSpec: String): Triple<Pair<Int, Int>, Char, String> {
val (bounds, characterSpec, password) = passwordSpec.split(" ")
val (min, max) = bounds.split("-").map { bound -> bound.toInt() }
val character = characterSpec[0]
return Triple(Pair(min, max), cha... | 0 | Kotlin | 0 | 0 | 0e26fdbb3415fac413ea833bc7579c09561b49e5 | 1,194 | advent-of-code-2020 | MIT License |
src/main/kotlin/com/ginsberg/advent2021/Day14.kt | tginsberg | 432,766,033 | false | {"Kotlin": 92813} | /*
* Copyright (c) 2021 by <NAME>
*/
/**
* Advent of Code 2021, Day 14 - Extended Polymerization
* Problem Description: http://adventofcode.com/2021/day/14
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day14/
*/
package com.ginsberg.advent2021
class Day14(input: List<String>) {
... | 0 | Kotlin | 2 | 34 | 8e57e75c4d64005c18ecab96cc54a3b397c89723 | 1,905 | advent-2021-kotlin | Apache License 2.0 |
src/main/kotlin/com/github/shmvanhouten/adventofcode/day22gridcomputing/EmptyNodeRoutePlanner.kt | SHMvanHouten | 109,886,692 | false | {"Kotlin": 616528} | package com.github.shmvanhouten.adventofcode.day22gridcomputing
class EmptyNodeRoutePlanner {
fun getRouteToCoordinate(targetCoordinate: Coordinate, sourceCoordinate: Coordinate, storageCluster: StorageCluster): NodeRoute {
//Todo: consolidate with week 13 routeFinder
var visitedNodes = setOf<Node... | 0 | Kotlin | 0 | 0 | a8abc74816edf7cd63aae81cb856feb776452786 | 2,729 | adventOfCode2016 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestZigZagPath.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,512 | kotlab | Apache License 2.0 |
sandbox/src/main/kotlin/tomasvolker/numeriko/sandbox/quaternions/Quaternion.kt | TomasVolker | 114,266,369 | false | null | package tomasvolker.numeriko.sandbox.quaternions
import kotlin.math.sqrt
class Quaternion(
val r: Double = 0.0,
val x: Double = 0.0,
val y: Double = 0.0,
val z: Double = 0.0
) {
private inline fun elementWise(operation: (Double)->Double) =
Quaternion(
... | 8 | Kotlin | 1 | 3 | 1e9d64140ec70b692b1b64ecdcd8b63cf41f97af | 2,392 | numeriko | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindUniqueBinaryString.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,739 | kotlab | Apache License 2.0 |
app/src/main/java/com/exemple/scrabble/Trie.kt | gabriaraujo | 315,707,735 | false | null | package com.exemple.scrabble
import java.lang.StringBuilder
import java.util.ArrayList
/**
* Title: Trie
*
* Author: <NAME>
*
* Brief:
* This object represents the implementation of a Trie tree for a 26 letter
* alphabet.
*
* Descrição:
* A Trie tree, or prefix tree, is an ordered tree that can be used to s... | 0 | Kotlin | 0 | 2 | 9623ecc939fe6a654c219fd6ef1b857240b34eaa | 13,107 | scrabble | MIT License |
aoc2023/src/main/kotlin/de/havox_design/aoc2023/day18/LavaductLagoon.kt | Gentleman1983 | 737,309,232 | false | {"Kotlin": 746488, "Java": 441473, "Scala": 33415, "Groovy": 5725, "Python": 3319} | package de.havox_design.aoc2023.day18
import de.havox_design.aoc.utils.kotlin.model.coordinates.*
import kotlin.math.abs
class LavaductLagoon(private var filename: String) {
private val BLACK = "#000000"
private val ICON_UP = "U"
private val ICON_DOWN = "D"
private val ICON_LEFT = "L"
private val ... | 4 | Kotlin | 0 | 1 | 35ce3f13415f6bb515bd510a1f540ebd0c3afb04 | 4,634 | advent-of-code | Apache License 2.0 |
src/Day04.kt | ostersc | 570,327,086 | false | {"Kotlin": 9017} | data class BingoSpace(var num: Int, var marked: Boolean)
class BingoBoard {
var grid = Array(5) { row ->
Array(5) { col ->
BingoSpace(0, false)
}
}
override fun toString(): String {
var s=""
for (col in 0..4) {
for (row in 0..4) {
val... | 0 | Kotlin | 0 | 0 | 836ff780252317ee28b289742396c74559dd2b6e | 3,923 | advent-of-code-2021 | Apache License 2.0 |
src/main/kotlin/days/Day3.kt | felix-ebert | 433,847,657 | false | {"Kotlin": 12718} | package days
class Day3 : Day(3) {
override fun partOne(): Any {
var gamma = ""
var epsilon = ""
for (i in inputList[0].indices) {
gamma += inputList.groupingBy { it[i] }.eachCount().maxWithOrNull(compareBy { it.value })?.key
epsilon += inputList.groupingBy { it[i]... | 0 | Kotlin | 0 | 2 | cf7535d1c4f8a327de19660bb3a9977750894f30 | 1,568 | advent-of-code-2021 | Creative Commons Zero v1.0 Universal |
src/Day03.kt | RichardLiba | 572,867,612 | false | {"Kotlin": 16347} | fun main() {
fun getPriority(char: Char): Int {
return if (char.isUpperCase()) char - 'A' + 27 else char - 'a' + 1
}
fun part1(input: List<String>): Int {
return input.sumOf {
it.chunked(it.length / 2).let {
it[0].toSet().intersect(it[1].toSet()).sumOf { getPrior... | 0 | Kotlin | 0 | 0 | 6a0b6b91b5fb25b8ae9309b8e819320ac70616ed | 669 | aoc-2022-in-kotlin | Apache License 2.0 |
jvm/src/main/kotlin/io/prfxn/aoc2021/day03.kt | prfxn | 435,386,161 | false | {"Kotlin": 72820, "Python": 362} | // Binary Diagnostic (https://adventofcode.com/2021/day/3)
package io.prfxn.aoc2021
fun main() {
fun part1() {
val bitCounts = IntArray(12) { 0 }
var numLines = 0
textResourceReader("input/03.txt").useLines { lineSeq ->
for (line in lineSeq) {
for (i in line.... | 0 | Kotlin | 0 | 0 | 148938cab8656d3fbfdfe6c68256fa5ba3b47b90 | 2,955 | aoc2021 | MIT License |
src/main/kotlin/de/tek/adventofcode/y2022/day05/SupplyStacks.kt | Thumas | 576,671,911 | false | {"Kotlin": 192328} | package de.tek.adventofcode.y2022.day05
import de.tek.adventofcode.y2022.util.readInputLines
typealias Item = Char
data class MoveCommand(val from: Int, val to: Int, val numberOfCrates: Int) {
companion object {
fun fromDescription(description: String): MoveCommand? {
val parsedInts = parseBy... | 0 | Kotlin | 0 | 0 | 551069a21a45690c80c8d96bce3bb095b5982bf0 | 4,278 | advent-of-code-2022 | Apache License 2.0 |
src/day04/Day04.kt | pientaa | 572,927,825 | false | {"Kotlin": 19922} | package day04
import readLines
fun main() {
fun getEachElfSection(input: List<String>) =
input.map { line ->
line.split(",")
.map { range ->
range.split('-').map { it.toInt() }
.let { it.first()..it.last() }
.... | 0 | Kotlin | 0 | 0 | 63094d8d1887d33b78e2dd73f917d46ca1cbaf9c | 1,102 | aoc-2022-in-kotlin | Apache License 2.0 |
jvm/src/main/kotlin/boj/CoffeeShopII.kt | imdudu1 | 196,377,985 | false | {"Java": 47989, "Kotlin": 39952, "Python": 38168, "Go": 15491, "Rust": 2583, "JavaScript": 1023} | package boj
import java.io.BufferedReader
import java.io.InputStreamReader
class CoffeeShopII constructor(private val numbers: Array<Long>) {
private val segmentTree: Array<Long> = Array(numbers.size * 4) { 0 }
init {
initTree(0, numbers.size - 1)
}
private fun initTree(begin: Int, end: Int... | 0 | Java | 0 | 0 | ee7df895761b095d02a08f762c682af5b93add4b | 2,317 | algorithm-diary | MIT License |
src/main/kotlin/day04/CampCleanup.kt | iamwent | 572,947,468 | false | {"Kotlin": 18217} | package day04
import readInput
import kotlin.math.max
import kotlin.math.min
class CampCleanup(
private val name: String
) {
private fun readAssignments(): List<Assignment> {
return readInput(name).map { pair ->
val (left, right) = pair.split(",")
.map { section ->
... | 0 | Kotlin | 0 | 0 | 77ce9ea5b227b29bc6424d9a3bc486d7e08f7f58 | 1,354 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/com/chriswk/aoc/advent2015/Day6.kt | chriswk | 317,863,220 | false | {"Kotlin": 481061} | package com.chriswk.aoc.advent2015
import com.chriswk.aoc.AdventDay
import com.chriswk.aoc.util.Pos
import com.chriswk.aoc.util.report
import com.chriswk.aoc.util.toInt
import java.lang.IllegalArgumentException
import java.lang.IllegalStateException
import kotlin.math.max
class Day6 : AdventDay(2015, 6) {
compani... | 116 | Kotlin | 0 | 0 | 69fa3dfed62d5cb7d961fe16924066cb7f9f5985 | 3,177 | adventofcode | MIT License |
src/Day06.kt | RaspiKonk | 572,875,045 | false | {"Kotlin": 17390} | /**
* Day 6: Funkgerät reparieren: Die ersten 4 Character im String finden die sich nicht wiederholen.
*
* Part 1: Die ersten 4 Character im String finden die sich nicht wiederholen.
* Part 2: same same with 14 chars
*/
fun main()
{
val start = System.currentTimeMillis()
val DAY: String = "06"
println("Advent ... | 0 | Kotlin | 0 | 1 | 7d47bea3a5e8be91abfe5a1f750838f2205a5e18 | 1,369 | AoC_Kotlin_2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindEventualSafeStates.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,698 | kotlab | Apache License 2.0 |
src/Day07.kt | calindumitru | 574,154,951 | false | {"Kotlin": 20625} | import java.util.function.Predicate
const val TOTAL = 70000000
const val UNUSED = 30000000
fun main() {
val part1 = Implementation("Find all of the directories with a total size of at most 100000. What is the sum of the total sizes of those directories?",
95437) { lines ->
val root = convertToGraph... | 0 | Kotlin | 0 | 0 | d3cd7ff5badd1dca2fe4db293da33856832e7e83 | 2,179 | advent-of-code-2022 | Apache License 2.0 |
hikotlin/src/main/java/me/li2/android/hikotlin/kotlin/Calculator.kt | li2 | 121,604,937 | false | {"Kotlin": 81758, "Java": 4651} | package me.li2.android.hikotlin.kotlin
import me.li2.android.hikotlin.kotlin.Operator.*
import java.util.*
/** + */
fun operatorPlus(input: Int): Int {
return input + MY_PLUS
}
/** - */
fun operatorMinus(input: Int): Int {
return input + MY_MINUS
}
/** x */
fun operatorMultiply(input: Int): Int {
retur... | 0 | Kotlin | 1 | 1 | 010d25e9d53b5b1d6355daa96b56071b82c28aae | 3,830 | android-architecture | Apache License 2.0 |
src/test/kotlin/dev/shtanko/algorithms/dp/LCSTest.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,189 | kotlab | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem2404/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem2404
/**
* LeetCode page: [2404. Most Frequent Even Element](https://leetcode.com/problems/most-frequent-even-element/);
*/
class Solution {
/* Complexity:
* Time O(N) and Space O(N) where N is the size of nums;
*/
fun mostFrequentEven(nums: IntArray): Int {
... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,366 | hj-leetcode-kotlin | Apache License 2.0 |
src/Day06.kt | lmoustak | 573,003,221 | false | {"Kotlin": 25890} | fun main() {
fun part1(input: List<String>): Int {
val chars = input[0].toCharArray()
for (i in 3 until chars.size) {
val charSet = setOf(chars[i - 3], chars[i - 2], chars[i - 1], chars[i])
if (charSet.size == 4) return i + 1
}
return -1
}
fun part2... | 0 | Kotlin | 0 | 0 | bd259af405b557ab7e6c27e55d3c419c54d9d867 | 899 | aoc-2022-kotlin | Apache License 2.0 |
solver/src/commonMain/kotlin/org/hildan/sudoku/solver/techniques/PointingTuples.kt | joffrey-bion | 9,559,943 | false | {"Kotlin": 51198, "HTML": 187} | package org.hildan.sudoku.solver.techniques
import org.hildan.sudoku.model.*
/**
* When the candidates for a digit in a box are all confined to a single line in that box, we know the digit for the
* whole line must land in that box. Therefore, we can eliminate this digit from the candidates of other cells of the
*... | 0 | Kotlin | 0 | 0 | 441fbb345afe89b28df9fe589944f40dbaccaec5 | 2,207 | sudoku-solver | MIT License |
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day06/Day06.kt | pfmaggi | 438,378,048 | false | {"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184} | /*
* Copyright 2021 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in wr... | 0 | Kotlin | 0 | 0 | 7c4946b6a161fb08a02e10e99055a7168a3a795e | 1,430 | AdventOfCode | Apache License 2.0 |
src/main/kotlin/g2101_2200/s2170_minimum_operations_to_make_the_array_alternating/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2101_2200.s2170_minimum_operations_to_make_the_array_alternating
// #Medium #Array #Hash_Table #Greedy #Counting
// #2023_06_26_Time_531_ms_(100.00%)_Space_53.9_MB_(100.00%)
class Solution {
fun minimumOperations(nums: IntArray): Int {
var maxOdd = 0
var maxEven = 0
var max = 0
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,623 | LeetCode-in-Kotlin | MIT License |
solutions/aockt/y2022/Y2022D16.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2022
import aockt.util.Graph
import aockt.util.pathTo
import aockt.util.search
import io.github.jadarma.aockt.core.Solution
object Y2022D16 : Solution {
/**
* A valve in the optimised volcano.
*
* @property index Numeric identifier of this valve, calculated as it's order in the lexi... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 11,353 | advent-of-code-kotlin-solutions | The Unlicense |
src/main/kotlin/year2023/day19/Problem.kt | Ddxcv98 | 573,823,241 | false | {"Kotlin": 154634} | package year2023.day19
import IProblem
import substr
import java.io.BufferedReader
import java.util.Collections
import java.util.Objects
class Problem : IProblem {
private val workflows = mutableMapOf<String, List<IRule>>()
private val ratings = mutableListOf<Rating>()
init {
javaClass
... | 0 | Kotlin | 0 | 0 | 455bc8a69527c6c2f20362945b73bdee496ace41 | 3,085 | advent-of-code | The Unlicense |
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumFactoredBinaryTrees.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,417 | kotlab | Apache License 2.0 |
src/main/kotlin/com/example/adventofcode2022/days/Day2.kt | matyig | 575,497,931 | false | {"Kotlin": 11004} | package com.example.adventofcode2022.days
import org.springframework.stereotype.Component
@Component
class Day2 : Day {
companion object {
val scores = mapOf(
// draw
Pair('A', 'X') to 3 + 1, // rock-rock
Pair('B', 'Y') to 3 + 2, // paper-paper
Pair('C', 'Z... | 0 | Kotlin | 0 | 0 | b34635978a9d6b4c622921d201965066fae2c8ad | 2,180 | adventofcode2022 | MIT License |
src/Day01.kt | wedrychowiczbarbara | 573,185,235 | false | null | fun main() {
fun part1(input: List<String>): Int {
var max=0
var suma=0
input.forEach{
if (it!="")
suma+=it.toInt()
else {
if (suma > max)
max = suma
suma = 0
}
}
return ma... | 0 | Kotlin | 0 | 0 | 04abc035c51649dffe1dde8a115d98640552a99d | 938 | AOC_2022_Kotlin | Apache License 2.0 |
src/Day10.kt | wgolyakov | 572,463,468 | false | null | import kotlin.math.absoluteValue
fun main() {
fun part1(input: List<String>): Int {
var x = 1
var cycle = 0
var strengths = 0
for (line in input) {
if (line == "noop") {
cycle++
if ((cycle - 20) % 40 == 0) strengths += cycle * x
} else {
val a = line.substringAfter("addx ").toInt()
cycle... | 0 | Kotlin | 0 | 0 | 789a2a027ea57954301d7267a14e26e39bfbc3c7 | 1,567 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/design_patterns/Strategy.kt | DmitryTsyvtsyn | 418,166,620 | false | {"Kotlin": 223256} | package design_patterns
/**
*
* Strategy is a behavioral design pattern used to define a family of algorithms,
*
* encapsulate each one and make them interchangeable
*
*/
// encapsulates the filtering algorithm
interface FoodFilterStrategy {
fun filter(items: List<FoodEntity>): List<FoodEntity>
}
class Onl... | 0 | Kotlin | 135 | 767 | 7ec0bf4f7b3767e10b9863499be3b622a8f47a5f | 2,187 | Kotlin-Algorithms-and-Design-Patterns | MIT License |
src/Day01.kt | MerickBao | 572,842,983 | false | {"Kotlin": 28200} | fun main() {
fun part1(input: List<String>): Int {
var ans = 0
var now = 0
for (s in input) {
if (s.equals("")) {
ans = Math.max(ans, now)
now = 0
} else {
now += s.toInt()
}
}
return Math.max... | 0 | Kotlin | 0 | 0 | 70a4a52aa5164f541a8dd544c2e3231436410f4b | 1,024 | aoc-2022-in-kotlin | Apache License 2.0 |
Kotlin/CountingSort.kt | argonautica | 212,698,136 | false | {"Java": 42011, "C++": 24846, "C#": 15801, "Python": 14547, "Kotlin": 11794, "C": 10528, "JavaScript": 9054, "Assembly": 5049, "Go": 3662, "Ruby": 1949, "Lua": 687, "Elixir": 589, "Rust": 447} | fun main(args : Array<String>) {
val sorted = countingSort(intArrayOf(4, 4, -4, 1, 7, 9, 5, 37564, -54, 0, 100))
sorted.forEach {
print("$it, ")
}
}
* Kotlin Counting Sort that allows for negative numbers.
*/
fun countingSort(input:IntArray):IntArray{
if(input.size == 1){
return inpu... | 4 | Java | 138 | 45 | b9ebd2aadc6b59e5feba7d1fe9e0c6a036d33dba | 1,261 | sorting-algorithms | MIT License |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[102]二叉树的层序遍历.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | import java.util.*
import kotlin.collections.ArrayList
//给你一个二叉树,请你返回其按 层序遍历 得到的节点值。 (即逐层地,从左到右访问所有节点)。
//
//
//
// 示例:
//二叉树:[3,9,20,null,null,15,7],
//
// 3
// / \
// 9 20
// / \
// 15 7
//
//
// 返回其层次遍历结果:
//
// [
// [3],
// [9,20],
// [15,7]
//]
//
// Related Topics 树 广度优先搜索
// 👍 718 👎 ... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,591 | MyLeetCode | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2017/Day02.kt | tginsberg | 112,672,087 | false | null | /*
* Copyright (c) 2017 by <NAME>
*/
package com.ginsberg.advent2017
/**
* AoC 2017, Day 2
*
* Problem Description: http://adventofcode.com/2017/day/2
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2017/day2/
*/
class Day02(stringInput: List<String>) {
private val input: List<List<I... | 0 | Kotlin | 0 | 15 | a57219e75ff9412292319b71827b35023f709036 | 1,153 | advent-2017-kotlin | MIT License |
year2015/src/main/kotlin/net/olegg/aoc/year2015/day21/Day21.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2015.day21
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.Vector3D
import net.olegg.aoc.utils.pairs
import net.olegg.aoc.year2015.DayOf2015
/**
* See [Year 2015, Day 21](https://adventofcode.com/2015/day/21)
*/
object Day21 : DayOf2015(21) {
private const val HP = 100
... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,780 | adventofcode | MIT License |
src/main/kotlin/com/groundsfam/advent/y2022/d13/Day13.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2022.d13
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.timed
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 2,711 | advent-of-code | MIT License |
src/main/kotlin/day11/Day11.kt | cyril265 | 433,772,262 | false | {"Kotlin": 39445, "Java": 4273} | package day11
import readToMatrix
fun main() {
println(part1(readInput()))
println(part2(readInput()))
}
private fun readInput() = StateContainer(
readToMatrix("day11.txt").map { row -> row.map { item -> Energy(item) }.toMutableList() }
)
private fun part1(input: StateContainer): Int {
(1..100).for... | 0 | Kotlin | 0 | 0 | 1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b | 2,142 | aoc2021 | Apache License 2.0 |
2021/src/day10/day10.kt | scrubskip | 160,313,272 | false | {"Kotlin": 198319, "Python": 114888, "Dart": 86314} | package day10
import java.io.File
fun main() {
val input = File("src/day10", "day10input.txt").readLines()
println(input.mapNotNull { getIllegalCharacter(it) }.sumOf { getScore(it) })
val scores = input.filter { getIllegalCharacter(it) == null }
.map { scoreCompletionString(getCompletionString(it... | 0 | Kotlin | 0 | 0 | a5b7f69b43ad02b9356d19c15ce478866e6c38a1 | 2,401 | adventofcode | Apache License 2.0 |
src/main/kotlin/Day10.kt | pavittr | 317,532,861 | false | null | import java.io.File
import java.math.BigInteger
import java.nio.charset.Charset
fun main() {
val testDocs = File("test/day10").readLines(Charset.defaultCharset()).map{it.toBigInteger()}
val puzzles = File("puzzles/day10").readLines(Charset.defaultCharset()).map{it.toBigInteger()}
val testEffectiveAdapters... | 0 | Kotlin | 0 | 0 | 3d8c83a7fa8f5a8d0f129c20038e80a829ed7d04 | 1,578 | aoc2020 | Apache License 2.0 |
src/Day01.kt | emmanueljohn1 | 572,809,704 | false | {"Kotlin": 12720} | fun main() {
fun getCalories(input: List<String>) = buildList {
var currentSum = 0L
for ((idx, value) in input.withIndex()) {
if (value.isEmpty()) {
add(currentSum)
currentSum = 0
} else {
currentSum += value.toLong()
... | 0 | Kotlin | 0 | 0 | 154db2b1648c9d12f82aa00722209741b1de1e1b | 1,174 | advent22 | Apache License 2.0 |
archive/src/main/kotlin/com/grappenmaker/aoc/year18/Day13.kt | 770grappenmaker | 434,645,245 | false | {"Kotlin": 409647, "Python": 647} | package com.grappenmaker.aoc.year18
import com.grappenmaker.aoc.*
fun PuzzleSet.day13() = puzzle(day = 13) {
val parseGrid = inputLines.asCharGrid()
data class CartData(
val pos: Point,
val direction: Direction,
val happy: Boolean = true,
val intersectionDirection: Int = -1
... | 0 | Kotlin | 0 | 7 | 92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585 | 2,044 | advent-of-code | The Unlicense |
src/main/kotlin/day17.kt | bfrengley | 318,716,410 | false | null | package aoc2020.day17
import aoc2020.util.loadTextResource
import kotlin.math.max
import kotlin.math.min
fun main(args: Array<String>) {
val initialState = loadTextResource("/day17.txt").lines().flatMapIndexed { y, line ->
line.mapIndexedNotNull { x, cell ->
when (cell) {
'#' -... | 0 | Kotlin | 0 | 0 | 088628f585dc3315e51e6a671a7e662d4cb81af6 | 2,654 | aoc2020 | ISC License |
src/main/java/tarehart/rlbot/math/Plane.kt | tarehart | 101,009,961 | true | {"Kotlin": 781564, "Python": 29120, "Batchfile": 324} | package tarehart.rlbot.math
import tarehart.rlbot.math.vector.Vector3
import java.util.*
class Plane(normal: Vector3, position: Vector3): Ray(position, normal) {
val normal
get() = this.direction
private val constant
get() = normal.dotProduct(position)
/**
* This is direction sensi... | 0 | Kotlin | 7 | 10 | 8a5ba0ba751235e775d383c9796ee8fa966030b9 | 3,025 | ReliefBot | MIT License |
core/src/main/kotlin/com/acmerobotics/roadrunner/util/MathUtil.kt | henopied | 242,858,073 | true | {"Kotlin": 346152, "Java": 184} | package com.acmerobotics.roadrunner.util
import kotlin.math.*
/**
* Various math utilities.
*/
object MathUtil {
/**
* Returns the real solutions to the quadratic [a]x^2 + [b]x + [c] = 0.
*/
@JvmStatic
fun solveQuadratic(a: Double, b: Double, c: Double): DoubleArray {
if (a epsilonEqu... | 0 | Kotlin | 1 | 2 | 19d779986d174601e08dda636cb043b1dddd84d7 | 2,498 | road-runner | MIT License |
src/main/kotlin/days/aoc2022/Day25.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2022
import days.Day
import kotlin.math.abs
class Day25 : Day(2022, 25) {
override fun partOne(): Any {
return calculateSumInSnafu(inputList)
}
override fun partTwo(): Any {
return 0
}
fun calculateSumInSnafu(input: List<String>): String {
val sum = input.... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 2,025 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
2017/src/main/kotlin/Day22.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | import grid.Direction
import grid.Point
import grid.Turn
import utils.splitNewlines
object Day22 {
fun part1(input: String, iterations: Int): Int {
val midpoint = (input.splitNewlines().size / 2)
val infections = parse(input).toMutableSet()
var carrier = Point(midpoint, midpoint)
var direction = Dir... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 2,316 | advent-of-code | MIT License |
day05/src/Day05.kt | simonrules | 491,302,880 | false | {"Kotlin": 68645} | import java.io.File
class Day05(path: String) {
data class Line(val x1: Int, val y1: Int, val x2: Int, val y2:Int)
private val regex = "(\\d+),(\\d+) -> (\\d+),(\\d+)".toRegex()
private val lines = mutableListOf<Line>()
private val size = 1000
private val map = IntArray(size * size)
init {
... | 0 | Kotlin | 0 | 0 | d9e4ae66e546f174bcf66b8bf3e7145bfab2f498 | 3,149 | aoc2021 | Apache License 2.0 |
src/Day08.kt | JohannaGudmandsen | 573,090,573 | false | {"Kotlin": 19316} | import java.io.File
import kotlin.collections.*
fun getViewingScore(height:Int, trees:List<Int>):Int{
var viewingScore = 0
for (tree in trees){
viewingScore++
if (tree >= height){
break;
}
}
return viewingScore;
}
fun Day08() {
val input = File("src/input/day08... | 0 | Kotlin | 0 | 1 | 21daaa4415bd20c14d67132e615971519211ab16 | 2,055 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/org/domnikl/data_structures/BTree.kt | domnikl | 231,452,742 | false | null | package org.domnikl.data_structures
class BTree<K : Comparable<K>, V> {
private var root = Node<K, V>(0)
var height = 0
private set
var size = 0
private set
fun isEmpty() = size == 0
operator fun get(key: K): V? {
return search(root, key, height)
}
private fun s... | 5 | Kotlin | 3 | 13 | 3b2c191876e58415d8221e511e6151a8747d15dc | 2,819 | algorithms-and-data-structures | Apache License 2.0 |
AdventOfCodeDay06/src/nativeMain/kotlin/Day06.kt | bdlepla | 451,510,571 | false | {"Kotlin": 165771} | class Day06(private val lines:List<String>) {
fun solvePart1():Long = simulate(80)
fun solvePart1a():Long = simulateAlt(80)
fun solvePart2():Long = simulate(256)
fun solvePart2a():Long = simulateAlt(256)
private fun simulateAlt(days:Int):Long {
val fishPerDay = LongArray(9)
.app... | 0 | Kotlin | 0 | 0 | 1d60a1b3d0d60e0b3565263ca8d3bd5c229e2871 | 2,160 | AdventOfCode2021 | The Unlicense |
src/main/kotlin/day01/Day01.kt | tiefenauer | 727,712,214 | false | {"Kotlin": 11843} | /**
* --- Day 1: Trebuchet?! ---
* Something is wrong with global snow production, and you've been selected to take a look. The Elves have even given you a map; on it, they've used stars to mark the top fifty locations that are likely to be having problems.
*
* You've been doing this long enough to know that to res... | 0 | Kotlin | 0 | 0 | ffa90fbdaa779cfff956fab614c819274b793d04 | 3,326 | adventofcode-2023 | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem2210/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem2210
/**
* LeetCode page: [2210. Count Hills and Valleys in an Array](https://leetcode.com/problems/count-hills-and-valleys-in-an-array/);
*/
class Solution {
private enum class LevelTrend { INCREASE, DECREASE, UNKNOWN }
/* Complexity:
* Time O(N) and Space O(1) wh... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,473 | hj-leetcode-kotlin | Apache License 2.0 |
app/src/main/kotlin/day07/Day07.kt | StylianosGakis | 434,004,245 | false | {"Kotlin": 56380} | package day07
import common.InputRepo
import common.readSessionCookie
import common.solve
import kotlin.math.absoluteValue
fun main(args: Array<String>) {
val day = 7
val input = InputRepo(args.readSessionCookie()).get(day = day)
solve(day, input, ::solveDay07Part1, ::solveDay07Part2)
}
private fun List... | 0 | Kotlin | 0 | 0 | a2dad83d8c17a2e75dcd00651c5c6ae6691e881e | 1,176 | advent-of-code-2021 | Apache License 2.0 |
src/main/kotlin/day03/Day03.kt | vitalir2 | 572,865,549 | false | {"Kotlin": 89962} | package day03
import Challenge
import split
object Day03 : Challenge(3) {
override fun part1(input: List<String>): Int {
return input.sumOf(::calculatePriority)
}
override fun part2(input: List<String>): Int {
return input.chunked(3)
.sumOf { rucksacks ->
val ... | 0 | Kotlin | 0 | 0 | ceffb6d4488d3a0e82a45cab3cbc559a2060d8e6 | 1,116 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/leetcode/problem0051/NQueens.kt | ayukatawago | 456,312,186 | false | {"Kotlin": 266300, "Python": 1842} | package leetcode.problem0051
class NQueens {
fun solveNQueens(n: Int): List<List<String>> {
val answer = arrayListOf<List<String>>()
val board = Array(n) { CharArray(n) { '.' } }
solve(board, 0, answer)
return answer
}
private fun solve(board: Array<CharArray>, row: Int,... | 0 | Kotlin | 0 | 0 | f9602f2560a6c9102728ccbc5c1ff8fa421341b8 | 1,517 | leetcode-kotlin | MIT License |
src/Day05.kt | acrab | 573,191,416 | false | {"Kotlin": 52968} | import com.google.common.truth.Truth.assertThat
fun main() {
fun part1(input: List<String>): String {
val (moves, initialCrates) = input.partition { line -> line.any { it.isDigit() } }
//Build crates
val crates = mutableListOf<MutableList<Char>>()
for (pile in initialCrates) {
... | 0 | Kotlin | 0 | 0 | 0be1409ceea72963f596e702327c5a875aca305c | 2,262 | aoc-2022 | Apache License 2.0 |
2022/Day14.kt | amelentev | 573,120,350 | false | {"Kotlin": 87839} | fun main() {
val input = readInput("Day14")
val m = 1000
val n = 1000
val map = Array(n) { BooleanArray(m) }
var maxy = 0
for (s in input) {
val trace = s.split(" -> ").map { p ->
p.split(',').map { it.toInt() }
}
fun range(a: Int, b: Int) = if (a <= b) a..b e... | 0 | Kotlin | 0 | 0 | a137d895472379f0f8cdea136f62c106e28747d5 | 1,404 | advent-of-code-kotlin | Apache License 2.0 |
leetcode2/src/leetcode/SubtreeOfAnotherTree.kt | hewking | 68,515,222 | false | null | package leetcode
import leetcode.structure.TreeNode
/**
* 572. 另一个树的子树
* https://leetcode-cn.com/problems/subtree-of-another-tree/
* @program: leetcode
* @description: ${description}
* @author: hewking
* @create: 2019-05-17 09:42
* 给定两个非空二叉树 s 和 t,检验 s 中是否包含和 t 具有相同结构和节点值的子树。s 的一个子树包括 s 的一个节点和这个节点的所有子孙。s 也可以看做... | 0 | Kotlin | 0 | 0 | a00a7aeff74e6beb67483d9a8ece9c1deae0267d | 2,183 | leetcode | MIT License |
src/Day03.kt | aadityaguptaa | 572,618,899 | false | null |
fun main() {
fun part1(input: List<String>): Int {
var score = 0;
for(i in input.indices){
var len = input[i].length/2
var mp1 = mutableMapOf<Char, Int>()
var mp2 = mutableMapOf<Char, Int>()
for(j in 0 until len){
mp1[input[i][j]] ... | 0 | Python | 2 | 10 | d76ac48851a9b833fbbd3493a7730f7e0b365da8 | 1,709 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/dfa/dfaUtils.kt | rwwiv | 161,536,383 | false | {"Kotlin": 13029} | package dfa
import kotlin.system.exitProcess
fun prettyPrintDFA(input: DFA) {
print("(states, ")
println("${input.states.joinToString(",", "(", ")")})")
print("(alpha, ")
when {
input.alpha.contains(' ') -> {
println("())")
}
else -> {
println("${input.a... | 0 | Kotlin | 0 | 0 | 13ae3efc52862ed96f08f33e957cb614903a168f | 5,596 | dfamin | MIT License |
src/main/kotlin/_2019/Day4.kt | thebrightspark | 227,161,060 | false | {"Kotlin": 548420} | package _2019
import aocRun
import java.util.stream.Stream
import kotlin.streams.toList
fun main() {
aocRun(puzzleInput) { input ->
return@aocRun getRangeStream(input)
.filter { hasAscendingDigits(it) }
.filter { hasAdjacentDigits(it) }
.count()
}
aocRun(puzzle... | 0 | Kotlin | 0 | 0 | ac62ce8aeaed065f8fbd11e30368bfe5d31b7033 | 1,865 | AdventOfCode | Creative Commons Zero v1.0 Universal |
src/day01/Day01.kt | voom | 573,037,586 | false | {"Kotlin": 12156} | package day01
import readInput
/**
* --- Day 1: Calorie Counting ---
*/
fun main() {
fun groupByElf(input: List<String>) = input
// group calories carried by each elf
.fold<String, ArrayList<ArrayList<Int>>>(ArrayList()) { acc, s ->
acc.apply {
if (isEmpty()) add(arra... | 0 | Kotlin | 0 | 1 | a8eb7f7b881d6643116ab8a29177d738d6946a75 | 1,090 | aoc2022 | Apache License 2.0 |
src/main/kotlin/sorting/MergeSort.kt | parmeshtoyou | 470,239,301 | false | {"Kotlin": 28087, "Java": 5414} | package sorting
//sort the left half
//sort the right half
//merge both the half
fun main() {
val input = intArrayOf(23, 47, 81, -1, 95, 7, 14, 39, 55, 63, 74)
val temp = IntArray(input.size) { -1 }
println("before sorting")
for (i in input) {
println(i)
}
mergeSort(input, temp)
... | 0 | Kotlin | 0 | 0 | aea9c82a6faebae741bd9b0f2c6ad3a930b60ef1 | 1,546 | DSAPlaybook | Apache License 2.0 |
src/day23/Day23.kt | EndzeitBegins | 573,569,126 | false | {"Kotlin": 111428} | package day23
import day23.LookupDirection.*
import readInput
import readTestInput
import kotlin.LazyThreadSafetyMode.NONE
private data class ElfPosition(val x: Int, val y: Int) {
val northernNeighbors by lazy(mode = NONE) {
listOf(
ElfPosition(x - 1, y - 1),
ElfPosition(x, y - 1)... | 0 | Kotlin | 0 | 0 | ebebdf13cfe58ae3e01c52686f2a715ace069dab | 5,097 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day04.kt | Kanialdo | 573,165,497 | false | {"Kotlin": 15615} | import kotlin.math.max
import kotlin.math.min
fun main() {
fun part1(input: List<String>): Int {
return input.count { line ->
val (a1, a2, b1, b2) = line.split(",").map { it.split("-").map { it.toInt() } }.flatten()
if (a2 - a1 >= b2 - b1) {
a1 <= b1 && b2 <= a2
... | 0 | Kotlin | 0 | 0 | 10a8550a0a85bd0a928970f8c7c5aafca2321a4b | 842 | advent-of-code-2022 | Apache License 2.0 |
src/year2021/16/Day16.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2021.`16`
import readInput
import utils.parseToLongRadix
import utils.printlnDebug
// region Models for task
data class Packet(
val header: Header,
val packetType: PacketType,
val packetValue: Long?,
val subPackets: List<Packet>,
) {
/**
* Finds sum of this packet and its subpack... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 9,487 | KotlinAdventOfCode | Apache License 2.0 |
kotlin/0343-integer-break.kt | neetcode-gh | 331,360,188 | false | {"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750} | /*
* DP solution O(n^2) time and space
*/
class Solution {
fun integerBreak(n: Int): Int {
val cache = IntArray(n + 1) {-1}
cache[1] = 1
for (num in 2..n) {
cache[num] = if (num == n) 0 else num
for (i in 1..num) {
val res = cache[i] * cache[num - i]
... | 337 | JavaScript | 2,004 | 4,367 | 0cf38f0d05cd76f9e96f08da22e063353af86224 | 1,614 | leetcode | MIT License |
src/net/sheltem/aoc/y2022/Day19.kt | jtheegarten | 572,901,679 | false | {"Kotlin": 178521} | package net.sheltem.aoc.y2022
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import net.sheltem.common.mapParallel
suspend fun main() {
Day19().run()
}
class Day19 : Day<Int>(33, 3472) {
override suspend fun part1(input: List<String>): Int = runBlocking(Dispatchers.Default) {
... | 0 | Kotlin | 0 | 0 | ac280f156c284c23565fba5810483dd1cd8a931f | 2,843 | aoc | Apache License 2.0 |
src/main/kotlin/g1701_1800/s1735_count_ways_to_make_array_with_product/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1701_1800.s1735_count_ways_to_make_array_with_product
// #Hard #Array #Dynamic_Programming #Math #2023_06_16_Time_394_ms_(100.00%)_Space_50.6_MB_(100.00%)
@Suppress("NAME_SHADOWING")
class Solution {
private lateinit var tri: Array<LongArray>
private var primes: List<Int>? = null
fun waysToFillA... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,982 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/endredeak/aoc2023/Day15.kt | edeak | 725,919,562 | false | {"Kotlin": 26575} | package endredeak.aoc2023
fun main() {
solve("Lens Library") {
val input = text.replace("\n", "").split(",")
fun String.hash(): Int {
var current = 0
forEach { c ->
current += c.code
current *= 17
current %= 256
}
... | 0 | Kotlin | 0 | 0 | 92c684c42c8934e83ded7881da340222ff11e338 | 1,611 | AdventOfCode2023 | Do What The F*ck You Want To Public License |
src/main/kotlin/09-aug.kt | aladine | 276,334,792 | false | {"C++": 70308, "Kotlin": 53152, "Java": 10020, "Makefile": 511} | import java.util.*
typealias Pii = Pair<Int, Int>
class Solution09Aug{
fun orangesRotting(grid: Array<IntArray>): Int {
var res = 0
var totalFresh = 0
val q: Queue<Pii> = LinkedList<Pii>() //val queue = LinkedList<IntArray>()
val n= grid.size
val m = grid[0].size
f... | 0 | C++ | 1 | 1 | 54b7f625f6c4828a72629068d78204514937b2a9 | 1,676 | awesome-leetcode | Apache License 2.0 |
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day08Test.kt | dirkgroot | 317,968,017 | false | {"Kotlin": 187862} | package nl.dirkgroot.adventofcode.year2022
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import nl.dirkgroot.adventofcode.util.input
import nl.dirkgroot.adventofcode.util.invokedWith
private fun solution1(input: String): Int {
val grid = createGrid(input)
val width = grid[0].s... | 1 | Kotlin | 1 | 1 | ffdffedc8659aa3deea3216d6a9a1fd4e02ec128 | 3,149 | adventofcode-kotlin | MIT License |
solutions/src/main/kotlin/fr/triozer/aoc/y2022/Day04.kt | triozer | 573,964,813 | false | {"Kotlin": 16632, "Shell": 3355, "JavaScript": 1716} | package fr.triozer.aoc.y2022
import fr.triozer.aoc.utils.readInput
// #region part1
private fun part1(input: List<String>) = input.count {
val (start1, end1, start2, end2) = it
.split(",")
.flatMap { pair ->
pair.split("-").map { n -> n.toInt() }
}
val (start, end) = start1... | 0 | Kotlin | 0 | 1 | a9f47fa0f749a40e9667295ea8a4023045793ac1 | 1,090 | advent-of-code | Apache License 2.0 |
src/main/kotlin/Classify.kt | fcruzel | 183,215,777 | false | {"Kotlin": 17006, "Java": 6293, "Assembly": 154} | import kotlin.math.ln
enum class Classification(val sym: String) {
TROLL("T"), NOT_TROLL("nT");
}
fun classify(
corpus: List<String>,
learnT: LearnInfo,
learnNT: LearnInfo
): List<Classification> {
val classification = ArrayList<Classification>()
val probT = learnT.corpusSize.toDouble() / (lea... | 0 | Kotlin | 0 | 0 | ecf073f58ff077064b6fc3e021d1f5b54db128b0 | 1,318 | pln-iaa | MIT License |
src/main/kotlin/DamerauLevensthein.kt | javacook | 111,961,341 | false | null | package de.kotlincook.textmining
import java.lang.Math.max
import java.util.HashMap
/**
* The Damerau-Levenshtein Algorithm is an extension to the Levenshtein
* Algorithm which solves the edit distance problem between a source string and
* a target string with the following operations:
*
* Character Insertion
*... | 0 | Kotlin | 0 | 0 | 79fd08394b50016f8174f922abbea8c3cb506e49 | 4,871 | dameraulevenshtein | Apache License 2.0 |
LeetCode/Kotlin/SearchInRotatedSortedArray.kt | vale-c | 177,558,551 | false | null | /**
* 33. Search in Rotated Sorted Array
* https://leetcode.com/problems/search-in-rotated-sorted-array/
*/
class Solution {
fun search(nums: IntArray, target: Int): Int {
val pivotIndex = searchPivot(nums, 0, nums.size - 1)
if (pivotIndex == -1) {
return binarySearch(nums, targe... | 0 | Java | 5 | 9 | 977e232fa334a3f065b0122f94bd44f18a152078 | 1,896 | CodingInterviewProblems | MIT License |
kotlin/src/com/s13g/aoc/aoc2021/Day17.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2021
import com.s13g.aoc.Result
import com.s13g.aoc.Solver
import com.s13g.aoc.XY
import com.s13g.aoc.addTo
import kotlin.math.max
import kotlin.math.min
import kotlin.math.sign
/**
* --- Day 17:
* https://adventofcode.com/2021/day/17
*/
class Day17 : Solver {
override fun solve(lines: Li... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 1,685 | euler | Apache License 2.0 |
app/src/main/java/com/skt/nugu/sampleapp/utils/SimilarityChecker.kt | umrhiumrhi | 515,390,621 | false | {"Kotlin": 2646293, "Java": 1646, "Ruby": 1432} | package com.skt.nugu.sampleapp.utils
import java.lang.Integer.max
import java.lang.Math.min
class SimilarityChecker {
companion object {
private const val korBegin = 44032
private const val korEnd = 55203
private const val chosungBase = 588
private const val jungsungBase = 28
... | 0 | Kotlin | 0 | 0 | 6c4bc151d2cfe4d18e409c04e66c190f49d4e284 | 4,002 | skt-summer-internship-2022 | Apache License 2.0 |
src/main/kotlin/Day10.kt | uipko | 572,710,263 | false | {"Kotlin": 25828} |
fun main() {
val signal = signalStrength("Day10.txt")
println("Signal strength: $signal")
renderText("Day10.txt").map { line -> line.map { pixel -> print(pixel) }; print("\n")}
}
fun signalStrength(fileName: String): Int {
var cycles = 0
var registerX = 1
val addOpcode = "addx"
val strengt... | 0 | Kotlin | 0 | 0 | b2604043f387914b7f043e43dbcde574b7173462 | 1,974 | aoc2022 | Apache License 2.0 |
src/main/kotlin/com/github/thibseisel/diff/myers/MyersDiffAlgorithm.kt | thibseisel | 329,431,410 | false | null | package com.github.thibseisel.diff.myers
import com.github.thibseisel.diff.DeltaType
import com.github.thibseisel.diff.Equalizer
internal class MyersDiffAlgorithm<T>(
private val equalizer: Equalizer<T>
) {
/**
* Computes the change set to patch the source list to the target list.
*
* @param so... | 0 | Kotlin | 0 | 0 | aae1e13aac0c19b86855c4ba7eaa238f9681b867 | 3,576 | kotlin-diff | Apache License 2.0 |
src/main/kotlin/day11.kt | p88h | 317,362,882 | false | null | internal data class Seat(val pos: Pair<Int, Int>) {
var adj = ArrayList<Pair<Int, Int>>()
var nc = 0
fun InitAdj(area: List<CharArray>, maxd: Int) {
adj.clear()
for (ii in -1..1) for (jj in -1..1) {
if (ii == 0 && jj == 0) continue
for (k in 1..maxd) {
... | 0 | Kotlin | 0 | 5 | 846ad4a978823563b2910c743056d44552a4b172 | 1,744 | aoc2020 | The Unlicense |
src/main/kotlin/solutions/day06/Day6.kt | Dr-Horv | 112,381,975 | false | null | package solutions.day06
import solutions.Solver
import utils.splitAtWhitespace
data class Tuple(val index: Int, val value: Int)
class Day6 : Solver {
override fun solve(input: List<String>, partTwo: Boolean): String {
val banks = input.first()
.splitAtWhitespace()
.map(St... | 0 | Kotlin | 0 | 2 | 975695cc49f19a42c0407f41355abbfe0cb3cc59 | 1,557 | Advent-of-Code-2017 | MIT License |
src/Day01.kt | gojoel | 573,543,233 | false | {"Kotlin": 28426} | import kotlin.math.max
fun main() {
val input = readInput("01")
// val input = readInput("01_test")
// calculate total from elf with most calories
fun part1(input: List<String>): Int {
var total = 0
var current = 0
input.forEachIndexed { index, calories ->
current +... | 0 | Kotlin | 0 | 0 | 0690030de456dad6dcfdcd9d6d2bd9300cc23d4a | 1,132 | aoc-kotlin-22 | Apache License 2.0 |
Kotlin/src/MinimumPathSum.kt | TonnyL | 106,459,115 | false | null | /**
* Given a m x n grid filled with non-negative numbers,
* find a path from top left to bottom right which minimizes the sum of all numbers along its path.
*
* Note: You can only move either down or right at any point in time.
*
* Example 1:
* [[1,3,1],
* [1,5,1],
* [4,2,1]]
* Given the above grid map, retu... | 1 | Swift | 22 | 189 | 39f85cdedaaf5b85f7ce842ecef975301fc974cf | 1,360 | Windary | MIT License |
src/main/kotlin/com/sk/set9/935. Knight Dialer.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.set9
class Solution935 {
/**
* DP top-down
*/
val max = 1e9.toInt() + 7
fun knightDialer(n: Int): Int {
var s = 0L
val dp = Array(n + 1) { Array(4) { LongArray(3) } }
for (i in 0 until 4) {
for (j in 0 until 3) {
s = (s + ways(... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 2,668 | leetcode-kotlin | Apache License 2.0 |
kotlin/src/main/kotlin/adventofcode/y2018/Day8.kt | 3ygun | 115,948,057 | false | null | package adventofcode.y2018
import adventofcode.DataLoader
import adventofcode.Day
object Day8 : Day {
val STAR1_DATA = DataLoader.readLinesFromFor("/y2018/Day8Star1.txt").first()
val STAR2_DATA = STAR1_DATA
override val day: Int = 8
override fun star1Run(): String {
val result = star1Calc(ST... | 0 | Kotlin | 0 | 0 | 69f95bca3d22032fba6ee7d9d6ec307d4d2163cf | 2,595 | adventofcode | MIT License |
src/Day03.kt | anilkishore | 573,688,256 | false | {"Kotlin": 27023} | fun main() {
fun part1(input: List<String>): Int {
return input.asSequence().map {
val first = it.substring(0, it.length / 2).toSet()
val second = it.substring(it.length / 2).toSet()
val ch = first.intersect(second).first()
if (ch in 'a'..'z') (ch - 'a' + 1) ... | 0 | Kotlin | 0 | 0 | f8f989fa400c2fac42a5eb3b0aa99d0c01bc08a9 | 770 | AOC-2022 | Apache License 2.0 |
kotlin/src/com/daily/algothrim/dp/MinDist.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.dp
import kotlin.math.min
/**
* 棋盘最小路径
*
* 假设我们有一个 n 乘以 n 的矩阵 matrix[n][n]。矩阵存储的都是正整数。棋子起始位置在左上角,终止位置在右下角。
* 我们将棋子从左上角移动到右下角。每次只能向右或者向下移动一位。从左上角到右下角,会有很多不同的路径可以走。
* 我们把每条路径经过的数字加起来看作路径的长度。那从左上角移动到右下角的最短路径长度是多少呢?
*/
class MinDist {
companion object {
@JvmStatic
fu... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 2,847 | daily_algorithm | Apache License 2.0 |
src/main/kotlin/com/groundsfam/advent/y2020/d18/Day18.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2020.d18
import com.groundsfam.advent.DATAPATH
import kotlin.io.path.div
import kotlin.io.path.useLines
fun evaluatePartOne(token: Token): Long = when (token) {
is NumberToken -> token.value
is TokenList -> {
val tokens = token.tokens
var ret = evaluatePartOne(to... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 2,527 | advent-of-code | MIT License |
src/test/kotlin/amb/aoc2020/day7.kt | andreasmuellerbluemlein | 318,221,589 | false | null | package amb.aoc2020
import org.junit.jupiter.api.Test
class Day7 : TestBase() {
companion object {
}
fun loadRegulations(inputFile: String) : Map<String,List<Pair<String,Int>>>{
val data = getTestData(inputFile).map { line ->
line.split(" bags contain ", " bags, ", " bag, "," bags.",... | 1 | Kotlin | 0 | 0 | dad1fa57c2b11bf05a51e5fa183775206cf055cf | 2,054 | aoc2020 | MIT License |
src/main/kotlin/aoc2022/Day05.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2022
import AoCDay
import util.*
private typealias Crate = Char
// https://adventofcode.com/2022/day/5
object Day05 : AoCDay<String>(
title = "Supply Stacks",
part1ExampleAnswer = "CMZ",
part1Answer = "QNHWJVJZW",
part2ExampleAnswer = "MCD",
part2Answer = "BPCZJLFJW",
) {
// parsin... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 2,952 | advent-of-code-kotlin | MIT License |
src/main/kotlin/pl/bizarre/day2_2.kt | gosak | 572,644,357 | false | {"Kotlin": 26456} | package pl.bizarre
import pl.bizarre.Day2Move.Companion.findMove
import pl.bizarre.Day2Move.Paper
import pl.bizarre.Day2Move.Rock
import pl.bizarre.Day2Move.Scissors
import pl.bizarre.common.loadInput
import java.util.regex.Pattern
fun main() {
val input = loadInput(2)
println("result ${day2_2(input)}")
}
fu... | 0 | Kotlin | 0 | 0 | aaabc56532c4a5b12a9ce23d54c76a2316b933a6 | 1,228 | adventofcode2022 | Apache License 2.0 |
Kotlin for Java Developers. Week 3/Taxi Park/Task/src/taxipark/TaxiParkTask.kt | Anna-Sentyakova | 186,426,055 | false | null | package taxipark
/*
* Task #1. Find all the drivers who performed no trips.
*/
fun TaxiPark.findFakeDrivers(): Set<Driver> =
allDrivers.associate { driver -> driver to findAllTrips(driver) }
.filterValues { trips -> trips.isEmpty() }
.keys
fun TaxiPark.findAllTrips(driver: Dr... | 0 | Kotlin | 0 | 1 | e5db4940fa844aa8a5de7f90dd872909a06756e6 | 3,463 | coursera | Apache License 2.0 |
src/main/kotlin/be/tabs_spaces/advent2021/days/Day10.kt | janvryck | 433,393,768 | false | {"Kotlin": 58803} | package be.tabs_spaces.advent2021.days
class Day10 : Day(10) {
override fun partOne() = inputList
.mapNotNull { SyntaxChecker.firstIllegalClosingCharIn(it) }
.sumOf { Syntax.syntaxErrorScoreFor(it) }
override fun partTwo() = inputList
.mapNotNull { SyntaxChecker.missingClosingCharsIn(... | 0 | Kotlin | 0 | 0 | f6c8dc0cf28abfa7f610ffb69ffe837ba14bafa9 | 2,317 | advent-2021 | Creative Commons Zero v1.0 Universal |
kotlin/problems/src/solution/TreeProblems.kt | lunabox | 86,097,633 | false | {"Kotlin": 146671, "Python": 38767, "JavaScript": 19188, "Java": 13966} | package solution
import data.structure.TreeNode
import java.util.*
import java.util.concurrent.ArrayBlockingQueue
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.max
import kotlin.math.min
class TreeProblems {
/**
* 由数组创建二叉树
*/
fun createTree(element: List<In... | 0 | Kotlin | 0 | 0 | cbb2e3ad8f2d05d7cc54a865265561a0e391a9b9 | 10,872 | leetcode | Apache License 2.0 |
solutions/src/solutions/y19/day 22.kt | Kroppeb | 225,582,260 | false | null | @file:Suppress("PackageDirectoryMismatch")
package solutions.solutions.y19.d22
import helpers.*
import kotlin.collections.*
import java.math.BigInteger
private fun part1(data: Data) {
var pos = 2020L
val l = 119315717514047
repeat(50030000) {
for (i in data) {
val p = i.split(' ')
when (p[0]) {
"deal" ... | 0 | Kotlin | 0 | 1 | 744b02b4acd5c6799654be998a98c9baeaa25a79 | 2,425 | AdventOfCodeSolutions | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.