HunterRobot's recent activity

  1. Comment on Day 2: Gift Shop in ~comp.advent_of_code

    HunterRobot
    Link
    Trying to get a little bit of Kotlin experience in. Nice little indentation pyramid of doom in part 2, not exactly proud but it works. Part 1 data class Range(val start: Long, val end: Long) fun...

    Trying to get a little bit of Kotlin experience in. Nice little indentation pyramid of doom in part 2, not exactly proud but it works.

    Part 1
    data class Range(val start: Long, val end: Long)
    
    fun main() {
        val input = Files.readString(Path("src/main/resources/day2/input"))
    
        val ranges = input.split(',')
                .map { it.split('-') }
                .map { Range(it[0].toLong(), it[1].toLong()) }
        var invalidIdSum = 0L
    
        ranges.forEach { range ->
            for (id in range.start..range.end) {
                val number = id.toString()
                val midpoint = number.length / 2
                if (number.length % 2 == 0 && number.take(midpoint).toInt() == number.substring(midpoint).toInt()) {
                    invalidIdSum += id
                }
            }
        }
        println("Sum: $invalidIdSum")
    }
    
    Part 2
    data class Range(val start: Long, val end: Long)
    
    fun main() {
        val input = Files.readString(Path("src/main/resources/day2/input"))
    
        val ranges = input.split(',')
                .map { it.split('-') }
                .map { Range(it[0].toLong(), it[1].toLong()) }
        var invalidIdSum = 0L
    
        ranges.forEach { range ->
            rangeLoop@ for (id in range.start..range.end) {
                val idString = id.toString()
                for (patternSize in 1 .. idString.length / 2) {
                    if (idString.length % patternSize == 0) {
                        val chunked = idString.chunked(patternSize)
                        if (chunked.all { it == chunked[0] }) {
                            println("Found invalid id $id for pattern size $patternSize")
                            invalidIdSum += id
                            continue@rangeLoop
                        }
                    }
                }
            }
        }
        println("Sum: $invalidIdSum")
    }
    
    1 vote
  2. Comment on Is there a postman alternative without the bloat? in ~tech

    HunterRobot
    Link
    Personally I have been using Bruno, which is almost exactly Postman without al the collaboration or cloud stuff. If you want to share with your team the collection files can simply be shared.

    Personally I have been using Bruno, which is almost exactly Postman without al the collaboration or cloud stuff. If you want to share with your team the collection files can simply be shared.

    22 votes
  3. Comment on The great Tildes Archipelago multiworld randomizer! Interest thread! in ~games

    HunterRobot
    Link
    This sounds like a great way to experiment with randomised games, I'm very interested! Currently thinking maybe Pokemon, but I'll have another look at the list.

    This sounds like a great way to experiment with randomised games, I'm very interested! Currently thinking maybe Pokemon, but I'll have another look at the list.

    3 votes
  4. Comment on Thor Bjørklund's ostehøvel, a popular cheese slicer which developed into an important Norwegian export, celebrates 100 this year in ~engineering

    HunterRobot
    Link Parent
    I've always used this wired design cheese slicer growing up in the Netherlands, but I have yet to encounter someone who's heard of them before. I like them more for the typically softer Dutch...

    I've always used this wired design cheese slicer growing up in the Netherlands, but I have yet to encounter someone who's heard of them before. I like them more for the typically softer Dutch cheeses, although the wires do break from time to time.
    http://osti.dk/en/products/

    3 votes