1. 程式人生 > >Walkthrough of Hacked -【黑客出擊】程式設計遊戲攻略

Walkthrough of Hacked -【黑客出擊】程式設計遊戲攻略

Chapter 1 The Hackpad

As a 16-year-old kid in a normal town, living a normal life, everything is boring as hell. Walking home, some guy comes up to you and says:
-Kid, you don’t know me, but I know you, I’d tell you about me and where I come from but you wouldn’t believe me. I don’t have much time. Take this HackPad,use it to stop Sky… Use it to save the world when the time comes. Right now, just learn how to use it, and keep it with you at all times. Go hack your way up kid! I believe in you!-

Increment me

  • Pattern detected
in out
2 3
5 6
8 9
  • Code
input+1;

Positive

  • Pattern detected
in out
3 true
-7 false
9 true
  • Code
input>0;

Absolute

  • Pattern detected
in out
1 1
-2 2
0 0
  • Code
if input < 0 {
    return -input;
}
return input;

Absolute2

  • Pattern detected
in out
1 1
-2 2
0 0
  • Code
abs(input);

Chapter 2 High School Hack

So here you are with this cool HackPad and a lot of time on your hands. Your grades are not so good, let’s use this HackPad to give them a little boost.
A High school grading system cannot be that hard to hack with this thing, right?

Power

  • Pattern detected
in out
2 4
3 9
4 16
  • Code
while var_a < input {
    var_b = var_b + input;
    var_a++;
}
retrun var_b;

Power 2

  • Pattern detected
in out
2 4
3 9
4 16
  • Code
pow(input,2);

Length

  • Pattern detected
in out
[3,8] 2
[4,5,3] 3
[6] 1
  • Code
foreach var_a in input {
    var_b++;
}
return var_b;

Push it

  • Pattern detected
in out
5 [0,1,2,3,4]
2 [0,1]
0 []
  • Code
var_a = [];
while var_b < input {
    var_a.push(var_b);
    var_b++;
}
return var_a;

Chapter 3 Jailbreak

A good friend of yours comes up to you with his brand new phone, asking if you could Jailbreak it. He’s pretty techsavvy, so you ask him why he doesn’t just go on the web and do it himself. He says no-one has managed to crack the security on this model yet.
Sounds like a job for your HackPad.

Max

  • Pattern detected
in out
[3,8] 8
[3,1] 3
[0,99] 99
  • Code
var_a = input[0];
foreach var_b in input {
    if var_a < var_b {
        var_a = var_b;
    }
}
return var_a;

Maxxxx

  • Pattern detected
in out
[3,1,8,0,2] 8
[1,3,2] 3
[9,42,7,13] 42
  • Code
var_a = input[0];
foreach var_b in input {
    var_a = max(var_a,var_b);
}

This is odd

  • Pattern detected
in out
5 1
7 1
2 0
  • Code
while input > 1 {
    input=input-2;
}

A man, a plan, a canal: Panama

  • Pattern detected
in out
[c,a,t] false
[k,a,y,a,k] true
[b,o,b] true
  • Code
var_a = input.length / 2;
var_b = input.length - 1;
while var_c < var_a {
    if input[var_c] != input[var_b - var_c] {
        return false;
    }
    var_c++;
}
return true;

Chapter 4 Ch

You’ve finished most of the games on the latest console, but there is one game resisting you. It’s ridiculously hard.
Turn on your HackPad and don’t put it down until you’ve hacked your way to the top.

Bring some order

  • Pattern detected
in out
[c,b,a] [a,b,c]
[d,g,e,h,f] [d,e,f,g,h]
[z,x,y,w] [w,x,y,z]
  • Code
while var_a < input.length - 1 {
    var_b=0;
    while var_b < input.length - var_a - 1 {
        if input[var_b] > input[var_b + 1] {
            var_c = input[var_b];
            input[var_b] = input [var_b + 1];
            input [var_b + 1] = var_c;
        }
        var_b++;
    }
    var_a++;
}
return input;

Missing numbers

  • Pattern detected
in out
[0,3,2] [1]
[1,3] [0,2]
[4,2,3] [0,1]
  • Code
    input.sort;
    var_a = [];
    while var_b < input.length {
        while var_c < input[var_b] {
            var_a.push(var_c);
            var_c++;
        }
        var_c++;
        var_b++;
    }
    return var_a;

