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/Day20.kt
catcutecat
572,816,768
false
{"Kotlin": 53001}
import kotlin.system.measureTimeMillis fun main() { measureTimeMillis { Day20.run { solve1(3L) // 3473L solve2(1623178306L) // 7496649006261L } }.let { println("Total: $it ms") } } object Day20 : Day.LineInput<List<Int>, Long>("20") { override fun parse(input: List...
0
Kotlin
0
2
fd771ff0fddeb9dcd1f04611559c7f87ac048721
1,717
AdventOfCode2022
Apache License 2.0
src/main/kotlin/de/huddeldaddel/euler/Problem011.kt
huddeldaddel
171,357,298
false
null
package de.huddeldaddel.euler import java.util.Arrays /** * Solution for https://projecteuler.net/problem=11 */ fun main() { val problem11 = Problem11() val grid = Problem11.Grid() val values = longArrayOf( problem11.getMaxAdjacentNumberProductVertical(grid), problem11.getMaxAdja...
0
Kotlin
1
0
df514adde8c62481d59e78a44060dc80703b8f9f
4,699
euler
MIT License
src/main/kotlin/year2023/day03/Problem.kt
Ddxcv98
573,823,241
false
{"Kotlin": 154634}
package year2023.day03 import IProblem class Problem : IProblem { private val nonSymbols = setOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.') private val matrix: Array<Array<Char>> private val n: Int private val m: Int init { val lines = mutableListOf<CharArray>() java...
0
Kotlin
0
0
455bc8a69527c6c2f20362945b73bdee496ace41
4,076
advent-of-code
The Unlicense
src/Day05.kt
oleksandrbalan
572,863,834
false
{"Kotlin": 27338}
import java.util.Deque import java.util.LinkedList fun main() { val (movesInput, shipInput) = readInput("Day05") .partition { it.startsWith("move") } val stacks = shipInput.first().length / 4 + 1 val shipCargo = shipInput .takeWhile { it.trim().startsWith("[") } .map { row -> row.c...
0
Kotlin
0
2
1493b9752ea4e3db8164edc2dc899f73146eeb50
1,942
advent-of-code-2022
Apache License 2.0
src/main/kotlin/co/csadev/advent2021/Day12.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2021 by <NAME> * * Advent of Code 2021, Day 12 * Problem Description: http://adventofcode.com/2021/day/12 */ package co.csadev.advent2021 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Resources.resourceAsList class Day12(override val input: List<String> = resourceAsList(...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
1,426
advent-of-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountSubarraysWithFixedBounds.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,150
kotlab
Apache License 2.0
calendar/day02/Day2.kt
divgup92
573,352,419
false
{"Kotlin": 15497}
package day02 import Day import Lines class Day2 : Day() { private val opponentMap = mapOf( "A" to GameOptions.ROCK, "B" to GameOptions.PAPER, "C" to GameOptions.SCISSORS, ) private val myMap = mapOf( "X" to GameOptions.ROCK, "Y" to GameOptions.PAPER, "Z" ...
0
Kotlin
0
0
dcd221197ecb374efa030a7993a0152099409f14
2,024
advent-of-code-2022
Apache License 2.0
src/Day08.kt
allwise
574,465,192
false
null
fun main() { fun part1(input: List<String>): Int { val treeHouse = Trees(input) return treeHouse.process() } fun part2(input: List<String>): Int { val dayMal = Trees(input) return dayMal.process2() } // test if implementation meets criteria from the description, ...
0
Kotlin
0
0
400fe1b693bc186d6f510236f121167f7cc1ab76
3,650
advent-of-code-2022
Apache License 2.0
src/Day20.kt
michaelYuenAE
573,094,416
false
{"Kotlin": 74685}
fun main() { val input = readInput("day20_input").mapIndexed { i, v -> i to v.toLong() } // val ans1 = solve(input.toMutableList(), 1, 1) val ans2 = solve(input.toMutableList(), 10, 811589153) println(ans2) // println(ans2) } fun solve(queue: MutableList<Pair<Int, Long>>, repeat: Int, key: Long): L...
0
Kotlin
0
0
ee521263dee60dd3462bea9302476c456bfebdf8
1,307
advent22
Apache License 2.0
src/main/kotlin/com/kishor/kotlin/algo/search/BinarySearch.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.search fun main() { // val list = listOf<Int>(2, 4, 5, 6, 9, 12) val list = arrayOf(2, 4, 5, 6, 9, 12) println("Binary Search ${BinarySearch().binarySearch(list, 12)}") println("Binary recursive Search ${BinarySearch().binaryRecursive(list, 12)}") } class BinarySearch { ...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
1,759
DS_Algo_Kotlin
MIT License
day11/src/main/kotlin/de/havox_design/aoc2023/day11/Day11.kt
Gentleman1983
715,778,541
false
{"Kotlin": 163912, "Python": 1048}
package de.havox_design.aoc2023.day11 import kotlin.math.abs class Day11(private var filename: String) { private val ICON_GALAXY = "#" fun solvePart1(): Long = processSumOfAllDistances(getResourceAsText(filename)) fun solvePart2(expansion: Long = 1000000): Long = processSumOfAllDistances...
1
Kotlin
0
0
eac8ff77420f061f5cef0fd4b8d05e7805c4cc5a
2,704
aoc2023
Apache License 2.0
src/main/kotlin/days/Day7.kt
felix-ebert
317,592,241
false
null
package days class Day7 : Day(7) { override fun partOne(): Any { val bags = inputList.map { parseRule(it) }.toMap() return bags.count { containsBag(it.value.keys.toList(), bags) } } override fun partTwo(): Any { val bags = inputList.map { parseRule(it) }.toMap() return cou...
0
Kotlin
0
4
dba66bc2aba639bdc34463ec4e3ad5d301266cb1
1,397
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/Excercise15.kt
underwindfall
433,989,850
false
{"Kotlin": 55774}
import java.awt.image.BufferedImage import java.io.File import java.util.* import javax.imageio.ImageIO private fun part1() { val input = getInputAsTest("15") { split("\n") }.map { it.toCharArray().map { char -> char.digitToInt() } } val m = input.size val n = input[0].size val grid = Array(m) { IntArray(...
0
Kotlin
0
0
4fbee48352577f3356e9b9b57d215298cdfca1ed
5,674
advent-of-code-2021
MIT License
src/main/kotlin/com/chriswk/aoc/advent2019/Day12.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2019 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.combinations import com.chriswk.aoc.util.dayInputAsLines import com.chriswk.aoc.util.gcd import com.chriswk.aoc.util.report class Day12 : AdventDay(2019, 12) { companion object { @JvmStatic fun main(ar...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,114
adventofcode
MIT License
src/main/kotlin/year2022/Day13.kt
forketyfork
572,832,465
false
{"Kotlin": 142196}
package year2022 private fun List<*>.compareTo(other: List<*>): Int { if (this.isEmpty() && other.isNotEmpty()) { return -1 } else if (this.isNotEmpty() && other.isEmpty()) { return 1 } else if (this.isEmpty()) { return 0 } val a = this[0] val b = other[0] val res...
0
Kotlin
0
0
5c5e6304b1758e04a119716b8de50a7525668112
2,313
aoc-2022
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2017/Day08.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2017 import com.nibado.projects.advent.Day import com.nibado.projects.advent.resourceRegex object Day08 : Day { private val regex = Regex("([a-z]{1,5}) (inc|dec) (-?[0-9]+) if ([a-z]{1,5}) (>|<|>=|<=|==|!=) (-?[0-9]+)") private val tests: Map<String, (Int, Int) -> Boolean>...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
1,769
adventofcode
MIT License
src/main/kotlin/days/Day14.kt
julia-kim
435,257,054
false
{"Kotlin": 15771}
package days import readInput fun main() { fun part1(input: List<String>): Int { var stepCount = 0 var polymerTemplate = input[0] val pairInsertionRules = input.subList(2, input.size) while (stepCount < 10) { val pairs = polymerTemplate.windowed(2) polymerTe...
0
Kotlin
0
0
5febe0d5b9464738f9a7523c0e1d21bd992b9302
1,373
advent-of-code-2021
Apache License 2.0
src/day6/Day6.kt
ZsemberiDaniel
159,921,870
false
null
package day6 import RunnablePuzzleSolver import java.lang.Math.abs class Day6 : RunnablePuzzleSolver { val part2AreaLessThan = 10_000 lateinit var coords: Array<Coord> var topLeft: Coord = Coord(Int.MAX_VALUE, Int.MAX_VALUE) var bottomRight: Coord = Coord(Int.MIN_VALUE, Int.MIN_VALUE) override f...
0
Kotlin
0
0
bf34b93aff7f2561f25fa6bd60b7c2c2356b16ed
3,775
adventOfCode2018
MIT License
src/main/kotlin/com/github/michaelbull/advent2021/day7/Day7.kt
michaelbull
433,565,311
false
{"Kotlin": 162839}
package com.github.michaelbull.advent2021.day7 import com.github.michaelbull.advent2021.Puzzle import com.github.michaelbull.advent2021.math.triangular import kotlin.math.abs private typealias FuelRate = (Int) -> Int object Day7 : Puzzle<List<Int>, Int>(day = 7) { override fun parse(input: Sequence<String>): Li...
0
Kotlin
0
4
7cec2ac03705da007f227306ceb0e87f302e2e54
1,501
advent-2021
ISC License
ceria/09/src/main/kotlin/Solution.kt
VisionistInc
317,503,410
false
null
import java.io.File; fun main(args : Array<String>) { val input = File(args.first()).readLines() println("Solution 1: ${solution1(input)}") println("Solution 2: ${solution2(input)}") } private fun solution1(input :List<String>) :Long { val preamble = 25 for (i in input.indices) { if (i < ...
0
Rust
0
0
002734670384aa02ca122086035f45dfb2ea9949
1,692
advent-of-code-2020
MIT License
src/Day02.kt
daniyarmukhanov
572,847,967
false
{"Kotlin": 9474}
//use this file as template fun main() { fun part1(input: List<String>): Int { return input.fold(0) { acc, s -> acc + findPoint(s.split(" ").first(), s.split(" ").last()) } } fun part2(input: List<String>): Int { var sum = 0 input.forEach { val a = it...
0
Kotlin
0
0
ebad16b2809ef0e3c7034d5eed75e6a8ea34c854
1,960
aoc22
Apache License 2.0
src/aoc2022/Day22_.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 import utils.Vertex import utils.checkEquals private const val EMPTY = -1 private const val WALL = 1 private const val TILE = 0 private const val RIGHT = 0 private const val DOWN = 1 private const val LEFT = 2 private const val UP = 3 fun main() { fun part1(input: List<String>): Int { val...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
15,818
Kotlin-AOC-2023
Apache License 2.0
advent-of-code-2021/src/code/day1/Main.kt
Conor-Moran
288,265,415
false
{"Kotlin": 53347, "Java": 14161, "JavaScript": 10111, "Python": 6625, "HTML": 733}
package code.day1 import java.io.File fun main() { doIt("Day1, Part 1: Test Input", "src/code/day1/test.input", part1); doIt("Day1, Part 1: Real Input", "src/code/day1/part1.input", part1); doIt("Day1, Part 2: Test Input", "src/code/day1/test.input", part2); doIt("Day1, Part 2: Real Input", "src/code/...
0
Kotlin
0
0
ec8bcc6257a171afb2ff3a732704b3e7768483be
1,188
misc-dev
MIT License
src/main/kotlin/com/chriswk/aoc/advent2020/Day14.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2020 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report import java.lang.IllegalArgumentException import java.lang.Math.pow import kotlin.math.pow class Day14 : AdventDay(2020, 14) { companion object { @JvmStatic fun main(args: Array<String>) { ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
3,631
adventofcode
MIT License
src/main/kotlin/days/Day13.kt
mstar95
317,305,289
false
null
package days class Day13 : Day(13) { override fun partOne(): Any { val timestamp = inputList.first().toInt() val input = prepareInput(inputList).map { it.second } val result = findBus(timestamp, input) val minutes = result.second - timestamp println("$result, $minutes, $ti...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
1,893
aoc-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/ru/timakden/aoc/year2023/Day01.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2023 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 1: Trebuchet?!](https://adventofcode.com/2023/day/1). */ object Day01 { @JvmStatic fun main(args: Array<String>) { measure { val input = readInput("year2023/Day01") ...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
1,651
advent-of-code
MIT License
src/chapter3/section2/ex11.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter3.section2 /** * 高度为N含有N个结点的二叉查找树能有多少种形状? * 使用N个不同的键能有多少种不同的方式构造一颗高度为N的二叉查找树?(参考练习3.2.2) * * 解:可以参考练习3.2.9中求所有不同形状的二叉查找树的方式, * 区别是3.2.9要求全排列,这里要求最坏情况,最小值只能在最左侧或最右侧,所以只保留第一个和最后一个排列, * 例如全排列P(N) = 0P(N-1) + 1P(N-1) + 2P(N-1) + ... + (N-1)P(N-1) * 最坏情况 P(N) = 0P(N-1) + (N-1)P(N-1) */ fun ex11(N: I...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
2,014
Algorithms-4th-Edition-in-Kotlin
MIT License
src/week1/MergeIntervals.kt
anesabml
268,056,512
false
null
package week1 import java.lang.Integer.max import java.util.* import kotlin.system.measureNanoTime class MergeIntervals { /** Using Stack * Sort the intervals based on increasing order of first element. * Push the first interval on to a stack. * For each interval do the following * If the cur...
0
Kotlin
0
1
a7734672f5fcbdb3321e2993e64227fb49ec73e8
2,715
leetCode
Apache License 2.0
grind-75-kotlin/src/main/kotlin/MergeTwoSortedLists.kt
Codextor
484,602,390
false
{"Kotlin": 27206}
import commonclasses.ListNode /** * You are given the heads of two sorted linked lists list1 and list2. * * Merge the two lists in a one sorted list. * The list should be made by splicing together the nodes of the first two lists. * * Return the head of the merged linked list. * * * * Example 1: * * * Inp...
0
Kotlin
0
0
87aa60c2bf5f6a672de5a9e6800452321172b289
1,287
grind-75
Apache License 2.0
src/Day01.kt
MSchu160475
573,330,549
false
{"Kotlin": 5456}
fun main() { fun part1(input: List<String>): Int { return input.fold(mutableListOf(0)) { acc, calories -> if (calories.isNotEmpty()) { val lastIndex = acc.lastIndex acc[lastIndex] = acc[lastIndex] + calories.toInt() }else { acc.add(0) ...
0
Kotlin
0
0
c6f9a0892a28f0f03b95768b6611e520c85db75c
1,041
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/tree/SegmentTree.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.tree import kotlin.math.ceil import kotlin.math.log2 import kotlin.math.pow println("test") val array = intArrayOf(1, 3, 5, 7, 9, 11) val tree = SegmentTree(array) println(tree.sum(0, 5)) // 36 println(tree.sum(0, 4)) // 25 println(tree.sum(2, 2)) // 5 println(tree.sum(0, 0)) // 1 println...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
4,224
KotlinAlgs
MIT License
src/main/kotlin/net/wrony/aoc2023/a4/Main.kt
kopernic-pl
727,133,267
false
{"Kotlin": 52043}
package net.wrony.aoc2023.a4 import kotlin.io.path.Path import kotlin.io.path.readLines import kotlin.math.pow data class Card(val number: Int, val wNumbers: Set<Int>, val tries: Set<Int>) { fun worthPoints(): Long { wNumbers.intersect(tries).count().let { return when (it) { 0 ...
0
Kotlin
0
0
1719de979ac3e8862264ac105eb038a51aa0ddfb
1,663
aoc-2023-kotlin
MIT License
src/main/kotlin/algorithms/FirstTable.kt
Furetur
439,579,145
false
{"Kotlin": 21223, "ANTLR": 246}
package algorithms import model.* fun Grammar.firstTable(k: Int, nullableTable: NullableTable = NullableTable(this)) = if (k == 1) OneFirstTable(this, nullableTable) else HigherFirstTable(this, k, nullableTable) interface FirstTable { val k: Int fun firstOf(nonTerm: NonTerm): Lang fun firstOf(term: ...
0
Kotlin
0
1
002cc53bcca6f9b591c4090d354f03fe3ffd3ed6
3,531
LLkChecker
MIT License
src/main/kotlin/aoc2016/SecurityThroughObscurity.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2016 fun securityThroughObscurity(input: List<String>): Int { val rooms = input.map { ObscureRoom(it) } return rooms.filter { it.isReal }.sumOf { it.sectorId } } fun securityThroughObscurity2(input: List<String>): Int { val rooms = input.map { ObscureRoom(it) } return ro...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,533
advent-of-code
MIT License
excercises/app/src/main/java/com/example/opgaver/02_control_flow_and_lambda_func.kt
Josef-TL
751,238,665
false
{"Kotlin": 11689}
package com.example.opgaver import java.util.* import kotlin.math.round fun main() { println(findLargestNumber(1,2,3)) //checkForPalindrome() //println(sumThese()) blackJack(1,-2) //val l: List<Int> = listOf(1,2,3,45,6,7,89,10,12) //println(filterNumOverTen(l)) //val stringL: List<String...
0
Kotlin
0
0
f613326087e43ea6553a03ac30becf0d23f99478
2,318
app-dev
MIT License
src/Day09.kt
Longtainbin
573,466,419
false
{"Kotlin": 22711}
import kotlin.math.abs /** * part2部分的没有求解处理 * * 我没明白节点到底怎么移动的 */ val moveOpeMap = initMoveOpe() fun main() { val input = readInput("input") fun part1(input: List<String>): Int { return helperForPart1(input) } fun part2(input: List<String>): Int { return helperForPart2(input) ...
0
Kotlin
0
0
48ef88b2e131ba2a5b17ab80a0bf6a641e46891b
2,795
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/day06/Day06.kt
W3D3
433,748,408
false
{"Kotlin": 72893}
package day06 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 6 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay06Part1, ::solveDay06Part2) } fun calculateFish(startingFish: List<Int>, days: ...
0
Kotlin
0
0
df4f21cd99838150e703bcd0ffa4f8b5532c7b8c
1,133
AdventOfCode2021
Apache License 2.0
src/day4/fr/Day04_2.kt
BrunoKrantzy
433,844,189
false
{"Kotlin": 63580}
//package day4.fr import java.io.File fun readInput(name: String) = File("src", "$name.txt").readLines() data class Carton(var mapNum: MutableMap<Int, Int> = mutableMapOf<Int, Int>()) { override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) ...
0
Kotlin
0
0
0d460afc81fddb9875e6634ee08165e63c76cf3a
3,825
Advent-of-Code-2021
Apache License 2.0
src/main/kotlin/_2021/Day4.kt
thebrightspark
227,161,060
false
{"Kotlin": 548420}
package _2021 import MutablePair import PATTERN_LINE_SEPARATOR import REGEX_WHITESPACE import aoc import splitToInts fun main() { aoc(2021, 4) { aocRun { input -> val bingo = parseBingo(input) var result: PlayResult = PlayResult.NO_WINNER while (result == PlayResult.NO_WINNER) result = bingo.play() ...
0
Kotlin
0
0
ac62ce8aeaed065f8fbd11e30368bfe5d31b7033
3,239
AdventOfCode
Creative Commons Zero v1.0 Universal
src/Day02.kt
MickyOR
578,726,798
false
{"Kotlin": 98785}
fun main() { fun part1(input: List<String>): Int { var map = mutableMapOf<Char, Int>(); map['A'] = 0; map['B'] = 1; map['C'] = 2; map['X'] = 0; map['Y'] = 1; map['Z'] = 2; var score: Int = 0; for (line in input) { var p1: Char = lin...
0
Kotlin
0
0
c24e763a1adaf0a35ed2fad8ccc4c315259827f0
1,540
advent-of-code-2022-kotlin
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[29]两数相除.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定两个整数,被除数 dividend 和除数 divisor。将两数相除,要求不使用乘法、除法和 mod 运算符。 // // 返回被除数 dividend 除以除数 divisor 得到的商。 // // 整数除法的结果应当截去(truncate)其小数部分,例如:truncate(8.345) = 8 以及 truncate(-2.7335) = -2 // // // // 示例 1: // // 输入: dividend = 10, divisor = 3 //输出: 3 //解释: 10/3 = truncate(3.33333..) = truncate(3) = 3 // // 示例 2: // //...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,692
MyLeetCode
Apache License 2.0
src/cn/leetcode/codes/simple104/Simple104.kt
shishoufengwise1234
258,793,407
false
{"Java": 771296, "Kotlin": 68641}
package cn.leetcode.codes.simple104 import cn.leetcode.codes.common.TreeNode import cn.leetcode.codes.createTreeNode import cn.leetcode.codes.out import java.util.* import kotlin.math.max fun main() { val node = createTreeNode(arrayOf(3, 9, 20, null, null, 15, 7)) val re = maxDepth(node) val re2 = maxD...
0
Java
0
0
f917a262bcfae8cd973be83c427944deb5352575
2,002
LeetCodeSimple
Apache License 2.0
src/day07/day07.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day07 import day07.Command.CdBackward import day07.Command.CdForward import day07.Command.CdRoot import day07.Command.Ls import day07.Command.LsDiscoverDir import day07.Command.LsDiscoverFile import day07.Node.* import util.readInput import util.shouldBe fun main() { val day = 7 val testInput = readIn...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
5,086
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day3.kt
ivan-gusiev
726,608,707
false
{"Kotlin": 34715, "Python": 2022, "Makefile": 50}
import util.* typealias Day3InputType = ArrayGrid2D<Char>; class Day3 : Runner { val TEST_INPUT: String = """ 467..114.. ...*...... ..35..633. ......#... 617*...... .....+.58. ..592..... ......755. ...${'$'}.*.... .664.598.. """.t...
0
Kotlin
0
0
5585816b435b42b4e7c77ce9c8cabc544b2ada18
2,725
advent-of-code-2023
MIT License
2022/15/15.kt
LiquidFun
435,683,748
false
{"Kotlin": 40554, "Python": 35985, "Julia": 29455, "Rust": 20622, "C++": 1965, "Shell": 1268, "APL": 191}
fun dist(x1: Long, y1: Long, x2: Long, y2: Long) = Math.abs(x1 - x2) + Math.abs(y1 - y2) fun main() { val sensors = generateSequence(::readlnOrNull).toList() .map { Regex("-?\\d+").findAll(it).toList() } .map { it.map { it.value.toLong() } } .sortedBy() { it[0] } val y = 2_000_000L ...
0
Kotlin
7
43
7cd5a97d142780b8b33b93ef2bc0d9e54536c99f
830
adventofcode
Apache License 2.0
src/Day15.kt
Kietyo
573,293,671
false
{"Kotlin": 147083}
import kotlin.math.abs fun main() { data class Sensor( val pos: MutableIntPoint, val manhattanDistance: Int ) { fun isWithinRange(other: MutableIntPoint): Boolean { return isWithinRange(other.x, other.y) } fun isWithinRange(x: Int, y: Int): Boolean { ...
0
Kotlin
0
0
dd5deef8fa48011aeb3834efec9a0a1826328f2e
4,985
advent-of-code-2022-kietyo
Apache License 2.0
mantono-kotlin/src/main/kotlin/com/mantono/aoc/day07/AmplificationCircuit.kt
LinAGKar
433,981,631
true
{"Python": 390591, "C#": 189476, "Rust": 166608, "C++": 127941, "F#": 68551, "Haskell": 60413, "Nim": 46562, "Kotlin": 29504, "REXX": 13854, "OCaml": 12448, "Go": 11995, "C": 9751, "Swift": 8043, "JavaScript": 1750, "CMake": 1107, "PowerShell": 866, "AppleScript": 493, "Shell": 255}
package com.mantono.aoc.day07 import com.mantono.aoc.AoC import com.mantono.aoc.IntCodeComputer import com.mantono.aoc.Part import com.mantono.aoc.State import java.util.* @AoC(7, Part.A) fun amplificationCircuit(input: String): Int { return phaseSettingsGenerator(listOf(0, 1, 2, 3, 4)) .map { setting -> ...
0
Python
0
0
4f51eed64ba8fc5254dfa6740c8461f2de1c18a0
2,347
advent_of_code_2019
Apache License 2.0
app/src/main/kotlin/aoc2019/day04/Day04.kt
dbubenheim
499,817,652
false
{"Kotlin": 20151}
package aoc2019.day04 import aoc2019.toFile fun part1() = "input-day04.txt".toFile() .readLines() .first() .split("-") .map { it.toInt() } .run { (this.first()..this.last()) .count { it.toString().isValidPart1() } } fun part2() = "input-day04.txt".toFile() .readLines()...
8
Kotlin
0
0
f761d923d8c7c317bd93336163a2d4f86bf16340
1,800
advent-of-code-2019
MIT License
string-similarity/src/commonMain/kotlin/com/aallam/similarity/Cosine.kt
aallam
597,692,521
false
null
package com.aallam.similarity import com.aallam.similarity.internal.Profile import com.aallam.similarity.internal.Shingle import kotlin.math.sqrt /** * Implements Cosine Similarity between strings. * * The strings are first transformed in vectors of occurrences of k-shingles (sequences of [k] characters). * In th...
0
Kotlin
0
1
40cd4eb7543b776c283147e05d12bb840202b6f7
2,085
string-similarity-kotlin
MIT License
src/leetcodeProblem/leetcode/editor/en/FindMinimumInRotatedSortedArray.kt
faniabdullah
382,893,751
false
null
//Suppose an array of length n sorted in ascending order is rotated between 1 //and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: // // // [4,5,6,7,0,1,2] if it was rotated 4 times. // [0,1,2,4,5,6,7] if it was rotated 7 times. // // // Notice that rotating an array [a[0], a[1], a[2], ..., a...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
4,186
dsa-kotlin
MIT License
Kotlin/sort/MergeSort/src/MergeSort.kt
HarshCasper
274,711,817
false
{"C++": 1488046, "Java": 948670, "Python": 703942, "C": 615475, "JavaScript": 228879, "Go": 166382, "Dart": 107821, "Julia": 82766, "C#": 76519, "Kotlin": 40240, "PHP": 5465}
fun mergeSort(list : MutableList<Int>) : MutableList<Int>{ // check if the given list has more than 1 elements if (list.size > 1){ // a list to store sorted list val sortedList = MutableList(list.size) { 0 } // taking note of middle element of the list val middle = list.size / 2 ...
2
C++
1,086
877
4f1e5bdd6d9d899fa354de94740e0aecf5ecd2be
2,973
NeoAlgo
MIT License
classroom/src/main/kotlin/com/radix2/algorithms/week3/SortingLinkedList.kt
rupeshsasne
190,130,318
false
{"Java": 66279, "Kotlin": 50290}
package com.radix2.algorithms.week3 import kotlin.random.Random class LinkedList<T : Comparable<T>> { private var head: Node<T>? = null private val toss = intArrayOf(-1, 1) fun add(data: T) { val n = Node(data) n.next = head head = n } fun reverse() { var trav = h...
0
Java
0
1
341634c0da22e578d36f6b5c5f87443ba6e6b7bc
2,854
coursera-algorithms-part1
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year22/Day23.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year22 import com.grappenmaker.aoc.* import com.grappenmaker.aoc.Direction.* fun PuzzleSet.day23() = puzzle { val initial = inputLines.asGrid { it == '#' }.filterTrue() data class Rule(val dir: Direction, val emptyDirs: List<Point>) fun Rule.offset(p: Point) = emptyDirs.map {...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,938
advent-of-code
The Unlicense
src/main/kotlin/d13/D13_2.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d13 import input.Input fun findDoubleRowsWithSmudge(pattern: List<String>): List<Int> { val doubleRows = mutableListOf<Int>() for (i in 1..<pattern.size) { if (countMismatches(pattern[i], pattern[i - 1]) > 1) continue doubleRows.add(i) } return doubleRows } fun findDoubleCols...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
2,714
aoc2023-kotlin
MIT License
src/main/kotlin/com/briarshore/aoc2022/day11/MonkeyBusinessPuzzle.kt
steveswing
579,243,154
false
{"Kotlin": 47151}
package com.briarshore.aoc2022.day11 import println import readInput import kotlin.math.absoluteValue typealias WorryLevel = Long infix fun Int.safeTimes(other: Int) = (this * other).also { check(other == 0 || it / other == this) { "Integer overflow at $this * $other" } } infix fun Long.safeTimes(other: Long) =...
0
Kotlin
0
0
a0d19d38dae3e0a24bb163f5f98a6a31caae6c05
8,049
2022-AoC-Kotlin
Apache License 2.0
src/Day18.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
data class Point3D(val x: Int, val y: Int, val z: Int) { constructor(csv: String) : this(csv.split(",").map { it.toInt() }) constructor(arr: List<Int>) : this(arr[0], arr[1], arr[2]) } typealias Surface = Pair<Point3D, Point3D> typealias Edge = Pair<Point3D, Point3D> class Cube(val p: Point3D) { val surfa...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
3,683
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day009.kt
teodor-vasile
573,434,400
false
{"Kotlin": 41204}
import kotlin.math.abs import kotlin.math.sign class Day009 { companion object { private val visitedTails = mutableSetOf<Point>() } var initialPoint = State(Point(0, 0), Point(0, 0)) fun moveTheSnake(input: List<String>): Int { println(input.size) input.forEach { m...
0
Kotlin
0
0
2fcfe95a05de1d67eca62f34a1b456d88e8eb172
2,338
aoc-2022-kotlin
Apache License 2.0
src/Day13.kt
sabercon
648,989,596
false
null
fun main() { fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b) fun lcm(a: Long, b: Long): Long = a * b / gcd(a, b) val input = readLines("Day13") val time = input[0].toLong() val buses = input[1].split(",").map { if (it == "x") 0 else it.toLong() } buses.filter { it != 0L } ...
0
Kotlin
0
0
81b51f3779940dde46f3811b4d8a32a5bb4534c8
742
advent-of-code-2020
MIT License
src/day4/Day4.kt
calvin-laurenson
572,736,307
false
{"Kotlin": 16407}
package day4 import readInput import java.lang.Exception fun main() { fun part1(input: List<String>): Int { var total = 0 for (line in input) { val (first, second) = line.split(",") val (firstFirst, firstSecond) = first.split("-").map(String::toInt) val (secon...
0
Kotlin
0
0
155cfe358908bbe2a554306d44d031707900e15a
1,470
aoc2022
Apache License 2.0
plan/src/main/kotlin/com/r3/demos/ubin2a/plan/graph/NodeSequence.kt
project-ubin
110,582,332
false
null
package com.r3.demos.ubin2a.plan.graph /** * Representation of a cyclic sequence of graph nodes. */ class NodeSequence<out T>(nodeList: List<T>) : Iterable<T> { private val elements: List<T> = when { nodeList.isEmpty() -> emptyList() nodeList.last() == nodeList.first() -> nodeList...
3
Kotlin
50
80
8eb2ab9a3decb92b2c258f2c6dd7a2b4e7ca95f8
6,589
ubin-corda
Apache License 2.0
07-functions-lambdas/src/main/kotlin/lambdas.kt
iproduct
277,474,020
false
{"JavaScript": 3237497, "Kotlin": 545267, "Java": 110766, "HTML": 83688, "CSS": 44893, "SCSS": 32196, "Dockerfile": 58}
package course.kotlin.functions fun <T> max(collection: Collection<T>, comparatorFn: (T, T) -> Int): T? { var maxElem: T? = null for (e in collection) { if (maxElem == null) { maxElem = e } else if (e != null && comparatorFn(e, maxElem) > 0) maxElem = e } return ...
0
JavaScript
1
4
89884f8c29fffe6c6f0384a49ae8768c8e7ab509
1,858
course-kotlin
Apache License 2.0
src/days/day11/Day11.kt
Riven-Spell
113,698,657
false
{"Kotlin": 25729}
package days.day11 import days.day3.* import kotlin.math.abs import kotlin.math.max fun distfromzero(p2d: point2D): Int { val dx = p2d.first - 0 val dy = p2d.second - 0 return if(dx.positive() == dy.positive()) abs(dx + dy) else max(abs(dx), abs(dy)) } fun Int.positive(): Boolean = t...
0
Kotlin
0
1
dbbdb390a0addee98c7876647106af208c3d9bc7
1,434
Kotlin-AdventOfCode-2017
MIT License
src/day2/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day2 import day2.Direction.* import java.io.File import java.util.* fun main() { val moves = File("src/day2/input.txt") .readLines() .map { it.split(" ") } .map { Move(valueOf(it[0].uppercase(Locale.getDefault())), it[1].toInt()) } println(calculate(PartOneState(), moves)) ...
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
1,573
advent-of-code-2021
MIT License
src/Day07/Day07.kt
martin3398
436,014,815
false
{"Kotlin": 63436, "Python": 5921}
import java.lang.Integer.MAX_VALUE import kotlin.math.abs fun main() { fun calc(input: List<Int>, fuelFunc: (List<Int>, Int) -> Int): Int { val maxIn = input.maxOf { it } var minVal = MAX_VALUE for (i in 0..maxIn) { val m = fuelFunc(input, i) if (m < minVal) { ...
0
Kotlin
0
0
085b1f2995e13233ade9cbde9cd506cafe64e1b5
969
advent-of-code-2021
Apache License 2.0
year2021/day07/part2/src/main/kotlin/com/curtislb/adventofcode/year2021/day07/part2/Year2021Day07Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- The crabs don't seem interested in your proposed solution. Perhaps you misunderstand crab engineering? As it turns out, crab submarine engines don't burn fuel at a constant rate. Instead, each change of 1 step in horizontal position costs 1 more unit of fuel than the last: the first step costs 1, ...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,290
AdventOfCode
MIT License
src/main/kotlin/days/Day4.kt
vovarova
726,012,901
false
{"Kotlin": 48551}
package days import util.DayInput class Day4 : Day("4") { class Card { var id: Int = 0 val winningNumbers = mutableListOf<Int>() val number = mutableListOf<Int>() } fun cards(dayInput: DayInput): List<Card> { //Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53 val ...
0
Kotlin
0
0
77df1de2a663def33b6f261c87238c17bbf0c1c3
1,587
adventofcode_2023
Creative Commons Zero v1.0 Universal
src/Day07.kt
jmorozov
573,077,620
false
{"Kotlin": 31919}
import java.util.ArrayDeque import java.util.Deque fun main() { val inputData = readInput("Day07") part1(inputData) part2(inputData) } private fun dirSizesMap(inputData: List<String>): MutableMap<String, Int> { val dirMap: MutableMap<String, Int> = mutableMapOf() val dirStack: Deque<String> = Arra...
0
Kotlin
0
0
480a98838949dbc7b5b7e84acf24f30db644f7b7
2,374
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/Day5_2.kt
vincent-mercier
726,287,758
false
{"Kotlin": 37963}
import java.io.File import java.io.InputStream import java.lang.RuntimeException // Doesn't work yet, but getting close. Since it execs in 55ms, it's probably much better than the brute force. fun main() { val inputStream: InputStream = File("./src/main/resources/day5.txt").inputStream() val inputText = input...
0
Kotlin
0
0
53b5d0a0bb65a77deb5153c8a912d292c628e048
3,857
advent-of-code-2023
MIT License
src/Day04.kt
aadityaguptaa
572,618,899
false
null
fun main() { fun part1(input: List<String>): Int { var count = 0; for (i in input) { var li = i.split(',').map { it.split('-').map { it.toInt() } } if (li[0][0] <= li[1][0] && li[0][1] >= li[1][1]) { count++ } else if (li[0][0] >= li[1][0] &&...
0
Python
2
10
d76ac48851a9b833fbbd3493a7730f7e0b365da8
1,107
advent-of-code-2022
Apache License 2.0
src/day4/Day04_A.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day4 import readInput import kotlin.math.max fun main() { val testInput = readInput("day4/Day04_test") check(part1(testInput) == 2) val input = readInput("day4/Day04") println(part1(input)) println(part2(input)) } fun parseInput(input: List<String>): List<List<IntRange>> { return in...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
858
advent-of-code-2022
Apache License 2.0
src/Day04.kt
rk012
574,169,156
false
{"Kotlin": 9389}
fun main() { fun List<String>.getNums() = map { s -> s.split('-', ',').map { it.toInt() } } fun part1(input: List<String>) = input.getNums().fold(0) { acc, (s0, e0, s1, e1) -> when { s0 <= s1 && e0 >= e1 -> acc + 1 s0 >= s1 && e0 <= e1 -> acc + 1 else -> ...
0
Kotlin
0
0
bfb4c56c4d4c8153241fa6aa6ae0e829012e6679
768
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2022/Day14.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2022 import com.dvdmunckhof.aoc.common.Point import com.dvdmunckhof.aoc.splitOnce class Day14(private val input: List<String>) { fun solvePart1() = solve(false) fun solvePart2() = solve(true) private fun solve(hasFloor: Boolean): Int { val grid = input.asSequenc...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
1,893
advent-of-code
Apache License 2.0
src/Day11_part1.kt
lowielow
578,058,273
false
{"Kotlin": 29322}
fun main() { val input = readInput("Day11") val itemList = mutableListOf<MutableList<Int>>() val operationList = mutableListOf<MutableList<String>>() val testList = mutableListOf<Int>() val trueList = mutableListOf<Int>() val falseList = mutableListOf<Int>() fun countMonkey(input: List<Str...
0
Kotlin
0
0
acc270cd70a8b7f55dba07bf83d3a7e72256a63f
3,192
aoc2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinSessions.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
3,558
kotlab
Apache License 2.0
day1/src/main/kotlin/Main.kt
joshuabrandes
726,066,005
false
{"Kotlin": 47373}
import java.io.File val startChars = listOf("o", "t", "f", "s", "e", "n") fun main() { println("------ Advent of Code 2023 - Day 1 -----") val puzzleInput = getPuzzleInput() val resultTask1 = puzzleInput.sumOf { getCalibrationValue(it) } val resultTask2 = puzzleInput.sumOf { getCalibrationValue(it, tr...
0
Kotlin
0
1
de51fd9222f5438efe9a2c45e5edcb88fd9f2232
2,680
aoc-2023-kotlin
The Unlicense
src/main/aoc2023/Day15.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2023 class Day15(input: List<String>) { val steps = input.first().split(",") private fun String.hash(): Int { var current = 0 forEach { ch -> current += ch.code current *= 17 current %= 256 } return current } private fun p...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
1,940
aoc
MIT License
src/day01/Day01.kt
daniilsjb
726,047,752
false
{"Kotlin": 66638, "Python": 1161}
package day01 import java.io.File fun main() { val data = parse("src/day01/Day01.txt") println("🎄 Day 01 🎄") println() println("[Part 1]") println("Answer: ${part1(data)}") println() println("[Part 2]") println("Answer: ${part2(data)}") } private fun parse(path: String): List<S...
0
Kotlin
0
0
46a837603e739b8646a1f2e7966543e552eb0e20
1,594
advent-of-code-2023
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/SortByBits.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,379
kotlab
Apache License 2.0
src/test/kotlin/io/noobymatze/aoc/y2023/Day1.kt
noobymatze
572,677,383
false
{"Kotlin": 90710}
package io.noobymatze.aoc.y2023 import io.noobymatze.aoc.Aoc import kotlin.test.Test class Day1 { @Test fun test() { val result = Aoc.getInput(1) .lineSequence() .map { "${it.find { it.isDigit() }}${it.findLast { it.isDigit() }}".toInt() } .sum() println(r...
0
Kotlin
0
0
da4b9d894acf04eb653dafb81a5ed3802a305901
3,428
aoc
MIT License
src/Day05.kt
lonskiTomasz
573,032,074
false
{"Kotlin": 22055}
fun main() { fun bothParts(input: List<String>, reverse: Boolean = true): List<String> { val crates = input.takeWhile { it.isNotEmpty() }.dropLast(1) .map { it.replace(" ", " ") } val procedures = input.dropWhile { it.isNotEmpty() }.drop(1) val stacks = sortedMapOf<Int, List<...
0
Kotlin
0
0
9e758788759515049df48fb4b0bced424fb87a30
1,362
advent-of-code-kotlin-2022
Apache License 2.0
src/day8/Day08.kt
dean95
571,923,107
false
{"Kotlin": 21240}
package day8 import readInput import kotlin.math.max private fun main() { fun parseInput(input: List<String>): List<List<Int>> { val matrix = mutableListOf<List<Int>>() input.forEach { line -> val row = mutableListOf<Int>() line.forEach { char -> row.add(cha...
0
Kotlin
0
0
0ddf1bdaf9bcbb45116c70d7328b606c2a75e5a5
5,021
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CombinationSum4.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * 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 w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,055
kotlab
Apache License 2.0
src/aoc2022/Day05.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2022 import readInput fun main() { val (year, day) = "2022" to "Day05" fun moveCrates(input: List<String>, onePerMove: Boolean): String { val stackLines = input.filter { '[' in it } val moveLines = input.filter { it.startsWith('m') } val stacks = Array((stackLines.maxOf { ...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
1,825
aoc-kotlin
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/regex_matching/v2/RegexMatching.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.regex_matching.v2 import datsok.* import org.junit.* class RegexMatching { @Test fun `some examples`() { match("", "") shouldEqual true match("a", "a") shouldEqual true match("a", "aa") shouldEqual false match("aa", "a") shouldEqual false matc...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,209
katas
The Unlicense
2021/src/main/kotlin/de/skyrising/aoc2021/day3/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2021.day3 import de.skyrising.aoc.* val test = TestInput(""" 00100 11110 10110 10111 10101 01111 00111 11100 10000 11001 00010 01010 """) @PuzzleName("Binary Diagnostic") fun PuzzleInput.part1(): Any { val input = lines val count = IntAr...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
1,333
aoc
MIT License
src/main/kotlin/com/github/michaelbull/advent2021/day9/HeightMap.kt
michaelbull
433,565,311
false
{"Kotlin": 162839}
package com.github.michaelbull.advent2021.day9 import com.github.michaelbull.advent2021.math.Vector2 import com.github.michaelbull.advent2021.math.Vector2.Companion.CARDINAL_DIRECTIONS fun Sequence<String>.toHeightMap(): HeightMap { val lines = this val heights = buildMap { for ((y, line) in lines.wi...
0
Kotlin
0
4
7cec2ac03705da007f227306ceb0e87f302e2e54
2,163
advent-2021
ISC License
src/2021/Day16.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2021` import java.io.File import java.math.BigInteger import java.util.* fun main() { Day16().solve() } fun Char.toBin(): List<Int> { return toString().toInt(16).toString(2).map { it.toString().toInt() } .let{MutableList(4-it.size){0}.apply{addAll(it)}} } fun String.toBin(): List<Int> { ...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
4,016
advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/TreeQueries.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,822
kotlab
Apache License 2.0
calendar/day05/Day5.kt
rocketraman
573,845,375
false
{"Kotlin": 45660}
package day05 import Day import Lines class Day5 : Day() { override fun part1(input: Lines): Any { return executeCraneOperations(input, true) } override fun part2(input: Lines): Any { return executeCraneOperations(input, false) } private fun executeCraneOperations(input: Lines, singleCrateMoves: B...
0
Kotlin
0
0
6bcce7614776a081179dcded7c7a1dcb17b8d212
1,572
adventofcode-2022
Apache License 2.0
src/day5/Solution.kt
chipnesh
572,700,723
false
{"Kotlin": 48016}
package day5 import readInput fun main() { fun part1(input: List<String>): String { val crates = Crates.ofDrawing(input.readDrawing()) CrateMover9000().execute( Instructions.ofList(input.readInstructions()), crates ) return crates.top() } fun part2...
0
Kotlin
0
1
2d0482102ccc3f0d8ec8e191adffcfe7475874f5
3,704
AoC-2022
Apache License 2.0
src/main/kotlin/com/askrepps/advent2022/day08/Day08.kt
askrepps
726,566,200
false
{"Kotlin": 99712}
/* * MIT License * * Copyright (c) 2022 <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, m...
0
Kotlin
0
0
5ce2228b0951db49a5cf2a6d974112f57e70030c
3,320
advent-of-code-kotlin
MIT License
src/main/kotlin/dayNine/DayNine.kt
janreppien
573,041,132
false
{"Kotlin": 26432}
package dayNine import AocSolution import java.io.File class DayNine : AocSolution(9) { data class Instruction(val direction: Char, val amount: Int) data class Rope(var parts: List<Pair<Int, Int>>) private val input = readInput() private fun readInput(): MutableList<Instruction> { val inpu...
0
Kotlin
0
0
b53f6c253966536a3edc8897d1420a5ceed59aa9
4,221
aoc2022
MIT License
src/Day19.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
fun main() { data class Blueprint( val number: Int, val oreOreCost: Int, val clayOreCost: Int, val obsidianOreCost: Int, val obsidianClayCost: Int, val geodeOreCost: Int, val geodeObsidianCost: Int ) { val maxNecessaryOreRobots = maxOf(geodeOreCost...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
4,726
AdventOfCode2022
Apache License 2.0
2020/Day7/src/main/kotlin/main.kt
airstandley
225,475,112
false
{"Python": 104962, "Kotlin": 59337}
import java.io.File fun getInput(): List<String> { return File("Input").readLines() } fun parseRule(line: String): Pair<String, MutableMap<String, Int>> { // Parse the rule to return a node var linkedNodes = mutableMapOf<String, Int>() // Drop the period and split on contains val parts = line.drop...
0
Python
0
0
86b7e289d67ba3ea31a78f4a4005253098f47254
4,328
AdventofCode
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem1155/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1155 import kotlin.math.min /** * LeetCode page: [1155. Number of Dice Rolls With Target Sum](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum/); * * TODO : There is solution with space complexity O(1) ([see REF](https://leetcode.com/problems/number-of-dice-r...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,683
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/day21.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day21 import aoc.utils.findFirstInt import aoc.utils.readInput fun main() { part2().let { println(it) } } data class Monkey( val name: String, var operation: Char?, var left: Monkey?, var right: Monkey?, val leftPlaceHolder: String?, val rightPlaceHolder: String?, var value: L...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
3,199
adventOfCode2022
Apache License 2.0
advent-of-code2016/src/main/kotlin/day17/Advent17.kt
REDNBLACK
128,669,137
false
null
package day17 import toHex import toMD5 import java.util.* /** --- Day 17: Two Steps Forward --- You're trying to access a secure vault protected by a 4x4 grid of small rooms connected by doors. You start in the top-left room (marked S), and you can access the vault (marked V) once you reach the bottom-right room: ...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
4,995
courses
MIT License
src/main/kotlin/day15/Day15.kt
Mee42
433,459,856
false
{"Kotlin": 42703, "Java": 824}
package dev.mee42.day15 import dev.mee42.* import java.util.* import kotlin.math.pow import kotlin.math.sqrt val test = """ 1163751742 1381373672 2136511328 3694931569 7463417111 1319128137 1359912421 3125421639 1293138521 2311944581 """.trimIndent() fun Int.wrap() = if(this > 9) this - 9 else this fun main() { ...
0
Kotlin
0
0
db64748abc7ae6a92b4efa8ef864e9bb55a3b741
3,441
aoc-2021
MIT License
src/year2021/Day6.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2021 import readFile fun main() { val input = parseInput(readFile("2021", "day6")) val testInput = parseInput(readFile("2021", "day6_test")) check(part1(testInput) == 5934L) println("Part 1:" + part1(input)) check(part2(testInput) == 26984457539L) println("Part 2:" + part2(input)...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
1,019
advent_of_code
MIT License
src/year2022/day04/Day04.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day04 import readInputFileByYearAndDay import readTestFileByYearAndDay // ctor expects Strings such as // 100-200 // no validation of any kind is done class InclusiveInterval(formatted: String) { val start: Int val end: Int init { formatted.split("-").apply { start = ...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
1,372
advent-of-code-kotlin
Apache License 2.0