this post was submitted on 02 Dec 2024
14 points (100.0% liked)

NotAwfulTech

385 readers
3 users here now

a community for posting cool tech news you don’t want to sneer at

non-awfulness of tech is not required or else we wouldn’t have any posts

founded 1 year ago
MODERATORS
 

copy pasting the rules from last year's thread:

Rules: no spoilers.

The other rules are made up aswe go along.

Share code by link to a forge, home page, pastebin (Eric Wastl has one here) or code section in a comment.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 3 weeks ago (1 children)

4:

4-1I tried something clever and was punished for my hubris, but it turned out ok.

I treated the input as a list of strings and searched for "XMAS" and "SAMX", rotating and transposing the list to scan for vertical and diagonal words.

In my arrogance, I thought I could do the diagonal rotation easily, but I was very wrong. I got it out in the end, though.

4-2this was easier than 4-1. An O(n^2^) solution just scanning for X-MAS was good enough. Maybe there was a more clever solution that used, i dunno, string hashing or something but whatever.

[–] [email protected] 2 points 3 weeks ago (1 children)

re: 4-2

is it really n^2 tho? You have to do a constant check around each element, but that does not increase with the number of elements. And you can optimize a bit by marking already seen 'A's as illegal states and don't have to check them when the next row is processed.

[–] [email protected] 2 points 3 weeks ago

i am a simple manI see square input, i say n^2^