14
this post was submitted on 02 Dec 2024
14 points (100.0% liked)
NotAwfulTech
386 readers
4 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
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
4:
4-1
I 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-2
this 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.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.
i am a simple man
I see square input, i say n^2^