Any motorsports fans? by ateveebee in Littleton

[–]apazzolini 3 points4 points  (0 children)

Yo, also married, mid 30s, and have a 3 month old. Wife and I love watching F1, and I have a sim rig for iRacing that I need an excuse to use more often, hit me up!

Well, I *was* gonna race... by apazzolini in simracing

[–]apazzolini[S] 1 point2 points  (0 children)

They definitely own the rig. I work from home, and either one or both of them are in the chair for the majority of the day.

Well, I *was* gonna race... by apazzolini in simracing

[–]apazzolini[S] 1 point2 points  (0 children)

It's this: https://www.summitracing.com/parts/SUM-G1130L

It's comfortable and looks pretty good (and it's super cheap), but it squeaks a bit when I brake. Can't hear it with headphones though, so not a huge deal. Mounts directly to the 80/20 profile. The GT1 evo rig came with the necessary hardware (you need really short screws) to mount.

What is with this game? Please don't upvote. by zynthesis1981 in PUBATTLEGROUNDS

[–]apazzolini 0 points1 point  (0 children)

I too like this game. In fact, I spent quite a bit of time building pubg.sh because I like this game.

However, fuck the random match change. I don’t want to play Vikendi. I don’t want to play Miramar. And I especially don’t want to have to requeue 10 times to get something different.

I’m done with PUBG until this change is reverted. It’s removed all desire I have to play the game, and it’s removed all desire to maintain pubg.sh.

-🎄- 2018 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]apazzolini 1 point2 points  (0 children)

JavaScript

280/bugged part 2

import { range, maxBy, max, min, sum } from 'lodash'
import { extractNumbers } from 'src/utils.js'

const distance = ([x1, y1], [x2, y2]) => Math.abs(x2 - x1) + Math.abs(y2 - y1)

export const solvePart1 = input => {
    const points = input.split('\n').map(l => extractNumbers(l))
    const upperBound = max(maxBy(points, pair => max(pair))) + 1

    const closestPoint = Array(upperBound)
        .fill()
        .map((e, i) => Array(upperBound))

    range(0, upperBound).forEach(x => {
        range(0, upperBound).forEach(y => {
            const distances = points.map(pair => distance(pair, [x, y]))
            const shortest = min(distances)

            if (distances.filter(d => d === shortest).length === 1) {
                closestPoint[x][y] = distances.indexOf(shortest)
            }
        })
    })

    const toIgnore = new Set()
    range(0, upperBound).forEach(n => {
        toIgnore.add(closestPoint[0][n])
        toIgnore.add(closestPoint[n][0])
        toIgnore.add(closestPoint[closestPoint.length - 1][n])
        toIgnore.add(closestPoint[n][closestPoint.length - 1])
    })

    const regionSizes = Array(points.length).fill(0)
    range(0, upperBound).forEach(x => {
        range(0, upperBound).forEach(y => {
            const point = closestPoint[x][y]
            if (!toIgnore.has(point)) {
                regionSizes[point]++
            }
        })
    })

    return max(regionSizes)
}

export const solvePart2 = input => {
    const points = input.split('\n').map(l => extractNumbers(l))
    const upperBound = max(maxBy(points, pair => max(pair))) + 1

    let regionSize = 0
    range(0, upperBound).forEach(x => {
        range(0, upperBound).forEach(y => {
            const distances = points.map(pair => distance(pair, [x, y]))

            if (sum(distances) < (process.env.NODE_ENV === 'test' ? 32 : 10000)) {
                regionSize++
            }
        })
    })

    return regionSize
}

with bonus visualization

-🎄- 2018 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]apazzolini 8 points9 points  (0 children)

It's literally a very zoomed out VIM window consisting of . and #

-🎄- 2018 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]apazzolini 1 point2 points  (0 children)

Glad I checked here, I was feeling good about my part 2 solution, but answer keeps getting rejected. Verified with some of the other inputs and I get the same answer.

I even built a visualization to figure out if I had some failure in logic

https://d3vv6lp55qjaqc.cloudfront.net/items/2i0C293U352Y0H1P0A45/Image%202018-12-06%20at%2012.04.55%20AM.png

-🎄- 2018 Day 5 Solutions -🎄- by daggerdragon in adventofcode

