#100DaysOfCode – Hello Algorithm Challenges!

Day 32: November 13, 2017 – Time spent, 1 hour

Today’s Progress: Raised completed Free Code Camp Challenges up to 238. Hit the first of the Algorithm Challenges. Started solving the “Reverse a String” challenge. Along the way learned more about JavaScript arrays. Though I’m not sure why anyone would want to reduce an array.

Thoughts: Happy that I’m still coding away. Grateful for FCC’s explanation of the algorithm challenges and how they expected them to be frustrating. Reverse a String was easy enough to put into pseudocode and I thought FCC’s “helpful links” were generous. It took me a bit to figure out how to get the string into an array. My first guess was to try and using the str.split function with a regular expression for a non-space character but that gave me error messages. I decided I was overthinking things and used a for loop with string and array index values to get the string into an array.

I have to get ready for work soon, so I didn’t finish the challenge. But I feel pretty clear on how to reverse the array, convert it back to a string and return the reversed string.

I have a feeling that I’ll be writing a lot of pseudocode over the next few weeks.

Links that helped me get stuff done

  1. String –https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String

Link(s) to work

  1. https://www.freecodecamp.org/challenges/reverse-a-string
Advertisements
Posted in Technology | Tagged | Leave a comment

#100DaysOfCode Day 31: Bottleneck Broken

Day 31: November 12, 2017 – Time spent, 1 hour

Today’s Progress: Solved the Profile Lookup exercise on Free Code Camp (FCC), raised my completed coding challenges to 227 and learned about general expressions and the beginnings of object oriented programming. Possibly learned how word processors do word counts – using some form of a general expression to find non-whitespace groups of characters. In JavaScript this would be \S+.

Thoughts: My problem with the loop in the Profile Lookup exercise is that I had originally tried to combine “no such contact” and “no such property” in my loop. Looking back it should have been obvious that only the first name in the profiles list weould ever return a result about property. So I moved (I thought) the “no such contact” statement outside the loop. The only way the program should get to that statment is if the loop fully executed without finding a name.

But it still didn’t work. Not until I carefully counted all my curly brackets and noted where my (return “no such contact”) statement was. As far as the computer was concerned, that was still in the loop, breaking it whenever the first contact wasn’t an input. So I moved my curly bracket and the program worked.

After that, most of the challenges went easy even though many of them covered new-to-me stuff. I’ve already gotten a health respect for “regular expressions” that can search strings and I’m looking forward to getting in deeper into Object Oriented Programming.

Lastly, I’d like to thank several people on Twitter who let me know that there is a free simple javascript console in most modern browsers. See the links below for details. Learning programming has so much more support these days than when I was in college.

Links that helped me get stuff done

  1. How To Use the JavaScript Developer Console – https://www.digitalocean.com/community/tutorials/how-to-use-the-javascript-developer-console
  2. How can I run JavaScript programs in my computer offline?! – https://www.codecademy.com/en/forum_questions/55edac31d3292f78cc000080 (This covered “control-enter” to get yourself new lines to write multi-line JavaScript in the command line console. )
Posted in Technology | Tagged | Leave a comment

#100DaysOfCode Day 30 – Troubleshooting code and logic on FCC Profile Lookup

Day 30: November 11, 2017 – Time spent, 1 hour 30 minutes

Today’s Progress: Raised the number of completed coding challenges to 216. Learned how to insert “troubleshooting printouts” into Free Code Camp (FCC) code challenges. Worked on FCC Profile lookup.

Thoughts: The FCC Profile Lookup is a challenge that looked straightforward but wasn’t. I wound up looking at the hints page BUT NOT THE CODE. I had originally thought that the look up was going to be along the lines of “Using Objects for Lookups” at https://www.freecodecamp.org/challenges/using-objects-for-lookups but I wasn’t sure how to go through a compound list like the dating profiles using that. The hint, not so shocking, was to use for loops and equality checks.

That’s where I’m at now, but my code seems to be breaking its loop too early. I figured this out by adding some items to my return statements, including where my loop iteration was. Along the way I also forced the FCC console to accept input of my choosing by reassigning the function’s parameters within my function – something that should not should be done in production.

Forcing the parameters to ones of my choosing did demonstrate that I have the equality test and property tests formatted correctly. But my logic in combining them with my loop isn’t sound.

I’m not ready to give up yet. Though I do think I need somewhere to run and display javascript outside of Free Code Camp. I also need to get ready for a still life photography opportunity as there is more to life than coding. If the weather holds I’m also looking forward to seeing the new Thor movie with a few friends of mine.

Links that helped me get stuff done

  1. freeCodeCamp Challenge Guide: Profile Lookup – https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-profile-lookup/18259

Link(s) to work

  1. FCC Profile Lookup – https://www.freecodecamp.org/challenges/profile-lookup
Posted in Technology | Tagged | Leave a comment

#100DaysOfCode Day 29: The computer is not as forgiving as I am

Darth Vader says I find your untidy syntax most disturbing.

Day 29: November 10, 2017 – Time spent, 1 hour 30 minutes

Today’s Progress: Successfully completed the card sorting challenge. Worked though other Free Code Camp (FCC) coding challenges to raise my completion total to 214. Learned new stuff about JavaScript objects and reviewed loops which is pretty much them same idea in many coding languages.

