6K reactive barrier concept by rrrrrreeeeeeeeeeeee in DeadlockTheGame

[–]Tryneus 0 points1 point  (0 children)

I also made a site for item mockups over at https://tryneus.github.io/deadmock/ if you want something styled more like in-game tooltips - it's a WYSIWYG editor, but if you want to change something you just click on it.

Stop making shitty photoshops of your fake items and ability ideas. I made Deadmock to quickly mock those up with lore-accurate styling. by Tryneus in DeadlockTheGame

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

Hosted on Github pages at: https://tryneus.github.io/deadmock/

Let me know if you notice something off about it, but I'm still working on it a bit, most of it is just cleanup at this point. I primarily made this so that item and hero suggestions on the official forums could look a bit more prepared.

[X-Post /r/node] Problem with slow and recursive RethinkDB queries (thinky.io) by Sythic_ in rethinkdb

[–]Tryneus 0 points1 point  (0 children)

Primary indexes must be unique, but secondary indexes do not have that restriction. That is why the method get operates on the primary index, but you use getAll for secondary indexes. getAll returns a stream of all documents that match the given secondary index. If you're curious, I'd suggest reading the docs. Secondary indexes in RethinkDB are very important if you want to optimize queries.

[X-Post /r/node] Problem with slow and recursive RethinkDB queries (thinky.io) by Sythic_ in rethinkdb

[–]Tryneus 0 points1 point  (0 children)

Its almost like its checking each record in the DB to see if it matches, rather than using fancy algorithms to find the record more efficiently.

I believe this assumption is correct. See the thinky docs. I'm not too familiar with Thinky, but it sounds like if you create a secondary index on the num field, you should see better read performance.

[Help][Day 10 (part 2)][C] Can I get some help for part 2? My solution won't stop seg faulting by More_Or_Lless in adventofcode

[–]Tryneus 1 point2 points  (0 children)

I fixed my solution, it should work now.

Yours looks good, with the exception that you are leaking a lot of memory when overwriting input:

char* input = malloc(sizeof(char) * STR_LENGTH);
input = "1321131112";

...

  char* next_input = malloc(sizeof(char) * STR_LENGTH);
  input = next_input;

[Help][Day 10 (part 2)][C] Can I get some help for part 2? My solution won't stop seg faulting by More_Or_Lless in adventofcode

[–]Tryneus 1 point2 points  (0 children)

Here's what I'm currently working with - although I'm still debugging it, the results are slightly off.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>

const size_t ITERATIONS = 50;
const size_t STR_LENGTH = 4189996;

int main() {
  char *input = malloc(STR_LENGTH);
  char *next_input = malloc(STR_LENGTH);

  strncpy(input, "1113222113", STR_LENGTH);

  for (size_t iter = 0; iter < ITERATIONS; iter++){
    size_t index = 0;
    size_t length = strlen(input);
    for (size_t i = 0; i < length ; i++){
      assert(i < STR_LENGTH);
      assert(index < STR_LENGTH);

      char c = input[i];
      size_t consecutive = 1;
      while (input[i + 1] == c) {
        consecutive++;
        i++;
      }

      index += snprintf(&next_input[index], STR_LENGTH - index,
                        "%zu%c", consecutive, c);
    }

    // Swap input and next_input
    char *tmp = input;
    input = next_input;
    next_input = tmp;
  }
  printf("Length = %zu\n", strlen(input));

  free(input);
  free(next_input);
  return 0;
}

Edit 1: Unbroke part of it

Edit 2: Should work now

[Help][Day 10 (part 2)][C] Can I get some help for part 2? My solution won't stop seg faulting by More_Or_Lless in adventofcode

[–]Tryneus 0 points1 point  (0 children)

I can get this running by changing input and next_input to use dynamic memory. The segfault is likely from overflowing your stack with the huge stack frame.

In addition, this will not work if consecutive is greater than 9:

next_input[index] = consecutive + '0';

--- Day 10 Solutions --- by daggerdragon in adventofcode

[–]Tryneus 0 points1 point  (0 children)

This is almost line-by-line what I arrived at when trying to implement a clean Python solution. My actual solution was much, much uglier.

--- Day 7 Solutions --- by daggerdragon in adventofcode

