Saturday, January 2, 2016

Caesar's Cipher Waypoint/Bonfire on Free Code Camp Solution

I'm working on front end development in Free Code Camp and haven't been able to walk away from my computer since I started except when I get stuck and hate coding and want to quit. Anyway, since the new waypoints/bonfires were added to the Basic JavaScript section yesterday, I hadn't been able to figure out Caesar's Cipher and was especially frustrated that I couldn't find any help on line and I'd become slightly dependent. So, since I finally figured it out and there is still no solution online, I figured I'd upload mine and hope it helps someone.

Even though you're probably just here to find some answers, I'm gonna explain why I did what I did.

1) First, I needed a way to transform letters into a letter 13 letters down the alphabet. I had a bunch of ideas about how to do this, but finally settled on using a huge switch statement. (For example, if the letter is A, make it N)
2) Since I eventually return the Free Code Camp-provided variable decodedArr, I figured the best way to store my answers from step 1 was in my decoded array
3) I needed a way to put every letter from encodedStr through my switch statement, so I made a for loop with codeArr[i].
That's it. It took me a million years to crack it but written out in three steps it looks stupidly easy.

*SOLUTION*


Here's a link to my solution on Free Code Camp if you want to see it with pretty colors and here is my FCC profile


There's probably a fancy way to format this on here so it doesn't look gross but I'm sorry:

function rot13(encodedStr) {

  var codeArr = encodedStr.split("");  // String to Array
  var decodedArr = []; // Your Result goes here
  // Only change code below this line

  for (var i=0; i<codeArr.length; i++) {

     switch (codeArr[i]) {
       case "A":
         decodedArr.push("N");
         break;
       case "B":
         decodedArr.push("O");
         break;
       case "C":
         decodedArr.push("P");
         break;
       case "D":
         decodedArr.push("Q");
         break;
       case "E":
         decodedArr.push("R");
         break;
       case "F":
         decodedArr.push("S");
         break;
       case "G":
         decodedArr.push("T");
         break;
       case "H":
         decodedArr.push("U");
         break;
       case "I":
         decodedArr.push("V");
         break;
       case "J":
         decodedArr.push("W");
         break;
       case "K":
         decodedArr.push("X");
         break;
       case "L":
         decodedArr.push("Y");
         break;
       case "M":
         decodedArr.push("Z");
         break;
       case "N":
         decodedArr.push("A");
         break;
       case "O":
         decodedArr.push("B");
         break;
       case "P":
         decodedArr.push("C");
         break;
       case "Q":
         decodedArr.push("D");
         break;
       case "R":
         decodedArr.push("E");
         break;
       case "S":
         decodedArr.push("F");
         break;
       case "T":
         decodedArr.push("G");
         break;
       case "U":
         decodedArr.push("H");
         break;
       case "V":
         decodedArr.push("I");
         break;
       case "W":
         decodedArr.push("J");
         break;
       case "X":
         decodedArr.push("K");
         break;
       case "Y":
         decodedArr.push("L");
         break;
       case "Z":
         decodedArr.push("M");
         break;
       default:
         decodedArr.push(codeArr[i]);
         break;
    }
  }

  // Only change code above this line

  return decodedArr.join(""); // Array to String
}

// Change the inputs below to test

rot13("SERR PBQR PNZC");



I can't promise that's a really efficient way to code it, but I can tell you that it made all the checkmarks green. Good luck!

Wednesday, December 31, 2014

Breathless

This blog has been kind of quiet for awhile because of school and everything. Yay for break! Unfortunately though, my creative inspiration had pretty much dried up while I was busy memorizing textbooks and concerning myself with curves, so Kelly came to the rescue! (You might remember her from this post or even this one) We came up with the concept for this shoot from this picture and luckily, I'd pressed some flowers from a walk I took at school at the beginning of the year and somehow managed to bring them home without breaking any.

Here are the results of our attempt at recreating that scene:











Saturday, September 20, 2014

Galaxy

5 years ago I was busy not paying attention in high school. The teacher was talking about something I couldn't care less about and standing in front of the projector so I couldn't see even if I wanted to. BUT it looked really cool projecting on her. Of course, while the idea was simple in theory, it was much harder to actually secure a projector. So I forgot about it for awhile...
(^^ This was the main inspiration)





