Grilled Cheese

ExploreLog inSign up

The Fuzion Language

@fuzionlang.bsky.social

2 Following5 Followers

A language that unifies concepts to improve productivity and to use tools for performance and correctness.

PostsRepliesMedia
@fridis.bsky.socialDec 5, 2026, 11:12 AMReposted by @fuzionlang.bsky.social

Dec 5 #adventofcode in @fuzionlang.bsky.social:

Emulate microwave buttons to find reachable states.

Main difficulty was the choice of a functional data structure to collect theresults. Fuzion provides an efficient partially sorted set called ps_set for this.

Sources: github.com/fridis/fuzio...

dec05 =>

  input := io.stdin.read_string! .split_if (c -> "[] \n".find c ??) .force

  process(n, button) =>
    if      button.starts_with "*" then n * button.substring 1 .parse_i64!
    else if button.starts_with "/" then n / button.substring 1 .parse_i64!
    else if button.contains "->"   then a := button.substring 0 1
                                        b := button.substring 3 4
                                        ($n).replace a b .parse_i64!
    else if button = "oct"         then n.oct.parse_i64!
    else if button = "bksp"        then n / 10
    else if "0" <= button <= "9"   then 10*n + button.parse_i64!
                                   else panic "unknown button [$button]"

  part1 =>
    (1..3).foldf (container.ps_set i64 .new [0]) found,_->
            found.combine input process
                 .reduce found (f,n -> f.add n)
          .sum

  part2 =>
    (1..).reduce (container.ps_set i64 .new [0]) found,_->
            r := found.combine input process
                      .filter (n -> 0 <= n <= 9999)
                      .reduce found (f,n -> f.add n)
            r = found ? abort r : r
         .sum

  say "$part1:$part2"
@fridis.bsky.socialDec 4, 2026, 2:58 PMReposted by @fuzionlang.bsky.social

Dec 4 #adventofcode in @fuzionlang.bsky.social:

Find shortest repeating sub-sequence in sequence with jokers. Part 2 differed in input size, making O(n³) solution impractical.

The trick: use of exceptional control flow for an early abort to avoid high runtime.

Sources: github.com/fridis/fuzio...

dec04 =>

  input := io.stdin.read_lines! .map (.codepoints.force)

  Sequence.first_match(f T->bool) => filter f .first

  solve(l) =>
    (1..).first_match s->
      (0..s-1) ∀ o->
        fail : flow.exception_tag is
        flow.exception fail
          .try ()->
             _ := l.indexed.flat_map ||>(i,e -> (i%s = o).as_option e)
                   .foldf "?" r,e->
                     if      e="?" || e=r then r
                     else if r="?"        then e
                     else (flow.exception fail).env.cause (error "")
          .or_outcome??

  part1 =>
    input.flat_map solve
         .sum

  part2 =>
    solve <| input.fold1 (++)

  say "$part1:$part2"
@fridis.bsky.socialDec 3, 2026, 3:47 PMReposted by @fuzionlang.bsky.social

Today's #adventofcode in @fuzionlang.bsky.social:

In a square bool grid, find tiles that form corners of a square. First only horizontal ones, in part 2 also rotated squares.

Possible addition to base lib:

Sequence.sum(f T -> N : numeric)
=>
map f .sum

Source: github.com/fridis/fuzio...

dec03 =>

  input := io.stdin.read_lines! .map (.codepoints.map ="#" .force) .force
  w => input.count
  a := array2 w w y,x->input[y][x]
  i(y,x) => 0 <= y < w && 0 <= x < w && input[y][x]

  part1 =>
    a.index_pairs.filter ||>i
                 .sum ||>y,x->
                    (1 .. w-1-max y x).count s->
                      (i y   x+s &&
                       i y+s x   &&
                       i y+s x+s    )

  part2 =>
    a.index_pairs.filter ||>i
                 .sum ||>y,x->
                    (1 .. w-1).sum s->
                                (0..(s-1)).count r->
                                  (i y+r   x+s-r   &&
                                   i y+s-r x-r     &&
                                   i y+s   x+s-2*r    )

  Sequence.sum(f T -> N : numeric) => map f .sum

  say "$part1:$part2"
@fridis.bsky.socialDec 2, 2026, 2:08 PMReposted by @fuzionlang.bsky.social

Today's #adventofcode in @fuzionlang.bsky.social:

On an endless repeating track, move robot to waypoints given in list. In part 2, rearrange list for max distance.

Part 1 straightforward, find next waypoint. P2: 6 steps for each wp, with minor adjustments.

Source:
github.com/fridis/fuzio...

dec02 =>

  input := io.stdin.read_string! .trim.utf8

  part1 =>
    # start at pos 0, iterate over the program
    input.foldf 0 pos,wp->
      # from the next position, find the first matching waypint
      ((pos+1)..).filter (s -> "roygbv".utf8[s % 6] = wp)
                 .first!

  part2 =>
    # active_wps, i.e., exclude shortest with zero count
    active_wps => "oygbvr".utf8
                          .drop_while (wp -> input.filter =wp .is_empty)
                          .count
    (6*input.count        # repeated waypoints add 6 steps
     - active_wps         # new ones add only 5, one less
     + 1)                 # except the very first

  say "$part1:$part2"
@fridis.bsky.socialDec 1, 2026, 11:04 PMReposted by @fuzionlang.bsky.social

Time for @adventofcode.bsky.social in @fuzionlang.bsky.social!

The task: find the 3 most / lest frequent numbers in a list and multiply.

The solution: after parsing the input, we group equal numbers, sort them by the group size, take 3 and get their product.

Source: github.com/fridis/fuzio...

dec01 =>

  input := io.stdin.read_lines!
                   .map l->l.parse_i64!

  part1 =>
    gs := input.group_by id
    gs.keys.sort_by (k -> -(gs[k]! .count))
         .take 3
         .product

  part2 =>
    gs := input.group_by id
    gs.keys.sort_by (k -> gs[k]! .count)
         .take 3
         .product

  say "$part1:$part2"
@fuzionlang.bsky.socialNov 17, 2026, 9:24 AM

The Fuzion November news are out:

- powerful compile-time reflection for `choice` (enum) types
- faster `Sequence.map` using specialization for function types instead of dynamic binding

All the details: fuzion-lang.dev/news/news_068

fuzion-lang.devFuzion Language PortalFuzion is a computer programming language with a focus on productivity, performance and correctness.
Terms of UsePrivacy PolicyCommunity StandardsHelpGet the app

Grilled Cheese is a product of Village Compute

Version devBuilt at: 2026-12-03 22:42:33 EST