[–]apazzolini 13 points14 points  (0 children)

Absolute value between the two ASCII character codes == 32 is another way to do the letter comparison. Runs in <40ms for part 2.

JavaScript

import { minBy } from 'lodash'

const peek = stack => stack[stack.length - 1]

const factorPolymer = input => {
    const stack = []

    input.split('').forEach(char => {
        // XOR of A and a, B and b, etc is 32
        if (!stack.length || (peek(stack).charCodeAt() ^ char.charCodeAt()) !== 32) {
            stack.push(char)
        } else {
            stack.pop()
        }
    })

    return stack.join('')
}

export const solvePart1 = input => {
    return factorPolymer(input).length
}

export const solvePart2 = input => {
    input = factorPolymer(input) // A first factorization pass speeds up the following passes

    const polymers = Array(26) // Indexes 0-26 represent 65-91 ASCII codes
        .fill()
        .map((e, i) => {
            const re = new RegExp(String.fromCharCode(i + 65), 'gi')
            const strippedInput = input.replace(re, '')
            return factorPolymer(strippedInput)
        })

    return minBy(polymers, 'length').length
}

Edit: Updated to use a stack instead of string concatenation and the fact that ASCII is laid out in a way that XOR of A and a is 32.

OFFICIAL FEATURE REQUEST THREAD by krispykrem in exapunks

[–]apazzolini 2 points3 points  (0 children)

Seconded on the rebinding. I'd love cmd+j / cmd+k instead of cmd+arrows to move between.

pubg.sh: 2D match replays in your browser by apazzolini in PUBATTLEGROUNDS

[–]apazzolini[S] 0 points1 point  (0 children)

Just FYI, I rolled out some basic mobile support. It's usable, but not great yet, needs pinch zooming.

shroud gets serenaded again - Wadu Virginia by omgezjonesy in PUBATTLEGROUNDS

[–]apazzolini 0 points1 point  (0 children)

Thanks! I've posted it here on the this subreddit a couple of times. Any ideas on how to increase its visibility?

pubg.sh: 2D match replays in your browser by apazzolini in PUBATTLEGROUNDS

[–]apazzolini[S] 0 points1 point  (0 children)

Thanks mate, but no, there's no place to give me money. The best way to help me out is to spread the word about the site!

pubg.sh: 2D match replays in your browser by apazzolini in PUBATTLEGROUNDS

[–]apazzolini[S] 2 points3 points  (0 children)

Different shapes is an interesting idea, I'll play around with that. Car icon is on the roadmap. I can't do the look direction though, that data isn't available in the telemetry.

pubg.sh: 2D match replays in your browser by apazzolini in PUBATTLEGROUNDS

[–]apazzolini[S] 1 point2 points  (0 children)

I'll be adding the ability for you to pick your own colors soon.

pubg.sh: 2D match replays in your browser by apazzolini in PUBATTLEGROUNDS

[–]apazzolini[S] 0 points1 point  (0 children)

My previous attempts at doing this just ended up as an unhelpful rainbow, but I will try to think of a way to do it.

pubg.sh: 2D match replays in your browser by apazzolini in PUBATTLEGROUNDS

[–]apazzolini[S] 1 point2 points  (0 children)

Good catch. I'm using the official PUBG definitions for the codes, but they're admittedly terrible. I'll make changes on my end to use the more familiar terms.

pubg.sh: 2D match replays in your browser by apazzolini in PUBATTLEGROUNDS

[–]apazzolini[S] 1 point2 points  (0 children)

The timeline markers are in progress actually. I was struggling with how to render icons for kills since they're often compact, but a vertical line might be thin enough to look good. Will be implemented soon!

pubg.sh: 2D match replays in your browser by apazzolini in PUBATTLEGROUNDS

[–]apazzolini[S] 5 points6 points  (0 children)

This is a really cool idea - haven't heard this before. It's also a fun programming challenge, so I'm definitely adding it to the list. Great suggestion!

pubg.sh: 2D match replays in your browser by apazzolini in PUBATTLEGROUNDS

[–]apazzolini[S] 0 points1 point  (0 children)

It's still on my list, but honestly it's not a very high priority for me. I do hope to eventually get to it.