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/leetcodeProblem/leetcode/editor/en/MaximumSubarray.kt
faniabdullah
382,893,751
false
null
//Given an integer array nums, find the contiguous subarray (containing at //least one number) which has the largest sum and return its sum. // // A subarray is a contiguous part of an array. // // // Example 1: // // //Input: nums = [-2,1,-3,4,-1,2,1,-5,4] //Output: 6 //Explanation: [4,-1,2,1] has the largest sum...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,452
dsa-kotlin
MIT License
aoc2023/src/main/kotlin/de/havox_design/aoc2023/day02/CubeConundrum.kt
Gentleman1983
737,309,232
false
{"Kotlin": 746488, "Java": 441473, "Scala": 33415, "Groovy": 5725, "Python": 3319}
package de.havox_design.aoc2023.day02 class CubeConundrum(private var filename: String) { fun solvePart1(): Long = getResourceAsText(filename) .mapNotNull(::getGameIdOfValidInputLine) .sum() .toLong() fun solvePart2(): Long = getResourceAsText(filename).sumO...
4
Kotlin
0
1
35ce3f13415f6bb515bd510a1f540ebd0c3afb04
2,265
advent-of-code
Apache License 2.0
src/test/kotlin/chapter4/boilerplate.kt
DavidGomesh
680,857,367
false
{"Kotlin": 204685}
package chapter4 import chapter3.Cons import chapter3.List import chapter3.Nil fun <A, B> List<A>.map(f: (A) -> B): List<B> = this.foldRight( List.empty(), { a, b -> Cons(f(a), b) }) fun <A, B> List<A>.foldRight(z: B, f: (A, B) -> B): B = when (this) { is Nil -> z is Cons -> f...
0
Kotlin
0
0
41fd131cd5049cbafce8efff044bc00d8acddebd
1,390
fp-kotlin
MIT License
src/main/java/dev/haenara/mailprogramming/solution/y2019/m08/d04/Solution190804.kt
HaenaraShin
226,032,186
false
null
package dev.haenara.mailprogramming.solution.y2019.m08.d04 import dev.haenara.mailprogramming.solution.Solution /** * 매일프로그래밍 2019. 08. 04 * 0, 1, 2로 이루어진 배열을 가장 효율적으로 정렬 하시오. 시간복잡도 O(n). * Given an array consisting of 0, 1 and 2s, sort this array. * Input: [0, 1, 2, 2, 0, 0, 0, 1] * Output: [0, 0, 0, 0, 1, 1, 2...
0
Kotlin
0
7
b5e50907b8a7af5db2055a99461bff9cc0268293
2,813
MailProgramming
MIT License
2019/07 - Amplification Circuit/kotlin/src/app.kt
Adriel-M
225,250,242
false
null
import java.io.File import kotlin.math.pow fun main() { val instructions = getInstructions("../input2") // println("===== Part 1 ===== ") // println(runPart1(instructions)) println("===== Part 2 ===== ") println(runPart2(instructions)) } fun runPart1(instructions: List<Int>): Int { val iter = P...
0
Kotlin
0
0
ceb1f27013835f13d99dd44b1cd8d073eade8d67
8,001
advent-of-code
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year22/Day07.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year22 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.queueOf import kotlin.math.abs fun PuzzleSet.day7() = puzzle { val normalFiles = mutableMapOf<String, Int>() val dirs = buildMap<String, List<String>> { val stack = queueOf<String>() val curre...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,429
advent-of-code
The Unlicense
day14/src/main/kotlin/aoc2015/day14/Day14.kt
sihamark
581,653,112
false
{"Kotlin": 263428, "Shell": 467, "Batchfile": 383}
package aoc2015.day14 /** * Created by <NAME> on 31.01.2019. */ object Day14 { private const val RACE_DURATION = 2503 fun calculateDistanceOfWinningReindeer(): Int { val reindeers = input.map { Parser.parse(it) } return Race(reindeers, RACE_DURATION).calculateFarthestDistance() } f...
0
Kotlin
0
0
6d10f4a52b8c7757c40af38d7d814509cf0b9bbb
2,840
aoc2015
Apache License 2.0
kotlin/backtracking/MisWeighted.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package backtracking import java.util.Random object MisWeighted { // maximum independent weighted set in O(3^(n/3)) // prerequisite: g[i] has i'th bit set fun mis(g: LongArray, unused: Long, weights: IntArray): Int { if (unused == 0L) return 0 var v = -1 var u: Int = Long.numberOfT...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
2,122
codelibrary
The Unlicense
year2020/day05/part1/src/main/kotlin/com/curtislb/adventofcode/year2020/day05/part1/Year2020Day05Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 5: Binary Boarding --- You board your plane only to discover a new problem: you dropped your boarding pass! You aren't sure which seat is yours, and all of the flight attendants are busy with the flood of people that suddenly made it through passport control. You write a quick program to use your phone's c...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
3,418
AdventOfCode
MIT License
src/main/kotlin/g1801_1900/s1900_the_earliest_and_latest_rounds_where_players_compete/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1801_1900.s1900_the_earliest_and_latest_rounds_where_players_compete // #Hard #Dynamic_Programming #Memoization #2023_06_22_Time_142_ms_(100.00%)_Space_33.6_MB_(100.00%) class Solution { fun earliestAndLatest(n: Int, firstPlayer: Int, secondPlayer: Int): IntArray { var p1 = Math.min(firstPlayer, ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,756
LeetCode-in-Kotlin
MIT License
Coding Challenges/Advent of Code/2021/Day 11/part2.kt
Alphabeater
435,048,407
false
{"Kotlin": 69566, "Python": 5974}
import java.io.File import java.util.Scanner val octopusMatrix: ArrayList<ArrayList<Int>> = arrayListOf() //energy matrix of the octupi. val octopusMatrixFlash: ArrayList<ArrayList<Boolean>> = arrayListOf() //keep track of which octopi flashed. fun sincronizationOfFlashes(n: Int): Boolean { var count = 0 for...
0
Kotlin
0
0
05c8d4614e025ed2f26fef2e5b1581630201adf0
3,943
Archive
MIT License
src/main/kotlin/days/Day14.kt
hughjdavey
317,575,435
false
null
package days class Day14 : Day(14) { // 11327140210986 override fun partOne(): Any { return InstructionRunner().run(getInstructions(true)) } // 2308180581795 override fun partTwo(): Any { return InstructionRunner().run(getInstructions(false)) } fun getInstructions(v1: Boo...
0
Kotlin
0
1
63c677854083fcce2d7cb30ed012d6acf38f3169
3,243
aoc-2020
Creative Commons Zero v1.0 Universal
year2023/src/main/kotlin/net/olegg/aoc/year2023/day17/Day17.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2023.day17 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.fit import net.olegg.aoc.utils.get import net.olegg.aoc.year2023.DayOf2023 import java.util.PriorityQueue /** * See [Year 2023, Day 17](https:...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,853
adventofcode
MIT License
src/main/kotlin/data/CDataClass.kt
tamilschool
711,222,508
false
{"Kotlin": 153687, "HTML": 1758}
package data data class CQuestionState( var selectedGroup: Group, var selectedRound: Round, var selectedTopic: Topic, var round2Kurals: List<Thirukkural>, var athikaramState: CAthikaramState, var kuralState: CThirukkuralState, var porulState: CThirukkuralState, var firstWordState: CFirstWordState, va...
0
Kotlin
0
0
39190f307d6f4ebdd63c5727dee4b89ff80176b6
6,330
tamilschool.github.io
Apache License 2.0
src/main/kotlin/aoc2022/Day22.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2022 import AoCDay import aoc2022.Day22.Direction.* import aoc2022.Day22.Space.* import util.illegalInput // https://adventofcode.com/2022/day/22 object Day22 : AoCDay<Int>( title = "Monkey Map", part1ExampleAnswer = 6032, part1Answer = 50412, part2ExampleAnswer = null, part2Answer = nu...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
3,946
advent-of-code-kotlin
MIT License
app/src/main/java/com/joyfulmath/datastructandalgorithms/algorthms/MaximumSubarray.kt
demanluandyuki
130,544,190
false
null
package com.joyfulmath.datastructandalgorithms.algorthms import com.joyfulmath.datastructandalgorithms.utils.TraceLog /** * leetcode 53 */ class MaximumSubarray { companion object { fun maxSubArray(nums: IntArray): Int { return maxSumRec(nums, 0, nums.lastIndex) } /** ...
0
Kotlin
0
0
ae9c577a264929788430368868391fe534f750bf
1,961
datastructure
MIT License
src/Day03.kt
Tiebe
579,377,778
false
{"Kotlin": 17146}
fun main() { fun part1(input: List<String>): Int { var total = 0 for (bag in input) { val firstHalf = bag.substring(0, bag.length/2) val secondHalf = bag.substring(bag.length/2) for (it in firstHalf) { if (it in secondHalf) { ...
1
Kotlin
0
0
afe9ac46b38e45bd400e66d6afd4314f435793b3
1,746
advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SnakesAndLadders.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
2,409
kotlab
Apache License 2.0
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem030.kt
mddburgess
261,028,925
false
null
package dev.mikeburgess.euler.problems import dev.mikeburgess.euler.common.digits import kotlin.math.pow /** * Problem 30 * * Surprisingly there are only three numbers that can be written as the sum of fourth powers of * their digits: * * 1634 = 1^4 + 6^4 + 3^4 + 4^4 * 8208 = 8^4 + 2^4 + 0^4 + 8^4 * 9474 = 9^...
0
Kotlin
0
0
86518be1ac8bde25afcaf82ba5984b81589b7bc9
899
project-euler
MIT License
src/main/kotlin/dev/bogwalk/batch2/Problem25.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch2 import dev.bogwalk.util.strings.digitCount import java.math.BigInteger import kotlin.math.* /** * Problem 25: N-digit Fibonacci Number * * https://projecteuler.net/problem=25 * * Goal: Find the first term in the Fibonacci sequence to have N digits. * * Constraints: 2 <= N <= 5000 * ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
3,778
project-euler-kotlin
MIT License
src/main/kotlin/Day06.kt
robfletcher
724,814,488
false
{"Kotlin": 18682}
class Day06 : Puzzle { override fun test() { val input = """ Time: 7 15 30 Distance: 9 40 200""".trimIndent() assert(part1(input.lineSequence()) == 288) assert(part2(input.lineSequence()) == 71503) } override fun part1(input: Sequence<String>) = parseInput1(input) .m...
0
Kotlin
0
0
cf10b596c00322ea004712e34e6a0793ba1029ed
1,220
aoc2023
The Unlicense
src/main/kotlin/io/opencui/du/matcher.kt
opencui
550,521,089
false
{"Kotlin": 944279, "Shell": 44}
package io.opencui.du // For only the candidates that are returned from retrieval phase, we do nested matcher. // There are two different places that we need nested matching: // 1. Find the exact match. This requires us to test whether utterance and examplar are the same, and // at the same time keep the filling i...
0
Kotlin
1
0
163f47189a37f66c02ca8090366bf21d4e5e960a
7,125
core
Apache License 2.0
src/main/kotlin/days/Day08.kt
TheMrMilchmann
433,608,462
false
{"Kotlin": 94737}
/* * Copyright (c) 2021 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
dfc91afab12d6dad01de552a77fc22a83237c21d
3,193
AdventOfCode2021
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year23/Day23.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year23 import com.grappenmaker.aoc.* import com.grappenmaker.aoc.Direction.* fun PuzzleSet.day23() = puzzle(day = 23) { val g = inputLines.asCharGrid() val s = Point(1, 0) val e = Point(g.width - 2, g.height - 1) val ps = (g.points.filter { p -> g[p] != '#' && ent...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,223
advent-of-code
The Unlicense
app/src/main/java/com/example/posetrackervrc/data/Vector3D.kt
t-34400
743,037,050
false
{"Kotlin": 69476}
package com.example.posetrackervrc.data import kotlin.math.sqrt data class Vector3D(val x: Float, val y: Float, val z: Float) { companion object { val zero = Vector3D(0.0f, 0.0f, 0.0f) val right = Vector3D(1.0f, 0.0f, 0.0f) val up = Vector3D(0.0f, 1.0f, 0.0f) val forward = Vector3D...
0
Kotlin
0
0
89daad8d0c9065e1954f38faf823a72b05a2fd99
2,280
PoseTrackerVRC
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem222/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem222 import com.hj.leetcode.kotlin.common.model.TreeNode /** * LeetCode page: [222. Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes/); */ class Solution { /* Complexity: * Time O((LogN)^2) and Space O(LogN) where N is the number of nod...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,294
hj-leetcode-kotlin
Apache License 2.0
src/Day03.kt
slawa4s
573,050,411
false
{"Kotlin": 20679}
const val CHUNK_SIZE = 3 fun main() { fun setOfCharsToSumInt(set: Set<Char>) = set.sumOf { Character.getNumericValue(it) + if (it.isUpperCase()) 17 else -9 } fun getChunkToInt(input: List<Set<Char>>): Int = setOfCharsToSumInt(input.reduce { first, second -> first.intersect(...
0
Kotlin
0
0
cd8bbbb3a710dc542c2832959a6a03a0d2516866
764
aoc-2022-in-kotlin
Apache License 2.0
src/Day01.kt
allisonjoycarter
574,207,005
false
{"Kotlin": 22303}
fun main() { fun part1(input: List<String>): Int { var amount = 0 var max = 0 for (i in input) { if (i.isEmpty()) { if (amount > max) { max = amount } amount = 0 } else if (i.isNotEmpty()) { ...
0
Kotlin
0
0
86306ee6f4e90c1cab7c2743eb437fa86d4238e5
1,062
adventofcode2022
Apache License 2.0
src/Day06.kt
karlwalsh
573,854,263
false
{"Kotlin": 32685}
fun main() { fun part1(input: String): Int = input.windowedSequence(4) .mapIndexed { index, chunk -> index to chunk } .filter { (_, chunk) -> chunk.toSet().size == 4 } .first() .first + 4 fun part2(input: String): Int = input.windowedSequence(14) .mapIndexed { index, chu...
0
Kotlin
0
0
f5ff9432f1908575cd23df192a7cb1afdd507cee
2,086
advent-of-code-2022
Apache License 2.0
src/main/kotlin/d16/d16t.kt
LaurentJeanpierre1
573,454,829
false
{"Kotlin": 118105}
package d16 import readInput import java.lang.IllegalStateException import java.util.PriorityQueue val openable = mutableListOf<Valve>() data class Path(val valve: Valve, val len: Int) : Comparable<Path> { override fun compareTo(other: Path): Int { return len.compareTo(other.len) } } fun dijkstra(fr...
0
Kotlin
0
0
5cf6b2142df6082ddd7d94f2dbde037f1fe0508f
4,917
aoc2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/chriswk/aoc/advent2021/Day15.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2021 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.Pos import com.chriswk.aoc.util.asInt import com.chriswk.aoc.util.report import java.util.PriorityQueue import kotlin.math.max class Day15: AdventDay(2021, 15) { companion object { @JvmStatic fun main(a...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
3,819
adventofcode
MIT License
src/2022/Day15.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2022` import common.Interval import common.Point import java.io.File import java.util.* import kotlin.math.abs fun main() { Day15().solve() } class Day15 { val input1 = """ Sensor at x=2, y=18: closest beacon is at x=-2, y=15 Sensor at x=9, y=16: closest beacon is at x=10, y=16 ...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
4,923
advent-of-code
Apache License 2.0
src/y2022/Day03.kt
Yg0R2
433,731,745
false
null
package y2022 import DayX class Day03 : DayX<Int>(157, 70) { /** * Lowercase item types a through z have priorities 1 through 26. * ascii a-z 97-122 * Uppercase item types A through Z have priorities 27 through 52. * ascii A-Z 65-90 */ override fun part1(input: List<String>): Int = ...
0
Kotlin
0
0
d88df7529665b65617334d84b87762bd3ead1323
1,307
advent-of-code
Apache License 2.0
src/adventofcode/Day22.kt
Timo-Noordzee
573,147,284
false
{"Kotlin": 80936}
package adventofcode import org.openjdk.jmh.annotations.* import java.util.concurrent.TimeUnit import kotlin.math.sqrt private operator fun IntRange.component1() = first private operator fun IntRange.component2() = last private operator fun List<CharArray>.contains(point: Point) = point.y in indices && point.x in t...
0
Kotlin
0
2
10c3ab966f9520a2c453a2160b143e50c4c4581f
8,879
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/days/Day22.kt
TheMrMilchmann
433,608,462
false
{"Kotlin": 94737}
/* * Copyright (c) 2021 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
dfc91afab12d6dad01de552a77fc22a83237c21d
3,777
AdventOfCode2021
MIT License
src/Day14/December14.kt
Nandi
47,216,709
false
null
package Day14 import java.nio.file.Files import java.nio.file.Paths import java.util.* import java.util.stream.Stream /** * todo: visualize * * This year is the Reindeer Olympics! Reindeer can fly at high speeds, but must rest occasionally to recover their * energy. Santa would like to know which of his reindeer ...
0
Kotlin
0
0
34a4b4c0926b5ba7e9b32ca6eeedd530f6e95bdc
3,771
adventofcode
MIT License
v2-model-extension/src/commonMain/kotlin/com/bselzer/gw2/v2/model/extension/wvw/WvwUpgrade.kt
Woody230
388,820,096
false
null
package com.bselzer.gw2.v2.model.extension.wvw import com.bselzer.gw2.v2.model.wvw.upgrade.WvwUpgrade import com.bselzer.gw2.v2.model.wvw.upgrade.tier.WvwUpgradeTier import kotlin.math.min /** * Calculates the upgrade level based on the number of [yaksDelivered] satisfying the number of [WvwUpgradeTier.yaksRequired]...
2
Kotlin
0
0
fcd2cdfa97d78ec10e44a84e10c9b13a01f896bb
3,251
GW2Wrapper
Apache License 2.0
fd-applet-server/src/main/kotlin/io/github/haruhisa_enomoto/server/utils/Stringify.kt
haruhisa-enomoto
628,298,470
false
null
package io.github.haruhisa_enomoto.server.utils import io.github.haruhisa_enomoto.backend.algebra.Indec /** * Returns a comparator that first compares lists by their sizes, then lexicographically * if the sizes are equal. */ fun <T : Comparable<T>> getMyComparator(): Comparator<List<T>> { return Comparator { o...
0
Kotlin
0
0
8ec1afe14e9f0d6330d02652c1cd782a68fca5db
2,695
fd-applet
MIT License
src/Day01.kt
gillyobeast
574,413,213
false
{"Kotlin": 27372}
import utils.appliedTo import utils.readInput fun main() { fun caloriesPerElf(input: List<String>): MutableList<Int> { val elvesCalories = mutableListOf<Int>() var total = 0 input.forEach { if (it.isBlank()) { elvesCalories.add(total) total = 0 ...
0
Kotlin
0
0
8cdbb20c1a544039b0e91101ec3ebd529c2b9062
1,213
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/org/example/adventofcode/puzzle/Day07.kt
nikos-ds
573,046,617
false
null
package org.example.adventofcode.puzzle import org.example.adventofcode.util.FileLoader object Day07 { private const val FILE_PATH = "/day-07-input.txt" fun printSolution() { println("- part 1: ${part1()}") println("- part 2: ${part2()}") } fun part1(): Int { val rootDirector...
0
Kotlin
0
0
3f97096ebcd19f971653762fe29ddec1e379d09a
5,782
advent-of-code-2022-kotlin
MIT License
year2022/src/cz/veleto/aoc/year2022/Day08.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2022 import cz.veleto.aoc.core.AocDay import cz.veleto.aoc.core.Pos import cz.veleto.aoc.core.get import cz.veleto.aoc.core.rotateBy class Day08(config: Config) : AocDay(config) { private val treesInRow: Int = cachedInput.lastIndex override fun part1(): String { val visibleP...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
2,585
advent-of-pavel
Apache License 2.0
src/main/kotlin/com/github/davio/aoc/y2022/Day3.kt
Davio
317,510,947
false
{"Kotlin": 405939}
package com.github.davio.aoc.y2022 import com.github.davio.aoc.general.Day import com.github.davio.aoc.general.getInputAsSequence import kotlin.system.measureTimeMillis fun main() { println(Day3.getResultPart1()) measureTimeMillis { println(Day3.getResultPart2()) }.also { println("Took $it ms") } ...
1
Kotlin
0
0
4fafd2b0a88f2f54aa478570301ed55f9649d8f3
1,024
advent-of-code
MIT License
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec24.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2020 import org.elwaxoro.advent.PuzzleDayTester import java.util.Locale /** * resource https://www.redblobgames.com/grids/hexagons/ * was SUPER helpful on this one, used the 3D coordinate system for this puzzle */ class Dec24 : PuzzleDayTester(24, 2020) { override fun part1(): Any...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
2,725
advent-of-code
MIT License
src/main/kotlin/10/10.kt
Wrent
225,133,563
false
null
package `10` import Coord import java.lang.Math.abs import java.lang.Math.atan2 fun main() { val asteroids = parseAsteroids(INPUT10) val visibleAsteroids = mutableMapOf<Coord, Set<Coord>>() asteroids.forEach { val visible = getVisible(it, asteroids) visibleAsteroids.put(it, visible) ...
0
Kotlin
0
0
0a783ed8b137c31cd0ce2e56e451c6777465af5d
5,519
advent-of-code-2019
MIT License
simpleCykParser/src/main/kotlin/org/michaeldadams/simpleCykParser/grammar/Grammar.kt
adamsmd
668,129,808
false
null
/** Types for representing a grammar. */ package org.michaeldadams.simpleCykParser.grammar import org.michaeldadams.simpleCykParser.util.EqRegex import org.michaeldadams.simpleCykParser.util.Generated as Gen // ================================================================== // // Terminals and Nonterminals // ===...
0
Kotlin
0
0
23f1485bc0e56c9f6fa438053fc526066cf5a7f4
3,685
simpleCykParser
MIT License
src/main/kotlin/com/nibado/projects/advent/y2017/Day03.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2017 import com.nibado.projects.advent.Day object Day03 : Day { val input = 277678 override fun part1() : String { var remainder = input var ring = 0 while(remainder > 0) { val size = if (ring == 0) 1 else size(ring) - size(ring - 1) ...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
2,534
adventofcode
MIT License
src/main/kotlin/dev/bogwalk/batch4/Problem45.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch4 import dev.bogwalk.util.maths.isHexagonalNumber import dev.bogwalk.util.maths.isPentagonalNumber import dev.bogwalk.util.maths.isTriangularNumber /** * Problem 45: Triangular, Pentagonal, & Hexagonal * * https://projecteuler.net/problem=45 * * Goal: Given a & b, find all numbers below ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
4,826
project-euler-kotlin
MIT License
src/main/kotlin/de/nosswald/aoc/days/Day09.kt
7rebux
722,943,964
false
{"Kotlin": 34890}
package de.nosswald.aoc.days import de.nosswald.aoc.Day // https://adventofcode.com/2023/day/9 object Day09 : Day<Int>(9, "Mirage Maintenance") { private fun parseInput(input: List<String>): List<List<Int>> { return input.map { line -> line.split(" ").map(String::toInt) } } private fun nextInSequ...
0
Kotlin
0
1
398fb9873cceecb2496c79c7adf792bb41ea85d7
1,227
advent-of-code-2023
MIT License
src/main/kotlin/se/brainleech/adventofcode/aoc2015/Aoc2015Day05.kt
fwangel
435,571,075
false
{"Kotlin": 150622}
package se.brainleech.adventofcode.aoc2015 import se.brainleech.adventofcode.compute import se.brainleech.adventofcode.readLines import se.brainleech.adventofcode.verify class Aoc2015Day05 { companion object { private val NON_VOWELS = Regex("[^aeiou]") private val DOUBLE_CHAR = Regex("([a-z])\\1")...
0
Kotlin
0
0
0bba96129354c124aa15e9041f7b5ad68adc662b
1,383
adventofcode
MIT License
src/main/kotlin/aoc2022/Day09.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2022 import AoCDay import util.illegalInput import kotlin.math.abs import kotlin.math.sign // https://adventofcode.com/2022/day/9 object Day09 : AoCDay<Int>( title = "Rope Bridge", part1ExampleAnswer = 13, part1Answer = 6067, part2ExampleAnswer = 1, part2Answer = 2471, ) { private d...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
2,229
advent-of-code-kotlin
MIT License
src/Day13.kt
laricchia
434,141,174
false
{"Kotlin": 38143}
import org.jetbrains.kotlinx.multik.api.mk import org.jetbrains.kotlinx.multik.api.zeros import org.jetbrains.kotlinx.multik.ndarray.data.D2Array import org.jetbrains.kotlinx.multik.ndarray.data.get import org.jetbrains.kotlinx.multik.ndarray.data.set import org.jetbrains.kotlinx.multik.ndarray.operations.count import ...
0
Kotlin
0
0
7041d15fafa7256628df5c52fea2a137bdc60727
3,342
Advent_of_Code_2021_Kotlin
Apache License 2.0
src/main/kotlin/Day02.kt
akowal
434,506,777
false
{"Kotlin": 30540}
fun main() { println(Day02.solvePart1()) println(Day02.solvePart2()) } object Day02 { private val input = readInput("day02") .map { it.split(" ") } .map { (direction, distance) -> direction to distance.toInt() } fun solvePart1(): Int { var depth = 0 var totalDistance =...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
1,094
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/g1601_1700/s1626_best_team_with_no_conflicts/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1601_1700.s1626_best_team_with_no_conflicts // #Medium #Array #Dynamic_Programming #Sorting // #2023_06_16_Time_370_ms_(100.00%)_Space_40.5_MB_(100.00%) class Solution { private class Player( val age: Int, val score: Int ) : Comparable<Player> { override fun compareTo(other: P...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,295
LeetCode-in-Kotlin
MIT License
src/commonMain/kotlin/advent2020/day15/Day15Puzzle.kt
jakubgwozdz
312,526,719
false
null
package advent2020.day15 fun part1(input: String): String { val starting = input.trim().split(',').map { it.toInt() } return solve(starting, 2020).toString() } fun part2(input: String): String { val starting = input.trim().split(',').map { it.toInt() } return solve(starting, 30000000).toString() } ...
0
Kotlin
0
2
e233824109515fc4a667ad03e32de630d936838e
799
advent-of-code-2020
MIT License
src/main/kotlin/Day01.kt
zychu312
573,345,747
false
{"Kotlin": 15557}
interface Caloric { val caloricIntake: Int } data class Item(override val caloricIntake: Int) : Caloric data class Elf(val id: Int, val items: List<Item>) { val totalCalories = items.sumOf { it.caloricIntake } } tailrec fun parseInputToElves(input: List<String>, acc: List<Elf> = emptyList()): List<Elf> { ...
0
Kotlin
0
0
3e49f2e3aafe53ca32dea5bce4c128d16472fee3
1,056
advent-of-code-kt
Apache License 2.0
2020/src/year2020/day11/Day11.kt
eburke56
436,742,568
false
{"Kotlin": 61133}
package year2020.day11 import util.readAllLines private fun readInput(filename: String): Array<CharArray> { val input = readAllLines(filename) return input.map { it.toCharArray() }.toTypedArray() } val getCell = { map: Array<CharArray>, row: Int, col: Int -> if (row in map.indices && col in map[row].indi...
0
Kotlin
0
0
24ae0848d3ede32c9c4d8a4bf643bf67325a718e
5,889
adventofcode
MIT License
kotlin/2021/qualification-round/cheating-detection/src/main/kotlin/NotConsideringIfCheatingSolution.kts
ShreckYe
345,946,821
false
null
import kotlin.math.exp import kotlin.math.ln fun main() { val t = readLine()!!.toInt() val p = readLine()!!.toInt() repeat(t, ::testCase) } fun testCase(ti: Int) { val results = List(100) { readLine()!!.map { it - '0' } } // simple estimation by averaging val ss = results.map { i...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
1,603
google-code-jam
MIT License
year2015/src/main/kotlin/net/olegg/aoc/year2015/day19/Day19.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2015.day19 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2015.DayOf2015 /** * See [Year 2015, Day 19](https://adventofcode.com/2015/day/19) */ object Day19 : DayOf2015(19) { private val TRANSITIONS = lines .dropLast(2) .map { it.split(" => ") } .map { it.first...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,553
adventofcode
MIT License
src/main/day17/Part2.kt
ollehagner
572,141,655
false
{"Kotlin": 80353}
package day17 import common.Grid fun main() { val totalIterations = 1000000000000 val jetsfile = "day17/input.txt" val (firstOccurrence, secondOccurrence) = countPeriodicity(jetsfile) val period = secondOccurrence - firstOccurrence val heightAtFirstOccurrence = solve(firstOccurrence, jetsfile) ...
0
Kotlin
0
0
6e12af1ff2609f6ef5b1bfb2a970d0e1aec578a1
1,430
aoc2022
Apache License 2.0
leetcode/src/daily/Q777.kt
zhangweizhe
387,808,774
false
null
package daily fun main() { // 777. 在LR字符串中交换相邻字符 // https://leetcode.cn/problems/swap-adjacent-in-lr-string/ println(canTransform1("LXXLXRLXXL", "XLLXRXLXLX")) } fun canTransform(start: String, end: String): Boolean { // 满足题意的 start 和 end,需要具备以下条件 // 1、start 和 end 长度相同 // 2、start 和 end 中,L 的数量...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
4,531
kotlin-study
MIT License
src/main/kotlin/nl/kelpin/fleur/advent2018/Day10.kt
fdlk
159,925,533
false
null
package nl.kelpin.fleur.advent2018 class Day10(input: List<String>) { data class Star(val position: Point, val velocity: Point) { companion object { private val starRE = Regex("""position=< ?(-?\d+), +(-?\d+)> velocity=< ?(-?\d+), +(-?\d+)>""") fun of(notation: String): Star? = sta...
0
Kotlin
0
3
a089dbae93ee520bf7a8861c9f90731eabd6eba3
1,867
advent-2018
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinTimeToMakeRopeColorful.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,397
kotlab
Apache License 2.0
lib/src/main/kotlin/aoc/day17/Day17.kt
Denaun
636,769,784
false
null
package aoc.day17 fun part1(input: String): Int { val tetris = Tetris(7, parse(input)) tetris.simulate(2022) return tetris.towerHeight() } data class Coordinate(val row: Int, val column: Int) { infix operator fun plus(other: Coordinate): Coordinate = Coordinate(row + other.row, column + other....
0
Kotlin
0
0
560f6e33f8ca46e631879297fadc0bc884ac5620
2,545
aoc-2022
Apache License 2.0
src/main/kotlin/day21/Day21.kt
Arch-vile
317,641,541
false
null
package day21 import readFile typealias Allergen = String typealias Ingredient = String fun main(args: Array<String>) { var products = readFile("./src/main/resources/day21Input.txt") .map { """(.*) \(contains ([^\)]*)\)""".toRegex().find(it)!!.groupValues } .map { Pair(it[1].split(" ").toSe...
0
Kotlin
0
0
12070ef9156b25f725820fc327c2e768af1167c0
1,534
adventOfCode2020
Apache License 2.0
leetcode2/src/leetcode/missing-number.kt
hewking
68,515,222
false
null
package leetcode import java.lang.IllegalArgumentException /** * https://leetcode-cn.com/problems/missing-number/ * 268. 缺失数字 * @program: leetcode * @description: ${description} * @author: hewking * @create: 2019-10-18 19:26 * 给定一个包含 0, 1, 2, ..., n 中 n 个数的序列,找出 0 .. n 中没有出现在序列中的那个数。 示例 1: 输入: [3,0,1] 输出: 2 ...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,500
leetcode
MIT License
src/main/kotlin/fp/kotlin/example/chapter09/solution/9_11_TreeMonoidWithFoldable.kt
funfunStory
101,662,895
false
null
package fp.kotlin.example.chapter09.solution import fp.kotlin.example.chapter09.Foldable import fp.kotlin.example.chapter09.SumMonoid /** * * 연습문제 9-11 * * 일반 트리를 Foldable 타입클래스의 인스턴스로 만들고, ``foldLeft``, ``foldMap`` 함수의 동작을 테스트해보자. * 이때 트리의 노드는 값 ``val value: A``와 하위 트리의 리스트인 ``val forest: FunList<Node<A>>``를 프로...
1
Kotlin
23
39
bb10ea01d9f0e1b02b412305940c1bd270093cb6
2,663
fp-kotlin-example
MIT License
src/main/kotlin/oct_challenge2021/LongestCommonSubsequence.kt
yvelianyk
405,919,452
false
{"Kotlin": 147854, "Java": 610}
package oct_challenge2021 fun main() { assert(longestCommonSubsequence("abcde", "ace") == 3) assert(longestCommonSubsequence("abc", "def") == 0) assert(longestCommonSubsequence("abc", "abc") == 2) val res = longestCommonSubsequence("abc", "abc") println(res) } fun longestCommonSubsequence(text1: S...
0
Kotlin
0
0
780d6597d0f29154b3c2fb7850a8b1b8c7ee4bcd
1,175
leetcode-kotlin
MIT License
DSA/kotlin-programming/happy_number.kt
atig05
422,574,082
true
{"C": 65911, "Python": 42641, "C++": 37467, "Jupyter Notebook": 21486, "Solidity": 9341, "Kotlin": 7674, "HTML": 3421, "JavaScript": 2689, "Shell": 1399, "CSS": 568}
/* kotlin program to check happy numbers A happy number is a number, if we reach to 1 after replacing the number by the squares of the digits of the number Following examples will help to understand better:- Input: n = 19 Output: True 19 is Happy Number, 1^2 + 9^2 = 82 8^2 + 2^2 = 68 6^2 + 8^2 = 100 1^2 + 0^2 + 0^2 ...
0
C
0
0
a13b4a72c3c13760643f0f2aa4d5dcd8bf2c79dc
1,542
HACKTOBERFEST-2021
MIT License
src/Day04.kt
gischthoge
573,509,147
false
{"Kotlin": 5583}
fun main() { fun part1(input: List<String>): Int { return input.map { pair -> pair.split(",") .map { range -> val (from, to) = range.split("-").map { it.toInt() } (from..to).toSet() } }.filter { (first, second) -> ...
0
Kotlin
0
0
e403f738572360d4682f9edb6006d81ce350ff9d
903
aock
Apache License 2.0
src/day1.kts
AfzalivE
317,962,201
false
null
println("Start") // val input = listOf(1721, 979, 366, 299, 675, 1456) val input = readInput("day1.txt").readLines().map { it.toInt() } fun part1() { var i = 0 var j = 1 var foundPair = false while (!foundPair) { j += 1 if (j == input.size - 2) { i += 1 j = i + ...
0
Kotlin
0
0
cc5998bfcaadc99e933fb80961be9a20541e105d
1,295
AdventOfCode2020
Apache License 2.0
src/day13/Day13.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day13 import logln import logEnabled import readInput private const val DAY_NUMBER = 13 fun parseFile(rawInput: List<String>): List<Pair<Packet, Packet>> { val iterator = rawInput.iterator() val pairList = mutableListOf<Pair<Packet, Packet>>() while (iterator.hasNext()) { pairList.add(par...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
4,841
advent-of-code-2022
Apache License 2.0
src/com/mrxyx/algorithm/Fib.kt
Mrxyx
366,778,189
false
null
package com.mrxyx.algorithm /** * 斐波那契数列 * https://leetcode-cn.com/problems/fibonacci-number/ */ class Fib { /** * 暴力递归 * @param n 入参 */ fun fibV1(n: Int): Int { if (n == 1 || n == 2) return 1 return fibV1(n - 1) + fibV1(n - 2) } /** * 带备忘录的递归 自顶向下 */ f...
0
Kotlin
0
0
b81b357440e3458bd065017d17d6f69320b025bf
1,317
algorithm-test
The Unlicense
day17/kotlin/corneil/src/main/kotlin/solution.kt
jensnerche
317,661,818
true
{"HTML": 2739009, "Java": 292790, "Python": 189361, "TypeScript": 172255, "Groovy": 155991, "Kotlin": 155380, "Jupyter Notebook": 116902, "Dart": 47762, "Haskell": 43633, "C++": 40222, "CSS": 35030, "Ruby": 27091, "Scala": 11409, "Dockerfile": 10370, "JavaScript": 9395, "PHP": 4152, "Go": 2838, "Shell": 2651, "Rust": 2...
package com.github.corneil.aoc2019.day17 import com.github.corneil.aoc2019.common.Combinations import com.github.corneil.aoc2019.intcode.Program import com.github.corneil.aoc2019.intcode.ProgramState import com.github.corneil.aoc2019.intcode.readProgram import java.io.File import java.io.PrintWriter import java.io.Str...
0
HTML
0
0
a84c00ddbeb7f9114291125e93871d54699da887
13,376
aoc-2019
MIT License
src/main/kotlin/graph/core/MaxWeightPathDAG.kt
yx-z
106,589,674
false
null
package graph.core import util.max // find a path in a directed acyclic graph that has max weight from s to t // report the total weight of such path fun <V> WeightedGraph<V, Int>.maxWeightedPath(s: Vertex<V>, t: Vertex<V>, ch...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,254
AlgoKt
MIT License
src/Day06.kt
KristianAN
571,726,775
false
{"Kotlin": 9011}
// Without using stdlib windowed data class CharAndIndex(val char: Char, val index: Int) data class Window(val windowSize: Int, val window: List<CharAndIndex?>) { fun update(char: Char, index: Int): Window = Window(windowSize, this.window.drop(1).plus(CharAndIndex(char, index))) fun nonEq() = this.win...
0
Kotlin
0
0
3a3af6e99794259217bd31b3c4fd0538eb797941
1,405
AoC2022Kt
Apache License 2.0
src/main/kotlin/adventofcode2019/Day03CrossedWires.kt
n81ur3
484,801,748
false
{"Kotlin": 476844, "Java": 275}
package adventofcode2019 import kotlin.math.abs class Day03CrossedWires data class DistanceCoordinate( val distance: Int, val coordinate: Pair<Int, Int> ) data class GravityWire(val coordinates: List<Pair<Int, Int>> = emptyList()) { val distanceCoordinates = mutableListOf<DistanceCoordinate>() fun ...
0
Kotlin
0
0
fdc59410c717ac4876d53d8688d03b9b044c1b7e
4,041
kotlin-coding-challenges
MIT License
src/main/kotlin/com/scavi/brainsqueeze/adventofcode/Day5BinaryBoarding.kt
Scavi
68,294,098
false
{"Java": 1449516, "Kotlin": 59149}
package com.scavi.brainsqueeze.adventofcode class Day5BinaryBoarding { private fun next(value: Int) = if (value % 2 == 1) (value / 2) + 1 else (value / 2) fun solve(boardingPasses: List<String>, mySeat: Boolean = false): Int { val seatIds = mutableListOf<Int>() for (boardingPass in boardingPas...
0
Java
0
1
79550cb8ce504295f762e9439e806b1acfa057c9
1,297
BrainSqueeze
Apache License 2.0
src/Day01.kt
karlwalsh
573,854,263
false
{"Kotlin": 32685}
fun main() { fun solve(input: List<Int>, n: Int): Int = input.sortedDescending().take(n).sum() fun part1(input: List<String>): Int = solve(input.toDaySpecificInput(), 1) fun part2(input: List<String>): Int = solve(input.toDaySpecificInput(), 3) val input = readInput("Day01") with(::part1) { ...
0
Kotlin
0
0
f5ff9432f1908575cd23df192a7cb1afdd507cee
1,287
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/JewelsStones.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
1,723
kotlab
Apache License 2.0
src/main/kotlin/com/github/solairerove/algs4/leprosorium/sorting/MergeSort.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.sorting fun main() { val items = mutableListOf(5, 6, 4, 3, 10, 9, 5, 6, 7) print("items: $items \n") mergeSort(items) print("items: $items \n") } // O(nlog(n)) time | O(n) space private fun mergeSort(arr: MutableList<Int>) { val n = arr.size va...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
1,099
algs4-leprosorium
MIT License
src/main/kotlin/endredeak/aoc2022/Day08.kt
edeak
571,891,076
false
{"Kotlin": 44975}
package endredeak.aoc2022 fun main() { solve("Treetop Tree House") { data class P(val x: Int, val y: Int, val w: Int) fun List<P>.linesOfSight(p: P, reversed: Boolean = false) = listOf(this.filter { it.x == p.x }.sortedBy { it.x }, this.filter { it.y == p.y }.sortedBy { it.y }) ...
0
Kotlin
0
0
e0b95e35c98b15d2b479b28f8548d8c8ac457e3a
1,205
AdventOfCode2022
Do What The F*ck You Want To Public License
src/Day18.kt
kipwoker
572,884,607
false
null
import kotlin.time.ExperimentalTime import kotlin.time.measureTime class Day18 { data class Point(val xs: Array<Int>) { fun isBetween(minPoint: Point, maxPoint: Point): Boolean { return xs .zip(minPoint.xs) .zip(maxPoint.xs) .all { p -> ...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
3,808
aoc2022
Apache License 2.0
src/main/java/com/barneyb/aoc/aoc2019/day14/SpaceStoichiometry.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2019.day14 import com.barneyb.aoc.util.Solver fun main() { Solver.benchmark( ::parse, { requiredOreForFuel(it, 1) }, { fuelFromOre(it, ONE_TRILLION) }, // { fuelFromOre2(it, ONE_TRILLION) }, ) } internal const val ONE_TRILLION = 1_000_000_000_000 int...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
3,375
aoc-2022
MIT License
src/main/kotlin/com/headlessideas/adventofcode/december16/PermutationPromenade.kt
Nandi
113,094,752
false
null
package com.headlessideas.adventofcode.december16 import com.headlessideas.adventofcode.utils.readFile fun dance(moves: List<Move>) { var programs = "abcdefghijklmnop".toCharArray().toMutableList() val seen = mutableListOf<String>() val repetitions = 1_000_000_000 for (i in 0..repetitions) { ...
0
Kotlin
0
0
2d8f72b785cf53ff374e9322a84c001e525b9ee6
2,143
adventofcode-2017
MIT License
src/day3/first/Solution.kt
verwoerd
224,986,977
false
null
package day3.first import tools.Coordinate import tools.manhattanDistance import tools.manhattanOriginComparator import tools.origin import tools.timeSolution import java.util.PriorityQueue import kotlin.test.fail fun main() = timeSolution { val points = mutableSetOf<Coordinate>() var last = origin // Find all ...
0
Kotlin
0
0
554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7
2,645
AoC2019
MIT License
src/main/kotlin/g0701_0800/s0749_contain_virus/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0701_0800.s0749_contain_virus // #Hard #Array #Depth_First_Search #Breadth_First_Search #Matrix #Simulation // #2023_03_06_Time_201_ms_(100.00%)_Space_37.5_MB_(100.00%) @Suppress("kotlin:S107") class Solution { private var m = 0 private var n = 0 private val dirs = arrayOf(intArrayOf(-1, 0), intA...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,125
LeetCode-in-Kotlin
MIT License
src/algorithmsinanutshell/PrimMinSpanningTreeAlgorithm.kt
realpacific
234,499,820
false
null
package algorithmsinanutshell import utils.assertArraysSame import java.util.* import kotlin.test.assertEquals /** * Prim Algorithm starts from min cost edge and then selects the next small cost edge * while maintaining the connection with first edge. * * This can be modeled using [PriorityQueue] sorted using [Ed...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,670
algorithms
MIT License
src/year2022/day04/Solution.kt
LewsTherinTelescope
573,240,975
false
{"Kotlin": 33565}
package year2022.day04 import utils.runIt fun main() = runIt( testInput = """ 2-4,6-8 2-3,4-5 5-7,7-9 2-8,3-7 6-6,4-6 2-6,4-8 """.trimIndent(), ::part1, testAnswerPart1 = 2, ::part2, testAnswerPart2 = 4, ) fun part1(input: String) = input.toAssignmentPairs().count { (a, b) -> a overlapsFully b } f...
0
Kotlin
0
0
ee18157a24765cb129f9fe3f2644994f61bb1365
861
advent-of-code-kotlin
Do What The F*ck You Want To Public License
advent-of-code-2022/src/test/kotlin/Day 5 Supply Stacks.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test class `Day 5 Supply Stacks` { @Test fun silverTest() { message(testInput) shouldBe "CMZ" } @Test fun silver() { message(loadResource("day5")) shouldBe "VRWBSFZWM" } @Test fun goldTest() { message9001(testInput) shouldBe "...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
2,206
advent-of-code
MIT License
src/Day11.kt
monsterbrain
572,819,542
false
{"Kotlin": 42040}
import java.math.BigInteger val OLD = -1L class Monkey(val index: Int) { private lateinit var op: OP var opValue: Long? = null var divisibleBy: Long = -1 var monkeyToThrowIfTrue = -1 var monkeyToThrowIfFalse = -1 var inspected = 0L val items = ArrayList<Long>() fun setItems(items: Li...
0
Kotlin
0
0
3a1e8615453dd54ca7c4312417afaa45379ecf6b
8,174
advent-of-code-kotlin-2022-Solutions
Apache License 2.0
src/main/kotlin/days/day07.kt
josergdev
573,178,933
false
{"Kotlin": 20792}
package days import java.nio.file.Files import java.nio.file.Paths fun createMapOfSizes(shellOuput: String): Map<List<String>, Int> = shellOuput .replaceFirst("\$ ", "") .split("\n\$ ") .map { when { it.startsWith("cd") -> "cd" to listOf(it.replaceFirst("cd ", "")) else ->...
0
Kotlin
0
0
ea17b3f2a308618883caa7406295d80be2406260
1,463
aoc-2022
MIT License
src/main/kotlin/com/groundsfam/advent/y2022/d22/Cube.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2022.d22 import com.groundsfam.advent.points.Point // HELPFUL FACT: Cubes are orientable! Therefore adjacent edges will _always_ // be in "opposition" when all faces are clockwise-oriented in the original map. // No need to store orientation of edges! // edges order: // 0 <-> right /...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
3,164
advent-of-code
MIT License
kotlin/03.kt
NeonMika
433,743,141
false
{"Kotlin": 68645}
class Day3 : Day<List<Day3.BitString>>("03") { // Classes data class BitString(val str: String) : CharSequence by str { val int: Int = str.toInt(2) } data class Counter(val zeros: Int = 0, val ones: Int = 0) { /** * Least frequent symbol, equal not defined */ v...
0
Kotlin
0
0
c625d684147395fc2b347f5bc82476668da98b31
2,561
advent-of-code-2021
MIT License
src/main/kotlin/co/csadev/advent2021/Day22.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2021 by <NAME> * Advent of Code 2021, Day 22 * Problem Description: http://adventofcode.com/2021/day/212 */ package co.csadev.advent2021 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Resources.resourceAsList import kotlin.math.max import kotlin.math.min class Day22(overri...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
3,290
advent-of-kotlin
Apache License 2.0
src/main/kotlin/dp/CandySwap.kt
yx-z
106,589,674
false
null
package dp import dp.Candy.* import util.* // suppose you are given three types of candies: A, B, C enum class Candy(val v: Int) { A(1), B(2), C(3); } // and also a row of such candies R[1..n] // you start with one candy A in hand and traverse through the row R from 1 to n // at each index, you may either swap you...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,730
AlgoKt
MIT License
leetcode2/src/leetcode/SecondMiniimumNodeInABinaryTree.kt
hewking
68,515,222
false
null
package leetcode import leetcode.structure.TreeNode /** * https://leetcode-cn.com/problems/second-minimum-node-in-a-binary-tree/ * 671. 二叉树中第二小的节点 * Created by test * Date 2019/6/18 0:56 * Description * 给定一个非空特殊的二叉树,每个节点都是正数,并且每个节点的子节点数量只能为 2 或 0。 * 如果一个节点有两个子节点的话,那么这个节点的值不大于它的子节点的值。  给出这样的一个二叉树,你需要输出所有节点中的第二...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
2,146
leetcode
MIT License
kotlin/128.Longest Consecutive Sequence(最长连续序列).kt
learningtheory
141,790,045
false
{"Python": 4025652, "C++": 1999023, "Java": 1995266, "JavaScript": 1990554, "C": 1979022, "Ruby": 1970980, "Scala": 1925110, "Kotlin": 1917691, "Go": 1898079, "Swift": 1827809, "HTML": 124958, "Shell": 7944}
/** <p>Given an unsorted array of integers, find the length of the longest consecutive elements sequence.</p> <p>Your algorithm should run in O(<em>n</em>) complexity.</p> <p><strong>Example:</strong></p> <pre> <strong>Input:</strong>&nbsp;[100, 4, 200, 1, 3, 2] <strong>Output:</strong> 4 <strong>Explanation:</stron...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
1,254
leetcode
MIT License
src/main/kotlin/tr/emreone/adventofcode/days/Day21.kt
EmRe-One
433,772,813
false
{"Kotlin": 118159}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day import kotlin.math.max class Day21 : Day(21, 2021, "<NAME>") { class DeterministicDice { var current = 0 var numberOfRolls = 0 fun roll(): Int { numberOfRolls++ current++ ...
0
Kotlin
0
0
516718bd31fbf00693752c1eabdfcf3fe2ce903c
2,964
advent-of-code-2021
Apache License 2.0
parser-processor/src/main/kotlin/parser/Node.kt
madisp
434,510,913
false
{"Kotlin": 388138}
package parser sealed class Node { data class Split(val delim: String, val left: LeafNode, val right: Node): Node() } sealed class LeafNode : Node() { data object Empty : LeafNode() data class Field(val name: String): LeafNode() data class Repeat(val delim: String, val field: Field): LeafNode() } sealed clas...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
2,379
aoc_kotlin
MIT License
src/main/kotlin/g2901_3000/s2909_minimum_sum_of_mountain_triplets_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2901_3000.s2909_minimum_sum_of_mountain_triplets_ii // #Medium #Array #2023_12_27_Time_463_ms_(100.00%)_Space_64.6_MB_(50.00%) import kotlin.math.min class Solution { fun minimumSum(nums: IntArray): Int { val n = nums.size val leftSmallest = IntArray(n) val rightSmallest = IntArr...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,329
LeetCode-in-Kotlin
MIT License