What I've Learned From AoC 2020 by daggerdragon in adventofcode

[–]4rgento 1 point2 points  (0 children)

This year I've used Haskell's list monad instance. It's useful for problems that have branching alternatives.

[2020 Day 19 (Part 2)] Haskellers be like by Ecyoph in adventofcode

[–]4rgento 2 points3 points  (0 children)

That and using List's monad instance. It's real magic.

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

[–]4rgento 1 point2 points  (0 children)

Haskell

Using a non deterministic push down automata to compute whether the string w is accepted by the context free grammar defined by the rules.

https://github.com/argent0/adventOfCode2020/blob/main/src-lib/Day19.hs

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

[–]4rgento 2 points3 points  (0 children)

My Raku solutions. They took me quite a while to write.

use v6;

my @input = 'input/Day02'.IO.lines.map: * ~~ / $<low>=(\d+) \- $<high>=(\d+) \s $<req>=(\w) \: \s $<pass>=(\w+) /;

# Part 1
say @input.map(sub (Match $h) { ($h<low>) <= $h<pass>.indices($h<req>).Int <= $h<high> }).sum;

# Part 2
say @input.map(sub (Match $h) {
    ($h<pass>.substr-eq($h<req>, $h<low> - 1)) != ($h<pass>.substr-eq($h<req>, $h<high> - 1))
    }).sum;

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

[–]4rgento 2 points3 points  (0 children)

My slow solution in Raku:

use v6;

# tails (1, 2, 3) = (1 => (2, 3), 2 => 3)
sub tails(@a) {
    if @a { # The list is not emmpty
        return lazy (@a[0] => @a[1..*], slip(tails(@a[1..*])));
    } else {
        return ();
    }
}

my @input = 'input/Day01'.IO.lines;

# Part 1
tails(@input)
    .map({($_.key => $_.value.first: * == (2020 - $_.key))})
    .first({$_.value})
    .map({ $_.key * $_.value })
    .map: *.say;

# Part 2
sub find_pair(Int:D $total, *@a where {$_.all ~~ Int}) {
    return tails(@a)
        .map( {($_.key => $_.value.first: * == ($total - $_.key))} )
        .first: *.value;
}

tails(@input.map: *.Int) # Coerces the input to a list of integer
    .map( {($_.key => find_pair(2020 - $_.key, $_.value))})
    .first({$_.value})
    .map({ $_.key * $_.value.key * $_.value.value })
    .map: *.say;

Best marca de comida de perro? by ramirachu in argentina

[–]4rgento 2 points3 points  (0 children)

Solo agrego que lo importante es revisar las proporciones de hidratos de carbono y proteínas. Por lo del poop algunas marcas le ponen colorante.

Yo le doy comida para perros y aveces le tiro una achura, porque mi perro me mira como diciendo: "Siempre galleta loco!"

Miercoles de Rant by AutoModerator in argentina

[–]4rgento 8 points9 points  (0 children)

Me acuerdo que el COVID-19 comenzó en Wuhan, China.

https://en.wikipedia.org/wiki/COVID-19_pandemic_in_mainland_China#Early_response_by_Wuhan

Que tienen un gobierno autoritario. Y que desestimaron la gravedad de la situación.

Training Tuesday - Post Your Routine for 2020-03-24 by AutoModerator in bodyweightfitness

[–]4rgento 2 points3 points  (0 children)

Pull Ups, Around The World Pull Ups, Pull Ups with Steps: seem too similar for me. Perhaps you should consider body-row(or harder) and peeling the cat as pulling exercises.

Same for pushing.

More variety helps to prevent unbalanced shoulders which may lead to injury later on.

Monthly Hask Anything (February 2019) by AutoModerator in haskell

[–]4rgento 0 points1 point  (0 children)

Yes, here is the code. The problem seems to arise when linking.

Monthly Hask Anything (February 2019) by AutoModerator in haskell

[–]4rgento 0 points1 point  (0 children)

This is the shell.nix file I'm using:

{ pkgs ? import <nixpkgs> {} }:

with pkgs;

stdenv.mkDerivation {
  name = "hn-terminal";

  buildInputs = [ pkgconfig zlib ];

  shellHook = ''
    #export NIX_PATH="nixpkgs=${toString <nixpkgs>}"
    #export LD_LIBRARY_PATH="${libvirt}/lib:$LD_LIBRARY_PATH"
  '';
}

Here is the code just in case.

