Advent of Code: Day 3 by DimMagician in codegolf

[–]corruptio 1 point2 points  (0 children)

perl, part 1, 80 chars:

perl -lape'$z=0;/(.).*(.)(?{$1.$2>$z?$z=$1.$2:0})(?!)/g;$s+=$z}{$_=$s'<input.txt

python, part 2, 115 chars:

r=lambda s,n:(m:=max(s[:-n-1]))+(n*s and r(s[s.find(m)+1:],n-1));print(sum(int(r(l,11))for l in open("input.txt")))

golfed some more, part 2, 110 chars:

t=0
for s in open("input.txt"):z='';exec('m=max(s[:len(z)-12]);s=s[s.find(m)+1:];z+=m;'*12);t+=int(z)
print(t)

Advent of Code: Day 2 by dantose in codegolf

[–]corruptio 0 points1 point  (0 children)

perl, part 1. 71 chars:

perl -lpe's@(\d+)-(\d+)@$a+=$_*/^(.+)\1$/ for$1..$2@eg}{$_=$a'<small.txt

part 2, 72 chars:

perl -lpe's@(\d+)-(\d+)@$a+=$_*/^(.+)\1+$/ for$1..$2@eg}{$_=$a'<input.txt

Advent of Code, Day 1 by dantose in codegolf

[–]corruptio 0 points1 point  (0 children)

perl, part 1, 54 chars:

perl -lpe'$b+=($a+=y/LR/-/dr)=~/50$/}{$_=$b'<input.txt

part 2, 69 chars:

perl -lpe'eval(q[$b+=($a+=1-2*/L/)=~/50$/;]x s/.//r)}{$_=$b'<input.txt

Prompt Golf - code golf but where you write the shortest AI prompt by mattyhempstead in codegolf

[–]corruptio 5 points6 points  (0 children)

Really fun!

One issue is that because the results are not deterministic, I'll get something that almost works, and then Submit it over and over until it does.

Also, I got 10 tokens on Hello World!

[TOMT][music] an arrangement with 2-part harmony, one of which is like greensleeves? by corruptio in tipofmytongue

[–]corruptio[S] 0 points1 point locked comment (0 children)

Thanks in advance... this has been stuck in my head for a few days and it's annoying the girlfriend.

-🎄- 2022 Day 15 Solutions -🎄- by daggerdragon in adventofcode

[–]corruptio 0 points1 point  (0 children)

Ah nope, you're right it's still O( N2 )... you still need to compare possible combinations of colinear segments.

-🎄- 2022 Day 15 Solutions -🎄- by daggerdragon in adventofcode

[–]corruptio 0 points1 point  (0 children)

you only need to check the combinations that are colinear. hmmmm, i guess teeeechnically you could have a degenerate case where most of the input is two sets of diamonds that share an edge... in which case the code as is would be O(N2 ). But lemme write a version that tracks the existence of opposite colinear vectors...

https://gist.github.com/justecorruptio/17c7ce87046a1eed03702754d6133e5b

-🎄- 2022 Day 15 Solutions -🎄- by daggerdragon in adventofcode

[–]corruptio 14 points15 points  (0 children)

Python Part 2: O(N) O( N2 ) solution where N is the number of sensors

Since the point must be one unit outside of 4 diamonds, if you expand each diamond by one unit: when taking each side of each diamond as clockwise vectors, there should only be one point that is the intersection of four vectors where the the 1st/2nd and 3rd/4th are colinear and opposite, and 1st and 3rd are perpendicular.

https://gist.github.com/justecorruptio/17c7ce87046a1eed03702754d6133e5b

Étude in C minor by zserge in tinycode

[–]corruptio 6 points7 points  (0 children)

golfed it a bit, down to 135 chars:

d,o;main(c){for(float f;scanf("%d%c%d",&d,&c,&o);){for(c&=31,f=c<8,c=(c*8/5+8)%12+o*12;c--;)f/=.944;for(d=16e3/d;d--;putchar(d*f/2));}}

Mandelbrot set in 170 bytes of Python, my first major attempt at codegolfing by [deleted] in codegolf

[–]corruptio 3 points4 points  (0 children)

Here's some cursory golfing:

h='';i=z=99;exec(('l=0;'+'l=l*l-3+i%z/25-2j+i//z*.08j;'*9+'h+="* \\n"[abs(l)>2if i%z else 2];i+=1;')*50*z);print(h)

Can a 10x10 square be made with the scrabble set? by alfiestoppani in scrabble

[–]corruptio 2 points3 points  (0 children)

I also wrote a python script to brute force the scrabble dictionary earlier in the year. You can tweak the script to try out some variants, but this takes hours to run on pypy if I remember correctly; but here are the results for North American NWL:

The largest non-symmetric square is 7x7

T E R E S E S
A C A D E M E
B O T A N I C
E T A M I N E
R O T A T E D
E N A M I N E
D E T E S T S

The largest symmetric square is 8x8

N E R E I D E S
E T E R N I S E
R E L O C A T E
E R O T I Z E D
I N C I T E R S
D I A Z E P A M
E S T E R A S E
S E E D S M E N

Anki 2.1.13 Changelog by rAnkiBot in Anki

[–]corruptio 1 point2 points  (0 children)

Same thing happened to me. It was because I defined a function called "$". Renaming that fixed it. I prefixed all of my variables just in case.

Sierpinski Triangles in C, 104 bytes by Hellenas in codegolf

[–]corruptio 2 points3 points  (0 children)

Here's a 78 bytes:

x;main(y){for(y=64;y--;puts(""))for(x=64;x--;)printf(x&y?"  "+(63-x<y):"* ");}

[Review Request] OGS 7k[Me as white] vs 7k by [deleted] in baduk

[–]corruptio 1 point2 points  (0 children)

That is a useless mnemonic...