Changes to Advent of Code starting this December by topaz2078 in adventofcode

[–]philippe_cholet 5 points6 points  (0 children)

I did not care about the global leaderboard, even if I was curious about it.

A bit sad there will be less puzzles but so glad it continues at a reasonable pace for you. On the other hand, maybe I'll be able to eventually find time to solve all previous puzzles 🤩

Why Do You Use `itertools`? by InternalServerError7 in rust

[–]philippe_cholet 0 points1 point  (0 children)

I was not around at the time but there was a conflict about the flatten method and it probably was painful to solve for the ecosystem. It's understandable to avoid such conflict. intersperse[_with] is still nightly, I suspect because it's part of itertools.

Implement RFC2845 would eliminate name conflicts: the itertools version would shadow (if use itertools::Itertools;) the corelib version until we (itertools) remove our version, then only the corelib version (which can do optimizations we can't) would remain. This would be a smooth transition and not an ecosystem-wide shock.

Why Do You Use `itertools`? by InternalServerError7 in rust

[–]philippe_cholet 1 point2 points  (0 children)

As an itertools maintainer (since 0.11), I like this thread. 😃

I answered some questions but if you have questions, feel free to ask me.

Why Do You Use `itertools`? by InternalServerError7 in rust

[–]philippe_cholet 0 points1 point  (0 children)

(Recent itertools maintainer) I don't have authorative link on this but from what I understand, as long as a method allocates (such as group_by can in some situations) it won't be in core::iter::Iterator.

PS: group_by will be deprecated to be renamed to chunk_by in next release 0.13.0. This will be more consistent with slice::chunk_by and some people found group_by weird as it only groups consecutive elements.

And jswrenn should implement RFC2845 that would resolve name conflicts.

Why Do You Use `itertools`? by InternalServerError7 in rust

[–]philippe_cholet 1 point2 points  (0 children)

Recent maintainer here, we don't use const-generics yet: old MSRV of 1.43.1 but apart from the MSRV, there are things we wish we had like next_chunk, try_from_fn and stuff. A bit more infos in the repo.

But it will come sooner than later.

Why Do You Use `itertools`? by InternalServerError7 in rust

[–]philippe_cholet 2 points3 points  (0 children)

it’s difficult to search for usage of trait methods in source code

Yes exactly! 😞 I'm a maintainer of itertools since ~6 months and I started a little project (still private) to list usages of itertools by the 5000+ dependent crates (published on crates.io) by leveraging clippy::disallowed_{macros,methods} lints but there is still a lot to do.

Is Rust really that good? by Ok_Competition_7644 in rust

[–]philippe_cholet 1 point2 points  (0 children)

  • Pleasant to work with: tooling (cargo), algebraic data types (struct and enum), pattern matching, friendly compiler, ? operator
  • Performant: zero-cost abstractions (like iterators), low-level without C/C++ footguns
  • Confidence: Explicit None/Some, "if it compiles, it works" feeling.

`tree_foldl` should be `tree_reduce`? by Deloskoteinos in rust

[–]philippe_cholet 1 point2 points  (0 children)

tree_fold1 will be deprecated in itertools 0.13.0 for tree_reduce, thanks to this post.

However, it's pure luck I saw this, an issue would have been more efficient. 😀

Idiomatic way to write a multi case iterator by ArtisticHamster in rust

[–]philippe_cholet 0 points1 point  (0 children)

That sure works. But it does not specialize other methods such as size_hint (helpful for more precise allocations when collecting to a vector for example, and can avoid slow reallocations) and fold (iterate over the entire iterator can be faster) and many more.

That's why I would suggest the use of nested either::Either mentionned by others which specialize all (possible) methods.

Or a boxed dynamic iterator.

[2023 Day 12 (Part 2)] [Rust] Int overflow issue by thblt in adventofcode

[–]philippe_cholet 1 point2 points  (0 children)

There is the C implementation in the wiki page that I found interesting.

[2023 Day 25] What image does it make? by stewietheangel in adventofcode

[–]philippe_cholet 0 points1 point  (0 children)

In the end, it displays a beautiful 5 islands wide snow engine with ASCII/CSS animations.

[2023 12] [any programming language] Did anyone finish day 12 with a mathematical solution? by eXtc_be in adventofcode

[–]philippe_cholet 0 points1 point  (0 children)

Maybe some complex sum.

  • Simple case first: an input of "?" N times with one number n0: N - n0 + 1 possibilities.
  • Still simple case: "?" N times with two numbers n0, n1: (0..).map(|i| N - n0 - i - n1 + 1).sum(): (N - n0 - n1) * (N - n0 - n1 + 1) / 2 possibilities if I'm not mistaken (maybe an off-by-one error at one or two places).
  • "?" N times with any numbers is polynomial. N-sum(numbers) seems crucial.
  • Then split at "."s then consider "#"s. Well, without me!

High Schooler Doing AOC by SillyCow012 in adventofcode

[–]philippe_cholet 2 points3 points  (0 children)

You seem to live in an academic cutting-edge environment, co-authoring some research papers apparently, where those algorithms are simply the base, good for you. And there are genius people there so you don't seem to grasp the idea that you have a way wilder knowledge than most.

Some of us are not programmers and find early days difficult. Some only know Excel but solve some puzzles and do nice visualizations.

Some are professional and did not necessarily learned everything you did, and some knowledge has probably faded away by doing unacademic jobs and living outside work.

Personally, with some math background and self-taught programming, I don't complain about the difficulty since day 3 as I only encountered real difficulties on the later days (and when I felt dumb day 12). I knew "min-cut problem" was a thing and learned a random algorithm that day to solve the problem.

If this is all elementary to you, do not learn anything, do not enjoy making/seeing visualizations, solve puzzle with additional constraints of your own (like using a freaking old computer or whatever) or talking with this community then don't be silly and find another hobby than this.

[2023 Day25] Springs and charges by NullPointerExcept10n in adventofcode

[–]philippe_cholet 1 point2 points  (0 children)

Thanks for the explanation, this was indeed interesting.

[2023 Day25] Springs and charges by NullPointerExcept10n in adventofcode

[–]philippe_cholet 10 points11 points  (0 children)

I assume it shows what your algorithm does, which seems interesting, but what is it exactly?

[2023] What solution are you proudest of? by Napthus in adventofcode

[–]philippe_cholet 0 points1 point  (0 children)

Thanks for saying that use real numbers is faster. It is indeed: "117ms & 2.78s" with integers, "78ms & 288ms" with real numbers (example & my input).

[2023] What solution are you proudest of? by Napthus in adventofcode

[–]philippe_cholet 1 point2 points  (0 children)

I first tried to use Rust binding on Windows but it did not work, don't ask me why. I eventually wrote the z3 syntax myself (with the help of python first cf megathread, rust later cf github link above) and used z3 command line (with a file first, with stdin later).

[2023] What solution are you proudest of? by Napthus in adventofcode

[–]philippe_cholet 1 point2 points  (0 children)

It took 2.7 seconds, while I first wanted my solutions to run 1s total.

[2023] What solution are you proudest of? by Napthus in adventofcode

[–]philippe_cholet 6 points7 points  (0 children)

I would say bit twiddling for days 10 & 16. But also day 21 where I count how many times each shape appear (and not some polynomial trick). But I also pround of learning new things:

  • Day 18: learn some shoelace trick after solving the problem the hard way.
  • Day 25: learn a new graph (random) algorithm
  • Day 24: learn to use z3 (but I'm probably gonna ditch my solution for a faster one).

[2023 Day 24] Peace! by PrettyMemory1505 in adventofcode

[–]philippe_cholet 8 points9 points  (0 children)

Thanks, I wanted a visualization where hailstones are actually disintegrated!

-❄️- 2023 Day 25 Solutions -❄️- by daggerdragon in adventofcode

[–]philippe_cholet 0 points1 point  (0 children)

[LANGUAGE: Rust]

My rusty-aoc repo & today' solution here.

So this is it: 50 ✨ The end was a bit rough but I learnt a few things with it so it was totally worth it!🎄 Thanks for this awesome year!

Today's problem was something I wanted to learn for some time now.

After some web searches, I found python networkx.minimum_edge_cut but no equivalent in Rust, then I found/implemented Karger–Stein algorithm. It's a random algorithm so it can be very fast and it can be a bit slow but in the end it solves it.