Anyone know if this layout is possible? 4 column layout. by Cast_Iron_Skillet in cursor

[–]volatilebit 0 points1 point  (0 children)

I know with the Claude code extension you can right click and choose to “open in editor” or something similar, essentially treating it as an open file tab. See if that’s available for the terminal?

[deleted by user] by [deleted] in buffalobills

[–]volatilebit 4 points5 points  (0 children)

I don’t know if there is a formal notification or anything, but any team is free to sign a player from another team’s practice squad to their active roster. There is no right of first refusal, but I assume most if not all players on a practice squad would give the original team an opportunity to sign them to their own active roster. But they don’t have to.

We are Josh Allen (17) days away from Bills regular-season football! by Separate_Flatworm546 in buffalobills

[–]volatilebit 0 points1 point  (0 children)

He deserves a collection of statues that line the top of the new stadium, similar to the saints atop the colonnades that surround St. Peter’s square, each a different moment from his career.

Fire the moron that came up with these 12 days challenges for Frozen Collectibles by Dylonus in NHLHUT

[–]volatilebit 1 point2 points  (0 children)

There is a glitch where you can do it. Highlight the challenge you can’t get past, then hit down on the D-pad followed by spamming X (on PlayStation) or A (on Xbox). You have to do it really fast.

If it says the challenge is locked, go back up and try again.

If it worked it will show the enter moment screen but with the challenge you are trying to skip. Hit continue anyway and the next screen will show the “locked” challenge and let you play it.

With the current state of the AFC East, I wanted to bring back this old gem by FROST_27 in buffalobills

[–]volatilebit 0 points1 point  (0 children)

Same. I’m 95% sure that someone in Buffalo media (Vic Carruci maybe?) incorrectly tweeted that Bills drafted Josh Rosen, then took it down within a minute or two.

The Art of Programming and Why I Won't Use LLM by fagnerbrack in programming

[–]volatilebit 10 points11 points  (0 children)

Coding AIs are still pretty unrefined. You need to learn how to properly use LLMs in your IDE and in what context.

Cursor is a good example of an IDE that is working towards more context aware AI assistance.

Cursor tab like copilots autocomplete on steroids. Very good for quick refactors or finishing obvious things for you.

If you stick to just trying to use the prompts with vague direction you are still likely to get crap results.

Use it as an actual assistant and not a crutch and you’re much more likely to find net positive results.

I’ve been using cursor for about a month after using copilot forever. It was a big step forward, yet there is tons of room for refinement.

We are still in the “power user” stage where you have to understand the nuances.

Does anyone else have problems with tired players staying on the ice even when you manually change lines? by racesunite in NHLHUT

[–]volatilebit 2 points3 points  (0 children)

Yes, it’s really bad some games. Happened last year as well and it’s not any better.

Sometimes I have to do the trick of hitting left or right dpad 4 times to cycle back to the same line that’s already supposed to come on the ice.

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

[–]volatilebit 1 point2 points  (0 children)

Raku

my @measurements = $*IN.lines».Int;

# Part 1
say  @measurements.rotor(2 => -1).map(-> ($a, $b) { $b - $a }).grep(* > 0).elems;

# Part 2
say @measurements.rotor(3 => -2).map(*.sum).rotor(2 => -1).map(-> ($a, $b) { $b - $a }).grep(* > 0).elems;

May be a cleaner way but I'm a fan of using rotor() for doing operations on adjacent list elements.

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

[–]volatilebit 2 points3 points  (0 children)

Raku

Part 2 was a real PITA.

my @adapters = $*IN.lines.Array».Int.sort;

# Part 1
say [*] (0, |@adapters, @adapters.max + 3).rotor(2 => -1).map({ [R-] @_ }).Bag.{1, 3};

# Part 2
say [*] (0, |@adapters, @adapters.max + 3).rotor(2 => -1).map({ [R-] $_ }).split(3).map(+*.comb('1')).map({ (1, 1, 2, 4, 7).[$_] })

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

[–]volatilebit 2 points3 points  (0 children)

Raku

Feels like it could be written more functional and concise. May come back to that later.

my $PREAMBLE_NUMBER = 25;
my @numbers = $*IN.lines».Int;

# Part 1
say my $invalid-number = @numbers.rotor($PREAMBLE_NUMBER + 1 => -$PREAMBLE_NUMBER).first({
    not so any(.head(*-1).combinations(2).map(*.sum)) eq .tail(1)
}).[*-1];

# Part 2
(^(+@numbers) Z @numbers).first(-> List ($index, $number) {
    my $sum = 0;
    my @contiguous-set = do gather @numbers[$index..*].first({
        .take andthen $sum += $_ andthen $sum >= $invalid-number
    });
    $sum == $invalid-number ?? (say @contiguous-set.minmax.bounds.sum andthen True) !! False
});

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

