Hacked app code solutions – puzzle packs – FBI Job

As I mentioned elsewhere, the learning curve for Hacked is probably a bit steep for new coders. I didn’t just want to give you the answers outright. I’ve included hints to help where you might get stuck, all wrapped in spoiler tags. Teach a man (or woman) to fish! I’ve also included comments in the code blocks, which you can’t do in the app, but may help those who are just starting out with coding. Ignore them when typing them into the hackpad.

Note that while I tend to use the keyword “return” for better readability/understanding, you don’t always need it when the final action is to output your answer, which will save you some keystrokes and score you more points.

Erase target

Code

var_a = "";
var_b = input[0];
var_c = input[1];
while var_d < var_c.length {
  if var_c[var_d] != var_b {
    var_a = var_a + var_c[var_d];
  }
  var_d++;
}
return var_a;

[collapse]

Where’s waldo

Horrible Code

var_a = ["w", "a", "l", "d", "o"]
var_b = 0;
var_d = 0;
while var_c < input.length {
  if input[var_c] != var_a[var_b] {
    var_b = 0;
    if input[var_c] == var_a[var_b] {
      var_d = var_c;
      var_b++;
    }
    else {
      var_d = -1;
    }
    var_c++;
  }
  else {
    if var_b == 0 {
      var_d = var_c;
    }
    if var_b == 4 {
      return var_d;
    }
    var_b++;
    var_c++;
  }
{
return var_d;

[collapse]

Alone

Code - Concise 350, Complex 250
var_b = [];
while var_c++ < input.sort[input.length-1] + 1 {
  var_b.push(0);
}
foreach var_c in input {
  var_b[var_c]++;
}
while var_d < var_b.length {
  if var_b[var_d] == 1 {
    return var_d;
  }
  var_d++;
}

[collapse]

Alternative Code


[collapse]

Count words

Code - Concise 710, Complex 350

while var_a < input.length {
  if input[var_a] == " " {
    var_b++;
  }
  var_a++;
}
return var_b + 1;

[collapse]

Split strings

Code - Concise 410, Complex 350

var_c = "";
var_b = [];
while var_a < input.length {
  if input[var_a] == "-" {
    var_b.push(var_c);
    var_c = "";
  }
  else {
    var_c = var_c + input[var_a];
  }
  var_a++;
}
var_b.push(var_c);

[collapse]

4 thoughts on “Hacked app code solutions – puzzle packs – FBI Job

  • Kahn

    Here is my solution for Where is Waldo

    var_a = "";
    while var_b < input.length - 4 {
      while var_c < 5 {
        var_a = var_a + input[var_b + var_c];
        var_c++;
      }
      if var_a == "waldo" {
        return var_b;
      }
      var_b++;
      var_c=0;
      var_a="";
    }
    
    Reply
    • Joseph

      Here’s my Where’s Waldo code:

      var_a = "waldo";
      var_b = input;
      while var_c < var_b.length {
          var_d = true;
          var_e = 0;
          while var_e < var_a.length {
              if var_b[var_c + var_e] != var_a[var_e] {
                  var_d = false;
              }
              var_e++;
          }
          if var_d {
              return var_c;
          }
          var_c++;
      }
      Reply
  • spaceship

    What is the meaning “&lt” and “&quot” and how can i type them in in the app? I have already solved this but i want tó try out different solutions

    Reply
    • Andrew

      Somewhere down the line the code got mangled and converted into html elements. They should have been < and > and ” symbols

      Reply

Leave a comment

Your email address will not be published. Required fields are marked *