Convert to LINQ
How would y'all make this using just LINQ functions?
basically input is a collection of grids separated by one whitespace line, and i want to transform it into a list of the grids
here is a cutout of an example of such a grid
8 Replies
shouldnt this
if(string.IsNullOrWhiteSpace(input[a]))
be == false
?nah its looking for the next blank line, then "chopping" there
I would probably just
yield
results myself, otherwise this is mostly fine
dont think you can easily rewrite this to "only LINQ". Probably can with the help of SuperLinq or MoreLinq thoubut input is a
string[]
. not a string
am i dumb, something is odd
no ok maybe i got thereinput[a] is a string
if that string is fully blank, or I guess pure whitespace, it counts as a delimiter
this type of input is very common in Advent of Code, but the usual approach there is to just split the entire string on
\n\n
firstand then it goes for the next group
can't you use the other linq operation for this, how is it called
i was thinking Chunk, but it's not it, you could probably do a GroupBy(not empty/space) maybe
Yeahhhh
I could have yielded it tbh but besides that I couldn’t think of anything else
I will look into chunk thanks :)
neither chunk or groupby will work here thou
just for fun, a way could be being fp about it
but there are could be other edge cases to work out and c# is probably not the language for this