Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Stephen Whitcombe
seal-mask
.a{fill-rule:evenodd;}techdegree
Stephen Whitcombe
iOS Development with Swift Techdegree Student 662 Points

Trouble with Code Challenges (iOS)

So, I just wanted some general feedback from the community because I am having trouble with the Code Challenges with iOS, and I am almost wondering whether I am capable of doing this stuff.

Little background about myself. I have zero experience in computer software. That said, I'm a smart person. I've always had a decent knack for math, and I am an attorney. I thought maybe I could pick-up coding while I was in-between jobs.

Anyway, I'm not sure why I am having so much trouble with the coding challenges. I am doing all the videos sincerely. I'm watching them carefully with no distractions. I'm taking notes and following along in my Xcode application. And I'm thinking through the videos analytically.

What I find strange is that it's not exactly the Swift language that is giving me problems, but it is the extra steps we did not discuss that I am unable to do. For example, one coding challenge asked us to get all numbers that were not "even." I would have never thought to do something like "n % 2 = !0."

I guess I'm just at a loss. Every coding challenge I try for about 30-45 minutes, and then I get somewhat close and look-up the answer eventually. And each time the issue is some small minor detail that I honestly am not sure I would have picked up on because it is something we didn't learn.

Sorry for the rant. Would appreciate some advice from more experienced individuals on Treehouse. Is it okay that I am massively struggling with the coding challenges? Am I not learning the material nearly as well as I think I am?

What I am worried about is that I am going to get to the first project, and have absolutely no idea what to do.

Thanks for any feedback.

Warm regards, Stephen

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Stephen Whitcombe ! First, you're not alone. Lots of people have problems with programming challenges. Just take a look at these boards :smiley: I once got stuck on one for 3 hours because I used the wrong quotation mark, and I'm not kidding. You've probably heard this before: "How do you eat an elephant? One bite at a time." That is no truer anywhere than it is in this particular discipline.

I have a theory about those of us that take on this particular challenge (and I mean programming). I feel like we tend to be very detail-oriented and in some cases so much that we get mentally "zoomed in" on the problem. We are looking at it and looking at it and can't see it. Ever put down a coffee cup, pen, or book and come back two minutes later and you can't find it? You could've sworn you put it right there. And then someone right beside you points to it, and it turns out you've been looking at it all along? That's a real psychological phenomenon known as a "mental schotoma" or blind spot. Once you say to yourself that you can't see it, your mind goes ahead and makes that real. Sometimes, the absolute best thing in the world you can do is stand up and walk off. Try and mentally "zoom out" for a bit if you can.

I feel like you might also be missing a step here. Before you try and put your thoughts into Swift code, try and put them into ordinary English (or whatever native language you might have). Now, I would bet you good money that you could teach a 3rd grader what an odd number is. And how would you define an odd number? You could say all numbers that are not divisible by 2, but that's not really accurate, is it? Because all numbers are divisible by two. Three divided by 2 is equal to 1.5. What you mean to say is that numbers that are not evenly divisible by 2 are odd. Then you have the challenge of what does evenly divisible by mean? Well, we say something is evenly divisible by another number when we can divide by that number and there is no remainder. This is what the modulus/remainder operator does. It returns the remainder of the division by that number. For instance 23 % 10 would return 3. Twenty-three is divisible by 10 twice, with remainder of three. Now, in the case of even/odd, we don't really care what the remainder is (as it can only be 0 or 1), we just care if there is a remainder. So any number that is evenly divisible by another will have a remainder of 0. Swift is a bit of an oddball here in that it actually uses the ! mark for other things, but in most languages, and even in this case you can actually read that as "NOT". So if (n % 2 != 0). And this is how you would read that in English: "If a number is divided by two and the remainder is NOT 0. Which means that number is odd :smiley:

So you are about to start on your first project, I take it. Remember, take it one step at a time. Break it down as small as you can possibly get it. Programmers even include things in the first parts of their code called "sanity checks" just to make sure basic things are working properly. I will leave you with this great quote to chew on:

"Every great developer you know got there by solving problems they were unqualified to solve until they actually did it." ~ Patrick McKenzie

Hope this helps! :sparkles:

Stephen Whitcombe
seal-mask
.a{fill-rule:evenodd;}techdegree
Stephen Whitcombe
iOS Development with Swift Techdegree Student 662 Points

This is stellar advice, and thank you so much for taking the time to respond. What particularly resonated was your statement "You can explain things like an odd number to a third grader." I think I need to take that approach, and think about what I want to do/say in simple terms and then move forward to figuring out how to say that in code.

Thanks so much. I feel reinvigorated!

Warm regards, Stephen