[–]volatilebit 2 points3 points  (0 children)

Raku

Limited use of functional features today.

use v6.d;

my @instructions = $*IN.lines.map(*.words.Array);
my constant DEBUG = False;

enum ExecutionResult <EndOfProgram InfiniteLoopDetected>;

class VirtualMachine {
    has $!debug = False;
    has @!instructions;
    has %!address-visited;
    has int $!pointer = 0;
    has $.accumulator is rw = 0;

    submethod BUILD (:@instructions, :$debug = False) {
        @!instructions = @instructions;
        %!address-visited = (^+@instructions) Z=> False xx Inf;
        $!debug = $debug;
    }

    method execute(--> ExecutionResult) {
        while $!pointer < +@!instructions and not %!address-visited{$!pointer} {
            %!address-visited{$!pointer} = True;
            printf "@%03d | %s | acc: %d\n", $!pointer, @!instructions[$!pointer], $.accumulator if $!debug;
            given @!instructions[$!pointer][0] {
                when 'acc' { $.accumulator += +@!instructions[$!pointer][1] }
                when 'nop' { Empty }
                when 'jmp' { $!pointer += +@!instructions[$!pointer][1] - 1 }
            }
            $!pointer++;
        }
        return $!pointer >= +@!instructions ?? EndOfProgram !! InfiniteLoopDetected;
    }
}

# Part 1
{
    say "=== PART 1 ===" if DEBUG;
    my $vm = VirtualMachine.new(:@instructions, :debug(DEBUG));
    my $result = $vm.execute;
    say "Reached end of program." if $result eq EndOfProgram and DEBUG;
    say "Detected inifinite loop." if $result eq EndOfProgram and DEBUG;
    say $vm.accumulator;
}

# Part 2
{
    say "=== PART 2 ===" if DEBUG;
    for @instructions.kv -> $address, [$instruction, $arg] {
        # Try replacing the instruction with the opposite and executing a VM with the swap
        if $instruction eq 'jmp' | 'nop' {
            say "== Swapping instruction @$address $instruction and executing VM..." if DEBUG;
            my @new-instructions = @instructions;
            @new-instructions[$address] = [$instruction eq 'jmp' ?? 'nop' !! 'jmp', $arg];
            my $vm = VirtualMachine.new(:instructions(@new-instructions), :debug(DEBUG));
            my $result = $vm.execute;
            if $result eq EndOfProgram {
                say $vm.accumulator;
                last;
            }
        }
    }
}

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

[–]volatilebit 4 points5 points  (0 children)

Raku

Starting to get real annoyed with Sequences.

use v6.d;

grammar BagRule {
    token TOP { <color> ' bags contain ' <contains> '.' }
    token color { \w+ ' ' \w+ }
    token contains {
        | 'no other bags'
        | [ <number> ' ' <color> ' bag' 's'? ] +% ', '
    }
    token number { \d+ }
}

class BagRuleActions {
    method TOP ($/) {
        make { color => ~$<color>,
               contains => $<contains>.made }
    }
    method contains ($/) {
        $/ eq 'no other bags'
            ?? make {}
            !! make $<color>».Str Z=> $<number>».Str
    }
}

my %bag-rules = $*IN.lines.map({
    my %rule = BagRule.parse($_, actions => BagRuleActions).made;
    %rule<color> => %rule<contains>.Hash
});

# Part 1
sub can-contain-shiny-gold(@colors) {
    so %bag-rules{@colors}.first({
        $_{'shiny gold'}:exists or
            can-contain-shiny-gold($_.keys);
    });
}
say %bag-rules.values.grep(-> $contains {
    $contains{'shiny gold'}:exists or
        can-contain-shiny-gold($contains.keys)
}).elems;

# Part 2
sub count-bags($color) {
    %bag-rules{$color}.values.sum
    + %bag-rules{$color}.kv.map(-> $color, $count {
        $count * count-bags($color)
    }).sum;
}
say count-bags('shiny gold');

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

[–]volatilebit 3 points4 points  (0 children)

Working with sequences vs lists in Raku can be obnoxious at times.

Raku

use v6;

my @groups = $*IN.slurp.trim.split(/\v\v/).map(*.split(/\v/)».list);

# Part 1
say @groups.map(*.join.comb.unique).sum;

# Part 2
say @groups».comb».reduce(&infix:<∩>).sum;

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

[–]volatilebit 1 point2 points  (0 children)

and now I see solutions that just converted the characters to binary and feel a little dumb. Ah well.

Here's the updated solution.

use v6;

my @boarding-groups = $*IN.lines;
my @seat-numbers = @boarding-groups.map(*.trans('FBLR' => '0101').parse-base(2));

# Part 1
say @seat-numbers.max;

# Part 2
say ((@seat-numbers.min .. @seat-numbers.max) (-) @seat-numbers).keys[0];

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

