Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2022 day 05a - Split issues #2

Open
GunterSchmidt opened this issue Oct 20, 2024 · 0 comments
Open

2022 day 05a - Split issues #2

GunterSchmidt opened this issue Oct 20, 2024 · 0 comments

Comments

@GunterSchmidt
Copy link

I really like your solution, but could not get it running on windows.

  1. \r\n is not supported and can not easily be implemented as the split requires one char only
  2. \r\n or \n can be at the end of the file, this breaks the logic.

I solved it like this:

   // let d = include_bytes!("../input.txt");
    let mut d_without_cr: Vec<u8> = input.into();
    if d_without_cr.contains(&b'\r') {
        d_without_cr.retain_mut(|it| *it != b'\r');
    };
    if d_without_cr.last().unwrap() == &b'\n' {
        d_without_cr.pop();
    }
    let d = &d_without_cr[..];

I did not want to fork as this of course has a performance impact.
But might be worse mentioning in case any other later comers like me take a look :)

Best,
G.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant