Leaena

Solver of Problems

Aug
12

I figured it out! Sort of on my own, sort of studying how others had “solved” it in different languages (a few of the “solutions” didn’t seem to work). Array Addition I is now my bitch. Also the next 10 easy problems from Coderbyte are on my GitHub. 6 more to go (well 7 actually, I gave up on ArithGeo, but the solving of Array Addition gives me hope that I will figure it out tomorrow). Problem description: Using the JavaScript language, have the function ArrayAdditionI(arr) take the array of numbers stored in arr and return the string true if any combination of numbers in the array can be added up to equal the largest number in the array, otherwise return the string false. For example: if arr contains [4, 6, 23, 10, 1, 3] the output should return true because 4 + 6 + 10 + 3 = 23. The array will not be empty, will not contain all the same elements, and may contain negative numbers. And my solution: (basically grabs the largest value out of a provided array and it runs through all the possible sum combinations of all the other numbers to see if one of those sums equals the largest values)

function ArrayAdditionI(arr) { 
  arr.sort(function(a,b){return a - b})
  var largest = arr.pop();
  var sum = 0;

  for (var i = 0; i < arr.length; i++){
    sum += arr[i];

    for (var j = 0; j < arr.length; j++){
      if (i != j) {
        sum += arr[j];
        if (sum == largest) {
          return true;
        }
      }
    }

    for (var k = 0; k < arr.length; k++) {
      if (i != k) {
        sum -= arr[k];
        if (sum == largest) {
          return true;
        }
      }
    }

    sum = 0;
  }

  return false;      
}

Coderbyte and Me

Aug
11

I’ve been practicing my JavaScript for the HackReactor interview on the 20th (wish me luck by the way). They sent around an email saying to be prepared so you didn’t have to reschedule (I’m suddenly glad I couldn’t get an appointment straightaway). They recommended being able to get through all the easy challenges on Coderbyte in < 5 minutes. Yikes? Surprisingly not. I’m having a lot of fun.

There are a couple things I’ve obviously forgotten (I had to look up the regex to keep only alpha characters, I suck at regex), but I’m pretty fast. I’m also realizing just how not amazing I am at the trickier puzzles. There are one or two in there that I still don’t understand, even after I caved and looked up how others solved them (Array Addition I, I’m glaring at you).

There are 26 easy challenges. I’ve decided to run through at least 10 a day, so I finished the first 10 today and uploaded them to my GitHub. My favorite one so far was the TimeConvert, which took a number (e.g. 126) and converted to the amount of hours and minutes (e.g. 2:6). I could have made it prettier by added a preceding 0 in the minutes, but the goal of these is speed and the instructions didn’t ask for that pretty extra. This was my favorite because I just have this weird love for modulus. The code to solve it:

function TimeConvert(num) { 
  var minutes = num % 60;
  var hours = parseInt(num/60);

  return "" + hours + ":" + minutes;         
}

Slogging Updates

Aug
07

I got a conditional acceptance from App Academy. I have to do the homework and take one more coding test before they will let me in because I bombed the last coding interview. I’m actually not upset at all. I was worried that I was going to feel obligated to go when I really want to see how my interview with Hack Reactor goes. I understand that App Academy would be a good choice from a finances perspective, but the raw talent that they seem to be churning out of Hack Reactor is really intriguing, especially when Ruby isn’t my favorite language and JavaScript was the first one I ever learned.

Updates as they come! Hack Reactor interview isn’t until the 20th and I probably won’t try to finish up the App Academy homework until around that time as well.

Programming Comments Off on Slogging Updates

Everyone’s On It

Aug
07

I just made something! For the first time ever I made a stupid little ruby program to do something that a PivotTable was giving me fits over at work. I had a spreadsheet like so:

Spreadsheet of Traits

But what I really needed was a text file that I could print and hand out to people like so:

Formatted Strengths

And I did it with the power of Ruby! I was so proud of myself. I’ve never taken a real world problem (from my work no less) and made a tiny bit of code do exactly what I want it to. It just adds to my love of coding.

require 'csv'

contents = CSV.open "strengths.csv", headers: true, header_converters: :symbol
File.open("out.txt", 'w') do |f|
  contents.each do |row|
    headers = contents.headers
      name = row[0]
    strength = {}
      i = 1
    while i < row.length
      if row[i]
        strength[(row[i].to_i)] = i
      end
      i += 1
    end
    f.write("#{name} \n")
    stren = strength.sort_by { |k, v| k }

    stren.each do |k,v|
      f.write("\t #{headers[v].to_s.capitalize} \n")
    end
    f.write("\n")
  end
end

And yes, those are my StrengthsFinder top 5 in the second picture. Everyone at work had to do them and I think mine are very accurate.

Programming , , Comments Off on Everyone’s On It

Third Guessing?

Aug
01
Programming Comments Off on Third Guessing?

Second Guessing

Aug
01

As an addition to my post below about App Academy. I’m starting to feel less confident in myself. I did well on the second coding test and I’m through the first interview now but according to the website I assumed that meant it was my only interview. Not so said the TA who put me through a coding test. So ugh. I was nervous, I got it done, but not prettily and I made some stupid mistakes. When I finished I was upset and called both my parents and my best friend. My dad was the best about the whole situation. He just wanted to make sure I wouldn’t give up if I didn’t get in to this ONE program. He was right.

I spent the rest of the evening prepping applications to the other programming schools in the Bay Area. I finished one for Coding Dojo and got an email this morning to set up an interview next week! I also applied to HackReactor which has suddenly vaulted itself to the top of my list. Not gonna lie, the free gym and really high success rate of graduates makes me happy. Both of those programs are also in November so they are my three that I’m most excited about. I also will probably apply to Dev Bootcamp and Hackbright, but they aren’t until next year and I don’t want to wait that long if I don’t have to.

Life, Programming Comments Off on Second Guessing