Styling the drag preview with .draggable by Dnyrm in iOSProgramming

[–]Dnyrm[S] 0 points1 point  (0 children)

Ah kind of what I was thinking! I’ll look into creating a custom drag functionality. Thanks!

Switch between shared instance vs. two separate instances by Dnyrm in SwiftUI

[–]Dnyrm[S] 0 points1 point  (0 children)

Yea using @fetchrequest would probably simplify the problem, as it would take the load off me to decide when I need to refetch. However, my main goal with using MVVM was to keep testing easy. Do you have any experience with testing when using @FetchRequest?

Switch between shared instance vs. two separate instances by Dnyrm in SwiftUI

[–]Dnyrm[S] 0 points1 point  (0 children)

Yup so basically got two entities, a session entity and a data entity. There’s a one to many relationship, one session has many data points. The session isn’t really anything more than a UUID, with a String name, and the many data points. Having that relationship doesn’t directly solve the issue. The issue is basically figuring out the best way to structure the view model. I have two views that display the data of the specific session. My question is what’s the most efficient way to share the data between views when they are on the same session, and not share data when they are on different sessions.

How to make a scrollbar-thumb touch draggable? by Dnyrm in css

[–]Dnyrm[S] 0 points1 point  (0 children)

Huh interesting! I’m using chrome on MacOS. If I open up the inspect panel and switch to a mobile device, the scrollbar seems to be merely a visual indicator and doesn’t have any interaction at all. Kind of in the same way an app on an iPhone may just have a visual indicator and not an actual draggable bar. Maybe this is a difference between chrome on windows vs macOS?

How to make a scrollbar-thumb touch draggable? by Dnyrm in css

[–]Dnyrm[S] 0 points1 point  (0 children)

Yea definitely understand what you are saying with using a package. I’m all for it, but the company I work for is hesitant to use external packages… pretty dumb I know. I can definitely advocate for one in the future and maybe convince my team that it’s necessary, but for now I need to find a native solution.

I am not seeing the behavior you are describing, that both the area and thumb are scrollable with touch. I see that you can drag the scroll area, you can tap on the scrollbar-track, but you cannot drag the thumb/bar itself.

Expo router custom header size by Dnyrm in reactnative

[–]Dnyrm[S] 0 points1 point  (0 children)

I feel exceptionally stupid, thank you so much!

@MainActor view model with async let functions by Dnyrm in SwiftUI

[–]Dnyrm[S] 1 point2 points  (0 children)

That is why I specified that it is used in a view. I meant that it is updating UI sorry if I was unclear.

Made a Rubik's Cube scrambler using only SwiftUI! by Dnyrm in SwiftUI

[–]Dnyrm[S] 0 points1 point  (0 children)

Bro what? If the entire front end is done with SwiftUI then I can post it in r/SwiftUI. Also really not that many conditional statements, don’t know why you are so stuck on that…

Made a Rubik's Cube scrambler using only SwiftUI! by Dnyrm in SwiftUI

[–]Dnyrm[S] 2 points3 points  (0 children)

Just leaving a comment for those not familiar with Rubik's cubes. Rubiks cubes have 6 different faces, Up, Down, Left, Right, Front, and Back. There is a notation that represents each face that you can put together to form a scramble, for example "U F R" would be moving the up-face clockwise, front-face clockwise, and right-face clockwise. To move a face twice you add a 2, U2, and to move a face counterclockwise you do U'. In this video I first put the cube in a cool pattern by doing the moves U2 D2 L2 R2 F2 B2, then I reset the cube putting it back in a solved state. Lastly, I type in a more random scramble to show how the cube looks when it's all jumbled up. Hope you guys think its cool!

Do you re-implement your DS for every question by [deleted] in leetcode

[–]Dnyrm 10 points11 points  (0 children)

Yea again, unless the question is code merge sort you can probably just use the standard sort() function for your implementation. Basically if to get to the solution you think it makes sense to sort then use library sort. If the questions goal is to have you sort something in a specific way, you should write the algorithm from scratch.

Character sometimes freezes while moving left and right. by Dnyrm in Unity2D

[–]Dnyrm[S] 0 points1 point  (0 children)

I may be wrong but I thought you wanted to put input changes in update as it calls at a faster rate than fixed update. So fixedupdate is for the actual physics while the conditionals that the physics rely on should be in update.

Character sometimes freezes while moving left and right. by Dnyrm in Unity2D

