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/com/nibado/projects/advent/y2017/Day25.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2017 import com.nibado.projects.advent.Day import com.nibado.projects.advent.Direction import com.nibado.projects.advent.collect.LList import com.nibado.projects.advent.resourceLines object Day25 : Day { private val input = resourceLines(2017, 25).map { it.trim() }.filterNot { ...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
3,146
adventofcode
MIT License
src/leetcode/aprilChallenge2020/weekone/MaxSubArray.kt
adnaan1703
268,060,522
false
null
package leetcode.aprilChallenge2020.weekone import kotlin.math.max fun main() { println(maxSubArray(intArrayOf(-2, 1, -3, 4, -1, 2, 1, -5, 4))) println(maxSubArray(intArrayOf(-2, -1, -3, -4, -1, -2, -1, -5, -4))) println(maxSubArray(intArrayOf(1, 2, 3, 4, 5))) println(maxSubArray(intArrayOf(-11))) ...
0
Kotlin
0
0
e81915db469551342e78e4b3f431859157471229
2,115
KotlinCodes
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/MatrixReshape.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,314
kotlab
Apache License 2.0
src/main/kotlin/me/circuitrcay/euler/challenges/twentySixToFifty/Problem43.kt
adamint
134,989,381
false
null
package me.circuitrcay.euler.challenges.twentySixToFifty import me.circuitrcay.euler.Problem class Problem43 : Problem<String>() { override fun calculate(): Any { val nums = mutableListOf<Long>() // d1 can be any number // d4 can be 0, 2, 4, 6, or 8 // d6 can be either 0 or 5 ...
0
Kotlin
0
0
cebe96422207000718dbee46dce92fb332118665
3,823
project-euler-kotlin
Apache License 2.0
src/main/kotlin/day02/Day02.kt
daniilsjb
434,765,082
false
{"Kotlin": 77544}
package day02 import java.io.File fun main() { val data = parse("src/main/kotlin/day02/Day02.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 02 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[Part 2]") println("...
0
Kotlin
0
1
bcdd709899fd04ec09f5c96c4b9b197364758aea
1,695
advent-of-code-2021
MIT License
app/src/main/kotlin/com/resurtm/aoc2023/day17/Solution.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day17 import java.util.PriorityQueue import kotlin.math.min import kotlin.system.measureTimeMillis fun launchDay17(testCase: String) { val grid = readInputGrid(testCase) val iters = 10 var part1 = 0 val part1msec = measureTimeMillis { repeat(iters) { pa...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
5,323
advent-of-code-2023
MIT License
kotlin/17.kt
NeonMika
433,743,141
false
{"Kotlin": 68645}
import kotlin.math.max import kotlin.math.min import kotlin.math.sign class Day17 : Day<Day17.Target>("17") { data class Target(val x: IntRange, val y: IntRange) data class Projectile(val xVel: Int, val yVel: Int, val x: Int = 0, val y: Int = 0) { fun step() = Projectile( x + xVel, ...
0
Kotlin
0
0
c625d684147395fc2b347f5bc82476668da98b31
1,540
advent-of-code-2021
MIT License
src/main/kotlin/com/github/dangerground/aoc2020/Day2.kt
dangerground
317,439,198
false
null
package com.github.dangerground.aoc2020 import com.github.dangerground.aoc2020.util.DayInput class Day2 { fun isPasswordMatchingByCount(pwAndPolicy: PasswordAndPolicy): Boolean { val count = getPasswordLength(pwAndPolicy) return count >= pwAndPolicy.num1 && count <= pwAndPolicy.nu...
0
Kotlin
0
0
c3667a2a8126d903d09176848b0e1d511d90fa79
2,001
adventofcode-2020
MIT License
src/processor/Main.kt
JIghtuse
262,494,294
false
null
package processor fun toIntList(s: String): List<Int> { return s.split(" ").filter { it.isNotEmpty() }.map { it.toInt() } } fun toDoubleList(s: String): List<Double> { return s.split(" ").filter { it.isNotEmpty() }.map { it.toDouble() } } class Matrix(val items: Array<List<Double>>) { val rows: Int = ite...
0
Kotlin
0
0
15f4e0d745a3e6814f783bf215786366d9dfeb9e
3,293
numeric-matrix-processor
MIT License
src/main/kotlin/days/Day19.kt
andilau
433,504,283
false
{"Kotlin": 137815}
package days import kotlin.math.absoluteValue @AdventOfCodePuzzle( name = "Beacon Scanner", url = "https://adventofcode.com/2021/day/19", date = Date(day = 19, year = 2021) ) class Day19(val input: String) : Puzzle { private val scanners = input.parse() private val alignedScanner: List<Scanner> by...
0
Kotlin
0
0
b3f06a73e7d9d207ee3051879b83e92b049a0304
4,253
advent-of-code-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/RotateFunction.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,416
kotlab
Apache License 2.0
src/main/kotlin/days/Day5.kt
mir47
433,536,325
false
{"Kotlin": 31075}
package days import kotlin.math.absoluteValue class Day5 : Day(5) { override fun partOne(): Int { var size = 0 val coords = inputList .map { it.replace(" -> ", ",") } .map { it.split(",") } .map { val x1 = it[0].toInt() val y1 = ...
0
Kotlin
0
0
686fa5388d712bfdf3c2cc9dd4bab063bac632ce
4,891
aoc-2021
Creative Commons Zero v1.0 Universal
src/leetcode_study_badge/data_structure/Day1.kt
faniabdullah
382,893,751
false
null
package leetcode_study_badge.data_structure import java.util.* class Day1 { fun singleNumber(nums: IntArray): Int { /* https://leetcode.com/problems/single-number/ TC: O(N) SC: O(1) // XOR of A XOR A = 0, so all duplicates will cancel each other, ...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,684
dsa-kotlin
MIT License
src/Day05.kt
RaspiKonk
572,875,045
false
{"Kotlin": 17390}
import java.lang.Integer.max /** * Day 5: Pakete mit dem Kran umschichten * * Part 1: Wie sind die Buchstaben der obersten Paketreihe nach dem Umschichten? Kran kann nur 1 Kiste aufnehmen. * Part 2: Kran kann auch mhrere Kisten aufnehmen. */ fun main() { val start = System.currentTimeMillis() val DAY: String =...
0
Kotlin
0
1
7d47bea3a5e8be91abfe5a1f750838f2205a5e18
4,332
AoC_Kotlin_2022
Apache License 2.0
src/main/kotlin/File07.kt
andrewrlee
319,095,151
false
null
import java.io.File import java.nio.charset.StandardCharsets.UTF_8 private class Challenge07 { data class Bag(val description: String, val quantity: Int, val children: List<Bag> = emptyList()) { constructor(args: List<String>) : this(args[2], args[1].toInt()) companion object { val fu...
0
Kotlin
0
0
a9c21a6563f42af7fada3dd2e93bf75a6d7d714c
1,903
adventOfCode2020
MIT License
Kotlin/src/NextPermutation.kt
TonnyL
106,459,115
false
null
/** * Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. * * If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order). * * The replacement must be in-place, do not allocate extra memory. ...
1
Swift
22
189
39f85cdedaaf5b85f7ce842ecef975301fc974cf
1,241
Windary
MIT License
src/tsp/Distance.kt
dbcorish
394,464,582
false
{"Kotlin": 19701}
package tsp import kotlin.math.sqrt /** * Handles all distance calculations */ object Distance { /** * Calculates total distance of journey */ fun total(tempSolutionAr: IntArray) : Double { var totalDistance = 0.0 for (i in 0 until numberOfCities - 1) { cit...
0
Kotlin
0
0
c0e6f74f431dcc37890ab07835bd7e9979296beb
2,351
kotlin-tsp-solver
MIT License
src/Day07_part1.kt
lowielow
578,058,273
false
{"Kotlin": 29322}
fun main() { fun part1(input: List<String>): Int { val dir = mutableListOf<String>() val list = mutableListOf<MutableList<String>>() var rawList = mutableListOf<String>() val dirRegex = Regex("\\$ cd ([a-z]+|/)") val listRegex = Regex("^([a-z]*\\d*) ([a-z][.a-z]*)$") ...
0
Kotlin
0
0
acc270cd70a8b7f55dba07bf83d3a7e72256a63f
2,460
aoc2022
Apache License 2.0
src/aoc2022/Day04.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 fun main() { fun String.splitElves() = this.split(',').map { elf -> val (startSection, endSection) = elf.split('-').map { it.toInt() } startSection..endSection } fun part1(input: List<String>): Int = input.count { assignmentPair -> val (firstElf, secondElf) = ass...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
1,132
Kotlin-AOC-2023
Apache License 2.0
src/Day03.kt
alexladeira
573,196,827
false
{"Kotlin": 3920}
fun main() { val sum = part2() print(sum) } private fun part2() = readInput("Day03").chunked(3).fold(0) { acc, strings -> val lowerCaseRange = CharProgression.fromClosedRange('a', 'z', 1) strings[0].find { c -> strings[1].contains(c) && strings[2].contains(c) }.let { c -> if (lowerCaseRange.con...
0
Kotlin
0
0
facafc2d92de2ad2b6264610be4159c8135babcb
839
aoc-2022-in-kotlin
Apache License 2.0
aoc_2023/src/main/kotlin/problems/day24/HailSimulator.kt
Cavitedev
725,682,393
false
{"Kotlin": 228779}
package problems.day24 import com.microsoft.z3.Context import com.microsoft.z3.Status import java.math.BigDecimal import java.math.MathContext class HailSimulator(lines: List<String>) { val hailstones = lines.map { line -> val (cord, mov) = line.split("@").map { val splits = it.split(",").map...
0
Kotlin
0
1
aa7af2d5aa0eb30df4563c513956ed41f18791d5
10,845
advent-of-code-2023
MIT License
app/src/main/java/com/fq/algorithm/Graph.kt
lodqc
682,931,448
false
null
package com.fq.algorithm import java.util.LinkedList import java.util.PriorityQueue import java.util.Queue class Graph { var nodes: HashMap<Int, Node> = HashMap() var edges: HashSet<Edge> = HashSet() } class Node(var value: Int) { var `in` = 0 var out = 0 var nexts: ArrayList<Node> = ArrayList() ...
0
Kotlin
0
0
bb50160451db7ca86eabe51478afa3e1f5c95e9b
5,474
algorithm
Apache License 2.0
stepik/sportprogramming/RecursiveComivoigerSolution.kt
grine4ka
183,575,046
false
{"Kotlin": 98723, "Java": 28857, "C++": 4529}
package stepik.sportprogramming private var a: Array<IntArray> = emptyArray() private var ans: Int = Int.MAX_VALUE private var ansPerm: String = "" private var p: IntArray = intArrayOf() private var used: BooleanArray = booleanArrayOf() private var n: Int = 0 fun main() { n = readInt() a = Array(n) { ...
0
Kotlin
0
0
c967e89058772ee2322cb05fb0d892bd39047f47
1,099
samokatas
MIT License
app/src/main/java/com/example/algoview/ui/algoview/Graph.kt
youness-1
544,147,511
false
{"Kotlin": 28008}
package com.example.algoview.ui.algoview import java.util.* import kotlin.math.abs import kotlin.math.sqrt class Edge(var destination: Vertex, var weight: Double) class Vertex( var id: Int, var i: Int, var j: Int ) : Comparable<Vertex> { var parent: Vertex? = null var distance = Double.POSITIVE_INFINI...
0
Kotlin
0
0
f420e99ebe2636f4152392784eb7caf1ede23434
1,704
AlgoView
Creative Commons Zero v1.0 Universal
src/Day01.kt
Qdelix
574,590,362
false
null
fun main() { fun part1(input: List<String>): Int { var highestSum = 0 var actualSum = 0 input.forEach { inputLine -> if (inputLine.isNotEmpty()) { actualSum += inputLine.toInt() } else { if (actualSum > highestSum) { ...
0
Kotlin
0
0
8e5c599d5071d9363c8f33b800b008875eb0b5f5
1,351
aoc22
Apache License 2.0
plugin/src/main/kotlin/com/jraska/module/graph/GraphvizWriter.kt
dafi
230,582,038
true
{"Kotlin": 20110}
package com.jraska.module.graph object GraphvizWriter { fun toGraphviz(dependencyGraph: DependencyGraph, groups: Set<String> = emptySet()): String { val longestPathConnections = dependencyGraph.longestPath() .nodeNames.zipWithNext() .toSet() val stringBuilder = StringBuilder() stringBuilde...
0
Kotlin
0
0
eee1159f56e7f8389f411b415b3a390c341e9dec
1,631
modules-graph-assert
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[18]四数之和.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* import kotlin.collections.ArrayList //给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d ,使得 a + b + c + // d 的值与 target 相等?找出所有满足条件且不重复的四元组。 // // 注意:答案中不可以包含重复的四元组。 // // // // 示例 1: // // //输入:nums = [1,0,-1,0,-2,2], target = 0 //输出:[[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]] // // // 示...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
2,654
MyLeetCode
Apache License 2.0
src/main/kotlin/io/github/alexandrepiveteau/datalog/core/interpreter/database/RulesDatabase.kt
alexandrepiveteau
607,114,441
false
null
package io.github.alexandrepiveteau.datalog.core.interpreter.database import io.github.alexandrepiveteau.datalog.core.rule.CombinationRule import io.github.alexandrepiveteau.datalog.core.rule.Rule /** * An intentional database, with predicate derivation rules. Each set of rules is associated with a * predicate and ...
3
Kotlin
0
2
68f3e2d43c866d2057a0231188175c31b2f26940
1,640
epfl-datalog-kotlin
MIT License
aoc2020kot/src/main/kotlin/main.kt
fasiha
365,094,027
false
null
import kotlin.math.PI import kotlin.math.cos import kotlin.math.roundToInt import kotlin.math.sin // From https://stackoverflow.com/a/53018129 fun getResourceAsText(path: String): String { return object {}.javaClass.getResource(path)?.readText() ?: throw Exception("Unable to read file") } fun getResourceAsBytes(p...
0
Kotlin
0
0
59edfcbdf03ebff3250b9c4d535d1e80e5ba5398
26,226
advent-of-code-2020
The Unlicense
code/day_05/src/jvm8Main/kotlin/task2.kt
dhakehurst
725,945,024
false
{"Kotlin": 105846}
package day_05 fun task2(lines: List<String>) = task2_3(lines) // just iterate for a long time ;-) fun task2_1(lines: List<String>):Long { val seeds = lines[0].substringAfter(":").split(" ").mapNotNull { it.trim().toLongOrNull() } val seeds2 = mutableListOf<LongRange>() var i = 0 while(i < seeds.size)...
0
Kotlin
0
0
be416bd89ac375d49649e7fce68c074f8c4e912e
3,722
advent-of-code
Apache License 2.0
src/main/kotlin/com/hopkins/aoc/day18/main.kt
edenrox
726,934,488
false
{"Kotlin": 88215}
package com.hopkins.aoc.day18 import com.hopkins.aoc.day17.Point import java.io.File const val debug = true const val part = 2 /** Advent of Code 2023: Day 18 */ fun main() { // Step 1: Read the file input val lines: List<String> = File("input/input18.txt").readLines() if (debug) { println("Step ...
0
Kotlin
0
0
45dce3d76bf3bf140d7336c4767e74971e827c35
4,824
aoc2023
MIT License
src/main/kotlin/LangDecoder.kt
nmicra
262,980,033
false
null
/** * Given map is how to encode any character in alphabet. * Write a decode function, that will return all possible variant that can be encoded for a given string * Example: for a given string "12", possible values [ab,l] * for "1213" --> [abac, abm, auc, lac, lm] */ val map = mapOf( "a" to "1", "b" to "2", ...
0
Kotlin
0
0
4bf80f01af6c4a08221131878b7d53e2826db241
1,984
kotlin_practice
Apache License 2.0
src/aoc2021/Day02.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2021 import readInput fun main() { val (year, day) = "2021" to "Day02" data class State( private val hasAim: Boolean = false, var horizontal: Int = 0, var depth: Int = 0, var aim: Int = 0 ) { fun move(direction: String, x: Int) = if (hasAim) { ...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
1,485
aoc-kotlin
Apache License 2.0
src/main/kotlin/Day11.kt
SimonMarquis
434,880,335
false
{"Kotlin": 38178}
import Neighborhood.Moore class Day11(val raw: List<String>) { private val cavern: Cavern get() = raw.toCavern() fun part1(): Int = with(cavern) { (1..100).sumOf { step() } } fun part2(): Int = with(cavern) { generateSequence(1) { it.inc() }.first { st...
0
Kotlin
0
0
8fd1d7aa27f92ba352e057721af8bbb58b8a40ea
1,542
advent-of-code-2021
Apache License 2.0
src/Day08.kt
benwicks
572,726,620
false
{"Kotlin": 29712}
fun main() { fun constructTreeGrid(input: List<String>) = arrayOf<IntArray>( *input.map { it.map { char -> char.code - 48 }.toIntArray() }.toTypedArray() ) fun isVisibleFromLeft(treeGrid: Array<IntArray>, x: Int, y: Int): Boolean { val interiorTreeHeight = treeGrid[y][x] val row...
0
Kotlin
0
0
fbec04e056bc0933a906fd1383c191051a17c17b
4,592
aoc-2022-kotlin
Apache License 2.0
src/aoc2021/day02/Code.kt
ldickmanns
572,675,185
false
{"Kotlin": 48227}
package aoc2021.day02 import readInput fun main() { val input = readInput("aoc2021/day02/input") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { var horizontalPosition = 0 var depth = 0 input.forEach { line: String -> when { "forward" i...
0
Kotlin
0
0
2654ca36ee6e5442a4235868db8174a2b0ac2523
1,389
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/g1201_1300/s1263_minimum_moves_to_move_a_box_to_their_target_location/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1201_1300.s1263_minimum_moves_to_move_a_box_to_their_target_location // #Hard #Array #Breadth_First_Search #Matrix #Heap_Priority_Queue // #2023_06_08_Time_183_ms_(100.00%)_Space_36.4_MB_(100.00%) import java.util.LinkedList import java.util.Queue class Solution { private var n = 0 private var m = 0...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,981
LeetCode-in-Kotlin
MIT License
src/main/java/sudoku/Sudoku.kt
ununhexium
125,272,921
false
null
package sudoku data class Grid(val given: List<List<Int>>) data class Guess(val position: Pair<Int,Int>, val number:Int) data class Proposal(val original:Sudoku, val proposition: List<Guess>) fun main(args: Array<String>) { // val grid1 = parse() } typealias Sudoku = List<List<Int>> fun parse(text: List<String>)...
0
Kotlin
0
0
11aca6b37e06fe1e8ad31467703dacf857332825
2,700
samples
The Unlicense
src/tommyred/days/Day2.kt
TommyRed
113,504,972
false
null
package cz.tommyred.days /** * Created by Rechtig on 06.12.2017. */ val sample = "5 1 9 5\n7 5 3\n2 4 6 8" val hardInput = "4347 3350 196 162 233 4932 4419 3485 4509 4287 4433 4033 207 3682 2193 4223\n648 94 778 957 1634 2885 1964 2929 2754 89 972 112 80 2819 543 2820\n400 133 1010 918 1154 1008 126 150 1118 117 1...
0
Kotlin
0
0
2c8b7c58cad55f29c54f89ddb6e0636cc1030fad
1,811
AoC2017
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem1372/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1372 import com.hj.leetcode.kotlin.common.model.TreeNode /** * LeetCode page: [1372. Longest ZigZag Path in a Binary Tree](https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree/); */ class Solution { /* Complexity: * Time O(N) and Space O(H) where N and H ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,310
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/structures/GraphWithWeights.kt
DmitryTsyvtsyn
418,166,620
false
{"Kotlin": 223256}
package structures /** * * data structure: directed graph with weights * * description: made up of vertices connected by edges that have direction and weight * */ class GraphWithWeights<T> { private val data = linkedMapOf<Vertex<T>, MutableList<VertexConnection<T>>>() /** * adds a new vertex with...
0
Kotlin
135
767
7ec0bf4f7b3767e10b9863499be3b622a8f47a5f
3,289
Kotlin-Algorithms-and-Design-Patterns
MIT License
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day18.kt
jmerle
434,010,865
false
{"Kotlin": 60581}
package com.jaspervanmerle.aoc2021.day class Day18 : Day("4124", "4673") { private data class Element(var value: Int, var depth: Int) override fun solvePartOne(): Any { val numbers = input.lines().map { parseLine(it) } var result = numbers[0] for (number in numbers.drop(1)) { ...
0
Kotlin
0
0
dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e
3,405
advent-of-code-2021
MIT License
src/main/kotlin/co/csadev/advent2020/Day03.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2021 by <NAME> * Advent of Code 2020, Day 3 * Problem Description: http://adventofcode.com/2020/day/3 */ package co.csadev.advent2020 class Day03(private val input: List<String>) { private val width = input.first().length fun solvePart1(): Int = checkTrees(3 to 1) fun solvePart2(...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
901
advent-of-kotlin
Apache License 2.0
kotlin/src/main/kotlin/AoC_Day11.kt
sviams
115,921,582
false
null
object AoC_Day11 { data class Position(val x: Int, val y: Int) { fun distance(): Int { val absX = Math.abs(x) val absY = Math.abs(y) return if (absX < absY) Math.ceil((absY-absX).toDouble()/2).toInt() + absX else absX } } data class State(val pos: Positio...
0
Kotlin
0
0
19a665bb469279b1e7138032a183937993021e36
1,146
aoc17
MIT License
src/Day06_part1.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { fun part1(input: String): Int { val inArr = input.toCharArray() val map = mutableMapOf<Char, Int>() for (i in inArr.indices) { map[inArr[i]] = map.getOrDefault(inArr[i], 0) + 1 if (i - 4 >= 0) { map[inArr[i - 4]] = map.getOrDefault(inArr[i...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
864
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g1701_1800/s1761_minimum_degree_of_a_connected_trio_in_a_graph/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1701_1800.s1761_minimum_degree_of_a_connected_trio_in_a_graph // #Hard #Graph #2023_06_18_Time_590_ms_(50.00%)_Space_80_MB_(100.00%) class Solution { fun minTrioDegree(n: Int, edges: Array<IntArray>): Int { val degrees = IntArray(n + 1) val adjMatrix = Array(n + 1) { IntArray(n + 1) } ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,113
LeetCode-in-Kotlin
MIT License
src/main/kotlin/de/niemeyer/aoc2022/Day17.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
/** * Advent of Code 2022, Day 17: Pyroclastic Flow * Problem Description: https://adventofcode.com/2022/day/19 */ package de.niemeyer.aoc2022 import de.niemeyer.aoc.utils.Resources.resourceAsText import de.niemeyer.aoc.utils.getClassName // chamber is 7 units wide // rock appears so that its left edge is two uni...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
7,695
AoC-2022
Apache License 2.0
src/main/kotlin/com/kylecorry/sol/math/statistics/Statistics.kt
kylecorry31
294,668,785
false
{"Kotlin": 714099, "Java": 18119, "Python": 298}
package com.kylecorry.sol.math.statistics import com.kylecorry.sol.math.RoundingMethod import com.kylecorry.sol.math.SolMath import com.kylecorry.sol.math.SolMath.lerp import com.kylecorry.sol.math.SolMath.round import com.kylecorry.sol.math.SolMath.square import com.kylecorry.sol.math.Vector2 import com.kylecorry.sol...
11
Kotlin
4
8
ac1e4f9b3635e7b50a9668f74c9303c0152c94ce
7,773
sol
MIT License
src/main/kotlin/be/amedee/adventofcode/aoc2015/day01/Day01.kt
amedee
160,062,642
false
{"Kotlin": 9459, "Markdown": 7503}
package be.amedee.adventofcode.aoc2015.day01 import java.io.BufferedReader import java.io.InputStreamReader /** * Single move to the next floor, up or down. * * @return do we go up or down */ fun move(): (String) -> Int = { when (it) { "(" -> 1 ")" -> -1 else -> 0 ...
0
Kotlin
0
1
02e8e0754f2252a2850175fc8b134dd36bc6d042
2,058
adventofcode
MIT License
src/main/kotlin/g1401_1500/s1405_longest_happy_string/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1401_1500.s1405_longest_happy_string // #Medium #String #Greedy #Heap_Priority_Queue // #2023_06_07_Time_119_ms_(100.00%)_Space_33.7_MB_(100.00%) class Solution { fun longestDiverseString(a: Int, b: Int, c: Int): String { val sb = StringBuilder() val remains = intArrayOf(a, b, c) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,495
LeetCode-in-Kotlin
MIT License
Algorithms_and_data_structures/ex01/ex.kt
Hasuk1
740,111,124
false
{"Kotlin": 120039}
import kotlin.math.pow import kotlin.math.sqrt fun main() { println(calculateTotalPoints(readInput())) } fun readInput(): List<Pair<Double, Double>> { val points = mutableListOf<Pair<Double, Double>>() for (i in 1..3) { val (x, y) = readLine()!!.split(" ").map { it.toDouble() } points.add(x to y) } ...
0
Kotlin
0
1
1dc4de50dd3cd875e3fe76e3da4a58aa04bb87c7
667
Kotlin_bootcamp
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/IncreasingSubsequences.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,708
kotlab
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MergeKLists.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,754
kotlab
Apache License 2.0
year2020/src/main/kotlin/net/olegg/aoc/year2020/day4/Day4.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2020.day4 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.toPair import net.olegg.aoc.year2020.DayOf2020 /** * See [Year 2020, Day 4](https://adventofcode.com/2020/day/4) */ object Day4 : DayOf2020(4) { private val HEIGHT_PATTERN = "^([0-9]+)(cm|in)$".toRegex() private ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,739
adventofcode
MIT License
src/main/kotlin/dev/luna5ama/palbreed/BreedCalculator.kt
Luna5ama
753,934,567
false
{"Kotlin": 5433}
package dev.luna5ama.palbreed import java.util.TreeMap class BreedCalculator(passiveData: List<Pal.Passive>, speciesData: List<Pal.Species>) { private val breedValueMap = TreeMap<Int, Pal.Species>() private val indexOrderMap = TreeMap<Int, Pal.Species>() private val passiveNameMap = passiveData.associateB...
0
Kotlin
0
1
2e16010ae6144f11f4531d6b7f60ee57c02219e0
4,162
pal-breed
MIT License
2022/08/08.kt
LiquidFun
435,683,748
false
{"Kotlin": 40554, "Python": 35985, "Julia": 29455, "Rust": 20622, "C++": 1965, "Shell": 1268, "APL": 191}
fun main() { val s = generateSequence(::readlnOrNull).toList() val indices = (0..s.size-1).toList() val visible: MutableSet<Pair<Int, Int>> = mutableSetOf() var highest: Int for (i in indices) { for (order in listOf(indices, indices.reversed())) { highest = 0 for (x...
0
Kotlin
7
43
7cd5a97d142780b8b33b93ef2bc0d9e54536c99f
1,455
adventofcode
Apache License 2.0
year2016/src/main/kotlin/net/olegg/aoc/year2016/day22/Day22.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2016.day22 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2016.DayOf2016 /** * See [Year 2016, Day 22](https://adventofcode.com/2016/day/22) */ object Day22 : DayOf2016(22) { val PATTERN = "/dev/grid/node-x(\\d+)-y(\\d+)\\s+(\\d+)T\\s+(\\d+)T\\s+(\\d+)T\\s+(\\d+)%".toRegex...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,394
adventofcode
MIT License
codeforces/globalround8/e.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.globalround8 private fun solve(out: List<MutableList<Int>>): String { val layer = IntArray(out.size) for (u in out.indices) { if (layer[u] == 2) continue for (v in out[u]) layer[v] = maxOf(layer[v], layer[u] + 1) } val ans = layer.indices.filter { layer[it] == 2 } return "${ans.size}\n${ans...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
838
competitions
The Unlicense
2017/src/main/kotlin/Day16.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import utils.splitCommas import utils.toIntList object Day16 { fun part1(programs: String, instructions: String): String { return dance(programs, parseInstructions(instructions)) } fun part2(initialPrograms: String, inputInstructions: String, times: Int): String { val instructions = parseInstructions(i...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
2,783
advent-of-code
MIT License
src/main/kotlin/year_2023/Day01.kt
krllus
572,617,904
false
{"Kotlin": 97314}
package year_2023 import Day import solve class Day01 : Day(day = 1, year = 2023, "Trebuchet?!") { override fun part1(): Int { return input.sumOf { val a = it.first { c: Char -> c.isDigit() }.digitToInt() val b = it.last { c: Char -> c.isDigit() }.digitToInt() a * 10 +...
0
Kotlin
0
0
b5280f3592ba3a0fbe04da72d4b77fcc9754597e
1,678
advent-of-code
Apache License 2.0
src/main/kotlin/eu/michalchomo/adventofcode/year2023/Day10.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2023 import eu.michalchomo.adventofcode.Day import eu.michalchomo.adventofcode.main import eu.michalchomo.adventofcode.toCharMatrix object Day10 : Day { override val number: Int = 10 private const val IN_CHAR = 'I' private const val OUT_CHAR = 'O' override fu...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
5,061
advent-of-code
Apache License 2.0
advent-of-code/src/main/kotlin/com/akikanellis/adventofcode/year2022/Day11.kt
akikanellis
600,872,090
false
{"Kotlin": 142932, "Just": 977}
package com.akikanellis.adventofcode.year2022 object Day11 { fun monkeyBusinessLevel(input: String, rounds: Int, itemDivisor: Int): Long { val monkeysWithoutHighWorryLevelItemDivisor = input .split("\n\n") .map { Monkey( monkeyLines = it.lines(), ...
8
Kotlin
0
0
036cbcb79d4dac96df2e478938de862a20549dce
3,998
advent-of-code
MIT License
src/main/kotlin/Day13.kt
pavittr
317,532,861
false
null
import java.io.File import java.nio.charset.Charset import kotlin.concurrent.thread import kotlin.math.absoluteValue import kotlin.streams.toList fun main() { val testDocs = File("test/day13").readLines(Charset.defaultCharset()) val puzzles = File("puzzles/day13").readLines(Charset.defaultCharset()) fun ...
0
Kotlin
0
0
3d8c83a7fa8f5a8d0f129c20038e80a829ed7d04
3,182
aoc2020
Apache License 2.0
Практика 1/Coding/src/main/kotlin/Main.kt
ArtyomKopan
691,592,839
false
{"Kotlin": 5782}
import java.nio.file.Files import java.nio.file.Path fun coding(grammar: List<String>): Map<String, Int> { val codes = mutableMapOf( ":" to 1, "(" to 2, ")" to 3, "." to 4, "*" to 5, ";" to 6, "," to 7, "#" to 8, "[" to 9, "]" to 10, ...
1
Kotlin
0
0
7aa1075078a87b474097872bced3050eb9628deb
3,575
Formal_Languages
MIT License
src/Day04.kt
annagergaly
572,917,403
false
{"Kotlin": 6388}
fun main() { fun part1(input: List<String>): Int { return input.map { val n = it.split("[,-]".toRegex()).map { it.toInt() } (n[0] <= n[2] && n[1] >= n[3]) || (n[2] <= n[0] && n[3] >= n[1]) }.count { it } } fun part2(input: List<String>): Int { return input.ma...
0
Kotlin
0
0
89b71c93e341ca29ddac40e83f522e5449865b2d
613
advent-of-code22
Apache License 2.0
coins.kt
LaraEstudillo
753,726,266
false
{"Kotlin": 1056}
import kotlin.collections.listOf var amount = 11 var result: ArrayList<CoinsAndQuantity> = ArrayList() fun main() { println(minCoins()) } fun minCoins() { val coins = listOf(1,2,5).sorted() val suma = coins.sum(); if(suma == amount) { println(suma); return; } calculation(c...
0
Kotlin
0
0
b710f683d826f5d1b15702be5e3f0d7c7dc6a2d3
1,056
coins_challenge_1
Apache License 2.0
src/main/kotlin/day11.kt
tianyu
574,561,581
false
{"Kotlin": 49942}
import assertk.assertThat import assertk.assertions.containsExactly import assertk.assertions.isEmpty import assertk.assertions.isEqualTo private fun main() { tests { "Parse monkeys" { val monkey = monkeys("day11-example.txt")[0] assertThat(monkey.items).containsExactly(79.toWorry(), 98.toWorry()) ...
0
Kotlin
0
0
6144cc0ccf1a51ba2e28c9f38ae4e6dd4c0dc1ea
4,291
AdventOfCode2022
MIT License
src/main/java/challenges/cracking_coding_interview/sorting_and_searching/introduction/BinarySearch.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.sorting_and_searching.introduction object BinarySearch { private fun binarySearch(a: IntArray, x: Int): Int { var low = 0 var high = a.size - 1 var mid: Int while (low <= high) { mid = low + (high - low) / 2 if (a...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
1,983
CodingChallenges
Apache License 2.0
src/Day06.kt
benwicks
572,726,620
false
{"Kotlin": 29712}
const val numUniqueCharsInStartOfPacketMarker = 4 const val numUniqueCharsInStartOfMessageMarker = 14 fun main() { fun findEndPositionOfMarker(input: String, numUniqueCharsInStartMarker: Int): Int { var mostRecentUniqueChars = mutableListOf<Char>() input.forEachIndexed { index, c -> val...
0
Kotlin
0
0
fbec04e056bc0933a906fd1383c191051a17c17b
1,351
aoc-2022-kotlin
Apache License 2.0
src/chapter2/section3/QuickSort.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter2.section3 import chapter2.compare import chapter2.section1.displaySortingProcessTemplate import chapter2.swap import edu.princeton.cs.algs4.StdRandom /** * 快速排序基础实现 * * 具体实现为:从第二个值开始向右循环,找到一个大于第一个值的位置 * 从末尾向左循环,找到一个小于第一个值的位置,交换两个位置上的值 * 继续循环,直到左右两侧相遇,数组遍历完成 * 交换左侧的第一位和最后一位,以左侧最后一位为分界线,左边都小于等于它,右...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,833
Algorithms-4th-Edition-in-Kotlin
MIT License
Coding Challenges/Advent of Code/2021/Day 3/part2.kt
Alphabeater
435,048,407
false
{"Kotlin": 69566, "Python": 5974}
import java.io.File import kotlin.math.pow fun getNewList(list: List<String>, position: Int, criteria: Char, length: Int): List<String> { if (list.size == 1) return list val criteriaBit = getBit(list, position, criteria) //get the new criteria bit which will determine the new list for the next step of the recu...
0
Kotlin
0
0
05c8d4614e025ed2f26fef2e5b1581630201adf0
1,999
Archive
MIT License
src/main/kotlin/days/Day4.kt
sicruse
315,469,617
false
null
package days class Day4 : Day(4) { private val passports: List<Map<String, String>> by lazy { inputString // split the input at blank lines to form record text blocks .split("\\n\\n".toRegex()) .map { record -> // for every record text block gather the f...
0
Kotlin
0
0
9a07af4879a6eca534c5dd7eb9fc60b71bfa2f0f
3,398
aoc-kotlin-2020
Creative Commons Zero v1.0 Universal
app/src/main/kotlin/com/resurtm/aoc2023/day18/Part2Good.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day18 import kotlin.math.abs /** * https://en.wikipedia.org/wiki/Shoelace_formula * https://artofproblemsolving.com/wiki/index.php/Shoelace_Theorem */ fun solvePart2Good(moves: List<Move>): Long { val lines = mutableListOf<Line>() val vertices = mutableListOf<Pos>() var bord...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
1,203
advent-of-code-2023
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[86]分隔链表.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给你一个链表和一个特定值 x ,请你对链表进行分隔,使得所有小于 x 的节点都出现在大于或等于 x 的节点之前。 // // 你应当保留两个分区中每个节点的初始相对位置。 // // // // 示例: // // //输入:head = 1->4->3->2->5->2, x = 3 //输出:1->2->2->4->3->5 // // Related Topics 链表 双指针 // 👍 334 👎 0 //leetcode submit region begin(Prohibit modification and deletion) /** * Example: * var li = ListN...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,441
MyLeetCode
Apache License 2.0
src/main/kotlin/g0401_0500/s0436_find_right_interval/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0401_0500.s0436_find_right_interval // #Medium #Array #Sorting #Binary_Search #Binary_Search_II_Day_11 // #2022_12_22_Time_333_ms_(100.00%)_Space_49.7_MB_(90.00%) import java.util.function.Function class Solution { private fun findminmax(num: Array<IntArray>): IntArray { var min = num[0][0] ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,173
LeetCode-in-Kotlin
MIT License
src/year2022/Day09.kt
Maetthu24
572,844,320
false
{"Kotlin": 41016}
package year2022 import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { return buildSet { var tailX = 0 var tailY = 0 var headX = 0 var headY = 0 add(Pair(tailX, tailY)) for ((dir, n) in input.map { Pair(it.split(" ...
0
Kotlin
0
1
3b3b2984ab718899fbba591c14c991d76c34f28c
5,174
adventofcode-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/exercises/SumsToTarget.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
1,920
kotlab
Apache License 2.0
src/main/kotlin/twentytwentytwo/Day10.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
package twentytwentytwo fun main() { val input = {}.javaClass.getResource("input-10.txt")!!.readText().linesFiltered { it.isNotEmpty() }; val day = Day10(input) println(day.part1()) println(day.part2()) } class Day10(private val input: List<String>) { fun part1(): Int { var cycle = 0 ...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
1,778
aoc202xkotlin
The Unlicense
aoc-2022/src/main/kotlin/nerok/aoc/aoc2022/day01/Day01.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2022.day01 import nerok.aoc.utils.Input import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun part1(input: List<String>): Long { var max = 0L var current = 0L for (item in input) { current = ( item.toLongOrNull()?.p...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
1,400
AOC
Apache License 2.0
LeetCode/0088. Merge Sorted Array/Solution.kt
InnoFang
86,413,001
false
{"C++": 501928, "Kotlin": 291271, "Python": 280936, "Java": 78746, "Go": 43858, "JavaScript": 27490, "Rust": 6410}
/** * 59 / 59 test cases passed. * Status: Accepted * Runtime: 557 ms */ class Solution { fun merge(nums1: IntArray, m: Int, nums2: IntArray, n: Int): Unit { val nums3 = IntArray(m + n) var i = 0 var j = 0 var k = 0 while (i < m + n) { if (j < m && k < n && nu...
0
C++
8
20
2419a7d720bea1fd6ff3b75c38342a0ace18b205
1,183
algo-set
Apache License 2.0
day22/src/main/kotlin/de/havox_design/aoc2023/day22/Brick.kt
Gentleman1983
715,778,541
false
{"Kotlin": 163912, "Python": 1048}
package de.havox_design.aoc2023.day22 data class Brick(val startPosition: Triple<Int, Int, Int>, val endPosition: Triple<Int, Int, Int>) { val fallen: Brick get() = Brick( Triple(startPosition.x(), startPosition.y(), startPosition.z() - 1), Triple(endPosition.x()...
1
Kotlin
0
0
eac8ff77420f061f5cef0fd4b8d05e7805c4cc5a
1,953
aoc2023
Apache License 2.0
core-kotlin-modules/core-kotlin-collections-map/src/test/kotlin/com/baeldung/map/theMaxEntry/FindMaxEntryInMapUnitTest.kt
Baeldung
260,481,121
false
{"Kotlin": 1476024, "Java": 43013, "HTML": 4883}
package com.baeldung.map.theMaxEntry import org.junit.jupiter.api.Test import kotlin.test.assertEquals class FindMaxEntryInMapUnitTest { val skillMap = mapOf( "Kai" to "Kotlin, typescript, Javascript, C, C++", "Saajan" to "Java, C, Python, Ruby, Shell, Go", "Eric" to "Kotlin, Java, C, Python, Ru...
10
Kotlin
273
410
2b718f002ce5ea1cb09217937dc630ff31757693
2,047
kotlin-tutorials
MIT License
src/2023/Day06.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2023` import java.io.File import java.util.* import kotlin.math.sqrt fun main() { Day06().solve() } class Day06 { val input1 = """ Time: 7 15 30 Distance: 9 40 200 """.trimIndent() val input2 = """ """.trimIndent() fun solve() { val f ...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
1,872
advent-of-code
Apache License 2.0
src/main/kotlin/io/korti/adventofcode/day/DayThree.kt
korti11
225,589,330
false
null
package io.korti.adventofcode.day import java.lang.Integer.sum import kotlin.math.abs class DayThree : AbstractDay() { override fun getDay(): Int { return 3 } override fun getSubLevels(): Int { return 1 } override fun run(input: List<String>): String { val wireOne = mutab...
0
Kotlin
0
0
410c82ef8782f874c2d8a6c687688716effc7edd
2,448
advent-of-code-2019
MIT License
src/Day14.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { fun addVerticalLine(lines: HashMap<Int, MutableList<Pair<Int, Int>>>, column: Int, from: Int, to: Int) { if (from > to) { addVerticalLine(lines, column, to, from) return } val existing = lines[column] ?: mutableListOf() existing.add(Pair(from, to)...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
4,544
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Problem2.kt
jimmymorales
496,703,114
false
{"Kotlin": 67323}
import kotlin.system.measureNanoTime /** * Even Fibonacci numbers * * Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the * first 10 terms will be: * * 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... * * By considering the...
0
Kotlin
0
0
e881cadf85377374e544af0a75cb073c6b496998
1,270
project-euler
MIT License
src/main/kotlin/Example2/Example2.kt
thomasnield
116,161,739
false
null
package Example2 import org.ojalgo.optimisation.ExpressionsBasedModel import org.ojalgo.optimisation.Variable import java.util.concurrent.atomic.AtomicInteger // declare ojAlgo Model val model = ExpressionsBasedModel() // custom DSL for Example3.getModel expression inputs, eliminate naming and adding val funcId = At...
0
Kotlin
0
4
ae3822b00e459c9d65d1b637811635ae3da820cc
2,735
ojalgo_abstract_examples
Apache License 2.0
src/Day01.kt
ajesh-n
573,125,760
false
{"Kotlin": 8882}
fun main() { fun part1(input: String): Int { val elvesTotalFood = input.split("\n\n").map { it.split("\n").sumOf { calories -> calories.toInt() } } return elvesTotalFood.max() } fun part2(input: String): Int { return input.split("\n\n").map { it.split("\n").sumOf { calor...
0
Kotlin
0
0
2545773d7118da20abbc4243c4ccbf9330c4a187
680
kotlin-aoc-2022
Apache License 2.0
src/questions/SymmetricTree.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import questions.common.TreeNode import utils.shouldBe import java.util.* /** * Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). * * [Source](https://leetcode.com/problems/symmetric-tree/) */ @Use...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
5,518
algorithms
MIT License
src/main/kotlin/aoc23/Day16.kt
tahlers
725,424,936
false
{"Kotlin": 65626}
package aoc23 import io.vavr.kotlin.hashSet import io.vavr.kotlin.toVavrSet import io.vavr.collection.Set as VavrSet object Day16 { enum class Direction { UP, LEFT, DOWN, RIGHT } data class Pos(val x: Int, val y: Int) { fun newPos(dir: Direction): Pos = when (dir) { ...
0
Kotlin
0
0
0cd9676a7d1fec01858ede1ab0adf254d17380b0
4,841
advent-of-code-23
Apache License 2.0
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/day16/FFT.kt
jrhenderson1988
289,786,400
false
{"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37}
package com.github.jrhenderson1988.adventofcode2019.day16 import kotlin.math.abs class FFT(private val signal: List<Int>, private val repetitions: Int = 1) { fun signalAt(phases: Int, offset: Int, length: Int = 8): List<Int> { val repeated = (0 until repetitions).map { signal }.flatten().drop(offset) ...
0
Kotlin
0
0
7b56f99deccc3790c6c15a6fe98a57892bff9e51
1,610
advent-of-code
Apache License 2.0
src/main/kotlin/net/voldrich/aoc2021/Day17.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2021 import net.voldrich.BaseDay import kotlin.math.abs import kotlin.math.max // https://adventofcode.com/2021/day/17 fun main() { Day17().run() } class Day17 : BaseDay() { override fun task1() : Int { val canon = ProbeCanon(input.lines()[0]) return canon.findHighestS...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
3,947
advent-of-code
Apache License 2.0
src/main/kotlin/com/frankandrobot/rapier/nlp/generalize.patterns.kt
frankandrobot
62,833,944
false
null
/* * Copyright 2016 <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 ...
1
Kotlin
1
1
ddbc0dab60ca595e63a701e2f8cd6694ff009adc
5,377
rapier
Apache License 2.0
src/main/kotlin/day7/SomeAssemblyRequired.kt
SaujanShr
685,121,393
false
null
package day7 import day7.GateType.* import getInput val INPUT = getInput("day7") fun run1(): String { val circuit = getCircuit(INPUT) val wires = getWires(circuit) processSignals(wires) val signals = getSignals(wires) return signals["a"]!!.toString() } fun run2(): String { val circuit = get...
0
Kotlin
0
0
c6715a9570e62c28ed022c5d9b330a10443206c4
2,802
adventOfCode2015
Apache License 2.0
src/main/kotlin/com/staricka/adventofcode2022/Day18.kt
mathstar
569,952,400
false
{"Kotlin": 77567}
package com.staricka.adventofcode2022 import com.staricka.adventofcode2022.Day18.Cube.Companion.parseCube class Day18 : Day { override val id = 18 data class Cube(val x: Int, val y: Int, val z: Int) { val neighbors by lazy { listOf( Cube(x - 1, y, z), Cube(x + 1, y, z), Cube(x, ...
0
Kotlin
0
0
2fd07f21348a708109d06ea97ae8104eb8ee6a02
1,928
adventOfCode2022
MIT License
dynamic_programming/highest_route/HighestRouteValue.kt
YaroslavHavrylovych
78,222,218
false
{"Java": 284373, "Kotlin": 35978, "Shell": 2994}
/** * TODO it's an old implementation I did which is not * dynamic programming approach. I hope soon I would replace that with the new * solution (today I'm focused on java). * <br/> * Check README to find the description. */ class HighestRouteValue { fun calculate(cell: Coordinate): Int { return next...
0
Java
0
2
cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd
2,027
codility
MIT License
AdventOfCodeDay13/src/nativeMain/kotlin/Day13.kt
bdlepla
451,510,571
false
{"Kotlin": 165771}
class Day13(private val lines:List<String>) { fun solvePart1():Int { val (points, folds) = parseInput(lines) val matrix = Matrix.create(points) val newMatrix = folds.take(1).foldMatrix(matrix) return newMatrix.allPointValues().count { it } } fun solvePart2():String { ...
0
Kotlin
0
0
1d60a1b3d0d60e0b3565263ca8d3bd5c229e2871
4,800
AdventOfCode2021
The Unlicense
core/src/main/kotlin/org/eln2/space/Location.kt
resnidar
403,165,234
true
{"Kotlin": 328082, "Nix": 4408, "Java": 3507}
package org.eln2.space import kotlin.math.abs /** * A vector in a two-dimensional space of integers. */ data class Vec2i(val x: Int, val y: Int) { /** * Gets the opposite vector. */ operator fun unaryMinus() = Vec2i(-x, -y) /** * Gets the sum of this vector and another vector. */ ...
0
Kotlin
1
0
d1fa0e39bf4008e459936ef789d76f5cc9662413
11,060
eln2
MIT License
src/main/kotlin/17.kts
reitzig
318,492,753
false
null
@file:Include("shared.kt") import java.io.File enum class GridElement(val rep: Char) { Active('#'), Inactive('.'); companion object { fun valueOfRep(rep: Char): GridElement = values().firstOrNull { it.rep == rep } ?: throw IllegalArgumentException("No element with rep ...
0
Kotlin
0
0
f17184fe55dfe06ac8897c2ecfe329a1efbf6a09
3,495
advent-of-code-2020
The Unlicense
2023/src/main/kotlin/de/skyrising/aoc2023/day4/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2023.day4 import de.skyrising.aoc.* val test = TestInput(""" Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53 Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19 Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1 Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83 Card 5: 87 83 26 ...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
904
aoc
MIT License