path stringlengths 5 169 | owner stringlengths 2 34 | repo_id int64 1.49M 755M | is_fork bool 2
classes | languages_distribution stringlengths 16 1.68k ⌀ | content stringlengths 446 72k | issues float64 0 1.84k | main_language stringclasses 37
values | forks int64 0 5.77k | stars int64 0 46.8k | commit_sha stringlengths 40 40 | size int64 446 72.6k | name stringlengths 2 64 | license stringclasses 15
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
src/main/kotlin/days/Day19.kt | hughjdavey | 225,440,374 | false | null | package days
import common.IntcodeComputer
import common.stackOf
class Day19 : Day(19) {
private fun program() = inputString.split(",").map { it.trim().toLong() }.toMutableList()
override fun partOne(): Any {
val tractorPoints = getTractorPoints(49, 49)
return tractorPoints.count { it.pulled... | 0 | Kotlin | 0 | 1 | 84db818b023668c2bf701cebe7c07f30bc08def0 | 2,517 | aoc-2019 | Creative Commons Zero v1.0 Universal |
src/Day01.kt | rafael-ribeiro1 | 572,657,838 | false | {"Kotlin": 15675} | fun main() {
fun part1(input: List<String>): Int {
return input.caloriesPerElf().max()
}
fun part2(input: List<String>): Int {
return input.caloriesPerElf().sortedDescending().take(3).sum()
}
// test if implementation meets criteria from the description, like:
val testInput = r... | 0 | Kotlin | 0 | 0 | 5cae94a637567e8a1e911316e2adcc1b2a1ee4af | 902 | aoc-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/days/Day20.kt | poqueque | 430,806,840 | false | {"Kotlin": 101024} | package days
import printMap
import util.Coor
class Day20 : Day(20) {
val algorithm: String = inputList[0]
val input = mutableMapOf<Coor, Int>()
val C = listOf(".", "#")
init {
var height = 0
var width = 0
inputList.forEachIndexed() { i, it ->
if (i > 1) {
... | 0 | Kotlin | 0 | 0 | 4fa363be46ca5cfcfb271a37564af15233f2a141 | 2,482 | adventofcode2021 | MIT License |
src/algorithmdesignmanualbook/searching/SmallestMissingNumber.kt | realpacific | 234,499,820 | false | null | package algorithmdesignmanualbook.searching
import kotlin.test.assertTrue
/**
* [4-34]
* Suppose that you are given a sorted sequence of distinct integers {a1, a2, . . . , an},
* drawn from 1 to m where n < m. Give an O(lg n) algorithm to find an integer ≤ m
* that is not present in a. For full credit, find th... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 2,062 | algorithms | MIT License |
src/app.kt | MaciejPawlik | 225,872,902 | false | null | import centile.Centile
import centile.model.Standard
import centile.model.Gender
import centile.model.Type
import java.io.File
import kotlin.math.pow
fun main() {
println("Youngster gender? (Girl / Boy):")
// Todo: add inputs check ;)
val pickedGender = readLine().toString()
val gender = Gender.valueOf... | 0 | Kotlin | 0 | 0 | 8f8ccf7d7fa7f0317871efa0309ae8f2c86d14c7 | 2,929 | youngster_bmi | MIT License |
src/main/kotlin/adventofcode2017/potasz/P12DigitalPlumber.kt | potasz | 113,064,245 | false | null | package adventofcode2017.potasz
object P12DigitalPlumber {
data class Program(val id: Int, val peers: MutableSet<Int> = mutableSetOf())
fun solve(lines: List<String>): List<Set<Int>> {
val programs = mutableMapOf<Int, Program>()
lines.map { it.split(" <-> ") }
.map { Pair(it[0... | 0 | Kotlin | 0 | 1 | f787d9deb1f313febff158a38466ee7ddcea10ab | 1,881 | adventofcode2017 | Apache License 2.0 |
src/Day03.kt | jwklomp | 572,195,432 | false | {"Kotlin": 65103} | fun main() {
val lookup = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
fun part1(input: List<String>): Int =
input
.map { it.chunked(it.length / 2) }
.map {
it.first()
.split("")
.intersect(it.last().split("").to... | 0 | Kotlin | 0 | 0 | 1b1121cfc57bbb73ac84a2f58927ab59bf158888 | 971 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/adventofcode2017/Day08LikeRegisters.kt | n81ur3 | 484,801,748 | false | {"Kotlin": 476844, "Java": 275} | package adventofcode2017
import adventofcode2017.Comparator.*
import adventofcode2017.RegisterOperation.*
class Day08LikeRegisters
enum class RegisterOperation {
INC, DEC
}
enum class Comparator {
LT, LET, EQ, NE, GET, GT
}
data class Register(val name: String, var value: Int = 0) {
fun inc(incValue: I... | 0 | Kotlin | 0 | 0 | fdc59410c717ac4876d53d8688d03b9b044c1b7e | 3,348 | kotlin-coding-challenges | MIT License |
src/Day10.kt | nikolakasev | 572,681,478 | false | {"Kotlin": 35834} | fun main() {
fun part1(input: List<String>): Int {
return acc(input, 0, 1, 1, listOf(20, 60, 100, 140, 180, 220))
}
fun part2(input: List<String>) {
var X = 1
var pointer = 0
var endCycle = false
var cycle = 0
for (y in 0..5) {
for (x in 0..39) {... | 0 | Kotlin | 0 | 1 | 5620296f1e7f2714c09cdb18c5aa6c59f06b73e6 | 2,271 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day12.kt | janbina | 112,736,606 | false | null | package day12
import getInput
import java.util.*
import kotlin.test.assertEquals
fun main(args: Array<String>) {
val input = getInput(12)
.readLines()
.map { Regex("\\w+").findAll(it).map { it.value.toInt() }.toList() }
val nodes = parseInput(input)
assertEquals(175, part1(nodes)... | 0 | Kotlin | 0 | 0 | 71b34484825e1ec3f1b3174325c16fee33a13a65 | 1,382 | advent-of-code-2017 | MIT License |
src/exercises/Day10.kt | Njko | 572,917,534 | false | {"Kotlin": 53729} | // ktlint-disable filename
package exercises
import readInput
fun main() {
fun part1(input: List<String>): Int {
var cycle = 1
var x = 1
val cyclesToCheck = mutableMapOf(20 to 0, 60 to 0, 100 to 0, 140 to 0, 180 to 0, 220 to 0)
input.forEach { instruction ->
if (instruc... | 0 | Kotlin | 0 | 2 | 68d0c8d0bcfb81c183786dfd7e02e6745024e396 | 2,694 | advent-of-code-2022 | Apache License 2.0 |
src/day01/Day01.kt | ankushg | 573,188,873 | false | {"Kotlin": 7320} |
@JvmInline
private value class Elf(private val inventory: List<Int>) {
val total get() = inventory.sum()
}
object Day01 : Solution<Int>(
dayNumber = "01",
part1ExpectedAnswer = 24000,
part2ExpectedAnswer = 45000
) {
private fun buildElfList(input: List<String>): List<Elf> {
val elves = mu... | 0 | Kotlin | 0 | 0 | b4c93b6f12f5677173cb9bacfe5aa4ce4afa5667 | 1,622 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/g1101_1200/s1129_shortest_path_with_alternating_colors/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1101_1200.s1129_shortest_path_with_alternating_colors
// #Medium #Breadth_First_Search #Graph #Graph_Theory_I_Day_10_Standard_Traversal
// #2023_10_02_Time_208_ms_(80.00%)_Space_39.9_MB_(70.00%)
import java.util.LinkedList
import java.util.Queue
@Suppress("NAME_SHADOWING")
class Solution {
private class... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,486 | LeetCode-in-Kotlin | MIT License |
src/Day02.kt | fonglh | 573,269,990 | false | {"Kotlin": 48950, "Ruby": 1701} | fun main() {
fun part1(input: List<String>): Int {
var score = 0
input.forEach {
var moves = it.split(" ")
if (isDraw(moves[0], moves[1])) {
score += 3
}
if (doesPlayerWin(moves[0], moves[1])) {
score += 6
}
... | 0 | Kotlin | 0 | 0 | ef41300d53c604fcd0f4d4c1783cc16916ef879b | 2,661 | advent-of-code-2022 | Apache License 2.0 |
src/Day06.kt | nguyendanv | 573,066,311 | false | {"Kotlin": 18026} | fun main() {
fun findStart(input: List<String>, uniqueChars: Int): Int {
val windows = input[0].windowed(uniqueChars, 1)
for (i in windows.indices) {
if (windows[i].toSet().size==uniqueChars)
return i + uniqueChars
}
return -1
}
fun part1(input: L... | 0 | Kotlin | 0 | 0 | 376512583af723b4035b170db1fa890eb32f2f0f | 1,189 | advent2022 | Apache License 2.0 |
src/Day19.kt | matusekma | 572,617,724 | false | {"Kotlin": 119912, "JavaScript": 2024} | class BluePrint(
val id: Int,
val oreRobotOreCost: Int,
val clayRobotOreCost: Int,
val obsidianRobotOreCost: Int,
val obsidianRobotClayCost: Int,
val geodeRobotOreCost: Int,
val geodeRobotObsidianCost: Int,
) {
val maxOreNeeded = listOf(
geodeRobotOreCost,
obsidianRobotOr... | 0 | Kotlin | 0 | 0 | 744392a4d262112fe2d7819ffb6d5bde70b6d16a | 7,697 | advent-of-code | Apache License 2.0 |
calendar/day08/Day8.kt | mpetuska | 571,764,215 | false | {"Kotlin": 18073} | package day08
import Day
import Lines
class Day8 : Day() {
override fun part1(input: Lines): Any {
val grid = input.map { it.split("").filter(String::isNotBlank).map(String::toInt) }
val height = grid.size
val width = grid[0].size
return (1 until height - 1).sumOf { y ->
(1 until width - 1).co... | 0 | Kotlin | 0 | 0 | be876f0a565f8c14ffa8d30e4516e1f51bc3c0c5 | 1,532 | advent-of-kotlin-2022 | Apache License 2.0 |
aoc2022/day21.kt | davidfpc | 726,214,677 | false | {"Kotlin": 127212} | package aoc2022
import utils.InputRetrieval
fun main() {
Day21.execute()
}
object Day21 {
fun execute() {
val input = readInput()
println("Part 1: ${part1(input)}")
println("Part 2: ${part2(input).toLong()}")
}
private const val ROOT_MONKEY_NAME = "root"
const val HUMAN_N... | 0 | Kotlin | 0 | 0 | 8dacf809ab3f6d06ed73117fde96c81b6d81464b | 4,964 | Advent-Of-Code | MIT License |
src/main/kotlin/io/hsar/practice3/ProblemE.kt | HSAR | 241,918,109 | false | null | package io.hsar.practice3
/*
https://codeforces.com/contest/1298/problem/E
Input:
10 4
5 4 1 5 4 3 7 1 2 5
4 6
2 1
10 8
3 5
Output:
5 4 0 5 3 3 9 0 2 5
*/
fun findNumberOfValidMentees(skillsLookup: List<Pair<Int, Int>>, quarrelsLookup: Map<Int, Set<Int>>, skillLevel: Int, index: Int): Int {
var mentees = 0
... | 0 | Kotlin | 0 | 0 | 69a1187ffa6e0a61324f88572851b2147d8a1210 | 1,994 | KotlinHeroes | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/RectangleArea.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,966 | kotlab | Apache License 2.0 |
src/main/kotlin/se/saidaspen/aoc/aoc2021/Day04.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2021
import se.saidaspen.aoc.util.Day
import se.saidaspen.aoc.util.P
import se.saidaspen.aoc.util.ints
fun main() = Day04.run()
object Day04 : Day(2021, 4) {
private val numbers = ints(input.lines().take(1)[0])
private val boards = toBoards()
override fun part1(): Any {
... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 3,617 | adventofkotlin | MIT License |
src/main/kotlin/de/dikodam/calendar/Day08.kt | dikodam | 573,126,346 | false | {"Kotlin": 26584} | package de.dikodam.calendar
import de.dikodam.AbstractDay
import de.dikodam.Coordinates2D
import de.dikodam.executeTasks
import kotlin.time.ExperimentalTime
@ExperimentalTime
fun main() {
Day08().executeTasks()
}
class Day08 : AbstractDay() {
val inputGrid = read2DGrid()
override fun task1(): String {
... | 0 | Kotlin | 0 | 1 | 3eb9fc6f1b125565d6d999ebd0e0b1043539d192 | 2,401 | aoc2022 | MIT License |
src/day13/Code.kt | fcolasuonno | 221,697,249 | false | null | package day13
import java.io.File
import kotlin.math.abs
private fun Triple<Int, Int, Int>.movements() = listOf(
Triple(first - 1, second, third + 1),
Triple(first + 1, second, third + 1),
Triple(first, second - 1, third + 1),
Triple(first, second + 1, third + 1))
private val test = ... | 0 | Kotlin | 0 | 0 | 73110eb4b40f474e91e53a1569b9a24455984900 | 2,201 | AOC2016 | MIT License |
src/Day01.kt | carotkut94 | 572,816,808 | false | {"Kotlin": 7508} | fun main() {
fun prepare(input:String): List<Long> {
return input.split("\n\n").map { it.split("\n") }.map {
it.sumOf { item -> item.toLong() }
}
}
fun part1(input: List<Long>): Triple<Long, Long, Long> {
var (first, second, third) = arrayOf(Long.MIN_VALUE, Long.MIN_VAL... | 0 | Kotlin | 0 | 0 | ef3dee8be98abbe7e305e62bfe8c7d2eeff808ad | 1,000 | aoc-2022 | Apache License 2.0 |
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem031.kt | mddburgess | 261,028,925 | false | null | package dev.mikeburgess.euler.problems
/**
* Problem 31
*
* In the United Kingdom the currency is made up of pound (£) and pence (p). There are eight coins
* in general circulation:
*
* 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p), and £2 (200p).
*
* It is possible to make £2 in the following way:
*
* 1 × £1 + 1 × 5... | 0 | Kotlin | 0 | 0 | 86518be1ac8bde25afcaf82ba5984b81589b7bc9 | 1,004 | project-euler | MIT License |
dcp_kotlin/src/main/kotlin/dcp/day262/day262.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day262
// day262.kt
// By <NAME>, 2019.
typealias Vertex = Int
typealias Edge = Pair<Vertex, Vertex>
data class UndirectedSimpleGraph(val nodes: Vertex, val adjacencies: Map<Vertex, Set<Vertex>>) {
init {
// The graph is simple because it uses a set.
// Make sure all adjacencies are l... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 2,052 | daily-coding-problem | MIT License |
src/Day21.kt | palex65 | 572,937,600 | false | {"Kotlin": 68582} | @file:Suppress("PackageDirectoryMismatch")
package day21
import readInput
abstract class Monkey(val name: String) {
abstract fun getNumber(monkeys: Map<String,Monkey>): Long?
open fun getForResult(monkeys: Map<String, Monkey>, res: Long): Long = error("getForResult in $name")
}
class MonkeyNumber(name: String... | 0 | Kotlin | 0 | 2 | 35771fa36a8be9862f050496dba9ae89bea427c5 | 3,339 | aoc2022 | Apache License 2.0 |
src/Day07.kt | MartinsCode | 572,817,581 | false | {"Kotlin": 77324} | fun main() {
// We need a stateful machine to parse the input.
// It has to rebuild a kind of tree with the dir structure
// And later on it has to traverse through the directories and calculate things.
// Therefore let's keep track of all directories:
// directories = mutableListOf("") // root
... | 0 | Kotlin | 0 | 0 | 1aedb69d80ae13553b913635fbf1df49c5ad58bd | 4,442 | AoC-2022-12-01 | Apache License 2.0 |
src/main/kotlin/Day7.kt | dlew | 75,886,947 | false | null | import java.util.regex.Pattern
class Day7 {
data class Address(val sequences: List<String>, val hypernet: List<String>) {
fun supportsTLS() = containsAbba(sequences) && !containsAbba(hypernet)
fun supportsSSL(): Boolean {
val sequenceAbas = sequences.map { findAbas(it) }.flatten()
val hypernetAb... | 0 | Kotlin | 2 | 12 | 527e6f509e677520d7a8b8ee99f2ae74fc2e3ecd | 1,613 | aoc-2016 | MIT License |
kotlin/src/com/daily/algothrim/leetcode/MinimumEffortPath.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode
import kotlin.math.abs
/**
* 1631. 最小体力消耗路径
*
* 你准备参加一场远足活动。给你一个二维 rows x columns 的地图 heights ,其中 heights[row][col] 表示格子 (row, col) 的高度。一开始你在最左上角的格子 (0, 0) ,且你希望去最右下角的格子 (rows-1, columns-1) (注意下标从 0 开始编号)。你每次可以往 上,下,左,右 四个方向之一移动,你想要找到耗费 体力 最小的一条路径。
*
* 一条路径耗费的 体力值 是路径上相邻格子之间 ... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 3,520 | daily_algorithm | Apache License 2.0 |
src/Utils.kt | ShuffleZZZ | 572,630,279 | false | {"Kotlin": 29686} | import java.io.File
import java.math.BigInteger
import java.security.MessageDigest
import kotlin.math.absoluteValue
import kotlin.math.sign
fun Boolean.toInt() = if (this) 1 else 0
fun IntProgression.isRange() = step.sign > 0
operator fun <T> List<List<T>>.get(ind: Pair<Int, Int>) = this[ind.first][ind.second]
oper... | 0 | Kotlin | 0 | 0 | 5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e | 2,717 | advent-of-code-kotlin | Apache License 2.0 |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[15]三数之和.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | import java.util.*
//给你一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?请你找出所有和为 0 且不重
//复的三元组。
//
// 注意:答案中不可以包含重复的三元组。
//
//
//
// 示例 1:
//
//
//输入:nums = [-1,0,1,2,-1,-4]
//输出:[[-1,-1,2],[-1,0,1]]
//
//
// 示例 2:
//
//
//输入:nums = []
//输出:[]
//
//
// 示例 3:
//
//
//输入:nums = [0]
//输出:[]
//
//... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 2,272 | MyLeetCode | Apache License 2.0 |
src/main/kotlin/mirecxp/aoc23/day02/Day02.kt | MirecXP | 726,044,224 | false | {"Kotlin": 42343} | package mirecxp.aoc23.day02
import java.io.File
//https://adventofcode.com/2023/day/2
class Day02(inputPath: String) {
private val gameInputs: List<String> =
File(inputPath).readLines()
data class Game(
val id: Long,
val draws: List<Draw>
) {
fun getMinimumDraw() = Draw(
... | 0 | Kotlin | 0 | 0 | 6518fad9de6fb07f28375e46b50e971d99fce912 | 2,549 | AoC-2023 | MIT License |
src/main/kotlin/com/leonra/adventofcode/advent2023/day03/Day3.kt | LeonRa | 726,688,446 | false | {"Kotlin": 30456} | package com.leonra.adventofcode.advent2023.day03
import com.leonra.adventofcode.shared.readResource
import kotlin.math.max
import kotlin.math.min
/** https://adventofcode.com/2023/day/3 */
private object Day3 {
fun partOne(): Int {
val schematic = mutableListOf<List<Char>>()
readResource("/2023/d... | 0 | Kotlin | 0 | 0 | 46bdb5d54abf834b244ba9657d0d4c81a2d92487 | 4,144 | AdventOfCode | Apache License 2.0 |
src/main/kotlin/day25/solution.kt | bukajsytlos | 433,979,778 | false | {"Kotlin": 63913} | package day25
import java.io.File
typealias SeaFloor = Array<Array<SeaCucumberType?>>
fun main() {
val lines = File("src/main/kotlin/day25/input.txt").readLines()
val seaFloor: SeaFloor =
SeaFloor(lines.size) { i -> lines[i].map { SeaCucumberType.fromSymbol(it) }.toTypedArray() }
var iterationCo... | 0 | Kotlin | 0 | 0 | f47d092399c3e395381406b7a0048c0795d332b9 | 2,359 | aoc-2021 | MIT License |
day03/src/main/kotlin/Main.kt | Prozen | 160,076,543 | false | null | import java.io.File
fun main() {
val strings = File(ClassLoader.getSystemResource("input.txt").file).readLines()
val field = Array(1000) { Array(1000) { 0 } }
strings.forEach {
val words = it.split(" ")
val start = words[2].dropLast(1).split(",").map { it.toInt() }
val size = words[... | 0 | Kotlin | 0 | 0 | b0e830f53e216dd9f010fb294bef9c5b8c10f4a8 | 1,269 | AdventOfCode2018 | Apache License 2.0 |
src/main/kotlin/se/saidaspen/aoc/aoc2017/Day07.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2017
import se.saidaspen.aoc.util.Day
fun main() = Day07.run()
object Day07 : Day(2017, 7) {
private var nodes: HashSet<String> = HashSet()
private var heldBy: HashMap<String, String> = HashMap()
private var holding: HashMap<String, List<String>> = HashMap()
private var w... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 2,530 | adventofkotlin | MIT License |
src/year2022/day05/Day05.kt | TheSunshinator | 572,121,335 | false | {"Kotlin": 144661} | package year2022.day05
import arrow.core.identity
import io.kotest.matchers.shouldBe
import utils.readInput
fun main() {
val testInput = readInput("05", "test_input")
val realInput = readInput("05", "input")
val testStart = testInput.takeWhile(String::isNotEmpty)
val testMovements = testInput.takeLas... | 0 | Kotlin | 0 | 0 | d050e86fa5591447f4dd38816877b475fba512d0 | 2,546 | Advent-of-Code | Apache License 2.0 |
src/Day11.kt | frungl | 573,598,286 | false | {"Kotlin": 86423} | import java.math.BigInteger
@OptIn(ExperimentalStdlibApi::class)
fun main() {
fun String.takeLastInt() =
takeLastWhile { it != ' ' }.toInt()
fun String.takeLastBigInteger() =
takeLastWhile { it != ' ' }.toBigInteger()
fun String.evalInt(): Int {
val tmp = this.split(' ')
r... | 0 | Kotlin | 0 | 0 | d4cecfd5ee13de95f143407735e00c02baac7d5c | 3,685 | aoc2022 | Apache License 2.0 |
src/main/java/com/barneyb/aoc/aoc2022/day09/RopeBridge.kt | barneyb | 553,291,150 | false | {"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020} | package com.barneyb.aoc.aoc2022.day09
import com.barneyb.aoc.util.Solver
import com.barneyb.aoc.util.toInt
import com.barneyb.aoc.util.toSlice
import com.barneyb.util.Dir
import com.barneyb.util.Vec2
import kotlin.math.abs
fun main() {
Solver.execute(
::parse,
::partOne,
::partTwo, // 2140... | 0 | Kotlin | 0 | 0 | 8b5956164ff0be79a27f68ef09a9e7171cc91995 | 2,046 | aoc-2022 | MIT License |
src/Day02.kt | yturkkan-figure | 487,361,256 | false | {"Kotlin": 5549} | fun main() {
fun part1(input: List<String>): Int {
var depth = 0
var horizontal = 0
for (line in input) {
val (direction, distance) = line.split(' ')
when (direction) {
"forward" -> horizontal += distance.toInt()
"down" -> depth += di... | 0 | Kotlin | 0 | 0 | cd79f4b6ac78b06cfb9b5ee381ae7427895a68c0 | 1,271 | kotlin-aoc-2021 | Apache License 2.0 |
src/Day07.kt | haitekki | 572,959,197 | false | {"Kotlin": 24688} | fun main() {
fun initFileSystem (input: String): Directory {
val root = Directory(
parentDirectory = null,
name = "root"
)
var current: Directory = root
for (line in input.lines()) {
val splittedLine = line.split(" ")
when (splittedLi... | 0 | Kotlin | 0 | 0 | b7262133f9115f6456aa77d9c0a1e9d6c891ea0f | 4,246 | aoc2022 | Apache License 2.0 |
src/main/kotlin/com/ikueb/advent18/Day18.kt | h-j-k | 159,901,179 | false | null | package com.ikueb.advent18
import com.ikueb.advent18.model.*
object Day18 {
fun getResourceValue(input: List<String>, iterations: Int): Int {
val state: Area = input.mapIndexed { y, line ->
InputLine(line.mapIndexed { x, value ->
Acre(Point(x, y), Content.parse(value))
... | 0 | Kotlin | 0 | 0 | f1d5c58777968e37e81e61a8ed972dc24b30ac76 | 2,466 | advent18 | Apache License 2.0 |
src/main/kotlin/aoc/year2023/Day01.kt | SackCastellon | 573,157,155 | false | {"Kotlin": 62581} | package aoc.year2023
import aoc.Puzzle
/**
* [Day 1 - Advent of Code 2023](https://adventofcode.com/2023/day/1)
*/
object Day01 : Puzzle<Int, Int> {
private val digitMap = mapOf(
"one" to 1,
"two" to 2,
"three" to 3,
"four" to 4,
"five" to 5,
"six" to 6,
"... | 0 | Kotlin | 0 | 0 | 75b0430f14d62bb99c7251a642db61f3c6874a9e | 1,398 | advent-of-code | Apache License 2.0 |
src/main/kotlin/g2301_2400/s2360_longest_cycle_in_a_graph/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2301_2400.s2360_longest_cycle_in_a_graph
// #Hard #Depth_First_Search #Graph #Topological_Sort
// #2023_07_02_Time_517_ms_(80.00%)_Space_59.3_MB_(100.00%)
class Solution {
fun longestCycle(edges: IntArray): Int {
val n = edges.size
val vis = BooleanArray(n)
val dfsvis = BooleanArr... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,240 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/com/simonorono/aoc2015/solutions/Day13.kt | simonorono | 662,846,819 | false | {"Kotlin": 28492} | package com.simonorono.aoc2015.solutions
import com.simonorono.aoc2015.lib.Day
object Day13 : Day(13) {
private val REGEX =
"""(.+) would (.+) (\d+) happiness units by sitting next to (.+).""".toRegex()
private val happinessMap: HashMap<String, HashMap<String, Int>> =
hashMapOf()
init {
... | 0 | Kotlin | 0 | 0 | 0fec1d4db5b68ea8ee05b20c535df1b7f5570056 | 2,309 | aoc2015 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxNumberOfApples.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 | 3,345 | kotlab | Apache License 2.0 |
src/Day04.kt | bigtlb | 573,081,626 | false | {"Kotlin": 38940} | fun main() {
fun List<String>.parseList(): List<List<Set<Int>>> = this.map { line ->
line.split(',').map { region ->
region.split('-').map(String::toInt).let { (begin, end) -> (begin..end).toSet() }
}
}
fun part1(input: List<String>): Int = input.parseList()
.count ... | 0 | Kotlin | 0 | 0 | d8f76d3c75a30ae00c563c997ed2fb54827ea94a | 847 | aoc-2022-demo | Apache License 2.0 |
src/chapter3/section2/ex30_OrderCheck.kt | w1374720640 | 265,536,015 | false | {"Kotlin": 1373556} | package chapter3.section2
import edu.princeton.cs.algs4.Queue
/**
* 有序性检查
* 编写一个递归的方法isOrdered(),接受一个结点Node和min、max两个键作为参数。
* 如果以该结点为根的子树中所有结点都在min和max之间,min和max的确分别是树中最小和最大的结点
* 且二叉查找树的有序性对树中的所有键都成立,返回true,否则返回false
*/
fun <K : Comparable<K>> isOrdered(node: BinarySearchTree.Node<K, *>, min: K, max: K): Boolean... | 0 | Kotlin | 1 | 6 | 879885b82ef51d58efe578c9391f04bc54c2531d | 2,060 | Algorithms-4th-Edition-in-Kotlin | MIT License |
src/day20/Day20.kt | HGilman | 572,891,570 | false | {"Kotlin": 109639, "C++": 5375, "Python": 400} | package day20
import readInput
fun main() {
val day = 20
val testInput = readInput("day$day/testInput")
// check(part1(testInput) == 3L)
// check(part2(testInput) == 1623178306L)
val input = readInput("day$day/input")
// println(part1B(input))
println(part2(input))
}
data class MarkedNumber... | 0 | Kotlin | 0 | 1 | d05a53f84cb74bbb6136f9baf3711af16004ed12 | 5,731 | advent-of-code-2022 | Apache License 2.0 |
src/Day19.kt | i-tatsenko | 575,595,840 | false | {"Kotlin": 90644} | import ResourceType.*
val inputRegex =
"^Blueprint (\\d+): Each ore robot costs (\\d+) ore. Each clay robot costs (\\d+) ore. Each obsidian robot costs (\\d+) ore and (\\d+) clay. Each geode robot costs (\\d+) ore and (\\d+) obsidian.$".toRegex()
data class RobotConfig(
val oreCost: Int,
val clayCost: In... | 0 | Kotlin | 0 | 0 | 0a9b360a5fb8052565728e03a665656d1e68c687 | 7,022 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/icfp2019/Brain.kt | teemobean | 193,117,049 | true | {"JavaScript": 797310, "Kotlin": 129405, "CSS": 9434, "HTML": 5859, "Shell": 70} | package icfp2019
import icfp2019.core.DistanceEstimate
import icfp2019.core.Strategy
import icfp2019.core.applyAction
import icfp2019.model.Action
import icfp2019.model.GameState
import icfp2019.model.Problem
import icfp2019.model.RobotId
fun strategySequence(
initialGameState: GameState,
strategy: Strategy,
... | 13 | JavaScript | 12 | 0 | a1060c109dfaa244f3451f11812ba8228d192e7d | 3,814 | icfp-2019 | The Unlicense |
api/src/main/kotlin/dev/kosmx/needle/util/KMP.kt | KosmX | 651,103,285 | false | {"Kotlin": 73311} | package dev.kosmx.needle.util
/**
* O(n+m) pattern matching with Knuth-Morris-Pratt algo
*
* @param T has to be comparable (== or .equals has to work as data-classes)
*/
class Word<T>(val word: Array<T>, private val comparator: (T, T) -> Boolean = { a, b -> a == b }) {
init {
require(word.isNotEmpty())... | 20 | Kotlin | 2 | 60 | b8d3ed169a9d9cdee4bcebea015a27b1f6740f84 | 2,346 | jneedle | MIT License |
src/main/kotlin/adventofcode/year2022/Day07NoSpaceLeftOnDevice.kt | pfolta | 573,956,675 | false | {"Kotlin": 199554, "Dockerfile": 227} | package adventofcode.year2022
import adventofcode.Puzzle
import adventofcode.PuzzleInput
class Day07NoSpaceLeftOnDevice(customInput: PuzzleInput? = null) : Puzzle(customInput) {
private val files by lazy {
input.lines().fold(emptyList<String>() to emptySet<File>()) { (currentPath, files), line ->
... | 0 | Kotlin | 0 | 0 | 72492c6a7d0c939b2388e13ffdcbf12b5a1cb838 | 1,723 | AdventOfCode | MIT License |
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/Backtracking.kt | betulnecanli | 568,477,911 | false | {"Kotlin": 167849} | /*
Use this technique to build a solution incrementally and follow the approach that
if the current solution can’t lead to a valid solution, abandon it and backtrack (or go back) to try another solution.
*/
//1. Combination Sum
fun combinationSum(candidates: IntArray, target: Int): List<List<Int>> {
val result = m... | 2 | Kotlin | 2 | 40 | 70a4a311f0c57928a32d7b4d795f98db3bdbeb02 | 3,271 | Kotlin-Data-Structures-Algorithms | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindPeakElement.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,401 | kotlab | Apache License 2.0 |
src/Day03.kt | MickyOR | 578,726,798 | false | {"Kotlin": 98785} | fun main() {
fun part1(input: List<String>): Int {
var sum = 0;
for (line in input) {
var set = mutableSetOf<Char>();
var s1 = line.substring(0, line.length/2);
var s2 = line.substring(line.length/2);
for (c in s1) {
set.add(c);
... | 0 | Kotlin | 0 | 0 | c24e763a1adaf0a35ed2fad8ccc4c315259827f0 | 1,480 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/days/Day12.kt | vovarova | 572,952,098 | false | {"Kotlin": 103799} | package days
import java.util.*
class Day12() : Day(12) {
class HeightMap(input: List<String>) {
val heightMap: Array<Array<Char>>
val start: Cell
val end: Cell
val acells: List<Cell>
init {
val rows = input.size
val columns = input[0].length
... | 0 | Kotlin | 0 | 0 | e34e353c7733549146653341e4b1a5e9195fece6 | 4,774 | adventofcode_2022 | Creative Commons Zero v1.0 Universal |
src/Day03.kt | seana-zr | 725,858,211 | false | {"Kotlin": 28265} | import java.util.regex.Pattern
import kotlin.math.max
import kotlin.math.min
fun main() {
// [start, end)
fun extractNumbersWithIndices(line: String): List<Triple<Int, Int, Int>> {
val pattern = Pattern.compile("\\d+")
val matcher = pattern.matcher(line)
val matches = mutableListOf<Tr... | 0 | Kotlin | 0 | 0 | da17a5de6e782e06accd3a3cbeeeeb4f1844e427 | 3,888 | advent-of-code-kotlin-template | Apache License 2.0 |
src/2022/Day08.kt | nagyjani | 572,361,168 | false | {"Kotlin": 369497} | package `2022`
import java.io.File
import java.lang.Integer.max
import java.util.*
fun main() {
Day08().solve()
}
class Day08 {
val input1 = """
30373
25512
65332
33549
35390
""".trimIndent()
data class Tree(
val height: Int,
var maxLeft: Int... | 0 | Kotlin | 0 | 0 | f0c61c787e4f0b83b69ed0cde3117aed3ae918a5 | 3,387 | advent-of-code | Apache License 2.0 |
src/main/kotlin/adventofcode2022/solution/day_3.kt | dangerground | 579,293,233 | false | {"Kotlin": 51472} | package adventofcode2022.solution
import adventofcode2022.util.readDay
private const val DAY_NUM = 3
fun main() {
Day3(DAY_NUM.toString()).solve()
}
class Day3(private val num: String) {
private val inputText = readDay(num)
fun solve() {
println("Day $num Solution")
println("* Part 1: ... | 0 | Kotlin | 0 | 0 | f1094ba3ead165adaadce6cffd5f3e78d6505724 | 1,380 | adventofcode-2022 | MIT License |
src/main/kotlin/day10/Day10TheStarsAlign.kt | Zordid | 160,908,640 | false | null | package day10
import shared.extractAllInts
import shared.minToMaxRange
import shared.readPuzzle
data class Light(val x: Int, val y: Int, val vx: Int, val vy: Int) {
fun posAt(time: Int) = x + vx * time to y + vy * time
}
fun part1and2(puzzle: List<List<Int>>): Int {
val lights = puzzle.map { Light(it[0], it[... | 0 | Kotlin | 0 | 0 | f246234df868eabecb25387d75e9df7040fab4f7 | 1,096 | adventofcode-kotlin-2018 | Apache License 2.0 |
leetcode-75-kotlin/src/main/kotlin/Dota2Senate.kt | Codextor | 751,507,040 | false | {"Kotlin": 49566} | /**
* In the world of Dota2, there are two parties: the Radiant and the Dire.
*
* The Dota2 senate consists of senators coming from two parties.
* Now the Senate wants to decide on a change in the Dota2 game. The voting for this change is a round-based procedure.
* In each round, each senator can exercise one of t... | 0 | Kotlin | 0 | 0 | 0511a831aeee96e1bed3b18550be87a9110c36cb | 3,236 | leetcode-75 | Apache License 2.0 |
src/main/kotlin/year2021/day-15.kt | ppichler94 | 653,105,004 | false | {"Kotlin": 182859} | package year2021
import lib.Grid2d
import lib.Position
import lib.TraversalAStar
import lib.aoc.Day
import lib.aoc.Part
fun main() {
Day(15, 2021, PartA15(), PartB15()).run()
}
open class PartA15 : Part() {
protected lateinit var cave: Grid2d<Int>
protected lateinit var end: Position
protected latein... | 0 | Kotlin | 0 | 0 | 49dc6eb7aa2a68c45c716587427353567d7ea313 | 1,983 | Advent-Of-Code-Kotlin | MIT License |
aoc-2018/src/main/kotlin/nl/jstege/adventofcode/aoc2018/days/Day18.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2018.days
import nl.jstege.adventofcode.aoccommon.days.Day
class Day18 : Day(title = "Settlers of The North Pole") {
private companion object Configuration {
private const val OPEN_GROUND = '.'
private const val TREE = '|'
private const val LUMBERYARD = '#... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 3,672 | AdventOfCode | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/SuperEggDrop.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 | 3,955 | kotlab | Apache License 2.0 |
src/main/kotlin/aoc/year2023/Day13.kt | SackCastellon | 573,157,155 | false | {"Kotlin": 62581} | package aoc.year2023
import aoc.Puzzle
import aoc.utils.transposed
import kotlin.math.min
/**
* [Day 13 - Advent of Code 2023](https://adventofcode.com/2023/day/13)
*/
object Day13 : Puzzle<Int, Int> {
override fun solvePartOne(input: String): Int = solve(input, ::getLineOfReflection)
override fun solvePar... | 0 | Kotlin | 0 | 0 | 75b0430f14d62bb99c7251a642db61f3c6874a9e | 1,521 | advent-of-code | Apache License 2.0 |
kotlin/310.Minimum Height Trees(最小高度树).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>For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minimum height trees (MHTs). Given such a graph, write a function to find all the MHTs and return a list of their roo... | 0 | Python | 1 | 3 | 6731e128be0fd3c0bdfe885c1a409ac54b929597 | 5,622 | leetcode | MIT License |
src/main/kotlin/com/marcdenning/adventofcode/day17/Day17a.kt | marcdenning | 317,730,735 | false | {"Kotlin": 87536} | package com.marcdenning.adventofcode.day17
import java.io.File
const val ACTIVE = '#'
const val INACTIVE = '.'
fun main(args: Array<String>) {
val numberOfBootCycles = args[1].toInt()
var pocketDimension = arrayOf(File(args[0]).readLines().map { it.toCharArray() }.toTypedArray())
for (i in 1..numberOfBo... | 0 | Kotlin | 0 | 0 | b227acb3876726e5eed3dcdbf6c73475cc86cbc1 | 4,008 | advent-of-code-2020 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/SmallestMissingValueSubtree.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 | 2,569 | kotlab | Apache License 2.0 |
src/Day10.kt | dakr0013 | 572,861,855 | false | {"Kotlin": 105418} | import kotlin.test.assertEquals
fun main() {
fun part1(input: List<String>): Long {
val program = parseInstructions(input)
return execute(program)
}
fun part2(input: List<String>): String {
val program = parseInstructions(input)
return execute2(program)
}
// test if implementation meets cri... | 0 | Kotlin | 0 | 0 | 6b3adb09f10f10baae36284ac19c29896d9993d9 | 2,368 | aoc2022 | Apache License 2.0 |
src/Day03.kt | jbotuck | 573,028,687 | false | {"Kotlin": 42401} | fun main() {
val lines = readInput("Day03")
println("part 1 ${lines.sumOf { part1(it) }}")
println("part 2 ${lines.chunked(3).sumOf { part2(it) }}")
}
private fun Char.priority() = if (isUpperCase()) code % 'A'.code + 27 else code % 'a'.code + 1
private fun part1(line: String) = line
.chunked(line.len... | 0 | Kotlin | 0 | 0 | d5adefbcc04f37950143f384ff0efcd0bbb0d051 | 556 | aoc2022 | Apache License 2.0 |
src/main/kotlin/g0801_0900/s0827_making_a_large_island/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0801_0900.s0827_making_a_large_island
// #Hard #Array #Depth_First_Search #Breadth_First_Search #Matrix #Union_Find
// #2023_03_25_Time_985_ms_(100.00%)_Space_92.1_MB_(33.33%)
class Solution {
private lateinit var p: IntArray
private lateinit var s: IntArray
private fun makeSet(x: Int, y: Int, r... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,719 | LeetCode-in-Kotlin | MIT License |
day10/app/src/main/kotlin/day10/App.kt | Devastus | 433,728,008 | false | {"Nim": 26335, "C": 14182, "Zig": 9701, "Kotlin": 3712, "Go": 2893, "JavaScript": 2704} | package day10
import java.io.File
import java.util.ArrayDeque
val INPUT = "input.txt"
fun old() {
val scoreMap = mapOf(')' to 3, ']' to 57, '}' to 1197, '>' to 25137)
val chars: CharSequence = "([{<)]}>"
val charMap = mapOf('(' to 0, ')' to 4,
'[' to 1, ']' to 5,
... | 0 | Nim | 0 | 0 | 69f6c228b5d0ca7ecd47a6b0b0703a1d88df2a4a | 2,769 | aoc-2021 | MIT License |
src/day8/Day8.kt | quinlam | 573,215,899 | false | {"Kotlin": 31932} | package day8
import utils.ArrayMovement
import utils.Day
/**
* Actual answers after submitting;
* part1: 1179
* part2: 172224
*/
class Day8 : Day<Int, Array<Array<Int>>>(
testPart1Result = 21,
testPart2Result = 8,
) {
/**
* Part1 can be done easily in O(n) but then i don't get to reuse any code.... | 0 | Kotlin | 0 | 0 | d304bff86dfecd0a99aed5536d4424e34973e7b1 | 2,304 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | valerakostin | 574,165,845 | false | {"Kotlin": 21086} | fun main() {
fun part1and2(input: List<String>): Pair<Int, Int> {
val pattern = """(-?\d+)-(-?\d+),(-?\d+)-(-?\d+)""".toRegex()
var answer1 = 0
var answer2 = 0
for (line in input) {
val match = pattern.find(line)
val (r1Min, r1Max, r2Min, r2Max) = match!!.de... | 0 | Kotlin | 0 | 0 | e5f13dae0d2fa1aef14dc71c7ba7c898c1d1a5d1 | 1,026 | AdventOfCode-2022 | Apache License 2.0 |
src/main/kotlin/com/dvdmunckhof/aoc/event2021/Day15.kt | dvdmunckhof | 318,829,531 | false | {"Kotlin": 195848, "PowerShell": 1266} | package com.dvdmunckhof.aoc.event2021
import com.dvdmunckhof.aoc.common.Grid
import com.dvdmunckhof.aoc.common.Point
class Day15(private val input: List<List<Int>>) {
fun solvePart1(): Int {
return solve(Grid(input))
}
fun solvePart2(): Int {
val multipliedH = input.map { row -> repeatLi... | 0 | Kotlin | 0 | 0 | 025090211886c8520faa44b33460015b96578159 | 1,633 | advent-of-code | Apache License 2.0 |
advent-of-code-2021/src/main/kotlin/Day3.kt | jomartigcal | 433,713,130 | false | {"Kotlin": 72459} | //Day 3: Binary Diagnostic
//https://adventofcode.com/2021/day/3
import java.io.File
import kotlin.math.pow
fun main() {
val list = File("src/main/resources/Day3.txt").readLines()
getPowerConsumption(list)
getLifeSupportRating(list)
}
fun getPowerConsumption(list: List<String>) {
val bits = getBitArr... | 0 | Kotlin | 0 | 0 | 6b0c4e61dc9df388383a894f5942c0b1fe41813f | 2,184 | advent-of-code | Apache License 2.0 |
src/day23/Parser.kt | g0dzill3r | 576,012,003 | false | {"Kotlin": 172121} | package day23
import readInput
import java.io.File
import java.lang.IllegalArgumentException
import kotlin.math.sign
data class Point (val x: Int, val y: Int) {
val adjacent: List<Point>
get () {
val list = mutableListOf<Point> ()
for (x in -1 .. 1) {
for (y in -1 .... | 0 | Kotlin | 0 | 0 | 6ec11a5120e4eb180ab6aff3463a2563400cc0c3 | 7,356 | advent_of_code_2022 | Apache License 2.0 |
src/day05/Day05.kt | AbolfaZlRezaEe | 574,383,383 | false | null | package day05
import readInput
import java.util.*
fun main() {
fun part01(lines: List<String>): String {
// Separate input and instructions
val columns = hashMapOf<Int, LinkedList<Char>>()
val instructions = lines.filter { line -> line.startsWith("move") }
val input = lines.filter ... | 0 | Kotlin | 0 | 0 | 798ff23eaa9f4baf25593368b62c2f671dc2a010 | 4,970 | AOC-With-Me | Apache License 2.0 |
src/main/kotlin/aoc2023/Day12.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2023
import AoCDay
// https://adventofcode.com/2023/day/12
object Day12 : AoCDay<Int>(
title = "Hot Springs",
part1ExampleAnswer = 21,
part1Answer = 7286,
part2ExampleAnswer = null,
part2Answer = null,
) {
private fun parseRow(row: String): Pair<String, List<Int>> {
val (spr... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 1,572 | advent-of-code-kotlin | MIT License |
src/main/aoc2021/Day8.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2021
class Day8(input: List<String>) {
val parsed = input.map { it.split(" | ") }
fun solvePart1(): Int {
return parsed.sumOf { line -> line.last().split(" ").count { it.length in listOf(2, 3, 4, 7) } }
}
/**
* Remove the first entry that matches the given condition and retur... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 4,142 | aoc | MIT License |
src/main/kotlin/de/pgebert/aoc/days/Day18.kt | pgebert | 724,032,034 | false | {"Kotlin": 65831} | package de.pgebert.aoc.days
import de.pgebert.aoc.Day
import kotlin.math.abs
class Day18(input: String? = null) : Day(18, "Lavaduct Lagoo", input) {
data class Vector(val x: Long, val y: Long) {
fun plus(other: Vector) = Vector(x + other.x, y + other.y)
fun multiply(multiplier: Long) = Vector(x... | 0 | Kotlin | 1 | 0 | a30d3987f1976889b8d143f0843bbf95ff51bad2 | 1,984 | advent-of-code-2023 | MIT License |
src/Day06.kt | realpacific | 573,561,400 | false | {"Kotlin": 59236} | fun main() {
fun numberOfCharacterBeforeSeeingTheFirstDistinctSequence(input: String, distinctCount: Int): Int {
val charactersSeen = mutableListOf<Char>()
input.forEachIndexed { currentIndex, character ->
if (charactersSeen.size == distinctCount) {
return currentIndex
... | 0 | Kotlin | 0 | 0 | f365d78d381ac3d864cc402c6eb9c0017ce76b8d | 1,797 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day08/day08.kt | corneil | 572,437,852 | false | {"Kotlin": 93311, "Shell": 595} | package main.day08
import utils.readFile
import utils.readLines
import utils.separator
import kotlin.math.max
fun main() {
val test = readLines(
"""30373
25512
65332
33549
35390"""
)
val input = readFile("day08")
class Grid(val lines: Array<IntArray>) {
fun width() = lines[0].size
fun height() = ... | 0 | Kotlin | 0 | 0 | dd79aed1ecc65654cdaa9bc419d44043aee244b2 | 3,184 | aoc-2022-in-kotlin | Apache License 2.0 |
Coding Challenges/Advent of Code/2021/Day 9/part1.kt | Alphabeater | 435,048,407 | false | {"Kotlin": 69566, "Python": 5974} | import java.io.File
import java.util.Scanner
fun setMapDimensions(file: File): Pair<Int, Int> {
val scanner = Scanner(file)
var row = 0
var col = 0
var bool = false
while (scanner.hasNextLine()) {
val line = scanner.nextLine()
if (!bool) {
col = line.length
... | 0 | Kotlin | 0 | 0 | 05c8d4614e025ed2f26fef2e5b1581630201adf0 | 1,644 | Archive | MIT License |
app/src/main/kotlin/day14/Day14.kt | W3D3 | 572,447,546 | false | {"Kotlin": 159335} | package day14
import common.InputRepo
import common.readSessionCookie
import common.solve
import util.splitIntoPair
fun main(args: Array<String>) {
val day = 14
val input = InputRepo(args.readSessionCookie()).get(day = day)
solve(day, input, ::solveDay14Part1, ::solveDay14Part2)
}
data class Pos(val x: ... | 0 | Kotlin | 0 | 0 | 34437876bf5c391aa064e42f5c984c7014a9f46d | 4,470 | AdventOfCode2022 | Apache License 2.0 |
leetcode-75-kotlin/src/main/kotlin/OddEvenLinkedList.kt | Codextor | 751,507,040 | false | {"Kotlin": 49566} | import commonclasses.ListNode
/**
* Given the head of a singly linked list,
* group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list.
*
* The first node is considered odd, and the second node is even, and so on.
*
* Note that the relative order inside... | 0 | Kotlin | 0 | 0 | 0511a831aeee96e1bed3b18550be87a9110c36cb | 1,370 | leetcode-75 | Apache License 2.0 |
src/main/kotlin/aoc2022/Day18.kt | w8mr | 572,700,604 | false | {"Kotlin": 140954} | package aoc2022
import aoc.parser.followedBy
import aoc.parser.number
import aoc.parser.seq
import aoc.parser.zeroOrMore
import java.util.*
typealias CubeSet = MutableMap<Int, MutableMap<Int, MutableSet<Int>>>
class Day18() {
data class Cube(val x: Int, val y: Int, val z: Int)
val cube = seq(number() follow... | 0 | Kotlin | 0 | 0 | e9bd07770ccf8949f718a02db8d09daf5804273d | 3,251 | aoc-kotlin | Apache License 2.0 |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions59.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.special
import com.qiaoyuang.algorithm.round0.PriorityQueue
fun test59() {
val initials = intArrayOf(4, 5, 8, 2)
val kthLargest = KthLargest(initials, 3)
printlnResult(kthLargest)
kthLargest.add(3)
printlnResult(kthLargest)
kthLargest.add(5)
printlnResult(kt... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 994 | Algorithm | Apache License 2.0 |
src/main/kotlin/leetcode/kotlin/binarysearch/69. Sqrt(x).kt | sandeep549 | 251,593,168 | false | null | package leetcode.kotlin.binarysearch
/**
* I understand that square root finding is complex problem and it require a through study for some mathematics algorithms,
* But as question does not need exact decimal points and aproximation, we can stick to this descrition and write simple algorithms.
* PS: Though I under... | 0 | Kotlin | 0 | 0 | 9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b | 1,291 | kotlinmaster | Apache License 2.0 |
src/main/adventofcode/Day12Solver.kt | eduardofandrade | 317,942,586 | false | null | package adventofcode
import adventofcode.Day12Solver.Action.*
import java.io.InputStream
import java.util.stream.Collectors
import kotlin.math.abs
class Day12Solver(stream: InputStream) : Solver {
private val processedInput: List<ShipMove>
init {
processedInput = processInput(stream)
}
priv... | 0 | Kotlin | 0 | 0 | 147553654412ae1da4b803328e9fc13700280c17 | 3,786 | adventofcode2020 | MIT License |
src/test/kotlin/adventofcode/day12/Day12.kt | jwcarman | 573,183,719 | false | {"Kotlin": 183494} | /*
* Copyright (c) 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 i... | 0 | Kotlin | 0 | 0 | d6be890aa20c4b9478a23fced3bcbabbc60c32e0 | 3,391 | adventofcode2022 | Apache License 2.0 |
csp-sudoku/src/main/kotlin/com/tsovedenski/csp/sudoku/Sudoku.kt | RedShuhart | 152,120,429 | false | null | package com.tsovedenski.csp.sudoku
import com.tsovedenski.csp.*
import kotlin.math.roundToInt
import kotlin.math.sqrt
/**
* Created by <NAME> on 15/10/2018.
*
* listOf(
* "12xx5xxx9",
* "x3x9xx4x8",
* ...
* )
*/
data class Sudoku (val grid: List<String>, val placeholder: Char = 'x') : Solvable<... | 0 | Kotlin | 1 | 4 | 29d59ec7ff4f0893c0d1ec895118f961dd221c7f | 2,731 | csp-framework | MIT License |
atcoder/arc158/e_slow.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package atcoder.arc158
fun main() {
readLn()
val top = readInts()
val bottom = readInts()
val inf = Long.MAX_VALUE / 4
data class Score(val score: Long, val improve: Long)
fun solve(from: Int, to: Int): Modular1 {
if (from + 1 == to) {
return (top[from] + bottom[from]).toModular() * 3.toModularUnsafe()
}
... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 4,167 | competitions | The Unlicense |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxConsecutiveAnswers.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,880 | kotlab | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2021/Day23.kt | colinodell | 433,864,377 | true | {"Kotlin": 111114} | package com.colinodell.advent2021
import java.util.*
import kotlin.Comparator
import kotlin.collections.HashSet
import kotlin.math.absoluteValue
import kotlin.math.max
import kotlin.math.min
// Adapted from https://github.com/schovanec/AdventOfCode/blob/master/2021/Day23/Program.cs
class Day23(input: List<String>) {
... | 0 | Kotlin | 0 | 1 | a1e04207c53adfcc194c85894765195bf147be7a | 5,807 | advent-2021 | Apache License 2.0 |
year2016/src/main/kotlin/net/olegg/aoc/year2016/day3/Day3.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2016.day3
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.year2016.DayOf2016
/**
* See [Year 2016, Day 3](https://adventofcode.com/2016/day/3)
*/
object Day3 : DayOf2016(3) {
private val DIGITS = "\\d+".toRegex()
override fun first(): Any? {
return lines
.map { lin... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,174 | adventofcode | MIT License |
src/day03/Day03.kt | molundb | 573,623,136 | false | {"Kotlin": 26868} | package day03
import readInput
fun main() {
val input = readInput(parent = "src/Day03", name = "Day03_input")
println(solvePartOne(input))
println(solvePartTwo(input))
}
private fun solvePartTwo(input: List<String>): Int {
var sum = 0
var teamCount = 0
val charsInFirst = mutableSetOf<Char>()... | 0 | Kotlin | 0 | 0 | a4b279bf4190f028fe6bea395caadfbd571288d5 | 1,748 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/days/Day22.kt | andilau | 399,220,768 | false | {"Kotlin": 85768} | package days
@AdventOfCodePuzzle(
name = "<NAME>",
url = "https://adventofcode.com/2020/day/22",
date = Date(day = 22, year = 2020)
)
class Day22(val lines: List<String>) : Puzzle {
override fun partOne(): Int {
val deck1: Deck = readDeckOf("Player 1")
val deck2: Deck = readDeckOf("Play... | 7 | Kotlin | 0 | 0 | 2809e686cac895482c03e9bbce8aa25821eab100 | 2,252 | advent-of-code-2020 | Creative Commons Zero v1.0 Universal |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.