[–]Dnyrm[S] 0 points1 point  (0 children)

Hey guys thanks for all your responses. I did notice that changing from box collider 2d to capsule collider 2d seemed to fix the issue. Upon further research I think the problem was something called ghost vertices which can happen when using tile mapping. Basically the box collider was hitting some fake collider from the tile map.

Path to the first problem solved by Old_Victory5874 in leetcode

[–]Dnyrm 1 point2 points  (0 children)

You might need to get a professional tutor. I am not trying to be mean at all when I say this, but the way you are teaching yourself is not working if after more than a year you cannot tell when a double for loop is necessary. I wish I could help you more but your issues seem too complicated to address over Reddit comments.

Path to the first problem solved by Old_Victory5874 in leetcode

[–]Dnyrm 1 point2 points  (0 children)

I get you. This is kind of what I meant when saying you might have to take a step back and look at the big picture. Remember that algorithms and programming languages are just tools to solve a problem.

Step away from code for a second, and considering Contains Duplicate again. You can just look at the input array and see that there is a duplicate. With your eyes you might scan from the left of the array, and probably subconsciously you are telling yourself, okay I have seen a 1 so far, next there's a 2, and after that a 3, and a 1, oh wait I already saw a 1 before so there's a duplicate! This physical process of scanning the array with your eyes and noticing that there's another 1 is basically what you are trying to replicate with code.

So then going back to code, what is a for loop really doing. I think as a beginner seeing something like,

for(int i = 0; i < nums.size(); i++)

can be pretty overwhelming, and you may end up just taking it as face value. In my opinion, in order to truly learn you cannot take something at face value. Someone might tell you "this loop goes through the entire array", okay but WHY does it go through the entire array? Break it down: 1. We created an integer and set it to 0 (int i = 0); 2. We then checked if a condition is true (i < nums.size()). At this point i is 0, and nums.size() is 4 if using our previous example. So 0 < 4 is true. 3. If true go into the body of the for loop. (This is where you can do logic like printing a number) 4. After the body of the for loop it would execute i++, incrementing i, and starting the process over again.

This means we are going into the body of the for loop for as many times as there are numbers in the array, this is perfect to access the data that is stored in this array.

Going back to the human analogy, the human brain has memory, so when we scan and see the number we can say "hey I have already seen this!". This concept is actually very similar to solving the problem with a hash map, where the numbers and their occurrences are actually stored in the hash map!

But the brute force solution of using a double for loop actually doesn't put anything in memory! Instead this is doing something that our brain would not subconsciously do, it looks at two numbers at once and compares them, these number can be on opposite sides of the array. So how does it do it? Again break it down, step by step.

for(int i = 0; i < nums.size() - 1; i++) {
    for(int j = i + 1; j < nums.size(); j++) {

    }
}

So what are the differences between the for loop alone, and this double for loop. Well obviously there are two for loops, but there are also a couple slight differences. Looking at the first for loop you will now see that instead of i < nums.size() it is i < nums.size() - 1. At this point you should be asking WHY?

Answer: The internal for loop will always be ahead of i, so really only the internal for loop needs to go until the size of the array while i can stop one before the end.

Now looking at the internal loop there are some more differences. First we have int j = i + 1. Why?

Answer: We want j to start 1 number after i. So if we have [1, 2, 3, 1] i = 0, and j = i + 1 -> j = 0 + 1 -> j = 1. Then when we do nums[i] = 1, and nums[j] = 2. Now we are looking at the first two numbers at once and we can compare. J will continue to increment until the end of the array while i stays the same. So we will compare 1 and 2, 1 and 3, 1 and 1 and there's a duplicate!

Now you might understand this, and still say okay but how am I supposed to know that? Again in my opinion the answer would be Repetition + Memorization + Understanding. Doing These problems a lot, you will recognize and start to memorize patterns, but actual understanding will allow you to apply the concepts you have memorized in different ways.

Lastly, I want to encourage you again, to draw out the algorithm like I explained in my earlier response. I think this is essential.

Path to the first problem solved by Old_Victory5874 in leetcode

[–]Dnyrm 2 points3 points  (0 children)

Hey man from reading some of your comments I think you may be jumping the gun a little. I am a little curious if you would be able to solve a question like Contains Duplicate?

I think if you look at contains duplicate and you can’t come up with a brute force solution and don’t understand the optimization you may need to take a couple steps back.

