Competition time :)

Not really but going for clickbait title :slight_smile:

What's the neatest reporter you can come up with to take a number surrounded by space chars (bonus points for any whitespace char) e.g " 5 " (5 surrounded by two spaces at each end) and just return the 5.

If the input is not considered numeric e.g "A5 ", (A,5 and two spaces) then it should return it untouched

Accidentally made this a predicate instead of a reporter, but the script should work!
untitled script pic (77)

I think you'll win the prize for most complicated way of doing it :slight_smile:

But it works :slight_smile:

Man I love javascript

untitled script pic (2)

untitled script pic (4)

The reason I compare trimmed to join (num) + is because when you set a veriable to NaN, it turns into 0.

Edit, here's a much more simplified version

Que? :slight_smile:

2nd solution looks good :slight_smile:

I said that because math calculations are done in javascript, so the javascript quirks still apply.

aah - got you :slight_smile:

And it even copes with other whitespace chars :slight_smile:

Here's essentially a single-block script doing the job:

untitled script pic (5)

It does handle e.g. " 5 4 " as a number (54) though, so I'm not sure if it qualifies.

Nice that it handle "5 4" (but not a requirement - this is for when I've parsed an AdventOfCode puzzle input but there is invisible whitespace surrounding numbers)

But it only handles " " and not all whitespace like @ego-lay_atman-bay so it's got 2nd prize :slight_smile:

If that's what you want, try this one-block script: untitled script pic (7)

yay i did it
it doesn't handle other whitespace characters though

untitled script pic (5)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.