![]() To help make your requests as heartfelt and unique as possible, we’ve compiled a creative list of eight ways to ask your nearest and dearest to join you as you say “I do.”įollow our page Things Remembered Coupon Code to save 15% OFF + FREE Shipping on Personalized Gifts with coupon code at Things Remembered. Given the deep friendships you share and the kind of commitment you’ll be asking of your gals, it’s only appropriate to show your bridal-party-to-be just how much they mean to you. Now it’s time to surround yourself with your closest friends and family members by popping a crucial question of your own. Re-wrote my pt 1 to make it reusable for pt 2.You’ve given one very enthusiastic, “Yes!” to your fiancé’s proposal, and in no time you’ll be headed to wedded bliss. ![]() Once I had the thought of getting the area of an irregular polygon it was just a matter of realizing you have to subtract the nodes on the perimeter from that area. Lines = String.split(input, "\n", trim: true) Then I did a flood fill from the top-left and counted the even coordinates that weren’t discovered. If you find “|” then it’s just trivially flipping the value of whether you’re inside or outside.įor part 2, I added a space between every existing space in the grid and filled it in with either an empty space or a path segment. However, if you find “L-7” then you end up inside. The “opener” part was the tricky part for me to figure out: suppose you start from outside and you find “L-J”, then at the end of it you end up outside again. With these three variables, depending on the symbol, you can infer whether you’re at an inner point or not. Once we have a “cleaned up” version (the only symbols present are part of the loop and and S is replaced with its actual value), we can cast a horizontal ray for each row and at each step maintain three variables: how many inner points we found so far, are we inside the loop or outside, and what was the previous “opener”.Having a mutable 2D array here would certainly speed up things. I ended up choosing tuples because I hypothesized that fast lookups and memory colocation would speed up things, but I don’t have any evidence to back up this claim. Using immutable data structures here felt very wasteful, because a) for lists, we would have to iterate through each element each time since it’s a linked list b) for tuples, lookup is faster, but filling in the symbols on an empty canvas requires to copy the entire 2D array each time. At the last step, I could also now infer what S actually is based on the starting point I chose and the last step before S. Same steps as above, but while iterating I was saving what symbols are actually part of the loop, and the rest I filled with “.”.Part 2 was obviously a lot trickier, so I did the following: Iterate through the loop based on where a symbol could lead, until you reach S.įor part 1, just calculate how many steps it took to reach S again and divide by 2.Choose an adjacent point to start with, since we don’t know what S is, based on whether it’s connected to S (note: I suppose there could be an edge case where one has “-” on left and right and “|” on top and bottom, in which case it might choose the wrong one, but it worked fine on my input and all examples).The logic is as follows (spoilers incoming):
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |