FAQ/Walkthrough by The Sound Defense

FAQ Table of Contents:


hide results

    FAQ/Walkthrough by The Sound Defense

    Version: 1.1 | Updated: 06/11/17 | Search Guide | Bookmark Guide

    Human Resource Machine FAQ
    Copyright 2017 Jim Avery
    For questions, comments or better solutions, send a PM to me on GameFAQs.

    Introduction

    Human Resource Machine is a fun and humorous puzzle game based around programming. Your character uses simple actions like jump, copy, add, subtract and more in order to simulate the steps that would be taken in an assembly language program, the low-level language that gets directly run on your computer processor.

    This guide will give solutions that will allow you to beat all of the game's optimization challenges. On top of that, I will offer some additional information, linking each puzzle to its related computer science concepts, and offering hints to solve or improve your programs in case you don't want to be simply told the answer.

    If you have any suggestions for improving this, please let me know!

    How to Read This Guide

    Because of the nature of this puzzle game and its solutions, the solution for each floor will have a specific format, as outlined below.

    Description

    The description of the puzzle taken from the game.

    Background

    This is where I will talk about this puzzle and the computer science concepts that it relates to, if applicable.

    Hints

    These are hints by me, to help you get closer to an optimized solution without explicitly looking at how it's done.

    Size Challenge: The requirements for completing the size challenge.
    Speed Challenge: The requirements for completing the speed challenge.

    If both optimization challenges can be solved by a single solution, then only one will be posted. If two solutions are required, there will be a different solution under each challenge requirement. If you have a better solution than one of these, let me know via GameFAQs PM.

    Structure of a Solution

    Tile labels

    For many of the later levels, I've included tile labels where possible, because it makes solutions easier to read and implement, and it also helps makes the solution look more like an actual computer program. If you see

    Tile label: foo

    It means that you can name (almost) any tile with that label. If you see a specific number, such as

    Tile 9 label: foo

    Then you should label a specific tile; in this case, tile 9 would get the label "foo". These will be referenced in quotes in the program, such as

    01. Bump+ "foo"

    Comments

    Anytime you see something that looks like

    // Setup

    That is a comment (using a common programming language syntax). These aren't necessary, but it helps you mentally map what parts of your program are doing what.

    Jump labels

    Whenever you see a bold letter followed by a colon, such as

    A:

    That is a location where your program will jump to. It will be referenced in the program at the time of the jump instruction, like so:

    01. Jump (to label A)

    Indirect access

    Later on in the game, you get to use indirect tile access. Like in the game, these are indicated with square brackets, like so:

    01. Copyfrom ["foo"]
    02. Copyto [1]

    All other instructions should be straightforward.

    Floors

    Mail Room

    Description

    Drag commands into this area to build a program.

    Your program should tell your worker to grab each thing from the INBOX, and drop it into the OUTBOX.

    Background

    Your first program! You don't get anything interesting to work with here, so the only thing to really talk about are inputs and outputs. Programs generally work by taking in an input (which here comes from the inbox), doing things to it, and then returning it as output (the outbox). If you're ever looking at a "function" or a "method", you'll usually see its input parameters near the top, and somewhere in the function body will be a return statement. This isn't always the case, but it often is. Of course, we won't be using any functions or methods in this game.

    Hints

    Nothing really to say here. This is more of a tutorial level than anything. The simple solution is the optimal one.

    Solution

    Size Challenge: Use 6 or fewer commands.
    Speed Challenge: Complete in 6 or fewer steps.

    01. Inbox
    02. Outbox
    03. Inbox
    04. Outbox
    05. Inbox
    06. Outbox

    Busy Mail Room

    Description

    Grab each thing from the INBOX, and drop each one into the OUTBOX.

    You got a new command! You can drag JUMP's arrow to different lines within your program.

    With this new ability, you can complete this assignment using only 3 total commands.

    Background

    Jumps are mostly used in assembly language, and are frowned upon in normal programming. More often, programs take the form of function calls (which we won't see in this game) or loops, which are a very common and powerful programming construct. We are going to see loops all over this game, so get used to them.

    Hints

    The size challenge is easy, but the speed challenge is not so straightforward. Jumps are very useful in this game, but using too many will slow your program down. This is an important lesson to learn, because a lot of the speed challenges in this game will involve finding and eliminating unnecessary jumps. So for this challenge, try reducing the number of times you ultimately jump. This is known as loop unrolling, and we'll see it again.

    Solution

    Size Challenge: Use 3 or fewer commands.

    A:
    01. Inbox
    02. Outbox
    03. Jump (to label A)

    Speed Challenge: Complete in 25 or fewer steps.

    A:
    01. Inbox
    02. Outbox
    03. Inbox
    04. Outbox
    05. Jump (to label A)

    Copy Floor

    Description

    Ignore the INBOX for now, and just send the following 3 letters to the OUTBOX:

    B U G

    The Facilities Management staff has placed some items over there on the carpet for you. If only there were a way you could pick them up...

    Background

    This puzzle introduces you to storing and retrieving data. In a normal program, you'd be storing them in variables - and later on, we'll be simulating this by giving names to the tiles on the floor. For now, though, the tiles are acting like something known as "registers". Registers are small data storage containers that your computer's processor uses to hold onto values it isn't using right now, but will need soon. Variables, on the other hand, are stored in your computer's RAM most of the time. And if you have data that you need to store for an extremely long time, or if you have too much data to fit in memory, it will be stored on your hard disk or solid state disk.

    Hints

    Nothing really to say here. This is another straightforward tutorial.

    Solution

    Size Challenge: Use 6 or fewer commands.
    Speed Challenge: Complete in 6 or fewer steps.

    01. Copyfrom 4
    02. Outbox
    03. Copyfrom 0
    04. Outbox
    05. Copyfrom 3
    06. Outbox

    Scrambler Handler

    Description

    Grab the first TWO things from the INBOX and drop them into the OUTBOX in the reverse order. Repeat until the INBOX is empty.

    You got a new command! Feel free to COPYTO where you like on the carpet. It will be cleaned later.

    Background

    Now you actually get to store data using the tiles, which is more like what will actually happen in a computer program. Registers don't usually have data already in them. As an aside: while your character can hold an input in their hand, a processor or a program can't really do this. If you don't store data in a register or a variable, it's going to disappear on you. As a result, pretty much every command you run will store a value somewhere.

    Hints

    You can now store values on the tiles, but make sure you don't store anything that you don't have to. What's the minimum amount of values you need to store?

    Solution

    Size Challenge: Use 7 or fewer commands.
    Speed Challenge: Complete in 21 or fewer steps.

    A:
    01. Inbox
    02. Copyto 0
    03. Inbox
    04. Outbox
    05. Copyfrom 0
    06. Outbox
    07. Jump (to label A)

    Coffee Time

    Well, back to work!

    Rainy Summer

    Description

    For each two things in the INBOX, add them together, and put the result in the OUTBOX.

    You got a new command! It ADDs the contents of a tile in the floor to whatever value you're currently holding.

    Background

    Yes, your program could do plenty of adding, especially if you're making a program for budgeting or something. The processor, however, does TONS of adding. It's the most common way of manipulating numbers. Multiplication, for example, is just repeated addition done extremely efficiently.

    Hints

    Again, it's about reducing the number of values you store.

    Solution

    Size Challenge: Use 6 or fewer commands.
    Speed Challenge: Complete in 24 or fewer steps.

    A:
    01. Inbox
    02. Copyto 0
    03. Inbox
    04. Add 0
    05. Outbox
    06. Jump (to label A)

    Zero Exterminator

    Description

    Send all things that ARE NOT ZERO to the OUTBOX.

    You got a new command! It jumps ONLY if the value you are holding is ZERO. Otherwise it continues to the next line.

    Background

    This is our very first conditional jump. Processors will use conditional jumps all the time, and they have a greater variety of them than this game will give you. When you're writing code, however, you don't usually use jumps. The most common conditional is an "if" statement - as in, if this certain condition is true, then your program will execute some code; if not, it may execute some other code. We'll be exploring this concept in the game as well, by simulating it with conditional jumps. Suffice to say, computer programs would not be very useful if they couldn't change what they do based on what input they get.

    Hints

    This is another straightforward tutorial puzzle. The simplest solution is the best one.

    Solution

    Size Challenge: Use 4 or fewer commands.
    Speed Challenge: Complete in 23 or fewer steps.

    A:
    B:
    01. Inbox
    02. Jump if zero (to label A)
    03. Outbox
    04. Jump (to label B)

    Tripler Room

    Description

    For each thing in the INBOX, TRIPLE it. And OUTBOX the result.

    Self improvement tip: Where are we going with this? Please leave the high level decisions to management.

    Background

    As I mentioned before, multiplication is just repeated addition. This puzzle, and the next few optional puzzles, are all based around this very concept.

    Hints

    This shouldn't be too tricky to pull off. Tripling the value you have is straightforward, with no tricks involved. When we multiply by other values later on, things will get harder.

    Solution

    Size Challenge: Use 6 or fewer commands.
    Speed Challenge: Complete in 24 or fewer steps.

    A:
    01. Inbox
    02. Copyto 0
    03. Add 0
    04. Add 0
    05. Outbox
    06. Jump (to label A)

    Zero Preservation Initiative

    Description

    Send only the ZEROs to the OUTBOX.

    Background

    This is the reverse of the previous puzzle. Now we have code that we are executing only if we take the conditional jump. In an actual processor, you'd rarely see this, because they would just have a conditional jump that used the opposite condition (jump if not equal to zero, for example). But we are not so lucky.

    Hints

    Now things are starting to get tricky. The size challenge isn't hard, but if you take the straightforward approach you're going to fail the speed challenge. If you do this the "standard" way, you're going to end up with two jump commands whether the number is a zero or not. As usual, removing wasteful jumps is the most important part of solving speed challenges.

    What we want to do is try to rearrange our program so in at least one of those two cases, we only encounter one jump. You'll need to think a little bit out of the box for this. Things that you assumed should be at the end of the program might not actually belong there.

    Solution

    Size Challenge: Use 5 or fewer commands.
    Speed Challenge: Complete in 25 or fewer steps.

    01. Jump (to label B)
    A:
    02. Outbox
    B:
    C:
    03. Inbox
    04. Jump if zero (to label A)
    05. Jump (to label C)

    Octoplier Suite

    Description

    For each thing in the INBOX, multiply it by 8, and put the result in the OUTBOX.

    Using a bunch of ADD commands is easy, but WASTEFUL! Can you do it using only 3 ADD commands? Management is watching.

    Background

    More repeated multiplication here. Fun fact: when doubling a number, instead of adding it to itself, computers can do something called a "left shift". This is something you can only do because at the lowest level, numbers are just made up of ones and zeroes. For more information, look up left shift and binary representation online.

    Hints

    Remember that 8 is 2 * 2 * 2. This means that multiplying something by 8 is the same as doubling it three times. How can you write your program so that each time you ADD, the number doubles?

    Solution

    Size Challenge: Use 9 or fewer commands.
    Speed Challenge: Complete in 36 or fewer steps.

    A:
    01. Inbox
    02. Copyto 0
    03. Add 0
    04. Copyto 1
    05. Add 1
    06. Copyto 2
    07. Add 2
    08. Outbox
    09. Jump (to label A)

    Sub Hallway

    Description

    For each two things in the INBOX, first subtract the 1st from the 2nd and put the result in the OUTBOX. AND THEN, subtract the 2nd from the 1st and put the result in the OUTBOX. Repeat.

    You got a new command! SUBtracts the contents of a tile on the floor FROM whatever value you're currently holding.

    Background

    Subtracting is another basic thing a processor can do to numbers, but lots of subtracting is quite a bit slower than lots of adding. Why is that? It's because when you're subtracting, the order in which you do it is very important, which isn't true with adding. A processor can do more additions at the same time than it can with subtractions, because it doesn't have to care about which additions happen before other ones. This puzzle will demonstrate how order is important.

    Hints

    Because you have to do both of the subtractions, there is no way to do this puzzle without storing both numbers. This is a pretty simple optimization, and you should be able to determine the most efficient thing to do after storing both numbers.

    Solution

    Size Challenge: Use 10 or fewer commands.
    Speed Challenge: Complete in 40 or fewer steps.

    A:
    01. Inbox
    02. Copyto 0
    03. Inbox
    04. Copyto 1
    05. Sub 0
    06. Outbox
    07. Copyfrom 0
    08. Sub 1
    09. Outbox
    10. Jump (to label A)

    Tetracontiplier

    Description

    For each thing in the INBOX, multiply it by 40, and put the result in the OUTBOX.

    Background

    When doing larger multiplications, processors will use a combination of simple adds and left shifts to produce the final product. If you look up "binary multiplication" you'll see that it's very similar in concept to how we all learned to multiply numbers - but because the only digits are zero and one, it might be even easier to do quickly.

    Hints

    Doubling a number takes two steps, while simply adding what's currently on the floor only takes one. To hit the speed challenge here, you'll need to know exactly when to stop doubling and when to start adding. Try playing around to see where the right balance is.

    Solution

    Size Challenge: Use 14 or fewer commands.
    Speed Challenge: Complete in 56 or fewer steps.

    A:
    01. Inbox
    02. Copyto 0
    03. Add 0
    04. Copyto 0
    05. Add 0
    06. Copyto 0
    07. Add 0
    08. Copyto 0
    09. Add 0
    10. Add 0
    11. Add 0
    12. Add 0
    13. Outbox
    14. Jump (to label A)

    Equalization Room

    Description

    Get two things from the INBOX. If they are EQUAL, put ONE of them in the OUTBOX. Discard non-equal pairs. Repeat!

    You got... COMMENTS! You can use them, if you like, to mark sections of your program.

    Background

    Comments can be lifesavers in your program. They help you understand what your code is doing when you've forgotten, and they make it easier to organize your code in more readable ways. Plus, if someone else has to look at your code in order to work on it, comments will make their life a hundred times easier.

    As for equality testing: a normal processor will have lots of comparison commands it can use (greater than, less than, equal than, and combinations of these). At the very lowest level, though, the processor is doing exactly what we will be doing here, by utilizing "jump if equal to zero" and another step.

    Hints

    You don't have a "jump if equal" command, so you'll have to invent another kind of test to make sure the numbers are equal; you'll need to use the "jump if zero" command, because that's the only conditional you have. And once you have it figured out, you'll need to optimize by reducing jumps again. Think about what you did to optimize on floor 9.

    Solution

    Size Challenge: Use 9 or fewer commands.
    Speed Challenge: Complete in 27 or fewer steps.

    01. Jump (to label B)
    A:
    02. Copyfrom 0
    03. Outbox
    B:
    C:
    04. Inbox
    05. Copyto 0
    06. Inbox
    07. Sub 0
    08. Jump if zero (to label A)
    09. Jump (to label C)

    Maximization Room

    Description

    Grab TWO things from the INBOX, and put only the BIGGER of the two in the OUTBOX. If they are equal, just pick either one. Repeat!

    You got a new command! Jumps only if the thing you're holding is negative. (Less than zero.) Otherwise continues to the next line.

    Background

    When comparing numbers, a processor will subtract one from the other, and whatever it gets as a result will determine how the numbers compare to one another. Now that you have "jump if negative", you have the tools necessary to implement comparison in the same way.

    Hints

    This solution is the first time we'll be using the full "if/else" concept for coding. If a given condition is true, we'll execute one set of commands; if the condition is false, we'll execute a different set of commands. How would you be able to set this up using a conditional jump?

    Remember: there are three possibilities when comparing numbers A and B (A is greater, B is greater, or they are equal), but you can still only get away with one conditional jump. Try writing your code so that two of those possibilities execute the exact same code.

    Solution

    Size Challenge: Use 10 or fewer commands.
    Speed Challenge: Complete in 34 or fewer steps.

    A:
    01. Inbox
    02. Copyto 0
    03. Inbox
    04. Sub 0
    05. Jump if negative (to label B)
    06. Add 0
    07. Jump (to label C)
    B:
    08. Copyfrom 0
    C:
    09. Outbox
    10. Jump (to label A)

    Employee Morale Insertion

    Well, that was fun! Now back to work.

    Absolute Positivity

    Description

    Send each thing from the INBOX to the OUTBOX. BUT, if a number is negative, first remove its negative sign.

    Background

    This is a much easier task for a computer than it is for us, with our blocks and tiles and commands. All you have to do is change all the 1's to 0's, all the 0's to 1's, and then add 1. For an idea of how this works, look up "two's complement representation" and then "two's complement negation".

    Hints

    If you wanted to take a positive number and get the negative version of it, how would you do it using only the commands you have in Human Resource Machine? Changing a negative number to a positive number should work the exact same way. Once that's done, work on removing jumps.

    Solution

    Size Challenge: Use 8 or fewer commands.
    Speed Challenge: Complete in 36 or fewer steps.

    01. Jump (to label C)
    A:
    02. Copyto 0
    03. Sub 0
    04. Sub 0
    B:
    05. Outbox
    C:
    06. Inbox
    07. Jump if negative (to label A)
    08. Jump (to label B)

    Exclusive Lounge

    Description

    For each TWO things in the INBOX:

    Send a 0 to the OUTBOX if they have the same sign. (Both positive or both negative.)

    Send a 1 to the OUTBOX if their signs are different. Repeat until the INBOX is empty.

    Background

    The operation we are recreating here is an "exclusive or", also written as XOR (which is why the name of the floor is "Exclusive Lounge"). If you were to ask a computer about "A OR B", it would return true if 1) A was true, 2) B was true, or 3) both were true. In the case of "A XOR B", only 1) and 2) apply. (In the case of "A AND B", only 3) applies.) This doesn't come up much in programming, in my experience, but it shows up in circuit design. For more information, look up "Boolean logic". If you want to be a programmer, you'll need to know it well.

    Hints

    Trying to decide if two numbers have the same sign by adding them or subtracting them is extremely difficult, if not impossible, and not worth the trouble. Instead, you should just have different paths to cover all four possible paths (++, --, +-, -+) and make them use as few commands as possible. Most importantly, even though there are four possible paths, there are only two ways a loop can end - output a 0, or output a 1.

    Solution

    Size Challenge: Use 12 or fewer commands.
    Speed Challenge: Complete in 28 or fewer steps.

    A:
    B:
    01. Inbox
    02. Jump if negative (to label D)
    03. Inbox
    04. Jump if negative (to label E)
    C:
    05. Copyfrom 4
    06. Outbox
    07. Jump (to label A)
    D:
    08. Inbox
    09. Jump if negative (to label C)
    E:
    10. Copyfrom 5
    11. Outbox
    12. Jump (to label B)

    Sabbatical Beach Paradise

    Ahh, this is the life. We really needed this break.

    Well, back to work!

    Countdown

    Description

    For each number in the INBOX, send that number to the OUTBOX, followed by all numbers down to (or up to) zero. It's a countdown!

    You got new commands! They add ONE or subtract ONE from an item on the floor. The result is given back to you, and for your convenience, also written right back to the floor. BUMP!

    Background

    Now we are looping over a single input until a certain condition is met - a very common programming construct. This is known as a "while loop", though the more advanced version, the "for loop", is more commonly found in practice. The basic idea is "while this condition is true, execute this code".

    Hints

    The size challenge isn't too bad; if you start out adding in steps one by one depending on what you need to do, you should quickly come across the right answer. Remember to only use one inbox and one outbox command. The speed challenge is a bit more tricky. The best way to go is to write your program so that you test if each number is negative only one time. Depending on the answer, you should be running different code.

    Solution

    Size Challenge: Use 10 or fewer commands.

    A:
    01. Inbox
    02. Copyto 0
    B:
    C:
    03. Outbox
    04. Copyfrom 0
    05. Jump if zero (to label A)
    06. Jump if negative (to label D)
    07. Bump- 0
    08. Jump (to label B)
    D:
    09. Bump+ 0
    10. Jump (to label C)

    Speed Challenge: Complete in 82 or fewer steps.

    01. Jump (to label D)
    A:
    B:
    C:
    02. Outbox
    D:
    03. Inbox
    04. Copyto 0
    05. Jump if zero (to label A)
    06. Jump if negative (to label F)
    E:
    07. Outbox
    08. Bump- 0
    09. Jump if zero (to label B)
    10. Jump (to label E)
    F:
    G:
    11. Outbox
    12. Bump+ 0
    13. Jump if zero (to label C)
    14. Jump (to label G)

    Multiplication Workshop

    Description

    For each two things in the INBOX, multiply them, and OUTBOX the result. Don't worry about negative numbers for now.

    You got... LABELS! They can help you remember the purpose of each tile on the floor. Just tap any tile on the floor to edit.

    Background

    Now that we have labels for tiles, we're going to start working with actual variables. Variables are used constantly in programming, and we'll be using them to store useful data. Counters, length, partial sums, all sorts of things. It's a bit trickier for us, since we can't just put any value we want into a variable like we could in a real program, but we'll make it work.

    Hints

    Multiplication is just repeated addition, as we've noted many times already; 9 * 5 = 9 + 9 + 9 + 9 + 9. You'll need to store each of the two numbers, the current running sum, and you'll need to track how many more additions you need to do; to save time and commands, you can use only three tiles to track all of this information.

    For the speed challenge, you'll need to think about what number gets summed in order to calculate the product. For 2 * 6, you could calculate it as 6 + 6, or as 2 + 2 + 2 + 2 + 2 + 2. One of these two solutions will be much faster to calculate.

    Solution

    Size Challenge: Use 15 or fewer commands.
    Tile label: num
    Tile label: count
    Tile label: sum
    Tile 9 label: zero

    A:
    01. Inbox
    02. Copyto "num"
    03. Copyto "sum"
    04. Inbox
    05. Jump if zero (to label D)
    06. Copyto "count"
    B:
    07. Bump- "count"
    08. Jump if zero (to label C)
    09. Copyfrom "sum"
    10. Add "num"
    11. Copyto "sum"
    12. Jump (to label B)
    C:
    13. Copyfrom "sum"
    D:
    14. Outbox
    15. Jump (to label A)

    Speed Challenge: Complete in 109 or fewer steps.
    Tile label: num1
    Tile label: num2
    Tile label: sum
    Tile 9 label: zero

    // Setup
    A:
    B:
    01. Inbox
    02. Jump if zero (to label F)
    03. Copyto "num1"
    04. Inbox
    05. Jump if zero (to label I)
    06. Copyto "num2"
    // Multiply
    07. Sub "num1"
    08. Jump if negative (to label D)
    // Num2 greater
    09. Copyfrom "num2"
    10. Copyto "sum"
    C:
    11. Bump- "num1"
    12. Jump if zero (to label G)
    13. Copyfrom "sum"
    14. Add "num2"
    15. Copyto "sum"
    16. Jump (to label C)
    // Num1 greater
    D:
    17. Copyfrom "num1"
    18. Copyto "sum"
    E:
    19. Bump- "num2"
    20. Jump if zero (to label H)
    21. Copyfrom "sum"
    22. Add "num1"
    23. Copyto "sum"
    24. Jump (to label E)
    // Short circuit
    F:
    25. Outbox
    26. Inbox
    27. Jump (to label A)
    G:
    H:
    28. Copyfrom "sum"
    I:
    29. Outbox
    30. Jump (to label B)

    Zero Terminated Sum

    Description

    The INBOX is filled with zero terminated strings! What's that? Ask me. Your Boss.

    Add together all the numbers in each string. When you reach the end of a string (marked by ZERO), put your sum in the OUTBOX. Reset and repeat for each string.

    Background

    In programming, a string is a collection of characters all combined into a single data structure. For example, "this is a string" is sixteen different character values all written out next to each other in memory. The computer knows when it's reached the end of a string when it finds a 0, just like in this puzzle.

    That doesn't mean you can't have strings with zeroes in them, though. The string "0123456789" is perfectly valid, for example. But the character "0" is not represented in memory with the actual value 0; instead, the character "0" has the value 48. Look up "ASCII" for more information on how most characters are represented in a computer.

    Hints

    The size challenge is not too big a deal. If you reserve one tile to keep track of the running sum, and never put anything else down, then it's very easy to meet the challenge. The speed challenge is not too different, but think about how you can skip to the end with certain inputs and bypass the sum altogether. Once you've done that, you may realize some other commands you had in the size challenge are no longer needed.

    Solution

    Size Challenge: Use 10 or fewer commands.
    Tile label: sum
    Tile 5 label: zero

    A:
    01. Copyfrom "zero"
    02. Copyto "sum"
    B:
    03. Inbox
    04. Jump if zero (to label C)
    05. Add "sum"
    06. Copyto "sum"
    07. Jump (to label B)
    C:
    08. Copyfrom "sum"
    09. Outbox
    10. Jump (to label A)

    Speed Challenge: Complete in 72 or fewer steps.
    Tile label: sum
    Tile 5 label: zero

    A:
    B:
    01. Inbox
    02. Jump if zero (to label E)
    // Sum start
    03. Copyto "sum"
    C:
    04. Inbox
    05. Jump if zero (to label D)
    06. Add "sum"
    07. Copyto "sum"
    08. Jump (to label C)
    D:
    09. Copyfrom "sum"
    10. Outbox
    11. Jump (to label A)
    // Short circuit
    E:
    12. Outbox
    13. Jump (to label B)

    Fibonacci Visitor

    Description

    For each thing in the INBOX, send to the OUTBOX the full Fibonacci Sequence up to, but not exceeding that value. For example, if INBOX is 10, OUTBOX should be 1 1 2 3 5 8. What's a Fibonacci Sequence? Ask your boss, or a friendly search box.

    1 1 2 3 5 8 13 21 34 55 89 ...

    Background

    The Fibonacci sequence is a pretty fascinating concept that we could talk about for a long time, but the gist of it is: each number in the sequence is the sum of the two numbers that came before, with the first two numbers being 1 and 1. For example, in the description, you can see the number 13 is formed by adding the previous numbers 5 and 8.

    There are lots of ways to generate the Fibonacci sequence, some of which are much faster than others. We'll be implementing one of the faster methods here.

    Hints

    Both of these can be done at once, but it's not easy to do. There are two parts in particular that are tricky: getting the initial two numbers set up, and knowing where to "begin" your loop that evaluates the rest of the numbers. My solution ended up using two outbox commands; one of these commands came right after setting up the first two numbers, and then the loop began immediately after that.

    Your main loop will need to do a couple things: generate a new Fibonacci number (which I'm putting in "n"), and then change the previous two numbers so they're ready to go for the next iteration. You'll also need to do a quick test to see if you're about to exceed your limit, at which point you start all over with a new number. You can do this entire puzzle using only two jump commands.

    As an additional hint, you should never be doing a copyfrom right before putting something in the outbox. Arrange your commands so that you're already holding the number you need to outbox, because you used it for something else.

    Solution

    Size Challenge: Use 19 or fewer commands.
    Speed Challenge: Complete in 156 or fewer steps.
    Tile label: n
    Tile label: n-1
    Tile label: n-2
    Tile label: limit
    Tile 9 label: zero

    // Setup
    A:
    01. Inbox
    02. Copyto "limit"
    03. Copyfrom "zero"
    04. Copyto "n"
    05. Bump+ "n"
    06. Copyto "n-1"
    07. Outbox
    B:
    // Sequence
    08. Copyfrom "n-1"
    09. Copyto "n-2"
    10. Copyfrom "n"
    11. Copyto "n-1"
    12. Outbox
    13. Copyfrom "n-2"
    14. Add "n-1"
    15. Copyto "n"
    16. Copyfrom "limit"
    17. Sub "n"
    18. Jump if negative (to label A)
    19. Jump (to label B)

    The Littlest Number

    Description

    For each zero terminated string in the INBOX, send to the OUTBOX only the SMALLEST number you've seen in that string. You will never be given an empty string. Reset and repeat for each string.

    What's a "zero terminated string"? Go ask your boss on the previous floor!

    Background

    Often times, finding the largest or smallest number in a group will be a built-in command in many programming languages (or at least it is for two numbers). Here, though, we'll have to implement it ourselves.

    Hints

    You can do this entire puzzle by using only a single tile on the floor, to keep track of the current smallest number. The problem is that, as soon as you compare a number from the inbox to the current minimum, then that number is gone. It's very easy to get it back, though, so don't worry about storing it. What's a faster way of getting back the original number after subtracting something from it?

    Solution

    Size Challenge: Use 13 or fewer commands.
    Speed Challenge: Complete in 75 or fewer steps.
    Tile label: min

    A:
    01. Inbox
    02. Copyto "min"
    B:
    C:
    03. Inbox
    04. Jump if zero (to label E)
    05. Sub "min"
    06. Jump if negative (to label D)
    07. Jump (to label B)
    D:
    08. Add "min"
    09. Copyto "min"
    10. Jump (to label C)
    E:
    11. Copyfrom "min"
    12. Outbox
    13. Jump (to label A)

    Slightly more efficient solution, using previously discussed optimizations:
    Tile label: min

    01. Jump (to label B)
    A:
    02. Copyfrom "min"
    03. Outbox
    B:
    04. Inbox
    05. Copyto "min"
    06. Jump (to label D)
    C:
    07. Add "min"
    08. Copyto "min"
    D:
    E:
    09. Inbox
    10. Jump if zero (to label A)
    11. Sub "min"
    12. Jump if negative (to label C)
    13. Jump (to label E)

    Mod Module

    Description

    For each two things in the INBOX, OUTBOX the remainder that would result if you had divided the first by the second. Don't worry, you don't actually have to divide. And don't worry about negative numbers for now.

    Background

    In school, you probably learned a method of division that gave you both the quotient and the remainder. In programming, those are usually two different operations. If you wrote the command "5 / 2", you'd get the quotient, 2. However, if you use the command "5 % 2", you'll get back the remainder, 1. This is known as the "mod operator", hence the name of this puzzle. If you were speaking the above command aloud, it would probably be "5 mod 2".

    Hints

    You'll need to store each of the two numbers on the floor, but after that you won't need to copy anything else to the floor for a given pair of numbers. Remember that division is just repeated subtraction.

    Solution

    Size Challenge: Use 12 or fewer commands.
    Speed Challenge: Complete in 57 or fewer steps.
    Tile label: num1
    Tile label: num2

    A:
    01. Inbox
    02. Copyto "num1"
    03. Inbox
    04. Copyto "num2"
    05. Copyfrom "num1"
    B:
    06. Sub "num2"
    07. Jump if negative (to label C)
    08. Jump (to label B)
    C:
    09. Add "num2"
    10. Outbox
    11. Jump (to label A)

    Cumulative Countdown

    Description

    For each thing in the INBOX, OUTBOX the sum of itself plus all numbers down to zero. For example, if INBOX is 3, OUTBOX should be 6, because 3 + 2 + 1 = 6.

    Background

    This puzzle could be seen as a simple implementation of a for loop, where you repeat the same bit of code while manipulating a certain variable each time, until it's time to stop. The simplest example is if you want to execute a bit of code ten times; you'll have a variable count up from zero to ten, and once the variable equals ten, you'll stop.

    Hints

    You can get away with using only two tiles here; one keeps track of the running sum, and the other will have to tell you when to stop. You actually never need to use the 0 that they put down for you, ever. Most of the solution is straightforward once you figure out what each tile is supposed to do, but you'll need to handle the special case where you're given a zero right off the bat. You can do that with a single additional command.

    Solution

    Size Challenge: Use 12 or fewer commands.
    Speed Challenge: Complete in 82 or fewer steps.
    Tile label: sum
    Tile label: count

    A:
    01. Inbox
    02. Jump if zero (to label D)
    03. Copyto "sum"
    04. Copyto "count"
    B:
    05. Bump- "count"
    06. Jump if zero (to label C)
    07. Add "sum"
    08. Copyto "sum"
    09. Jump (to label B)
    C:
    10. Copyfrom "sum"
    D:
    11. Outbox
    12. Jump (to label A)

    Small Divide

    Description

    For each two things in the INBOX, how many times does the second fully fit into the first? Don't worry about negative numbers, divide by zero, or remainders.

    Self improvement tip: This might be a good time to practice copying and pasting from a previous assignment!

    Background

    Division seems simple, but it's actually one of the slowest things you can tell a processor to do. Division means doing a lot of repeated subtractions, and they can't just be done in whatever order you like, which slows the whole process down tremendously. Mod operations are also very slow, for the same reason. Avoid doing lots of them if you can.

    Hints

    This solution is going to be very similar to your solution for the Mod Module puzzle. You have more things to do now, though, because you have to keep track of how many subtractions you've done so far. As the description suggests, you can basically copy your solution to Mod Module, paste it here, and add a few commands to make it work. I did it using three of my own tiles and the zero tile.

    Solution

    Size Challenge: Use 15 or fewer commands.
    Speed Challenge: Complete in 76 or fewer steps.
    Tile label: dividend
    Tile label: divisor
    Tile label: quotient
    Tile 9 label: zero

    A:
    01. Copyfrom "zero"
    02. Copyto "quotient"
    03. Inbox
    04. Copyto "dividend"
    05. Inbox
    06. Copyto "divisor"
    B:
    07. Copyfrom "dividend"
    08. Sub "divisor"
    09. Jump if negative (to label C)
    10. Copyto "dividend"
    11. Bump+ "quotient"
    12. Jump (to label B)
    C:
    13. Copyfrom "quotient"
    14. Outbox
    15. Jump (to label A)

    Midnight Petroleum

    Working hard to get that promotion? Good luck!

    Three Sort

    Description

    For each THREE THINGS in the INBOX, send them to the OUTBOX in order from smallest to largest.

    Background

    Sorting is one of the classical computer science problems. It can be done in many, many different ways, some of which are very slow and some of which are very fast.

    The simplest algorithm to implement is Bubble Sort. With this method, you look at each pair of two adjacent numbers. If two numbers are in the wrong order, swap them. Keep doing this until you can look at every pair of numbers and not see anything out of place. Alternately, you could look at the entire list N times, where N is how many numbers you have in the list, and once you're done swapping the list is guaranteed to be sorted, because the largest numbers have all slowly bubbled up to the top.

    Hints

    If you want to nail the size challenge, you'll probably need to use Bubble Sort. As the game suggests, you'll put all three numbers down on the first three tiles before starting the sort. Because there are only three numbers, you can explicitly say "swap these two if necessary, otherwise swap these two if necessary, otherwise return the numbers because they're sorted". This is not going to come even close to satisfying the speed challenge, though.

    My solution for the speed challenge was ugly. I basically wrote out every possible path as explicitly as possible, leading to a huge 58-command program. To simplify it: I looked at the first two numbers, then executed one of two different batches of commands depending on which number was larger than the other. There is a lot of repeated code, but for each group of numbers there are very few jumps that aren't conditional tests. On the other hand, the outbox command appears 16 times.

    To help save some commands: if you know what order the first two numbers are in, then you only need to make, at most, two more comparisons to determine what order to send all the numbers in.

    Solution

    Size Challenge: Use 34 or fewer commands.
    Tile 5 label: tmp

    A:
    01. Inbox
    02. Copyto 0
    03. Inbox
    04. Copyto 1
    05. Inbox
    06. Copyto 2
    // Bubble
    B:
    07. Sub 1
    08. Jump if negative (to label D)
    09. Copyfrom 1
    10. Sub 0
    11. Jump if negative (to label C)
    12. Jump (to label F)
    C:
    13. Copyfrom 0
    14. Copyto "tmp"
    15. Copyfrom 1
    16. Copyto 0
    17. Copyfrom "tmp"
    18. Copyto 1
    19. Jump (to label E)
    D:
    20. Copyfrom 1
    21. Copyto "tmp"
    22. Copyfrom 2
    23. Copyto 1
    24. Copyfrom "tmp"
    25. Copyto 2
    E:
    26. Copyfrom 2
    27. Jump (to label B)
    // Out
    F:
    28. Copyfrom 0
    29. Outbox
    30. Copyfrom 1
    31. Outbox
    32. Copyfrom 2
    33. Outbox
    34. Jump (to label A)

    Speed Challenge: Complete in 78 or fewer steps.

    A:
    B:
    C:
    D:
    E:
    F:
    // #1
    01. Inbox
    02. Copyto 0
    // #2
    03. Inbox
    04. Copyto 1
    05. Sub 0
    06. Jump if negative (to label I)
    // 0 < 1
    07. Inbox
    08. Copyto 2
    09. Sub 0
    10. Jump if negative (to label H)
    11. Copyfrom 0
    12. Outbox
    13. Copyfrom 2
    14. Sub 1
    15. Jump if negative (to label G)
    16. Copyfrom 1
    17. Outbox
    18. Copyfrom 2
    19. Outbox
    20. Jump (to label A)
    G:
    21. Copyfrom 2
    22. Outbox
    23. Copyfrom 1
    24. Outbox
    25. Jump (to label B)
    H:
    26. Copyfrom 2
    27. Outbox
    28. Copyfrom 0
    29. Outbox
    30. Copyfrom 1
    31. Outbox
    32. Jump (to label C)
    // 0 > 1
    I:
    33. Inbox
    34. Copyto 2
    35. Sub 1
    36. Jump if negative (to label K)
    37. Copyfrom 1
    38. Outbox
    39. Copyfrom 2
    40. Sub 0
    41. Jump if negative (to label J)
    42. Copyfrom 0
    43. Outbox
    44. Copyfrom 2
    45. Outbox
    46. Jump (to label D)
    J:
    47. Copyfrom 2
    48. Outbox
    49. Copyfrom 0
    50. Outbox
    51. Jump (to label E)
    K:
    52. Copyfrom 2
    53. Outbox
    54. Copyfrom 1
    55. Outbox
    56. Copyfrom 0
    57. Outbox
    58. Jump (to label F)

    Storage Floor

    Description

    Imagine each thing in the INBOX is an address. And each address refers to a tile 0-9 on the floor. Your task: For each address in the INBOX, pick up the letter at that address and OUTBOX it.

    Congratulations! You can now access tiles on the floor INDIRECTLY! Observe this example to see how it works, compared to what you've been doing so far:

    Background

    Indirect access is another extremely useful and powerful ability to have while programming. You will encounter this a lot if you ever work with arrays, which are basically lists of objects; if you were to call on "myArray[4]", you would get the element in the 4th position of the array named myArray.

    More broadly, indirect access is a metaphor for going to a certain memory address and getting whatever value exists there; this is closer to what we will be doing in this puzzle. Try looking up "memory address" for more information.

    Hints

    This is a tutorial floor. The solution should not give you any trouble.

    Solution

    Size Challenge: Use 5 or fewer commands.
    Speed Challenge: Complete in 25 or fewer steps.

    A:
    01. Inbox
    02. Copyto 12
    03. Copyfrom [12]
    04. Outbox
    05. Jump (to label A)

    String Storage Floor

    Description

    Each thing in the INBOX is an address of a tile on the floor. For each address provided in the INBOX, OUTBOX the requested item from the floor and ALL FOLLOWING items on the floor until you reach a ZERO. Repeat!

    Background

    This floor basically has you grabbing substrings, i.e. subsections of strings that already exist.

    Hints

    This is another straightforward floor. You should get both challenges without too much work. You need to maintain a tile that just keeps track of which floor tile you're grabbing letters from.

    Solution

    Size Challenge: Use 7 or fewer commands.
    Speed Challenge: Complete in 203 or fewer steps.
    Tile label: index

    A:
    01. Inbox
    02. Copyto "index"
    B:
    03. Copyfrom ["index"]
    04. Jump if zero (to label A)
    05. Outbox
    06. Bump+ "index"
    07. Jump (to label B)

    String Reverse

    Description

    For each zero terminated string in the INBOX, reverse it and put the result in the OUTBOX. Repeat!

    Background

    Sometimes computer programs need to reverse strings, too.

    In any case, if you want to loop over every character in a string, or every item in an array, you'll usually need an additional variable to track where you currently are in the string or array. Several languages have ways to abstract this out and do it for you automatically.

    Hints

    You just learned about indirect access, and that zero on the ground is going to be useful for determining where a certain letter is going to be placed on the ground. Your instinct will be to start laying letters down at tile 0, but if you do that then you'll have to spend extra commands and steps resetting the index variable to 0 for each new word. If you start laying down letters at another point, your life will be easier.

    Solution

    Size Challenge: Use 11 or fewer commands.
    Speed Challenge: Complete in 122 or fewer steps.
    Tile 14 label: index

    A:
    B:
    01. Bump+ "index"
    02. Inbox
    03. Jump if zero (to label C)
    04. Copyto ["index"]
    05. Jump (to label A)
    C:
    D:
    06. Bump- "index"
    07. Jump if zero (to label B)
    08. Copyfrom ["index"]
    09. Outbox
    10. Jump (to label D)

    Inventory Report

    Description

    For each thing in the INBOX, send to the OUTBOX the total number of matching items on the FLOOR.

    Background

    This is your first time subtracting letters from other letters in this game. This is kind of a weird thing and I'm not sure how directly it applies to programming. In the underlying representation, all letters are ultimately represented as numbers, so they can be added and subtracted with a bit of work, but the applications are dubious. It's more common to add numbers to letter in order to get other letters; this is, in fact, how capitalization and lowercasing are generally implemented.

    Hints

    This is another case where you'll want to rearrange code to reduce the number of jumps. Take some end-of-loop elements and try putting them near the top of the loop instead, like you did on floor 9. The ideal scenario is that if you ever do a conditional jump, you shouldn't do another jump right after executing the conditional code that comes after that conditional jump.

    Solution

    Size Challenge: Use 16 or fewer commands.
    Speed Challenge: Complete in 393 or fewer steps.
    Tile 14 label: zero
    Tile 15 label: index
    Tile 16 label: count
    Tile 17 label: current

    01. Jump (to label B)
    A:
    02. Copyfrom "count"
    03. Outbox
    B:
    // Setup
    04. Inbox
    05. Copyto "current"
    06. Copyfrom "zero"
    07. Copyto "index"
    08. Copyto "count"
    09. Jump (to label E)
    C:
    10. Bump+ "count"
    D:
    11. Bump+ "index"
    E:
    12. Copyfrom ["index"]
    13. Jump if zero (to label A)
    14. Sub "current"
    15. Jump if zero (to label C)
    16. Jump (to label D)

    Where's Carol?

    I haven't seen her for a while. Oh well, back to work!

    Vowel Incinerator

    Description

    Send everything from the INBOX to the OUTBOX, except for vowels.

    Background

    Really not much to say here. Just another fun puzzle.

    Hints

    I ended up using two tiles in addition to the tile with the zero on it. With numbers, if you subtract one number from another, you can just add it again to get the original number back. You can't do this with letters, though; subtracting one letter from another gets you a number, and you can't add a letter back to that. This means you'll need to store the letter from the inbox so you can keep grabbing it back.

    That zero that has been placed on the floor needs to pull double duty here. It should not only act as a way to reset another variable, but also a way to know when you are done looking at vowels. Lastly, reduce jumps where you can.

    Solution

    Size Challenge: Use 13 or fewer commands.
    Speed Challenge: Complete in 323 or fewer steps.
    Tile 5 label: zero
    Tile 6 label: current
    Tile 7 label: index

    01. Jump (to label B)
    A:
    02. Copyfrom "current"
    03. Outbox
    B:
    C:
    04. Inbox
    05. Copyto "current"
    06. Copyfrom "zero"
    07. Copyto "index"
    D:
    08. Copyfrom ["index"]
    09. Jump if zero (to label A)
    10. Sub "current"
    11. Jump if zero (to label C)
    12. Bump+ "index"
    13. Jump (to label D)