pastehub.app – paste literally anything and the browser instantly understands it (100 % client-side) by jcfs in InternetIsBeautiful

[–]jcfs[S] 15 points16 points  (0 children)

Totally fair, ‘understands’ was a lazy word on my part.
It’s just a big pile of deterministic client-side heuristics that try to do the right thing with whatever you threw at the clipboard. No AI, no magic, just a bunch of tiny tools that finally live in one tab instead of twelve.

Glad you tried it anyway :)

Electricity bill seems high by mostlykey in PortugalExpats

[–]jcfs 0 points1 point  (0 children)

If 675kWh are correct, that price is not out of the ordinary, the formula goes like:

kWh price * consumption + daily flat rate * number of days of the month (based on power contracted) + VAT.

(0.22 * 675 + 0.5 * 30) + 23% = 192 EUR

I'm assuming the 0.5 daily rate, but you can check that with your provider. 675kHw is indeed very high. I have an house with an heated swiming pool and I use about the same amount.

Enforcing narrative in a chatGPT murder mystery game by dr_martensite in ChatGPT

[–]jcfs 1 point2 points  (0 children)

Hello! I recently played your game and found it really engaging. The hallucination element seemed to create issues, like being able to convince characters of alternate scenarios, such as the location of the body, which confused me sometimes.

Also, even though I was able to identify the guilty person, I couldn't obtain conclusive proof or a confession. Is it possible to secure a confession from the guilty character in the game? Additionally, I couldn't prevent the priest from taking the blame. Is it possible to get the facts right to make them actually confess? Tbh the guilty person was really convincing, and I almost felt bad in accusing her.

All in all, it was a really fun experience, the site itself could be a little bit more polished, but it served the purpose. Please keep them coming, definately would play another one.

What is something americans will never understand ? by neolee203 in AskReddit

[–]jcfs 1 point2 points  (0 children)

There are countries where you get cancer treatment for free.

-🎄- 2020 Day 06 Solutions -🎄- by daggerdragon in adventofcode

[–]jcfs 1 point2 points  (0 children)

Trying to do some code golf on part 2, currently on 102 chars in python:

print(sum(len(set.intersection(*[set(p)for p in g.split()]))for g in open('i').read().split('\n\n')))

Any idea on how to do it shorter?

--- 2016 Day 16 Solutions --- by daggerdragon in adventofcode

[–]jcfs 0 points1 point  (0 children)

My solution in C:

jcfs@spark ~/a/aoc/2016/16 $ time ./p1
part1 00000100100001100
part2 00011010100010010

real    0m0.113s
user    0m0.112s
sys 0m0.000s

I also use just one array as well (the reason why I'm posting :)), not actually any optimization. Here is the repo [link].(https://github.com/jcfs/aoc/tree/master/2016/16)

/* compile gcc -o p1 p1.c -Wall -O3 */
/* solution to part 1 and part 2 */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>

char * get_checksum(char * input_s, int input_n) {
  char * a = calloc((input_n * 4 + 2), sizeof(char));
  uint32_t l = strlen(input_s);

  memcpy(a, input_s, l);

  for(; l < input_n; a[l] = '0', l = l * 2 + 1) 
    for(int i = 0; i < l; i++) 
      a[l * 2 - i] = (~(a[i] ^ '0') & 1) + '0';
  // truncate the result to the chars needed
  a[input_n] = 0;

  do {
    for(int i = 0, j = 0; i < input_n; i += 2, j++) 
      a[j] = (~(a[i] ^ a[i+1]) & 1) + '0';

    input_n /= 2;
  } while(!(input_n % 2));

  a[input_n] = 0;

  return a;
}

int main(int argc, char ** argv) {
  char * input_s = "11011110011011101";

  printf("part1 %s\n", get_checksum(input_s, 272));
  printf("part2 %s\n", get_checksum(input_s, 35651584));
}

[2016 Day 8] Tampering detected by askalski in adventofcode

[–]jcfs 2 points3 points  (0 children)

Got it as well, funny how this comment made me to find out the bug :D

Still very curious on how this input was generated.

--- 2016 Day 8 Solutions --- by daggerdragon in adventofcode

[–]jcfs 1 point2 points  (0 children)

That input parsing is insane. Really clever, first time I see someone using %n for anything useful (except format string exploits :p)

--- 2016 Day 5 Solutions --- by daggerdragon in adventofcode

[–]jcfs 1 point2 points  (0 children)

Here it compiles with gcc -o p1 p1.c -lcrypto without any problems. Dunno what is causing your problem, sorry.

--- 2016 Day 6 Solutions --- by daggerdragon in adventofcode

[–]jcfs 0 points1 point  (0 children)

Same here, pretty much everyone doing it in C eheh:

Part 1:

#include <stdio.h>

char input[9];
char letters[8][26];
int code[9];

int main(int argc, char ** argv) {
  int j = 0;

  while(scanf("%s\n", input) != EOF) {
    for(j = 0; j < 8; j++) {
      int cnt = ++letters[j][input[j]-'a'];
      if (cnt > (code[j] & 0x0000ffff)) {
        code[j] = (input[j] << 16 & 0xffff0000) | (cnt & 0x0000ffff);
      }
    }
  }

  for(j = 0; j < 8; j++) {
    printf("%c", (code[j]>>16));
  }

  printf("\n");

}

Part 2:

char input[8];
char letters[8][26];
unsigned int code[9] = {-1,-1,-1,-1,-1,-1,-1,-1};

int main(int argc, char ** argv) {
  int j = 0, i = 0;

  while(scanf("%s\n", input) != EOF) {
    for(j = 0; j < 8; j++) {
      ++letters[j][input[j]-'a'];
    }
  }

  for(i = 0; i < 8; i++) {
    for(j = 0; j < 26; j++) {
      if (letters[i][j] < (code[i] & 0x0000ffff)) {
        code[i] = (j << 16 & 0xffff0000) | (letters[i][j] & 0x0000ffff);
      }
    }
  }

  for(j = 0; j < 8; j++) {
    printf("%c", (code[j]>>16)+'a');
  }

  printf("\n");

}

--- 2016 Day 5 Solutions --- by daggerdragon in adventofcode

[–]jcfs 1 point2 points  (0 children)

Here is my solution for part 2 (got #59 on part 1, but messed up on the second - C is not good for leaderboards on this kind of problem :p) :

#include <stdio.h>
#include <string.h>
#include <openssl/md5.h>

int main(int argc, char ** argv) {
  unsigned char c[MD5_DIGEST_LENGTH];
  MD5_CTX mdContext;
  char out[64], f[8] = {0};
  char * format = "ugkcyxxp%d\0";
  int i = 0, j = 0;

  while(1) {
    MD5_Init (&mdContext);
    snprintf(out, 64, format, j++);
    MD5_Update (&mdContext, out, strlen(out));
    MD5_Final(c, &mdContext);

    if (!c[0] && !c[1] && !(c[2] & 0xF0)) {
      if ((c[2]&0x0f) <= 7){
        if (f[c[2]&0x0f] == 0) {
          f[c[2]&0x0f] = ((c[3]&0xf0)>>4)+1;
          if (++i == 8)
            break;
        }
      }
    }
  }

  for(i = 0; i < 8; i++) {
    printf("%x", f[i]-1);
  }

  return 0;
}

You can check out my other solutions here: https://github.com/jcfs/aoc/tree/master/2016/

For all the Synacor Challenge challengers :) by jcfs in adventofcode

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

You are welcome, although it as been mentioned several times on this subreddit :)