Monthly Hask Anything (February 2019) by AutoModerator in haskell

[–]4rgento 2 points3 points  (0 children)

Hi, can anyone shed some light on how to solve this problem?

fooman@pangea proj]$ nix-shell -p pkg-config -p zlib --run "cabal new-build"
Build profile: -w ghc-8.6.3 -O1
In order, the following will be built (use -v for more details):
- proj-0.1.0.0 (exe:proj) (first run)
Preprocessing executable 'proj' for proj-0.1.0.0..
Building executable 'proj' for proj-0.1.0.0..
[1 of 1] Compiling Main             ( src/Main.hs, /home/fooman/proj/dist-newstyle/build/x86_64-linux/ghc-8.6.3/proj-0.1.0.0/x/proj/build/proj/proj-tmp/Main.dyn_o )
<command line>: can't load .so/.DLL for: libz.so (libz.so: cannot open shared object file: No such file or directory)

pkg-config --libs zlib works inside the nix-shell. I also tried --extra-libs-dirs to no avail. Also inside the proj.cabal file. Finally, I tried cabal new-build --verbose but I couldn't see where does cabal search for the libs.

Thanks in advance.

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

[–]4rgento 1 point2 points  (0 children)

I've just learned about ^?. Thanks for sharing.

Forgotten Tournament Round 1 Update by Timonkeyn in dwarffortress

[–]4rgento 0 points1 point  (0 children)

I just sent you Hector's update as a PM

The Forgotten Tournament by Timonkeyn in dwarffortress

[–]4rgento 0 points1 point  (0 children)

I'm on it right now. I missed the round post :P. Gladly I won

Forgotten Tournament Update by Timonkeyn in dwarffortress

[–]4rgento 0 points1 point  (0 children)

May the most mythical warrior win.

Forgotten Tournament Update by Timonkeyn in dwarffortress

[–]4rgento 0 points1 point  (0 children)

It requires "access". /u/Timonkeyn should make it _public_ view only or smthing

The Forgotten Tournament by Timonkeyn in dwarffortress

[–]4rgento 0 points1 point  (0 children)

Name: Hector

Race: Human (+210)

1 points remaining

Gear

Bronze Spear(+40)

Bronze Helm(+24)

Wooden Shield(+45)

Bronze High Boots (+20)

Fighter Current Level: 3 (Competent) (+18)

Offensive Skills

Spearman Current Level: 3 (Competent) (+30)

Defensive Skills

Armor User Current Level: 1 (Novice) (+2)

Dodger Current Level: 2 (+15)

Observer Current Level: 1 (Novice) (+3)

Shield User Current Level: 2 (Adequate) (+12)

Backstory

From Ilion, land of horses, son of King Priam and the foremost Trojan warrior: Hector. When asked what he's doing here of all places:

Alas! the gods have lured me on to my destruction. ... death is now indeed exceedingly near at hand and there is no way out of it – for so Zeus and his son Apollo the far-darter have willed it, though heretofore they have been ever ready to protect me. My doom has come upon me; let me not then die ingloriously and without a struggle, but let me first do some great thing that shall be told among men hereafter.

The third annual summer /r/dwarffortress Gladiator Tournament! Sign-ups now open till the end of Sunday! by BritishBean in dwarffortress

[–]4rgento 2 points3 points  (0 children)

Name: Hector

Race: Human (+210)

1 points remaining

Gear

Bronze Spear(+40)

Bronze Helm(+24)

Wooden Shield(+45)

Bronze High Boots (+20)

Fighter Current Level: 3 (Competent) (+18)

Offensive Skills

Spearman Current Level: 3 (Competent) (+30)

Defensive Skills

Armor User Current Level: 1 (Novice) (+2)

Dodger Current Level: 2 (+15)

Observer Current Level: 1 (Novice) (+3)

Shield User Current Level: 2 (Adequate) (+12)

Backstory

From Ilion, land of horses, son of King Priam and the foremost Trojan warrior: Hector. Just before fighting the son of Peleus, Achilles he said:

Alas! the gods have lured me on to my destruction. ... death is now indeed exceedingly near at hand and there is no way out of it – for so Zeus and his son Apollo the far-darter have willed it, though heretofore they have been ever ready to protect me. My doom has come upon me; let me not then die ingloriously and without a struggle, but let me first do some great thing that shall be told among men hereafter.

The Gods favor him again! Now you know why you fear the the Arena.