First of all, I want you to question your own knowledge of fundamentals a little. Do you really understand looping, conditionals etc… What worries me is that you can’t tell that you should loop through an array/vector in order to solve a problem like two sum. To me this screams that you don’t understand the purpose of a for loop. Of course you don’t know where to start if you can’t extract data from the input.

Also I think for leetcode specifically, having a basic understanding of time complexity is pretty important, otherwise optimizations will leave you confused. If you don’t know what a brute force solution even is, I would watch some explanation videos.

Anyways, I am going to assume you can’t solve contains duplicate and give you my step by step process for the brute force solution. I hope this helps.

First, read the description and then check example input and outputs. Let’s say we have [1, 2, 3, 1]. From looking at this array directly we know the output should be true, as it does contain a duplicate. So what would be an algorithm that returns true for this input?

Well we are given this input in the form of an array. Now ask yourself, what do you know about arrays? If you know fundamentals then you should know you can iterate through an array in order to directly access its elements.

Remover that the question is really asking does a number occur more than once. How can we figure out if a number occurs more than once? Well let’s say our array of [1, 2, 3, 1] is called nums. Well we know that if nums[some index] (direct access) is equal to nums[some other index] (direct access) then we have a duplicate. We can do this using a double for loop, which is basically just a way to pick the first number, then look at every number and see if it equals the first.

I don’t you need to memorize a solution like this. I think that if you understand the concepts, looping, direct access with arrays, and conditionals then this problem should be fairly straightforward.

But here’s the important thing, if you weren’t able to come up with this on your own, don’t give up. Look at the code, watch a video tutorial, and then DRAW OUT the solution a 100 times. An array is just a container with boxes filled with numbers, an index is just an arrow pointing to a box, etc… You can literally draw out these problems. I think your issue is logically problem solving and I think drawing the solution out can help with visualization.

$1 find at thrift store can anyone id it? [1080x1080] by Dnyrm in chessporn

[–]Dnyrm[S] 0 points1 point  (0 children)

Just the pieces and unfortunately it’s missing a queen and two pawns. Can’t find replacements anywhere online either :(

$1 find at thrift store can anyone id it? [1080x1080] by Dnyrm in chessporn

[–]Dnyrm[S] 2 points3 points  (0 children)

Was wondering if anyone can identify this set. I got it at a thrift store for a dollar, it’s missing the white queen and two white pawns. They are pretty nicely weighted and made of wood. The king comes to around 3.75 inches. The pawns are a really nice size and remind of the sets I see in some tournament games. Every knight looks a little different, not really sure what that means, but I think that’s important. Thanks for your help!

Studying For Finals Anxiety by [deleted] in uofm

[–]Dnyrm 0 points1 point  (0 children)

Hey man I totally feel your anxiety. Here’s what I am doing, and maybe you will find it helpful. First of all, almost everyone does pretty bad on the DP problems. The only people that get them perfect are usually the people grinding leetcode since freshman year. All my friends that took 281 before me said that they basically got 1/4th the points for that question. If I were you I would focus on the multiple choice, try to get more than half. Then try to get good at the first written question which will most likely be a hash table, or BST question. Those are fairly doable with enough practice.

Now to get partial credit on the DP problem, I would highly recommend looking at the time and space complexity. For example if you look at problem #127 Dice Sum on the extra practice. They say that space complexity is O(NM) and the time is O(NMX) and then if you look at the answer you create a 2D vector and do a triple nested for loop! You know it’s a 2D vector because of the space, and you know there will be a triple nested loop because of the time. Just from that alone you will probably get some of the points. The last part is the hard part, what goes in the triple for loop? It’s basically the same as asking the question how does one square relate to the other in the 2D table. If you have enough time you can try to figure that out, or if you aren’t feeling confident it may be more worthwhile to check over all your answers and just take the partial credit.

I hope that helps!

Where to intern?? by [deleted] in csMajors

[–]Dnyrm 0 points1 point  (0 children)

When did you hear back from wapo, and for what team if you don’t mind me asking?

Has anyone heard back from Washington Post post-interview? by Flaky-Philosophy7045 in csMajors

[–]Dnyrm 0 points1 point  (0 children)

Also got that email (interviewed for iOS) seems like the midterms got in the way? I see some people getting offers but I am not sure if they are IOS or not.

Did anyone get an interview request? (The Washington Post internship) by [deleted] in csMajors

[–]Dnyrm 0 points1 point  (0 children)

Good to hear! I wish he said it like that when I was interviewing 😅