Fast forward to my Wednesday Electronic and Computer Music 1 Class. The room is too small for all 15 of us so we have to rearrange every few minutes, depending on whether we need to see the computer, white board, or projector. WAIT. PROJECTOR. We each get 2 hours in the studio every week to do that week's assignment. So I seized my chance. Unfortunately, sacrifices had to be made so the assignment didn't exactly get done, but- WORTH IT. I came prepared. I brought my camera and tripod and had picked out pictures to project. My friends came and we infiltrated room 117. And yeah we needed our backs to be bare... This is what we got:




You can find these in better quality on flickr here

Thursday, September 11, 2014

Climbing Trees

Maybe you've felt like this before. Or, I don't know you, maybe you haven't. But I do now. It's the feeling 
of swallowing the lump.
of not enough oxygen when you breathe in.
of freefalling and grasping at air.
of the walls of this carefully constructed numbness caving in.
It's the feeling of being overwhelmed. 
When I get to this place, all I can think about is art. I can't sleep because I know I have things to do but I'll stay up and still not do them. Instead, I get incredibly creative.  It's a coping mechanism and it's a curse. There's that quote about "If you judge a fish on it's ability to climb a tree, it will live its whole life believing it is stupid"... and I don't know why but I haven't been able to get that out of my head since I heard it three years ago because it is just so relevant. I am judged everyday on my ability to do science when I know that's not what I am best at. So, right when I need to study the most, in the days before the test, I turn to art to prove to myself that I still have value even if I can't climb the tree. It's just kind of sad that the fish in this case was unlucky enough to be born into a world that pays its treeclimbers far better than its swimmers. And maybe it's good for me to learn to climb the tree but it's not exactly what I was designed for and sometimes it hurts when I fall off. But it's 5:21am and I'm hungry and I really need to study...



Saturday, August 23, 2014

End of Summer Edits

The end of summer scares me. In the beginning, I have a long list of things I want to do before the end of August, but every day I go to bed telling myself I can do it tomorrow... until tomorrow I'm back at school and nothing on the list got done. So this is the beginning of the list that I should have started in May but I'm actually just doing now. And I go back to school tomorrow.

Sunday, August 17, 2014

Mountain Air

There is a huge difference between seeing a picture of a place and being there. I guess it took me an extremely long time to reach that conclusion because that seems pretty obvious but it was news to me. I was standing on top of a mountain, trying to capture the view with a picture so I could savor it later when my muscles didn't ache and I didn't have to pee and it wasn't hailing/sleeting/snowing/raining on me, and nothing could match the feeling of being there. Even a panoramic picture can't capture the experience of having that much open space around you in every direction.  



I usually am at home, on a couch, and trying to edit pictures into coolness. Finally I had taken pictures that actually were cool and even had an adventure to match, but since mountain pictures are so naturally cool and easy to snap with a cellphone, they're so common. And that means that everyone has seen or taken mountain pictures at one point and now they've become pretty boring. Mine could not compare to any of the top ten Google image search results, so I didn't want to post yet another set of mundane mountain photography. You've seen that before. 





And everyone in my generation can easily run it through a filter before posting it on Instagram. 




Or a billion creative people around the world have already taken decent pictures and added text. 




But these deserved better than any of the available options. I felt mountains under my feet and in my hair and in my lungs when I breathed in the icy mountain air. It felt uninspired to just throw up the unedited pictures because relatively they are nothing special. But being there was special and I wanted to communicate that. And that's how this happened. 



 

and then I tried to edit this eleven times and failed miserably

 

and here's my flickr where you can find the raw, sooc photos if you want

Monday, July 28, 2014

Adventures

I took pictures with my friend and it rained so we went inside and took some more. Yeah.


Find these on my Flickr
This is my gorgeous friend Kelly who you can find on Instagram being famous here (she takes incredible pictures so you'd be missing out if you didn't check her out!)
Actually, this is a variation off the body ink theme which I will one day get my shit together and do. I've been obsessing about it since sophomore year of high school... and I'm about to be a junior in college in a month.