Anagrams

  • Pattern detected
in out
[[d,a,d],[a,d,d]] true
[[a,t,e],[e,a,t],[t,e,a]] true
[[n,o,t],[o,n,e]] false
  • Code
var_a = input[0].length;
while var_b < input.length {
    if var_a != input[var_b].length {
        return false;
    }
    input[var_b].sort;
    var_b++;
}
while var_c < input[0].length {
    var_d=0;
    while var_d < input.length {
        if input[0][var_c] != input[var_d][var_c] {
            return false;
        }
        var_d++;
    }
    var_c++;
}
return true;

Chapter 5 Corrupted

Wikileaks is awesome . You would love to be part of their team and expose corrupted politicians. You already joined a bunch of forums to see what they’re up to. Right now they’re trying to prove that an influential politician is involved in drugs and weapon trafficking in third world counties.
This is your chance to use your HackPad for justice, all you have to do is figure out a way to infiltrate his emails…

110101110101000101

  • Pattern detected
in out
[1,0,1] 5
[0,1,0] 2
[1,1,0] 6
  • Code
while var_a < input.length {
    var_b = var_b + input[var_a] * pow(2,input.length-var_a-1);
    var_a++;
}
return var_b;

Prime

  • Pattern detected
in out
3 true
12 false
17 true
  • Code
if input < 2 {
    return false;
}
var_a = 2;
while var_a * var_a < input {
    if mod(input,var_a) == 0 {
        return false;
    }
    var_a++;
}
return true; 

Number in order

  • Pattern detected
in out
[f,o,r,t,y] true
[d,o,s] true
[q,u,a,t,r,e] false
  • Code
var_a = [];
foreach var_b in input {
    var_a.push(var_b);
}
var_a.sort;
while var_c < input.length {
    if var_a[var_c] != input[var_c] {
        return false;
    }
    var_c++;
}
return true;

Chapter 6 Cyber Attack

You try to help the world by exposing a dirty politician and all you got in return is a stay in jail. What were you thinking? You’re going to trial in a few days, and they’ve got an army of lawyers against you…
phone rings
-Who is this?
-Hey kid, this is Agent D., FBI. Look, we know you’re not a bad guy, and you’re in a pretty messed up situation right now. We might be able to help.
-Really?
-See, we need more hackers like you around here. So if you’re willing to work for us, I’ll pull some strings to get you off. What do you say?
-… Do I have a choice?
-Sure, either work for us or spend the next 10 years behind bars.
-Deal, when do I start?
-Right now. We got these guys hacking our systems as I speak. It’s driving us mental. Stop them and you’re a free man.

Complete

  • Pattern detected
in out
[0,1] [0,1]
[1,2] [0,1,2]
[3,4,5] [0,1,2,3,4,5]
  • Code
input.sort;
var_a = [];
while var_b < input[input.length - 1] + 1 {
    var_a.push(var_b);
    var_b++;
}
return var_a;

Match

  • Pattern detected
in out
[(,)] true
[(,(,)] false
[(,(,),)] true
  • Code
if input[0] == ")" {
    return false;
}
foreach var_a in input {
    if var_a == "(" {
        var_b++;
    }
    else {
        var_b--;
    }
}
if var_b == 0 {
    return true;
}
return false;

Rotate

  • Pattern detected
in out
[2,5] [5,2]
[3,8,4] [8,4,3]
[6,2,9,1] [2,9,1,6]
  • Code
var_a = [];
while var_b < input.length - 1 {
    var_a.push(input[var_b + 1]);
    var_b++
}
var_a.push(input[0]);

Chapter 7 Nuclear Plant

You work for the FBI now, it’s not a bad gig, but it can get really stressful. You have millions of lives depending on you right now.
These crazy hackers are trying to blow up a nearby nuclear power plant by messing with the temperature control systems.
Everybody is relying on you to stop their virus and save the country. If you mess up, we all die. No pressure.

Add one

  • Pattern detected
in out
[0,1] [1,2]
[1,2] [2,3]
[3,6,8] [4,7,9]
  • Code
while var_a < input.length {
    input[var_a]++;
    var_a++;
}
return input;

Positivity

  • Pattern detected
in out
[1] [true]
[-1,1] [false,true]
[1,-1,1] [true,false,true]
  • Code
function f1: var_a {
    if var_a < 0 {
        return false;
    }
    return true;
}
var_b = [];
while var_c < input.length {
    var_b.push(f1(input[var_c]));
    var_c++;
}
return var_b;

Nearest to [0,0]

  • Pattern detected
in out
[[10,12],[2,3]] [2,3]
[[5,3],[15,0]] [5,3]
[[12,3],[6,15],[1,2]] [1,2]
  • Code
var_a = [];
while var_b < input.length {
    var_c = pow(input[var_b][0],2) + pow(input[var_b][1],2);
    var_a.push(var_c);
    var_b++;
}
while var_d < input.length {
    if var_a[var_e] > var_a[var_d] {
        var_e = var_d;
    }
    var_d++;
}
var_d--;
return input[var_e];

Chapter 8 Killer Robot

You managed to save the country - you’re a national hero.
So when a crazy computer scientist devides it would be a good idea to upload his new self learning AI system into a Mech X5-40, aka the most dangerous robot weapon of all time, everybody comes to you to save the day. Again. This hero thing is really cutting into your WOW time.

Addition

  • Pattern detected
in out
[[2],[3]] [5]
[[1,2],[1,9]] [3,1]
[[3],[1,2]] [1,5]
  • Code
while var_a<input.length {
    var_b = 0;
    while var_b < input[var_a].length {
        var_c = var_c + input[var_a][var_b]*pow(10,input[var_a].length-var_b-1);
        var_b++;
    }
    var_a++;
}
var_d = [];
while var_c>0 {
    var_d.push(mod(var_c,10);
    var_c=var_c/10;
}
var_e=[];
var_f=var_d.length-1;
while var_f>-1 {
    var_e.push(var_d[var_f]);
    var_f--;
}
return var_e;

Match 2

  • Pattern detected
in out
[(,)] true
[(,[,),]] false
[(,[,],)] true
  • Code
var_a = [];
if input[0] == ")" || input[0] == "]" {
    return false;
}
while var_b < input.length {
    if input[var_b] == "(" || input[var_b] == "[" {
        var_a.push(input[var_b]);
    }
    if input[var_b] == ")" {
        if var_a[var_a.length-1] =="(" {
            var_a.pop;
        }
        else {
            return false;
        }
    }
    if input[var_b] == "]" {
        if var_a[var_a.length-1] =="[" {
            var_a.pop;
        }
        else {
            return false;
        }
    }
    var_b++;
}
if var_a.length==0 {
    return true;
}
else {
    rerurn false;
}

Chapter 9 Skynet

The robot has been neutralized by your virus and dismantled by the FBI. But somehow, the AI that was running it managed to replicate itself across hundreds of data centers, unnoticed… Until today.
It calls itself Skynet, and it has an army of robot marching across the world to terminate the human race. You can hear them outside the building. To stop them, you have to attack the source directly. You must create the most powerful virus you’ve ever made. And you must act fast.

Tree

  • Pattern detected
in out
[[1,2],[[3,4],5]] [1,2,3,4,5]
[[1,2,3],[[4],5]] [1,2,3,4,5]
[[1],2,[[3,4,5]]] [1,2,3,4,5]
  • Code
function f1: var_a,var_b {
    var_c = 0;
    while var_c < var_a.length {
        if var_a[var_c].is_list {
            f1(var_a[var_c],var_b);
        }
        else {
            var_b.push(var_a[var_c]);
        }
        var_c++;
    }
}
var_d = [];
f1(input,var_d);
return var_d;

Chapter 10 Retirement

Wiah, you stopped skynet. That was… freaking stressful!
You hate this pressure, the job is becoming too much for you. You want to quit and go to a quiet place where you can just relax and play video games all day. You wonder if you can play games on your HackPad…
You’ll probably have to write the games yourself… let’t see what you can do.

Draw

  • Pattern detected
in out
[1,2] ·
[3,4] ·
[0,0] ·
  • Code
draw(input[0],input[1]);