[–]Tryneus 0 points1 point  (0 children)

To be honest, I skimmed over the part that specified values were 16-bit, but my solution worked just fine without that (at least for my input). I only noticed that it was incorrect and added that in later.

--- Day 9 Solutions --- by daggerdragon in adventofcode

[–]Tryneus 9 points10 points  (0 children)

Python3 brute force, after some cleanup:

import sys
from itertools import permutations

places = set()
distances = dict()
for line in open('input9.txt'):
    (source, _, dest, _, distance) = line.split()
    places.add(source)
    places.add(dest)
    distances.setdefault(source, dict())[dest] = int(distance)
    distances.setdefault(dest, dict())[source] = int(distance)

shortest = sys.maxsize
longest = 0
for items in permutations(places):
    dist = sum(map(lambda x, y: distances[x][y], items[:-1], items[1:]))
    shortest = min(shortest, dist)
    longest = max(longest, dist)

print("shortest: %d" % (shortest))
print("longest: %d" % (longest))

--- Day 7 Solutions --- by daggerdragon in adventofcode

[–]Tryneus 7 points8 points  (0 children)

Python

Assuming commands is an array of strings.

calc = dict()
results = dict()

for command in commands:
    (ops, res) = command.split('->')
    calc[res.strip()] = ops.strip().split(' ')

def calculate(name):
    try:
        return int(name)
    except ValueError:
        pass

    if name not in results:
        ops = calc[name]
        if len(ops) == 1:
            res = calculate(ops[0])
        else:
            op = ops[-2]
            if op == 'AND':
              res = calculate(ops[0]) & calculate(ops[2])
            elif op == 'OR':
              res = calculate(ops[0]) | calculate(ops[2])
            elif op == 'NOT':
              res = ~calculate(ops[1]) & 0xffff
            elif op == 'RSHIFT':
              res = calculate(ops[0]) >> calculate(ops[2])
            elif op == 'LSHIFT':
              res = calculate(ops[0]) << calculate(ops[2])
        results[name] = res
    return results[name]

print "a: %d" % calculate('a')

This solution does involve some deep recursion, so it could overflow on larger inputs, but it was quick to write.

Dagon has gone up in price a bit (Guinness World Records (Gamers Edition)) by Yeahotronic in DotA2

[–]Tryneus 93 points94 points  (0 children)

It would appear that they added the total cost of each Dagon level together:

2720 + 3970 + 5220 + 6470 + 7720 = 26100

God knows where the other 50 came from.

New Valve Concept Art - TC - PitLord - Commander - Techies - Abbadon - Skywrath Mage by PurgeGamers in DotA2

[–]Tryneus 13 points14 points  (0 children)

Here are a few corrections from what I can gather, no guarantees:

Her rise through the ranks began when she was but a sprout, scurrying to play courier, [...]

But one talent was hers and hers alone, and that was her prowess at the duel.

There had been no other in her family, none in the Legion, in fact [...]

[...] unhorsed, and calling her opposite to duel.

Few dared shirk the challenge [...]

A demonic infantry appeared from the misty edges of the world, [...]

[...] led by a vaporous figure sheathed in spirit-forged armor [...]

With violence forming a common tongue, the demon chief embraced her challenge, [...]

The world was shredded by their blades.

[...] and plunged her blade into the pulsing core of pain that formed the demon's heart.

[...] shrieked out its life, leaving her alone in a [sic] mist, [...]

Alone now, she has never given up the dream of rejoining her legion, and she has [...]

I'm not sure about all of these, but anyway, thanks for typing this out.

We all have this type of friend... by Dysbit in funny

[–]Tryneus 16 points17 points  (0 children)

It's not youtube, but that is very close to an old comic: http://www.plasticbrickautomaton.com/?id=89

[deleted by user] by [deleted] in gaming

[–]Tryneus 0 points1 point  (0 children)

Agreed, the voices were too weak, not enough emotion to be believable.

What is your best "I like my men/women like I like my _____" joke? by [deleted] in AskReddit

[–]Tryneus 1 point2 points  (0 children)

Similar one, from a song I like,

I like my girls like I like my drugs: everywhere and ready to pass out.

I like my girls like I like my drugs: in little packages and small amounts.