this post was submitted on 01 Dec 2023
18 points (100.0% liked)

NotAwfulTech

386 readers
8 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
 

Rules: no spoilers.

The other rules are made up as we 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 1 year ago
  1. Not my best work. No code in this comment, just check 5.dart if you want to see it in the github repo linked above.

GeneralI used a class this time because it looked like it might be helpful. I don't think it turned out to be that useful. Still, you can see Dart's interesting constructor and getter syntax on display.

a.Pretty straightforward, though I didn't read the format correctly and had the destination/source data reversed. Oops! Luckily, my performance here will in no way affect my future career.

b.I didn't read the prompt correctly, which tripped me up. Also, while my solution is correct, it assumes that the input could be trickier than what the problem threw at me. Specifically, the edge case I had in mind was a range of values split into many subintervals and needing to track those mappings. I threw in some print statements to discover that intervals were never split beyond two subintervals, which was disappointing. Oh well- being correct is the best feeling you can have if you are otherwise empty inside.

Other than processing the input in the form of intervals, I don't think there were any notable tricks at play here, so this was more of an exercise in implementing code cleanly, which I struggle with.