Number Factory

From Esolang
Jump to: navigation, search

Number Factory:
You've been called upon to program a robot to work at the Number Factory. You'll need to direct the bot to move from one room to another to create the correct numbers as desired by... you, I guess. To write a program for the robot, you write the sequence of commands for the robot to follow. The rooms operate themselves as the robot moves numbers around the factory. While programming, you need to keep track of the robot's location and what numbers each room contains.

Factory Map

+-+-+-+-+-+
|0|1|2|T|%|
+-+-+-+-+-+
|-|S|P|Q|*|
+-+-+-+-+-+
|+|#|@|C|&|
+-+-+-+-+-+
|=|/|X|!|~|
+-+-+-+-+-+

Commands

  • >: Move the robot 1 room right, wrapping around.
  • <: Move the robot 1 room left, wrapping around.
  • ^: Move the robot 1 room up, wrapping around.
  • V: Move the robot 1 room down, wrapping around.
  •  %: If holding a number, place it in the current room; otherwise, pick up a number from the current room, if any.
  • (: If room X contains a 0, skip to the matching ).
  • ): Unless room X contains a 0, return to the matching (.

Any other character is ignored as a comment.

Rooms

0, 1, 2, T: Material Lines
These rooms always contain the number shown (T is 10); if it's taken, a replacement is placed here.
If the robot places a number here, it is discarded.

+: Fusing Machine
This room starts empty. When one number is placed, nothing happens.
When a second number is placed here, both are discarded and their sum is placed here.

-: Carving Machine
This room starts empty. When one number is placed, nothing happens.
When a second number is placed here, both are discarded and their difference is placed here.
To be clear, the second number is subtracted from the first.

#: The Copier
This room starts empty. When a number is placed here, a copy of it is placed in room @.
If a second number is placed here, the first is discarded.

@: Copy Dropoff
This room starts empty; copied numbers are placed here.
If a second number is placed here, the first is discarded.

S, P: Stack Storage
This room starts empty; any amount of numbers can be stored in these rooms.
When a number is taken from here, the most recent number placed there is taken (last in, first out).

Q: Queue Storage
This room starts empty; any amount of numbers can be stored here.
When a number is taken here, the oldest number is taken (first in, first out).

C: Storage Closet
This room starts empty; a number can be stored here.
If a second number is placed here, the first is discarded.

%: Receiving Dock
When the robot enters this room, the user is prompted for an integer as input.
The integer received is placed here. If a second number is placed here, the first is discarded.

*: Shipping Dock
This room is always empty.
If a number is placed here by the robot, it is discarded and sent to the user as output.

&: The Disposal
This room is always empty.
If a number is placed here, it is discarded with no effect.

=: Quality Control
This room starts empty. When one number is placed, nothing happens.
When a second number is placed, both are discarded.
If the discarded numbers are equal, place a 1 in room X; if not, place a 0.

/: Uniqueness Detector
This room starts empty. When one number is placed, nothing happens.
When a second number is placed, both are discarded.
If the discarded numbers are equal, place a 0 in room X; if not, place a 1.

!: Inverting Transformer
This room starts empty. When a non-zero number is placed here, it is replaced with a 0.
When a 0 is placed here, it is replaced by a 1.
If a second number is placed here, the first is discarded.

X: Command Center
The robot starts here; this room starts with a 1.
If a second number is placed here, the first is discarded.

~: Postal Office
This room is always empty.
If a number is placed here by the robot, it is discarded, converted into a letter and sent to the user as output.
1=A, 2=B, 3=C, 25=Y, 26=Z; 0 becomes a space and 27 becomes a new line; any number out of range (0-27) is just discarded.

Interpreter

Python Interpreter (currently untested)