Coder Social home page Coder Social logo

Comments (6)

gobanos avatar gobanos commented on September 1, 2024

Hum, input is trimmed to ease parsing (for example, when parsing a number on each line) here :

ArcStr(Arc::from(f.trim_end_matches('\n')))

There is currently no way to turn it off :/

from cargo-aoc.

tsheinen avatar tsheinen commented on September 1, 2024

Oh okay, I missed that while I was looking through the source. It might be worth mentioning that in the readme (or adding a way to turn it off) since it threw me for a loop this morning. My parser depended on a trailing newline for each passport and although it was easy enough to fix I didn't realize I needed to do that.

from cargo-aoc.

tsheinen avatar tsheinen commented on September 1, 2024

What would be the use case for stripping the trailing newline? str::lines is probably the best way to split a string like this into lines and it gives the same result with and without a trailing newline.

from cargo-aoc.

gobanos avatar gobanos commented on September 1, 2024

You're right, a flag to prevent trimming could be nice. After a glance at some old inputs, it still seems like a good default to me.

from cargo-aoc.

aldanor avatar aldanor commented on September 1, 2024

I would go as far as saying it would make sense to not trim anything at all - because otherwise a solution that works without cargo-aoc may not work with it, and vice versa.

from cargo-aoc.

dnlmlr avatar dnlmlr commented on September 1, 2024

So I'm pretty much zombifying this issue, but this behavior is absolutely unexpected and should not be the default imo.

Trimming the input in your solution or a generator function is literally one line, if you actually need it. Efficiently untrimming the input on the other hand is pretty much impossible without bad hacks.

This breaks for example a possible optimized solution with array_chunks::<4>() for aoc2022 day2. All lines consist of a structure like A X\n, which is exactly 4 bytes. When the trailing newline is trimmed, this skipps the last line and stops working.

from cargo-aoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.