Thoughts: Typos matter. If you write a letter or e-mail to another human being and there are typos, you will likely be understood. The reader may or may not be judgmental towards you but they will usually understand you. Not so with computers, not so!

Let’s start with the card counting challenge. The first thing I did this morning was to take a notebook and some test data and run the algorithm by hand. It worked. Got the results I was supposed to get – really. But my code wasn’t running that way. In the FCC environment it is a little hard to tell how your intermediate steps run as they just give you the final line of output. After some additional noodling around, I decided to look at the hint page. Results:

Hint 1 – Yep I did that.
Hint 2 – Previously done.
Hint 3 – Yes, I fingured that’s how it was done. But my code produces different results.

After that was “spolier alert – here’s the solved code.” I only looked at it because I felt I had followed all three hints.

Surprise! To my mind, the code solution matched my code exactly! I had already written this and yet it didn’t give the same result. For a moment I indulged a fantasy of FCC not running code correctly. But I realized the problem was most likely coder error. Even though I THOUGHT my solution looked like theirs, there must be a typo if I just looked hard enough.

Sure enough. Fixing a missing curly bracket in my switch and realizing that my “copy-paste-edit” approach had left me with two Jacks and no Aces was enough for my output to match the what the challenge asked for.

Feel free to judge me if you want because I did see the final code and maybe I should have kept just staring at my code after reading through the hints and knowing I had to be on the right track. I’m counting it as a win because I chose the correct elements,the pseudo code of the algorithm was exactly right and the fixes amounted to clerical changes and not a change in approach. But I will spend more time reviewing code for typos in the future.

Some of the other challenges this morning took longer due to typos of some sort of another. But all (mostly case sensitivity) were resolved without references to hints or code.

I’m human. I will make mistakes. But on some level it is nice knowing that so far, I’m getting the thinking straight and mostly need to honor punctuation and case sensitivity.

Links that helped me get stuff done
1. FCC Challenge Guide: Counting Cards – https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-counting-cards/16809

Link(s) to work
1. FCC Counting Cards challenge – https://www.freecodecamp.org/challenges/counting-cards

Posted in Technology | Tagged | Leave a comment

#100DaysOfCode Day 28 – FINALLY, a challenge! (card counting)

Day 28: November 9, 2017 – Time spent, 1 hour 20 minutes

Today’s Progress: Brought my Free Code Camp (FCC) completed code challenge count up to to 197. Learned new JavaScript tools like “switch.” Figured out one way to partially solve card counting challenge.

Thoughts: On the card counting challenge I haven’t run out of ideas, but I have run out of time. I find that I’m most consistent about coding when I do it first thing in the morning. On the plus side, for 28 days I’ve been consistently coding an hour or so day. Since I have a day job, the downside is that I only code for about an hour or so a day. But I’m happy for the coding time.

I did figure out part of the card counting challenge. Since 7,8,9 don’t affect the card count, I pulled them out of the function proper. Now those work. Tomorrow I’ll probably change my code from being switch based to if then based in case I don’t understand the new to me switch logic. If that doesn’t work, I’ll probably spend some pen and paper time working with the algorithm and seeing if I can generate pseudocode for it.

I’m not discouraged. Actually, after racing though a lot of JavaScript review, when I got to this challenge and didn’t get it right off, I thought “FINALLY! A challenge!” For some reason I picture Chris Hemsworth’s Thor saying this. Although certainly not in response to a coding challenge. Loki strikes me more as the hacker type. He’d definitely pick up coding if he thought it was a shortcut to global domination.

Tomorrow is a holiday for me. So I might get in more coding time. It does seem like I will need it!

Link(s) to work https://www.freecodecamp.org/challenges/counting-cards

Posted in Technology | Tagged | Leave a comment

#100DaysOfCode Day 27: Arrays and familiar feelings

Day 27: November 8, 2017 – Time spent, 1 hour

Today’s Progress: Worked up to 185 completed Free Code Camp (FCC) code challenges. Learned more about manipulating arrays in JavaScript and reviewed if-then statements and value comparisons.

Thoughts: Some of the Java array stuff really gave me a workout. I’m going to have to work at remembering what shift and unshift do. Pop and push made more sense to me. I might be naive, but it could be I actually do know more JavaScript than I thought I did. At least much seems familiar. Or it’s just the product of having a nodding accquaintance with several coding languages.

Links that helped me get stuff done

  1. Free Code Camp – https://www.freecodecamp.org/
Posted in Technology | Tagged | Leave a comment

#100DaysOfCode Day 26 – A little Github, A little review

Day 26: November 7, 2017 – Time spent, 1 hour

Today’s Progress: Committed Free Code Camp (FCC) Portfolio page code to GitHub. Worked on FCC JavaScript code challenges. Have now completed 157 FCC coding challenges so far. This includes all the HTML/CSS I did before the tribute and portfolio pages.

Thoughts: This has been a nice break. I’ve been exposed to JavaScript before. Just not proficient enough to claim it as a skill. Yet. Focused mostly on variable assignment, arithmetic and basic string functions that are common to a lot of programming languages. So far a good review. Expect more new learning soon.

Links that helped me get stuff done

  1. Free Code Camp –  https://www.freecodecamp.org/
Posted in Technology | Tagged | Leave a comment