# Proposal for new exercise: 3D Printer

I am proposing a new exercise that “builds” on top of the idea of a robot simulator but makes it more advanced by adding multiple principles like 3D instead of 2D. Here is a proposal of introduction + instructions (It needs to be refined but this is a draft meant as a proposal):

## Introduction.md

A company called Walker3DPrinters has approached you and requested that you build a program for them, that controls the motors and the extruder of a 3D printer.

An extruder is a piece that outputs the material.

The company would like the software to work on all of their different machines which involves different print areas.
The printer should have several safety features like hit detection, which detects if it hits an already printed area or prints in mid-air.

## Instructions.md

Your task is to build a program that controls the 3d printer.
The program is meant to receive instructions that tell the printer how to print.
It shall return a 3D representation of the result of the instructions, in the format there each axis is formated such as `[x[y[z]]]`, and where 1 represents that a grid has been printed and 0 that it hasn’t.

The instructions involve:

• How big is the printing area on all axis (x,y,z)).
• The coordinates of the extruder (x,y,z).
• Controlling movements of the axis (x,y,z).
• Move up
• Move down
• Move forward
• Move backward
• Move to the right
• Move to the left
• Controlling if the extruder should print.

(A picture to get some sense, not meant for final use)

The printer should stop printing if any of the following is true:

• The printer hits an already printed area.
• The printer prints in mid-air.
• The printer prints more than 1 grid at a 90* angle without any support.

(A picture to get some sense, not meant for final use)

The program is given the size of the grid by giving the size in 3 axes (x, y, z), like: (100, 50, 20).
The extruder is set on the 3D grid at a set of coordinates (x, y, z), like: (10, 4, 5).
The printer is fed with the printing instructions and then starts to follow them.

• The instructions: “SFRULBERDSE” means:
• Start printing
• Move forward
• Move to the right
• Move up
• Move to the left
• Move backward
• End printing
• Move backward yet again
• Move down
• Start printing yet again
• End printing yet again
• If the grid was of size (2, 2, 2) and it started at (0,0,0) the result of the 3d representation would be the following:
``````[[[1, 1], [1, 0]], [[1, 1], [1, 1]]]
``````

I have to say, that I like riddles and logic puzzles.
For Exercism, I am not sure where this exercise would fit in. What do you want to teach with it? Is it about three-dimensional data types?

3D dimensional datatypes, but also that you have to be aware of your position at all times since an incorrect position should raise an error and incorrect printing as well.

I like the idea, however I think if you implement it you probably have to include the actual drawing as well. Visualize 3D datatypes, or just 3D spaces/objects in general is not an easy thing for many people if they only have text to go with.

Yeah, if this goes forward I think pictures are needed, it is just that for a proposal I didn’t really want to spend hours working on art and then it doesn’t get past the proposal stage. These pictures did I quite quickly just make in paint.

This could be an interesting exercise.

CAD tools could make the drawings simple to generate. I could do something fairly quickly and easily in OpenSCAD … but probably not for 2-3 weeks.

If you wanted to dig deeper, there’s interesting things that can be done here. For example, you only need to track the max z-value for any x-y coordinate, since the head cannot fill beneath the surface. In real life, the head cannot fill an x-y even if it is empty when the surrounding x-y coordinates are filled – the head needs a gap larger than the head and surrounding structure.

Yeah that is true, but it feels like it may become a bit too complicated if we apply such rules? At the same time it would be a fun challenge.

As for the images, maybe the picture that is of the 3d printer could an SVG, but the later ones I think could fit as being in 3d, so if you like to create them feel free to.