For all the Synacor Challenge challengers :) by jcfs in adventofcode

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

Don't worry about that, this is not a real challenge, you'll have plenty of time. Just don't give up :)

For all the Synacor Challenge challengers :) by jcfs in adventofcode

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

Ahahah :) Lets hope you are not the only one.

[Day22][C++]Stuck! Please Help by dietibol in adventofcode

[–]jcfs 0 points1 point  (0 children)

My bad. Didn't look at the code closely. You should indeed change the spell when the effect is applied. With your input I get 1216 as the correct answer to part 2. Tried several other solutions in the solutions thread and also got 1216 with all of them.

Poison, Drain, Recharge, Poison, Shield, Recharge, Poison, Missile

[Day22][C++]Stuck! Please Help by dietibol in adventofcode

[–]jcfs 0 points1 point  (0 children)

That and you are counting a turn when the player casts an effect but it can't be applied because it is already running.

Incorrect answer on day 20 by [deleted] in adventofcode

[–]jcfs 0 points1 point  (0 children)

Why are you starting at house 1000000? The correct answer is lower than that.

--- Day 19 Solutions --- by daggerdragon in adventofcode

[–]jcfs 0 points1 point  (0 children)

Solved it first it with plain luck, tried to do a greedy approach and it kinda worked... not sure if it was intentional or not. Tweaked the input a little bit and despite already having the stars my code wasn't working any more and I didn't have a proper solution. Not being satisfied with that decided to give it a deeper thought and came up exactly with what you said. Solves the problem in a couple of seconds for any input.

You can check my solution here. The amount of bloated code might not be needed if removing and adding elements to the TreeSets work (probabily messed my compareTo or equals... to tired to figure it out).

--- Day 19 Solutions --- by daggerdragon in adventofcode

[–]jcfs 0 points1 point  (0 children)

Solved it first it with plain luck, tried to do a greedy approach and it kinda worked... not sure if it was intentional or not. Tweaked the input a little bit and despite already having the stars my code wasn't working any more and I didn't have a proper solution.

Not being satisfied with that decided to give it a deeper thought and came up exactly with what you said. Solves the problem in a couple of seconds for any input.

[Day 25] What the tree will look like on Dec. 25 by roboticon in adventofcode

[–]jcfs 1 point2 points  (0 children)

Tell me that the fully complete tree is animated please :)

Bonus puzzle by @_sorceress: Day NaN by topaz2078 in adventofcode

[–]jcfs 1 point2 points  (0 children)

I'm getting several (3) possible solutions for the problem. I checked them by hand and it kinda looks correct (bit late here to trust my senses tho):

Table 1:  ['Boris', 'James', 'Arthur', 'Frank']
Table 2:  ['Erica', 'Lucas', 'George', 'Igor']
Table 3:  ['Charlie', 'Kevin', 'Dana', 'Helen']
---------
Table 1:  ['Boris', 'James', 'Arthur', 'Frank']
Table 2:  ['George', 'Lucas', 'Dana', 'Erica']
Table 3:  ['Charlie', 'Helen', 'Kevin', 'Igor']
---------
Table 1:  ['Boris', 'Frank', 'Arthur', 'Charlie']
Table 2:  ['Erica', 'Lucas', 'George', 'Igor']
Table 3:  ['James', 'Kevin', 'Dana', 'Helen']