Live data from Hacker News

Designing a programming language to speedrun Advent of Code

blog.vero.site

61–70 of 101 posts

Re: Designing a programming language to speedrun Advent of Code

#61
post #40

Earlier quoted context omitted.

Not sure if it would be considered simpler but lookaheads can be used to express it in a single pattern. ^(?=.{8}k.$)(?=[^a]*a[^a]*$)(?=[^b]*b[^b]*$)(?=[^c]*c[^c]*$)

It does lead to a very concise invocation: $ perl -ne 'print if /^(?=.{8}k.$)(?=[^a]*a[^a]*$)(?=[^b]*b[^b]*$)(?=[^c]*c[^c]*$)/' /usr/share/dict/words

  [me@fedora ~]$ time perl -ne 'print if /^(?=.{8}k.$)(?=[^a]*a[^a]*$)(?=[^b]*b[^b]*$)(?=[^c]*c[^c]*$)/' /usr/share/dict/words | wc -l
  17

  real 0m0,250s
  user 0m0,245s
  sys 0m0,006s

Re: Designing a programming language to speedrun Advent of Code

#62
post #55
post #40

Earlier quoted context omitted.

It does lead to a very concise invocation: $ perl -ne 'print if /^(?=.{8}k.$)(?=[^a]*a[^a]*$)(?=[^b]*b[^b]*$)(?=[^c]*c[^c]*$)/' /usr/share/dict/words

and to squash a little further: perl -ne '/^(?=([abc].*){3})(?!.*([abc]).*\2).{8}k.$/&&print' /usr/share/dict/words

Bug: 11 words are missing.

  [me@fedora ~]$ time perl -ne '/^(?=([abc].*){3})(?!.*([abc]).*\2).{8}k.$/&&print' /usr/share/dict/words | wc -l
  6

  real 0m0,118s
  user 0m0,112s
  sys 0m0,007s

Re: Designing a programming language to speedrun Advent of Code

#63

Earlier quoted context omitted.

grep { len($_) == 10 && /^[^a]*a[^a]*$/i && /^[^b]*b[^b]*$/i && /^[^c]*c[^c]*$/i && /k.$/i } @words; Is there a simpler way?

[me@fedora ~]$ time perl -n -e 'length($_) == 10 && /^[^a]*a[^a]*$/i && /^[^b]*b[^b]*$/i && /^[^c]*c[^c]*$/i && /k.$/i && print' /usr/share/dict/words | wc -l 26 real 0m0,168s user 0m0,162s sys 0m0,007s [me@fedora ~]$ time perl -n -e '/^(?=.{8}k.$)(?=[^a]*a[^a]*$)(?=[^b]*b[^b]*$)(?=[^c]*c[^c]*$)/ && print' /usr/share/dict/words | wc -l 17 real 0m0,260s user 0m0,254s sys 0m0,006s [me@fedora ~]$ time perl -n -e '/^.{8}…

Bug fixed.

  [me@fedora ~]$ time perl -n -e 'length($_) == 11 && /^[^a]*a[^a]*$/i && /^[^b]*b[^b]*$/i && /^[^c]*c[^c]*$/i && /k.$/i && print' /usr/share/dict/words | wc -l
  17

  real 0m0,160s
  user 0m0,153s
  sys 0m0,008s

Re: Designing a programming language to speedrun Advent of Code

#64

> The title is clickbait. I did not design and implement a programming language for the sole or even primary purpose of leaderboarding on Advent of Code. I did: https://github.com/lukechampine/slouch "Find all ten-letter words that contain each of the letters A, B, and C exactly once and that have the ninth letter K" :load wordlist wordlist.txt words wordlist | filter -:(len == 10 and .8 == "k") A more interesting ex…

You should write a longer post about it!

Re: Designing a programming language to speedrun Advent of Code

#66
post #64

> The title is clickbait. I did not design and implement a programming language for the sole or even primary purpose of leaderboarding on Advent of Code. I did: https://github.com/lukechampine/slouch "Find all ten-letter words that contain each of the letters A, B, and C exactly once and that have the ninth letter K" :load wordlist wordlist.txt words wordlist | filter -:(len == 10 and .8 == "k") A more interesting ex…

You should write a longer post about it!

aight

Re: Designing a programming language to speedrun Advent of Code

#67
post #64

> The title is clickbait. I did not design and implement a programming language for the sole or even primary purpose of leaderboarding on Advent of Code. I did: https://github.com/lukechampine/slouch "Find all ten-letter words that contain each of the letters A, B, and C exactly once and that have the ninth letter K" :load wordlist wordlist.txt words wordlist | filter -:(len == 10 and .8 == "k") A more interesting ex…

You should write a longer post about it!

Are you participating in AoC maybe? I might write some stuff.

Re: Designing a programming language to speedrun Advent of Code

#68
post #32

Earlier quoted context omitted.

Honestly I'm jealous of JavaScript's arrow syntax. I don't really need anything else but the arrows are nice (and Turing complete).

I always figured that once Python got the walrus operator it would be a matter of time until arrow functions of some sort made more and more sense on Python.

I really hope not tbh, once you break that seal it will consume the entire language into nested anonymous function soup without all the facilities JS has accumulated over the years to mitigate it. Python is an iterator based language and it leads to some very nice code if you design with that in mind.

It's really incredible how much such a small feature in the grand scheme of things `(function() { })()` influences all API and library design. Right now passing around functions in Python is ugly and reads as such which is enough of a deterrent for most people.

Re: Designing a programming language to speedrun Advent of Code

#69

> The title is clickbait. I did not design and implement a programming language for the sole or even primary purpose of leaderboarding on Advent of Code. I did: https://github.com/lukechampine/slouch "Find all ten-letter words that contain each of the letters A, B, and C exactly once and that have the ninth letter K" :load wordlist wordlist.txt words wordlist | filter -:(len == 10 and .8 == "k") A more interesting ex…

How does that do the fiddly bit "contain each of the letters A, B, and C exactly once" ?

Re: Designing a programming language to speedrun Advent of Code

#70

Earlier quoted context omitted.

reads a bit like javascript now. You might want to consider switching languages

Honestly I'm jealous of JavaScript's arrow syntax. I don't really need anything else but the arrows are nice (and Turing complete).

I really wish python would steal 'let' from JS, specifically in a block scoped form - coming from perl's 'my' as a way of life, python's (and ruby's) function level scoping and "surprise! variable just popped into existence on assignment!" behaviour really messed me up.
Post reply on HN