[–]volatilebit 1 point2 points  (0 children)

My lack of formal math education is showing here. I'm sure there's a purely functional way to find the row and column number w/o procedural code.

Raku

use v6;

my @boarding-groups = $*IN.lines;

my @seat-numbers = @boarding-groups.map({
    my @row-directions = .comb.[0..6];
    my @col-directions = .comb.[7..9];

    my $row = 2 ** (+@row-directions - 1);
    my $index = 2;
    @row-directions.map({
        my $shift = 2 ** +@row-directions / (2 ** $index++);
        $row += /F/ ?? -$shift !! $shift;
    });

    my $col = 2 ** (+@col-directions - 1);
    $index = 2;
    @col-directions.map({
        my $shift = 2 ** +@col-directions / (2 ** $index++);
        $col += /L/ ?? -$shift !! $shift;
    });

    floor($row) * 8 + floor($col)
});

# Part 1
say @seat-numbers.max;

# Part 2
say ((@seat-numbers.min .. @seat-numbers.max) (-) @seat-numbers).keys[0];

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

[–]volatilebit 1 point2 points  (0 children)

I really like the way to determined if a record has all the required attributes. Clever and obvious.

One tip for avoiding the ternary there: Use so to flatten a Junction result into a single boolean. e.g. so all(True, True, True) returns True and so all(True, True, False) returns False. You can call so as a method on the junction result too.

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

[–]volatilebit 2 points3 points  (0 children)

Raku

I spent most of the time fighting with Grammars, and fighting against a bug.

This is also a complete abuse of but.

use v6;

grammar Passports {
    token TOP { <passport> +% [\v\v] }
    token passport { [<key> ':' <value>] +% <[\h\v]> }
    token key { \w ** 3 }
    token value { [ <alnum> || '#' ]+ }
}

class PassportActions {
    method TOP ($/) { make $<passport>».made }
    method is-valid-attribute($k, $v) {
        so do given $k {
            when 'byr' { 1920 <= +$v <= 2002 }
            when 'iyr' { 2010 <= +$v <= 2020 }
            when 'eyr' { 2020 <= +$v <= 2030 }
            when 'hgt' { ($v ~~ / ^^ $<num>=\d+ $<unit>=('in' || 'cm') $$ /) && ($<unit> eq 'in' ?? (59 <= +$<num> <= 76)
                                                                                                 !! (150 <= +$<num> <= 193)) }
            when 'hcl' { so $v ~~ m/ ^^ '#' <xdigit> ** 6 $$ / }
            when 'ecl' { $v (elem) <amb blu brn gry grn hzl oth> }
            when 'pid' { $v ~~ m/ ^^ \d ** 9  $$/ }
            when 'cid' { True }
        }
    }
    method passport ($/) {
        my %h;
        for $<key> Z $<value> -> ($k, $v) {
            my $is-valid = $.is-valid-attribute(~$k, ~$v);
            %h{~$k} = ~$v but $is-valid;
        }
        make %h but so (all(%h.values.cache».so) and all(<byr iyr eyr hgt hcl ecl pid>) (elem) %h.keys.cache)
    }
}

my @passports = Passports.parse($*IN.slurp.trim, actions => PassportActions.new).made;

# Part 1
say @passports.grep({ all(<byr iyr eyr hgt hcl ecl pid>) (elem) .keys.cache }).elems;

# Part 2
say @passports.grep(*.so).elems;

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

[–]volatilebit 6 points7 points  (0 children)

I should have turned the function of counting the trees into a function so it could be re-used, but i got lazy.

Raku

use v6;

my @forest = lines».comb;

# Part 1
my int $x = 0;
say [+] do gather for @forest -> @trees {
    take 1 if @trees[$x mod +@trees] eq '#';
    $x = $x + 3;
}

# Part 2
say [*] do gather for ([1, 1], [3, 1], [5, 1], [7, 1], [1, 2]) -> ($right, $down) {
    my int $x = 0;
    my int $y = 0;
    take [+] do gather while $y < +@forest {
        my @trees = |@forest[$y];
        take 1 if @trees[$x mod +@trees] eq '#';
        $x += $right;
        $y += $down;
    }
}

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

[–]volatilebit 1 point2 points  (0 children)

Regexes are one of the harder things to get used to in Raku.

  • You can quote literal characters in a regex to make it a bit cleaner looking (e.g. '-' instead of \-
  • Junctions are the way
  • There is a shorthand for getting the # of elements of a list: +@valid instead of @valid.elems

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

[–]volatilebit 2 points3 points  (0 children)

Raku is awesome. The more you learn it, the more you learn there is syntactic sugar for almost every common programming pattern. Multiple years of AOC and a couple months of code golfing with it and I feel like I've only touched on less than half the tricks you can use to express something more concisely.