My experience on the Lighthouse Labs 21-Day Coding Challenge 2019.

Here is the complete package of my experience of the 21 Day Coding Challenge 2019 .

Screenshot 2019-05-21 at 4.01.14 PM.png

What I learned

My Experience

The decision to embark on this journey was certainly worth it. I initially thought this challenge would be super hard and I wouldn't be able to finish it. But it turned out to be the opposite. I was very excited to do the next challenge every day and it sort of became a routine.

The best thing about this challenge is actually the help forum. The community, which had a mix of newbies and senior developers was fantastic and helpful. And solutions aren't allowed in the forum, which was for the best as people could have just copied the solutions and finished the challenges without putting in any effort.

I am not from Canada, which means I am not eligible for the prizes (such a bummer :( ), but this challenge actually meant more to me than the prizes. It was an experience, an endeavour, a training that taught me about failing and how important it is to have good code. It was the errors and bugs that gave me an imperative insight of how coding is like, a lot of debugging and making sure your code works.

Another thing about this challenge was how it provokes you to come up with solutions and how flexible the solutions were. There were many ways I could have solved the challenge, some were long and some were simple and short. That made me realise that coding requires you to think out of the box and come up with the best solution possible.

This challenge was a remarkable practice and shift towards being a better programmer and problem solver. I highly recommend all those who wants to learn more, in an intuitive and fun way to join this challenge in the future.

My Solution

function powerOn() {
  ship.powerOn = true
}

function countModules () {
  return availableModules.length
}

function countEssential() {
  var count = 0;
  for (let i=0; i<countModules(); i++) {
    if (availableModules[i].essential) {
      count++;      
    }
  }
  return count;
}

function loadModule(index) {
  var module = availableModules[index];
  module.essential = true;
  module.enabled = true;
  ship.modules.push(module);
}

function loopModule() {
  for (let i = 0; i < availableModules.length; i++) {
    if(availableModules[i].name === "life-support") {
    loadModule(i);
    }
  }
}
loopModule();

function findModuleIndex(name){
  for (let i=0; i < availableModules.length; i++){
    if (availableModules[i].name === name){
      return i;
    }
  }
}

loadModule(findModuleIndex("propulsion"));
loadModule(findModuleIndex("navigation"));
loadModule(findModuleIndex("communication"));

function resetLarry() {
  for (let i = 0; i < 10; i++) {
    LARRY.quack()
  }
}
resetLarry();

function setMessage() {
  radio.message = JSON.stringify(navigation);
}
setMessage();

function activateBeacon() {
  radio.beacon =true;
}

let setFrequency = (item) => radio.frequency = (radio.range.low + radio.range.high) / 2;

function initialize() {
  navigation.x = 0;
  navigation.y = 0;
  navigation.z = 0;
}

function calibrateX() {
  for (let i=0; i<12; i++) {
    signal = checkSignal();
    if (typeof signal !== 'undefined') {
      navigation.x = signal  
      break;
    }
  }
}

function calibrateY() {
  for (let i=0; i<60; i++) {
    signal = checkSignal();
    if (typeof signal !== 'undefined') {
      navigation.y = signal  
      break;
    }
  }
}

function calibrateZ() {
  for (let i=0; i<60; i++) {
    signal = checkSignal();
    if (typeof signal !== 'undefined') {
      navigation.z = signal  
      break;
    }
  }
}

function calibrate() {
  calibrateX();
  calibrateY();
  calibrateZ();
}

function setSpeed(speed) {
  var intSp = parseInt(speed, 10);
  if (Math.sign(intSp) !== -1 ) {
    navigation.speed = intSp;
  } 
}

function activateAntenna() {
  ship.antenna.active = true;
}
activateAntenna();

function sendBroadcast() {
  for (let i=0; i<100; i++) {
    broadcast();
  }
}
sendBroadcast();

function configureBroadcast() {
  for (let i = 0; i<100; i++) {
    setFrequency();
  }
  activateAntenna();
}

configureBroadcast();

function decodeMessage(message){
message = message
  .replace(/1/g,'i')
  .replace(/2/g,'u')
  .replace(/3/g,'e')
  .replace(/4/g,'a')
  .replace(/5/g,'y')
  .replace(/0/g,'o');
  return message;
}

function returnToEarth() {
  let x = broadcast("x");
  let y = broadcast("y");
  let z = broadcast("z");

  let messageX = parseInt(decodeMessage(x), 16);
  let messageY = parseInt(decodeMessage(y), 16);
  let messageZ = parseInt(decodeMessage(z), 16);

  navigation.x = messageX;
  navigation.y = messageY;
  navigation.z = messageZ;
}
returnToEarth();

More resources from Lighthouse Labs

Thanks for reading and have fun coding!

No Comments Yet