text:
Calculate the Kronecker Product
Related, but very different.

In the examples below, \$A\$ and \$B\$ will be \$2\times2\$ matrices, and the matrices are one-indexed.
A Kronecker product has the following properties:
A⊗B =  A(1,1)*B   A(1,2)*B
        A(2,1)*B   A(2,2)*B

     =  A(1,1)*B(1,1)   A(1,1)*B(1,2)   A(1,2)*B(1,1)   A(1,2)*B(1,2)
        A(1,1)*B(2,1)   A(1,1)*B(2,2)   A(1,2)*B(2,1)   A(1,2)*B(2,2)
        A(2,1)*B(1,1)   A(2,1)*B(1,2)   A(2,2)*B(1,1)   A(2,2)*B(1,2)
        A(2,2)*B(2,1)   A(2,2)*B(1,2)   A(2,2)*B(2,1)   A(2,2)*B(2,2)

Challenge: Given two matrices, \$A\$ and \$B\$, return \$A\otimes B\$.

The size of the matrices will be at least \$1\times1\$. The maximum size will be whatever your computer / language can handle by default, but minimum \$5\times5\$ input.
All input values will be non-negative integers
Builtin functions that calculate Kronecker products or Tensor/Outer products are not allowed
In general: Standard rules regarding I/O format, program & functions, loopholes etc.

Test cases:
A =
     1     2
     3     4
B =
     5     6
     7     8
A⊗B =
     5     6    10    12
     7     8    14    16
    15    18    20    24
    21    24    28    32

B⊗A =
     5    10     6    12
    15    20    18    24
     7    14     8    16
    21    28    24    32
------------------------
A =
     1
     2
B =
     1     2

A⊗B =
     1     2
     2     4
------------------------
A =
    16     2     3    13
     5    11    10     8
     9     7     6    12
     4    14    15     1

B =
     1     1
     0     1

A⊗B  =
    16    16     2     2     3     3    13    13
     0    16     0     2     0     3     0    13
     5     5    11    11    10    10     8     8
     0     5     0    11     0    10     0     8
     9     9     7     7     6     6    12    12
     0     9     0     7     0     6     0    12
     4     4    14    14    15    15     1     1
     0     4     0    14     0    15     0     1

B⊗A =
    16     2     3    13    16     2     3    13
     5    11    10     8     5    11    10     8
     9     7     6    12     9     7     6    12
     4    14    15     1     4    14    15     1
     0     0     0     0    16     2     3    13
     0     0     0     0     5    11    10     8
     0     0     0     0     9     7     6    12
     0     0     0     0     4    14    15     1
------------------------

A = 2
B = 5
A⊗B = 10

Jelly, 10 9 bytes
×€€;"/€;/

Uses Büttner's Algorithm (ü pronounced when trying to make an ee sound [as in meet] in the mouth-shape of an oo sound [as in boot]).
The ;"/€;/ is inspired by Dennis Mitchell. It was originally Z€F€€;/ (which costs one more byte).

Test case 1
Test case 2
Test case 3
Test case 4

Or, in IPA, /y/

Not every person knows IPA.

Thanks for the explanation of how to pronounce Martin's last name. It's super relevant. :P

Well it's how I show respect...

;/ can be Ẏ now. (feature postdates challenge?)

CJam, 13 bytes
{ffff*::.+:~}

This is an unnamed block that expects two matrices on top of the stack and leaves their Kronecker product in their place.
Test suite.
Explanation
This is just the Kronecker product part from the previous answer, therefore I'm here just reproducing the relevant parts of the previous explanation:
Here is a quick overview of CJam's infix operators for list manipulation:

f expects a list and something else on the stack and maps the following binary operator over the list, passing in the other element as the second argument. E.g. [1 2 3] 2 f* and 2 [1 2 3] f* both give [2 4 6]. If both elements are lists, the first one is mapped over and the second one is used to curry the binary operator.
: has two uses: if the operator following it is unary, this is a simple map. E.g. [1 0 -1 4 -3] :z is [1 0 1 4 3], where z gets the modulus of a number. If the operator following it is binary, this will fold the operator instead. E.g. [1 2 3 4] :+ is 10.
. vectorises a binary operator. It expects two lists as arguments and applies the operator to corresponding pairs. E.g. [1 2 3] [5 7 11] .* gives [5 14 33].

ffff*  e# This is the important step for the Kronecker product (but
       e# not the whole story). It's an operator which takes two matrices
       e# and replaces each cell of the first matrix with the second matrix
       e# multiplied by that cell (so yeah, we'll end up with a 4D list of
       e# matrices nested inside a matrix).
       e# Now the ffff* is essentially a 4D version of the standard ff* idiom
       e# for outer products. For an explanation of ff*, see the answer to
       e# to the Kronecker sum challenge.
       e# The first ff maps over the cells of the first matrix, passing in the
       e# second matrix as an additional argument. The second ff then maps over
       e# the second matrix, passing in the cell from the outer map. We
       e# multiply them with *.
       e# Just to recap, we've essentially got the Kronecker product on the
       e# stack now, but it's still a 4D list not a 2D list.
       e# The four dimensions are:
       e#   1. Columns of the outer matrix.
       e#   2. Rows of the outer matrix.
       e#   3. Columns of the submatrices.
       e#   4. Rows of the submatrices.
       e# We need to unravel that into a plain 2D matrix.
::.+   e# This joins the rows of submatrices across columns of the outer matrix.
       e# It might be easiest to read this from the right:
       e#   +    Takes two rows and concatenates them.
       e#   .+   Takes two matrices and concatenates corresponding rows.
       e#   :.+  Takes a list of matrices and folds .+ over them, thereby
       e#        concatenating the corresponding rows of all matrices.
       e#   ::.+ Maps this fold operation over the rows of the outer matrix.
       e# We're almost done now, we just need to flatten the outer-most level
       e# in order to get rid of the distinction of rows of the outer matrix.
:~     e# We do this by mapping ~ over those rows, which simply unwraps them.

Your code almost looks like an IPv6 address

MATLAB / Octave, 83 42 Bytes
Saved 41 bytes, thanks to  FryAmTheEggman!
@(A,B)cell2mat(arrayfun(@(n)n*B,A,'un',0))

Test it here!
Breakdown
arrayfun is a disguised for-loop that multiplies n*B, for a variable n defined by the second argument. This works because looping through a 2D matrix is the same as looping through a vector. I.e. for x = A is the same as for x = A(:).
'un',0 is equivalent to the more verbose 'UniformOutput', False, and specifies that the output contains cells instead of scalars.
cell2mat is used to convert the cells back to a numeric matrix, which is then outputted.

You should clarify that arrayfun loops linearly as you say, as if the matrix were a vector, but for does not (it loops over columns of the array)

Pyth, 14 12 11 bytes
JEsMs*RRRRJ

Translation of Jelly answer, which is based on Büttner's Algorithm (ü pronounced when trying to make an ee sound [as in meet] in the mouth-shape of an oo sound [as in boot]).
Try it online (test case 1)!
Bonus: calculate B⊗A in the same number of bytes
JEsMs*LRLRJ

Try it online (test case 1)!

Julia, 40 39 37 bytes
A%B=hvcat(sum(A^0),map(a->a*B,A')...)

Try it online!
How it works

For matrices A and B, map(a->a*B,A') computes the Kronecker product A⊗B.
The result is a vector of matrix blocks with the dimensions of B.
We have to transpose A (with ') since matrices are stored in column-major order.
sum(A^0) computes the sum of all entries of the identity matrix of A's dimensions. For an n×n matrix A, this yields n.
With first argument n, hvcat concatenates n matrix blocks horizontally, and the resulting (larger) blocks vertically.

R, 98 86 bytes
function(x,y,`+`=array)aperm(apply(x,1:2,`*`,y)+c(w<-dim(y),v<-dim(x)),c(1,3,2,4))+v*w

Try it online!
Reimplementation of .kronecker and outer for matrices. I do think there's a golfier approach out there, maybe using apply? 6 bytes golfed using apply and array thanks to Dominic van Essen!
The builtins are %x% for kronecker(A,B,"*") and %o% for outer(A,B,"*").
R, 120 bytes
function(A,B){l=list()
a=dim(A)
for(i in 1:a[2]-1)l[[i+1]]<-do.call(rbind,lapply(A,"*",B)[1:a+a[2]*i])
do.call(cbind,l)}

Try it online!
Naive approach: calculate the subarrays \$a_{ij}B\$ and bind them together in the appropriate order. There are probably golfs here too, but I don't think it'll be shorter than the one above.

This is funny!  I got almost exactly the same answer yesterday (when your edit put this post to the top), but it seemed so un-golfy I didn't even submit it...!  My best attempt was 92 bytes...

@DominicvanEssen there's the better version with apply. I knew it was out there, just couldn't wrap my head around it. Feel free to post it yourself.

@DominicvanEssen PS 86 bytes

Hmm...  That's getting good, but...  I think you should just incorporate these into your answer, instead of outgolfing yourself in your own comments...!

@DominicvanEssen fair enough! But I do think it's a shame such a matrix-friendly language is longer than the JS answer...

I completely agree, but, if it's any consolation, if JS 'map' was called 'apply' (like in R), the JS answer would be 87 bytes long...

JavaScript (ES6), 79
Straightforward implementation with nested looping
(a,b)=>a.map(a=>b.map(b=>a.map(y=>b.map(x=>r.push(y*x)),t.push(r=[]))),t=[])&&t

Test

f=(a,b)=>a.map(a=>b.map(b=>a.map(y=>b.map(x=>r.push(y*x)),t.push(r=[]))),t=[])&&t

console.log=x=>O.textContent+=x+'\n'

function show(label, mat)
{
  console.log(label)
  console.log(mat.join`\n`)
}

;[
  {a:[[1,2],[3,4]],b:[[5,6],[7,8]] },
  {a:[[1],[2]],b:[[1,2]]},
  {a:[[16,2,3,13],[5,11,10,8],[9,7,6,12],[4,14,15,1]],b:[[1,1],[0,1]]},
  {a:[[2]],b:[[5]]}
].forEach(t=>{
  show('A',t.a)
  show('B',t.b)
  show('A⊗B',f(t.a,t.b))
  show('B⊗A',f(t.b,t.a))
  console.log('-----------------')
})

J, 10 bytes
This is one possible implementation.
[:,./^:2*/

J, 13 bytes
This is a similar implementation, but instead uses J's ability to define ranks. It applies * between each element on the LHS with the entire RHS.
[:,./^:2*"0 _

Usage
   f =: <either definition>
    (2 2 $ 1 2 3 4) f (2 2 $ 5 6 7 8)
 5  6 10 12
 7  8 14 16
15 18 20 24
21 24 28 32
   (2 1 $ 1 2) f (1 2 $ 1 2)
1 2
2 4
   2 f 5
10

APL (Dyalog Unicode), 10 bytes
{⍪/,/⍺×⊂⍵}

Try it online!
How it Works
{  ...   }  ⍝ dfn that takes ⍺=A and ⍵=B
     ⍺×⊂⍵   ⍝ Product of each element of A with all of matrix B
            ⍝ Gives a nested array: an matrix of matrices
   ./       ⍝ Join rows
 ⍪/         ⍝ Join columns

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Draw a simple cube
We don't have a single challenge about drawing a real 3 dimensional cube, so here it goes:
Challenge
Your task is to draw a rotated, cube with perspective. It can be in a separate window or as an image.
Input
Your input is 3 separate numbers between 0 and 359.99... These represent the rotation around the x, y and z axis in degrees.
0 0 0
30 0 40
95 320 12

Output
You can either display it in a separate window or save an image. You can use any type of display (vector based, rasterized, etc.).
Edit: ASCII is allowed too, to allow golfing languages with only textual output.
The output for rasterized or ASCII graphics must be at least 50*50 (pixels for rasterization, characters for ASCII)
Additional information
The positive z axis points out from the window, the x axis is horizontal, and the y axis is vertical. Basically the OpenGL standard.
Rotations are counter-clockwise if you look at the cube in the negative direction of a specific axis, e.g looking down for the y axis.
The camera should be on the z axis at a reasonable distance from the cube in the negative z direction, the cube should be at (0;0;0). The. cube also needs to be fully visible, and take up at least 50% of the drawing frame. The camera should look in the positive z direction at the cube.
The rotations of the cube get applied in the x->y->z order.
The cube is rotated around it's center, it doesn't move.
To project a cube in 2d space, you need to divide the x and y coordinates of the cube with the distance parallel to the z-axis between the point and the camera.
Rules
Rendering libraries are allowed, but the vertices need to be defined in the code. No 3d cube model class.
Test cases

Does it have to be wireframe?

Care to include an algorithm for the points?

@EᴀsᴛᴇʀʟʏIʀᴋ No, I made that rule before I thought about rotating it, to prevent people from drawing a simple square, it can be solid.

@KennyLau I'm not sure what you mean with that.

@KennyLau google will tell you the formula.

@Bálint I mean the algorithm for the projections of the points into the 2D plane.

@KennyLau It's usually done by dividing the x and y coordinates with the z.

What order/directions are the rotations done in? Where is the camera looking from? What kind of projection do we have to use?

@flawr camera is at 0;0;0, rotations are counter clockwise.

Counterclockwise from what direction? And if the camera is at 0,0,0 then the rotations are going to move the cube out of the field..

@flawr I included it in the post

But as I said, the rotations will not work out. As you defined it now, the cube will be moved out of the field of view if e.g. rotated around the x axis. Please use the sandbox.

@EᴀsᴛᴇʀʟʏIʀᴋ  google will tell you the formula. No, challenges should contain as much of the material and information needed to solve them as possible, included in the body of the post. I shouldn't have to go googling or Wikipedia-ing just to start understanding.

@cat true.  That was a mistake.

related http://codegolf.stackexchange.com/q/22756/15599 . I don't think this is a duplicate, but in the light of this Ï disagree with the first line of this question

@flawr 's points are valid. If the cube is on z axis, but is then rotated about the x or y axis, it will move off the z axis and out of view. I think you want the cube centred on the origin, so that it rotates about its centre. The camera would then be placed some distance away on the z axis. You should also specify how far, otherwise I would make the distance infinity to avoid having to deal with perspective, and simply do an orthogonal projection: x2d=x3d, y2d=y3d, z3d ignored. For a cube of  sidelength 2 and hence vertices (+/-1,+/-1,+/-1) a camera at (0, 0,10 to 20) would be appropriate.

Once that is sorted, the only other point is to mention the order in which the rotations are done, and I'd be ready to cast a reopen vote.

@EᴀsᴛᴇʀʟʏIʀᴋ I hope it's clear now.

There is still a contradiction here: cube rotates about its center + cube rotates about x,y,z axes means cube must be at 0,0,0 (which is where you say the camera is.) As I said before, the easiest way to resolve this is to rotate about the origin and move the camera to some point on the z axis. Alternatively it would have to be '[3 numbers] represent the rotation about the z axis and axes parallel to x and y axes that pass through its centre'. You would also be wise to specify exactly how many cube sidelengths away the camera should be.

@LevelRiverSt Done

Reminds me of this thing I did... https://codereview.stackexchange.com/questions/114767 Relevant for if you need to find some code for calculating perspective 3D points and what-not.

Would answers in Unity count?

@Blue If you write a code, wich generates the vertices for it.

@Bálint lol I'd post my OpenGL answer but then you know... its OpenGL and it takes 2 pages....

Shoes (Ruby) 235 231
Everything computed from scratch.
Shoes.app{p,a,b,c=ARGV.map{|j|j.to_f/90}
k=1+i="i".to_c
p=(0..3).map{|j|y,z=(k*i**(j+a)).rect
x,z=(((-1)**j+z*i)*i**b).rect
q=(x+y*i)*i**c
[90*(k+q/(z-4)),90*(k+q/(4+z))]}
4.upto(15){|j|line *(p[j%4][0].rect+p[(j+j/4)%4][1].rect)}}

Call from commandline eg shoes cube3d.rb 0 30 0
The idea is to simultaneously generate / rotate the four vertices of a tetrahedron in 3d. Then, as these are reduced to 2d, we generate the four vertices of the inverse tetrahedron (the total 8 vertices being those of the cube.) This gives 4 pairs of vertices corresponding to the 4 body diagonals. Finally the 2d vertices are connected by lines: each vertex of the original tetrahedron must be connected to each vertex of the inverse tetrahedron forming the 12 edges and 4 body diagonals of the cube. The ordering ensures the body diagonals are not plotted.
Test cases output
Note that, to be consistent with the last two test cases, rotation about the z axis is clockwise from the POV of the viewer. This seems to be in contradiction with the spec however. Rotation direction can be reversed by modifying *i**c -> /i**c

ungolfed
Shoes.app{
  p,a,b,c=ARGV.map{|j|j.to_f/90}   #Throw away first argument (script name) and translate next three to fractions of a right angle.
  k=1+i="i".to_c                   #set up constants i=sqrt(-1) and k=1+i

  p=(0..3).map{|j|                 #build an array p of 4 elements (each element wil be a 2-element array containing the ends of a body diagonal in complex number format)
    y,z=(k*i**(j+a)).rect          #generate 4 sides of square: 1+i,i-1,-1-i,-i+1, rotate about x axis by a, and store in y and z as reals
    x,z=(((-1)**j+z*i)*i**b).rect  #generate x axis displacements 1,-1,1,-1, rotate x and z about y axis by b, store in x and z as reals
    q=(x+y*i)*i**c                 #rotate x and y about z axis, store result in q as complex number
  [90*(k+q/(z-4)),90*(k+q/(4+z))]} #generate "far" vertex q/(4+z) and "near" vertex q/-(4-z) opposite ends of body diagonal in 2d format.

  4.upto(15){|j|                   #iterate through 12 edges, use rect and + to convert the two complex numbers into a 4 element array for line method
    line *(p[j%4][0].rect+         #cycle through 4 vertices of the "normal" tetrahedron
     p[(j+j/4)%4][1].rect)         #draw to three vertices of the "inverted" tetrahedron. j/4=1,2,3, never 0
  }                                #so the three edges are drawn but the body diagonal is not.
}

Note that for historical reasons a scale factor of 90 is applied in line 9 (chosen to be the same as 90 degrees in line 2 for golfing) but in the end there was no golfing advantage in using this particular value, so it has become an arbitrary choice.

HTML/CSS/JS, 739 bytes, probably non-competing
But I just wanted to show off CSS 3D transforms.

w=_=>o.style.transform=`rotateZ(${z.value}deg) rotateY(${y.value}deg) rotateX(${-x.value}deg)`
input {
  width: 5em;
}

#c{width:90px;height:90px;margin:90px;position:relative;perspective:180px}#o{position:absolute;width:90px;height:90px;transform-style:preserve-3d;transform-origin:45px 45px 0px;}#o *{position:absolute;width:90px;height:90px;border:2px solid black}#f{transform:translateZ(45px)}#b{transform:rotateX(180deg)translateZ(45px)}#r{transform:rotateY(90deg)translateZ(45px)}#l{transform:rotateY(-90deg)translateZ(45px)}#u{transform:rotateX(90deg)translateZ(45px)}#d{transform:rotateX(-90deg)translateZ(45px)}

  X:<input id="x" type="number" value="0" min="0" max="360">
  Y:<input id="y" type="number" value="0" min="0" max="360">
  Z:<input id="z" type="number" value="0" min="0" max="360">

This actually looks pretty neat. I experienced with CSS3 transformations before, but I had issues with it.

You seem to have the rotations in the wrong order. It should be x then y then z. You have z then y then x. @Bálint may confirm.

@LevelRiverSt When I wrote this I didn't know what the order should be, and I couldn't work it out from the test cases, so thanks for updating me. I've also flipped the direction of the X rotation, so now I match all of the test cases.

Can you still provide a byte count? Even if answers are non-competing they should always have a byte count

@Downgoat Golfed or ungolfed?

@Neil golfed, all answers to [tag:code-golf] should be golfed to be valid submissions

Maple, 130+14 (in progress)
with(plots):f:=(X,Y,Z)->plot3d(0,x=0..1,y=0..1,style=contour,tickmarks=[0,0,0],labels=["","",""],axes=boxed,orientation=[Z,-X,Y]);

This plots a constant function inside a box, then uses plot options to hide ticks, labels and the function itself. Adding projection=.5 to the options brings the camera closer, enabling perspective view.
I wrote this before the specs were finalized and the rotation order is x, y', z'' instead of x, y, z. Until I fix the angles, here is another solution
POV-Ray, 182
#include"a.txt"
#include"shapes.inc"
camera{location 9*z look_at 0}
light_source{9*z color 1}
object{Wire_Box(<-2,-2,-2>,<2,2,2>,.01,0)texture{pigment{color rgb 1}}rotate<R.x,-R.y,-R.z>}

reads input through the a.txt file which should contain
#declare R=<xx,yy,zz>;
with xx,yy,zz being the rotation angles

Yay for using POV-ray, it's a great program. Unfortunately, the rules now state that no 3d cube class can be used.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
ASCII Art Mayan Numerals
This challenge is simple.  Given a number, output a ascii-art representation of the number, using the Mayan Base-20 numeral system.
What is the Mayan system?
The Mayans used base 20 to store numbers, so the first position was the 1s place, the next the 20s place, then the 400s, etc.
So Mayan number 1 is 1 in base 10, but 10 is actually 20 in base 10, 207 is 807 in base 10, etc..
And they represented their numbers as pictographs, with a special symbol for 0.
 -------------------
|    |    |    |    |
|    |    |    |    |
|-------------------|
|                   |
|                   |
 -------------------

That was their zero.  (at least the half picascii half my artisticness ascii art version)

That is a real picture of the mayan zero symbol.1
This was their five:
--------------------------------
|                              |
--------------------------------

And a 4:
 ----   ----   ----   ----
|    | |    | |    | |    |
|    | |    | |    | |    |
 ----   ----   ----   ----

Finally, to put it together:
 ----   ----   ----
|    | |    | |    |
|    | |    | |    |
 ----   ----   ----
--------------------------------
|                              |
--------------------------------
--------------------------------
|                              |
--------------------------------

So they have x//5 bars, and x%5 dots on top of the bars.  And if x=0, they use the shell/loaf instead of a blank space.
For more images, try the Wikimedia Commons page of Maya number images.
But this is only for numbers up to 19. We aren't allowed to have more than 4 bars and 4 dots in a single 'story'... So we go up!
The output for 20 is:
 ----
|    |
|    |
 ----

 -------------------
|    |    |    |    |
|    |    |    |    |
|-------------------|
|                   |
|                   |
 -------------------

Note this would normally be invalid, because is has a 1 and a 0 at the same time.  But the 3 (note that, your answer needs at least 3) newlines before the 0 mean a new place value.
The bottom story has dots, meaning 1, and bars meaning 5.  But it actually has dots meaning 20^0 and bars meaning 20^0 * 5.
Each story goes up a power.  The second story dots mean 20 (20^1) and 100 (20^1 * 5).
So the number 506 can be represented as:
 ----
|    |
|    |
 ----

--------------------------------
|                              |
--------------------------------

 ----
|    |
|    |
 ----
--------------------------------
|                              |
--------------------------------

This is (20^0) * 1 + (20^0 * 5) * 1 + (20^1 * 5) * 1 + (20^2) * 1 = 1 + 5 + 100 + 400 = 506.
Your mission, should you choose not or choose to (it doesn't matter), is to output a ascii art representation of the base-10 number.
Other Rules:

Leading/trailing space is okay, as long as the dots, bars, and shells are intact.
The bars, dots, and shells must be exactly what the test cases have.  No resizing.
Leading '0's are okay. (leading shells on the output)
You don't have to have exactly 3 newlines between each place value or story, just at least 3.

Test Cases:
15

--------------------------------
|                              |
--------------------------------
--------------------------------
|                              |
--------------------------------
--------------------------------
|                              |
--------------------------------

12

 ----   ----
|    | |    |
|    | |    |
 ----   ----
--------------------------------
|                              |
--------------------------------
--------------------------------
|                              |
--------------------------------

4

 ----   ----   ----   ----
|    | |    | |    | |    |
|    | |    | |    | |    |
 ----   ----   ----   ----

0

 -------------------
|    |    |    |    |
|    |    |    |    |
|-------------------|
|                   |
|                   |
 -------------------

24

 ----
|    |
|    |
 ----

 ----   ----   ----   ----
|    | |    | |    | |    |
|    | |    | |    | |    |
 ----   ----   ----   ----

33

 ----
|    |
|    |
 ----

 ----   ----   ----
|    | |    | |    |
|    | |    | |    |
 ----   ----   ----
--------------------------------
|                              |
--------------------------------
--------------------------------
|                              |
--------------------------------

20

 ----
|    |
|    |
 ----

 -------------------
|    |    |    |    |
|    |    |    |    |
|-------------------|
|                   |
|                   |
 -------------------

1: They also used the heads of gods for the symbols, but for this challenge the shell/bread/zelda chest will be used.

but for this challenge the shell/bread will be used.. Not shell, not bread. LOZ link to the past chest.

https://www.youtube.com/watch?v=69AyYUJUBTg

@epicTCK .... that is actually remarkably like it...

Related.

Ruby, 223 180 177 179 bytes
Anonymous function, returns a multiline string.
Forgot to add some extra spacing that was needed, and also the recursion. Also golfed a bit more by shifting things around.
f=->n{s=?|;e=' ';n<20?(n<1?[t=e+d=?-*19,a=s+(e*4+s)*4,a,s+d+s,b=s+e*19+s,b,t]:((r=n%5)>0?[t=" ----  "*r,m="|    | "*r,m,t]:[])+[a=?-*32,s+e*30+s,a]*(n/5))*$/:f[n/20]+$/*5+f[n%20]}

You are the golfiest. Congrats!

Python 3.5, 404 400 392 312 311 308 290 281 285 281 bytes:
(Thanks to Adnan for a tip on saving 9 bytes(290->281) and Neil for a tip on saving 4 bytes(285->281)!)
def u(z):
 p=[];P=print;S,N,M,X=' -|\n'
 while not p or z:p+=[z%20];z=z//20
 E=lambda i:(S+N*4+S)*i+X+((M+S*4+M)*i+X)*2+(S+N*4+S)*i+X;F=N*32+X+M+S*30+M+X+N*32+X;[P(S+N*19+S+X+M+((S*4+M)*4+X+M)*2+N*19+M+X+(M+S*19+M+X)*2+S+N*19+S+X*3)if y<1else P(E(y%5)+F*(y//5)+X*3)for y in p[::-1]]

Try it online! (Ideone)
Analysis
For the purposes of this analysis, we will use the character set 0123456789ABCDEFGHIJ to represent each digit in base 20.
So, I could have gone and converted base 10 into base 20 using one of two algorithms I have. The first algorithm I thought of using is what I call the powers algorithm. This is not the one that I used in the code though as it would have made it way longer than it should have been, so I'm not going to talk about this one. However, I did create a python script that converts any integer in base 10 into any other base provided using this method, which you can use here on repl.it. The one I used instead for this challenge is what I call the division algorithm, which I think is explained pretty good here. But basically what happens is that it takes the base 10 number provided and divides it by the base it needs to convert the number to, which in this case is 20, until the remainder is either 0 or 1. It then takes the quotiant and remainder, in that order, from the last division operation, and then all the other remainders from the other division operations in the order from last to first. All these digits are then joined together, and that joined sequence reversed is your base 10 number in base 20! To illustrate this, assume you want to convert the base 10 number 431 to base 20. So, what we would do is this:
[]=list we will put all remainders and the last quotient in
R = Remainder

1. 431/20 = 21 R11 [B (B=11 in base 20)]
2. 21/20 = 1 R1 [Add the remainder and quotient: B11]

Then, finally we would take the list we have, which in this case contains B11, and reverse it so that we now have 11B. In doing this, we have finally got our final answer! 431 in base 10 converted to base 20 is 11B, which can be confirmed using my Python script that uses the powers algorithm which I already shared a link to above, but I will do it again here. Here is one that also uses the division algorithm described in this answer and returns the same answer as the powers one.
This entire process is essentially what happens in my script in this while loop: while not p or z:p+=[z%20];z=z//20. The only difference is that numbers >9 are not represented as letters but instead as themselves.
Moving on, after the base 10 number has been converted to base 20, for each digit in the base 20 integer, which we will call g, g mod 5 dots are printed out and then g//5 bars are printed out. Then the program prints 3 blank lines and moves on to the next digit. However, if the digit is 0, then a single "loaf" is printed out followed by 3 new lines, and then the program moves onto the next digit. So, taking the base 20 number 11B, we go to the first digit. The first digit is 1, and therefore it would print 0 bars since 1//5=0, and 1 dot since 1%5=1. So, we would first get this:
 ----
|    |
|    |
 ----

and then 3 new lines. Moving onto the the second digit, we also see that it is 1, so it would output the same thing:
 ----
|    |
|    |
 ----

and also 3 new lines. Finally, moving onto the last digit, we see that it's a B. Since B=11 in base 20, the program would output 1 dot since 11%5=1 and 2 bars since 11//5=2. So now, we get this:
 ----
|    |
|    |
 ----
--------------------------------
|                              |
--------------------------------
--------------------------------
|                              |
--------------------------------

Finally, putting all this together, we get this:
 ----
|    |
|    |
 ----

 ----
|    |
|    |
 ----

 ----
|    |
|    |
 ----
--------------------------------
|                              |
--------------------------------
--------------------------------
|                              |
--------------------------------

And, that's the mayan numeral for 431! You finally have your base 10 number represented in base 20 Mayan numerals.
Note: You may or may not have noticed that lambda function in my code. Regardless, this function is used for the creation of the dots since multiple dots must be output next to each other.

I'm not sure if it's possible, but can you do S,N,M,X=' -|\n' instead of S,N,M,X=' ','-','|','\n'?

@Adnan that is possible.

@Adnan Really? Wow, I did not know that. Thanks!

401 contains an inside zero.

@Neil Oh, right. Thanks for the heads-up. It's fixed now.

Rather than adding the J variable, can you use the fact that p is an empty list on the first time through the loop?

@Neil Yeah, I guess I can. Back to 281 bytes now! :)

I thought spaces were needed between the "dots"? Good job on the explanation though, and enjoy your bounty :D

Also, because of bool-to-int conversion and what-not, it is perfectly fine to do (not p)+z instead of not p or z! You might also be able to leverage this tip from the Python golf tips page for the last printing step

Python 3, 243 bytes
s,v,h,x=' |-\n';P=print
t=s+h*19+s+x
def m(n):
 n//20and m(n//20);r=n%20
 if r:
  for a,b,f in[(r%5*' ----  ',r%5*'|    | ',1),('-'*32,'|'+' '*30+'|',r//5)]:P(*((a,b,b,a)*f),sep=x)
 else:P(t+2*(v+(4*s+v)*4+x)+v+h*19+v+x+2*(v+s*19+v+x)+t)
 P(x)

Discussion
n//20and m(n//20) calls m() recursively if there are higher powers of 20 to be handled.  The recursion is done before printing the current place value, so that higher powers get printed first.
If the current place value is non-zero (r!=0), the for a,b,f-loop prints the units and then the fives.  a is the first/forth row and b is the second/third row. The trick is in the print(*((a,b,b,a)*f),sep=x).  For the units, f = 1 resulting in print(*(a,b,b,a),sep=x), which prints the 4 rows that make up the units symbols (x is a '\n').  For the fives, f = the number of fives to print (r//5), so the tuple (a,b,b,a) gets multiplied (i.e., repeated) by the number of fives to print. If f = 2, we get print(*(a,b,b,a,a,b,b,a),sep=x), which prints two symbols for five.
If the current place value is 0, then the zero symbol is printed.

I did have to reward the bounty to R. Kap, but this might deserve it's own bounty! Nice job!

Python, 411 bytes
w,m=input(),[]
for i in[20**i for i in range(int(w**0.25))][::-1]:m.append(w/i);w=w%i
for i in m or[0]:print(lambda x,y='\n',w=' ----  ',z='|    | ':w*(x%5)+y+z*(x%5)+y+z*(x%5)+y+w*(x%5)+y+('-'*32+'\n|'+' '*30+'|\n'+'-'*32+y)*(x/5)if x else''' -------------------
|    |    |    |    |
|    |    |    |    |
|-------------------|
|                   |
|                   |
 ------------------- ''')(i),'\n\n\n'

I created this to generate test cases, you can use it as a benchmark. Sorta golfed.

You could take off 26 bytes by removing whitespace, and another 4 by doing s=math.sqrt and calling s(s(w)) instead of math.sqrt(math.sqrt(w))

@DrGreenEggsandHamDJ thanks.  I don't think I got 26 bytes off from whitespace though?

Oh, sorry, counting error I meant 25. Also, w**0.25 is even better than s(s(w)). Although it got longer?

@DrGreenEggsandHamDJ yeah, I somehow lost the shell zero string in transit from file to answer.

JavaScript (ES6), 254 bytes
f=(n,r=(s,n=19)=>s.repeat(n))=>(n>19?f(n/5>>2)+`

`:``)+(n%5?`${r(s=` ----  `,n%5)}
${t=r(`|    | `,n%5)}
${t}
${s}
`:``)+r(`${s=r(`-`,32)}
|${r(` `,30)}|
${s}
`,n/5&3)+(n%20?``:` ${s=r(`-`)}
${t=r(`|    `,4)}|
${t}|
|${s}|
|${t=r(` `)}|
|${t}|
 ${s}
`)

I can't get this to work? It errors with Missing } in template expression. I don't know very much js, how can I fix it?

@EᴀsᴛᴇʀʟʏIʀᴋ My bad, I moved some code around and accidentally pasted it in the wrong place. It's fixed now.

Python 3, 213 bytes
Came up with an even shorter version using a different approach:
s,v,h,x=' |-\n'
t=s+h*19+s
k=4*s+v
w=v+4*k
y=v+s*19+v
a=' ----  '
b=v+k+s
c=h*32
d=v+s*30+v
m=lambda n:m(n//20)+([n%5*a,n%5*b,n%5*b,n%5*a][:n%5*4]+n%20//5*[c,d,d,c]if n%20else[t,w,w,v+h*19+v,y,y,t])+[x,x]if n else[]

explanation
The first 9 lines or so, build up strings that are used to make the symbols
s,v,h,x = ' |-\n'
k = '    |'

    # parts for a unit
a = ' ----  '
b = '|    | '

    # parts for a five
c = '--------------------------------'
d = '|                              |'

    # parts for a zero
t = ' ------------------- '
w = '|    |    |    |    |'
y = '|                   |'

The core of the solution is the recursive function m, which builds a list of strings, one string for each line in the output.  Schematically, m looks like:
m(n//20) + (ones + fives if n%20 else zero) + [x,x] if n else []

m can be rewritten like:
def m(n):
  if n:
    ans = m(n//20)                             # process high digits first

    if n%20:                                   # if there is a base-20 digit
      ans += [n%5*a,n%5*b,n%5*b,n%5*a][:n%5*4] # add strings for the 'ones' if any
      ans += n%20//5 * [c, d, d, c]            # add strings for the 'fives' if any

    else:
      ans += [t,w,w,v+h*19+v,y,y,t]            # otherwise, add strings for a `zero`

    ans += [x,x]                               # blank lines between digit groups

  else:
    ans = []                                   # base case

  return ans

The recursive call m(n//20) comes first so that the most significant digits are done first.
[n%5*a,n%5*b,n%5*b,n%5*a] are the string for ones symbols.  a is the top row for a single symbol.  n%5 is the number of one symbols for this digit.  So, n%5*a is a string for the top (and bottom) row of n%5 ones. Similarly, 'n%5*b` is a string for the 2nd (and 3rd) row.
The expression [:n%5*4] acts like an if to avoid extra blank lines in the output if there aren't any 'ones' to output.  It's not needed, but makes the output look better.
n%20//5 is the number of symbols for five that are needed.  [c,d,d,c] are the strings to make one symbol for five.
[t,w,w,v+h*19+v,y,y,t] are the strings to make the zero symbol
[x,x] puts at least three blank lines between groups of Mayan digits

Can you give an explanation on how this works?

Vyxal, 89 bytes
20τƛ¶3*,¬[ð19-…\|4꘍4*\|+…,\|19-\|+,\|19꘍\|+…,,]5ḋ£ð4-ðd+`|  `mð+"mƛ¥*t,;n5ḭ(32\|15꘍-m3/⁋,

Try it Online!
Outputs a lot of extra newlines.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Shortest Unique Substring
Given (on STDIN, as command line arguments, or as function arguments) two distinct non-empty strings, find and return the shortest substring of the first string which is not a substring of the second. If no such substring exists, you may return the empty string, return any string which isn't a substring of the original string, or throw an exception. If you are returning from a function, you may also return null (or undefined, None, etc.) in this case. If multiple such substrings are tied for the shortest, you may return any one of them.
Strings can consist of any printable ascii characters.
Input given on STDIN will be given with one string on each line. At your request, a single empty line may be added at the end of the input.
This is code golf, so the shortest valid program wins.
SOME TEST CASES
INPUT:
STRING ONE
STRING TWO

OUTPUT:
E

INPUT:
A&&C
A&$C

VALID OUTPUTS:
&&
&C

INPUT:
(Two randomly-generated 80-letter strings)
QIJYXPYWIWESWBRFWUHEERVQFJROYIXNKPKVDDFFZBUNBRZVUEYKLURBJCZJYMINCZNQEYKRADRYSWMH
HAXUDFLYFSLABUCXUWNHPSGQUXMQUIQYRWVIXGNKJGYUTWMLLPRIZDRLFXWKXOBOOEFESKNCUIFHNLFE

ALL VALID OUTPUTS:
AD
BJ
BR
CZ
DD
EE
ER
EY
EY
FF
FJ
FW
FZ
HE
IJ
IN
IW
JC
JR
JY
KL
KP
KR
KV
LU
MH
MI
NB
NQ
OY
PK
PY
QE
QF
QI
RA
RB
RF
RO
RV
RY
RZ
SW
UE
UH
UN
UR
VD
VQ
VU
WB
WE
WI
WU
XN
XP
YI
YK
YK
YM
YS
YW
YX
ZB
ZJ
ZN
ZV

shortest or longest?

@FryAmTheEggman Then should I still post my solution...

"One string on each line" with or without quotes?

Can we take an array of strings?

is "B" a substring of "aBc" ?

Can we return something else than a string (0, None, undefined, etc.) if there is no unique substring?

@downrep_nation ...yes.

so any non empty character string2 doesnt contain is fine... i see
please add test cases tho

-1 for lack of test cases.

Brachylog, 23 bytes
:1foh.,{,.[A:B]hs?'~sB}

Works on the old Java transpiler. Expects the two strings in a list as input, unifies the output with the substring. If no substring is found, returns false.
Unfortunately I have not yet coded the subset built-in in the new Prolog transpiler.
Explanation
:1f               Find all bindings which satisfy predicate 1 with that binding as input and
                  with the Input of the main predicate as output.
   oh.,           Order that list of bindings, and unify the output with the first one.

{
 ,.[A:B]          Unify the output with the list [A,B]
        hs?       Unify the input with a subset of A
           '~sB   Check that no subset of B can be unified with the input
               }

Python, 119 115 91
lambda a,b:[a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a))if a[m:m+n]not in b][0]

Test cases:
| Input 1  | Input 2     | Output        |
|----------+-------------+---------------|
| 'abcd'   | 'abc'       |  'd'          |
| 'abcd'   | 'dabc'      |  'cd'         |
| 'abcd'   | 'dcbabbccd' |  'abc'        |
| 'abcdf'  | 'abcdebcdf' |  'abcdf'      |
| 'abc'    | 'abc'       |  (IndexError) |

Working on making it shorter, but this is my brain instinct. Not really much of a golfer yet.
Thanks to @user81655 and @NonlinearFruit for the extra bytes.
Edit:
Dang. Tried this code:
def z(a,b):
 for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
  if s not in b:return s
 return''

Thought it was a few bytes shorter. Turns out it was 1 byte longer than what I had before the edit.

I don't know much python, but maybe you can do (r=range)(1,len(a)+1) then use r?

@CᴏɴᴏʀO'Bʀɪᴇɴ Can't do it quite that way. If I assign range to r in the line above, it actually adds a byte. Good idea, though. There's probably a shorter way to iterate through the substrings.

range(1,len(a)) and range(len(a)-1) should work shouldn't it? Also I think using a tab character for the two space indent would save a byte.

No, with range(1,len(a)), the 4th test cast fails because it won't try the full string; it'll only go to the length of the string - 1. And with range(len(a)-1), the 1st test case fails returning 'cd' instead of just 'd'. There may be something there, though.

Sorry, I'm not familiar with Python and I assumed the ranges were inclusive. In that case try range(1,len(a)+1) and range(len(a)).

That works. I hate double-checking substrings I've already checked for the sake of a few bytes, but the challenge is for shortest, so... Thanks!

You can save a couple bytes (maybe make it a one-liner) if you compact your for loops and if statement. For example, [ n+m for m in range(...) for n in range(...) if n%2==0]

@NonlinearFruit Maybe I'm not understanding your suggestion. In the code in the Edit section of my post, I tried doing that, but it ended up being a byte longer. Is your example the suggested change? Because I'm not understanding the even-check at the end. Or adding n and m together.

I was just making stuff up for a short example, for your case it would be [a[m:m+n] for m in range(...) for n in range(...) if a[m:m+n]not in b]. This would give an array of possible answers, so return the 0th one unless it is empty, then return ''

Aha! Much better. Man, code golfing takes a certain kind of problem solving for sure. It's like a completely different thought process.

You can save 2 more bytes by doing a[m:m+n+1]for n in range(len(a))...

Then a couple more by doing lambda a,b,r=range,l=len:..., then call r() and l() instead of range() and len(). This might actually beat Dennis's answer

@Blue regarding the first suggestion: but then I would have to increment the second n later on too, which would result in no improvement. Regarding the second suggestion: the range aliasing results in no improvement, and the len aliasing actually adds two bytes. If I called the functions more often, then it would have helped. That's probably why @Dennis used the aliasing for enumerate since it's a longer word lol. It actually had a positive effect.

@iAmMortos the first one works because it is equivalent to what you are doing now. As for the other 2, yeah, I tested and realized. Sorry

@Blue nah, it happens. It always surprises me how those bytes add up, especially when I find some way to optimize something, and it turns out to be longer. lol

Python, 87 86 bytes
lambda s,t,e=enumerate:[s[i:i-~j]for j,_ in e(s)for i,_ in e(s)if(s[i:i-~j]in t)<1][0]

If it exists, this will return the leftmost of all shortest unique substrings.
If there is no unique substring, an IndexError is raised.
Test it on Ideone.

There it is. I was waiting for somebody to kill my non-lambda implementation. nice lol

I think you can make this shorter by supplying the optional second argument to enumerate to start j at i+1.

@user2357112 That throws a NameError, unfortunately. The code defines j first, then i.

@Dennis: Yeah, but it doesn't need to. You could switch the loop order.

@user2357112 If I switch the loop order, the first unique substring it finds may not be the shortest. Simply swapping the order returns 'ab' for input 'abc','aaa'.

Ah, you're right. It didn't register to me that the list comprehension includes substrings of non-minimal length.

JavaScript (ES6), 79 bytes

f=
(a,b)=>[...a].some((_,i,c)=>c.some((_,j)=>b.indexOf(s=a.substr(j,i+1))<0))?s:''

<input id="a"/><input id="b"/>

If returning false is acceptable, save 2 bytes by using &&s instead of ?s:''.

Python, 82 bytes
g=lambda u:{u}|g(u[1:])|g(u[:-1])if u else{''}
f=lambda s,t:min(g(s)-g(t),key=len)

Usage: f('A&&C', 'A&$C') -> returns '&&'
Raises ValueError if there is no suitable substring.
Explanation:
g=lambda u:{u}|g(u[1:])|g(u[:-1])if u else{''} recursively creates a set of the substrings of u
f=lambda s,t:min(g(s)-g(t),key=len) takes the shortest substring from the set difference

Perl, 87 85
sub{(grep{$_[1]!~/\Q$_/}map{$}=$_;map{substr($_[0],$_,$})}@}}(@}=0..length$_[0]))[0]}

This is an anonymous function which returns the first (by position) of the shortest substrings of $_[0] that do not occur in $_[1], or undef if no such substring exists.
Test program with strings taken from @iAmMortos's answer, tested with Perl 5.22.1:
#!/usr/bin/perl -l
use strict;
use warnings;

my $f = <see above>;
print $f->('abcd', 'abc');
print $f->('abcd', 'dabc');
print $f->('abcd', 'dcbabbccd');
print $f->('abcdf', 'abcdebcdf');
print $f->('abc', 'abc');

Haskell, 72 bytes
import Data.Lists
a#b=argmin length[x|x<-powerslice a,not$isInfixOf x b]

Usage example: "abcd" # "dabc"-> "cd".
A straightforward implementation: build all substrings of a and keep those which do not appear in b. argmin returns an element of a list which minimizes the function given a the 2nd argument, here: length.

I didn't know about argmin! It seems extremely useful.

Pyth, 11 bytes
Jwhf!}TJ.:z

Try it online!

JavaScript (Firefox), 80 bytes

solution=

a=>b=>[for(_ of(i=0,a))for(_ of(j=!++i,a))if(b.includes(s=a.substr(j++,i)))s][0]

document.write("
"+
[ [ "test", "best" ], [ "wes", "west" ], [ "red", "dress" ] ]
.map(c=>c+": "+solution(c[0])(c[1])).join`\n`)

Test works only in Firefox. Returns undefined if there is no substring.

Strings could contain printable ASCII characters such as \ or other RegExp metacharacters, but if you're limiting yourself to Firefox, why not use b.includes instead?

@Neil The question didn't say that the strings could be any character before but thanks for letting me know! Updated to use includes.

The test snippet throws a SyntaxError: unexpected token 'for'

@NoOneIsHere That's the error you'll get if you're not using Firefox...

Retina, 37 bytes
M!&`\G(.+?)(?!.*¶.*\1)
O$#`.+
$.&
G1`

Output is empty if no valid substring is found in A.
Try it online! (Slightly modified to run several test cases at once. The input format is actually linefeed separated, but test suites are easiest to write with one test case per line. The test framework turns the space into a linefeed before the actual code starts.)
Explanation
M!&`\G(.+?)(?!.*¶.*\1)

For each possible starting position in A, match the shortest substring which does not appear in B. The & is for overlapping matches, such that we actually try every starting position, even if a match is longer than one character. The \G ensures that we don't skip any positions - in particular, this way we have to stop at the linefeed, such that we don't get additional matches from B itself. The reason this doesn't mess things up is actually quite subtle: because if there's a starting position in A where we can't find any valid substring, then that's also a failure which will cause \G to stop checking any further positions. However, if (from the current starting position) all substrings appear in B, so will all substrings that start further right of the current position, so discarding those is not an issue (and actually improves performance).
Due to the M! configuration, all of these matches will be returned from the stage, joined with linefeeds.
O$#`.+
$.&

This sorts the lines of the previous result by length. This is done by matching the line with .+. Then $ activates a form of "sort-by", such that the match is substituted with $.& for determining sort order. The $.& itself replaces the match with its length. Finally, the # option tells Retina to sort numerically (otherwise, it would treat the resulting numbers as strings and sort them lexicographically).
G1`

Finally, we simply keep only first line, by using a grep stage with an empty regex (which always matches) and a limit of 1.

Pyth - 9 6 bytes
h-Fm.:

Try it online here.

Crossed out 9 is still 9

I'd love to know how this works.

@mroman the .: with one arg is all substrs. So I map that over both strings, then fold setwise diff, so I have all substrs of first that arnt of the second, then I pick the first one, which is smallest cuz .: is sorted.

C#, 152 bytes
string f(string a,string b){int x=a.Length;for(int i=1;i<=x;i++)for(int j=0;j<=x-i;j++){var y=a.Substring(j,i);if(!b.Contains(y))return y;}return null;}

Ruby, 70 bytes
Collects all substrings of a certain length from the first string, and if there is one that isn't in the second string, return it.
->a,b{r=p;(1..l=a.size).map{|i|(0...l).map{|j|b[s=a[j,i]]?0:r||=s}};r}

Burlesque - 26 bytes
Right now the shortest way I can come up with is:
lnp^sujbcjz[{^p~[n!}f[-][~

Japt, 14 bytes
Êõ!ãU c k!èV g

Try it online!
Returns undefined if there is no valid substring. This is distinct from returning the string "undefined", though the difference is only visible because of the -Q flag.
Explanation:
Ê                 :Length of the first input
 õ                :For each number in the range [1...length]:
  !ãU             : Get the substrings of the first input with that length
      c           :Flatten to a single array with shorter substrings first
        k         :Remove ones which return non-zero to:
         !èV      : Number of times that substring appears in second input
             g    :Return the shortest remaining substring

Japt -h, 11 bytes
à f@øX «VøX

Try it
                :Implicit input of strings U & V
à               :All combinations of U
  f@            :Filter each as X
    øX          :  Does U contain X?
       «        :  Logical AND with the negation of
        VøX     :  Does V contain X?
                :Implicit output of last element


text:
Run through an array
We all often hear the idiom "walk through the array" to mean "map the function over the following array". However, I need it done (now!), so I want you to run through the array.
How do I run?
Imagine there's a wild pack of wolves behind you
Running through an array is like walking through one, except you  can skip over elements. Yes, it's sometimes messy, but it (generally) works. "Which elements are skipped?", you may ask. Well, this is done at random. Let's walk through running through the array!

Let e be the current element.
Let random generate a random float in [0,1). If random() < 0.5, then you go the next element and then to step 1. (You may generate a number by other means, so long as their is an (ideally) equal chance of skipping and remaining. E.g., you can use choose an element from a two-member set and perform the action based on the result.)
Otherwise, you perform function f on e.

Objective
Given an array/list/string like either A and a number K, run through the array, adding K to each member accessed. Output/return this array. A will only contain non-negative integers, and K will only ever be a non-negative integers. This is a code-golf, so the shortest program in bytes wins.
Test cases (examples)
K, A => possible K'
[1, 2, 3, 4], 0 => [1, 2, 3, 4]
[1, 2, 3, 4], 1 => [1, 3, 3, 5]
[0, 0, 0, 0], 2 => [2, 0, 0, 2]

[0,1) typo? 2 more to go...

Does the random choice have to be determined by float comparison or can we pick at random?

Can I post a program, or can it be a function? It makes a very distibguishable differebce in java.

@epicTCK That means a half-open interval, i.e. a real number x such that 0 ≤ x < 1.

@MartinBüttner Isn't that [0,1[? At least it is in math.

@Bálint Both notations exist.

@AlexA. Any random comparison is valid, so long as there is an equal (or, as equal as you can make it) chance of both events occurring.

@Bálint You can post either

Can I also output a newline separated list?

@Adnan Yes, you may

Pyth, 7
m+*O2vz

Try it here
Uses a random choice instead of floating point comparison, but should be indistinguishable.
Expansion:
m+*O2vz     ## implicitly, a d and Q are added to the end of the program
m+*O2vzdQ   ## Q = eval(input()), z= input()
m           ## map over each element d of Q
 +     d    ## add to d
  *O2vz     ## the product of eval(z) and a random number chosen from [0, 1]

Using floating point:
m+*<.5O0vz

Try it here

floating point is floating point >:(

@KennyLau the change is trivial, this was just golfier. I didn't think it was meant that it was required, just that the behaviour is the same. I'll add a version with fp and ask the OP.

@KennyLau what about languages without floating points?

@FryAmTheEggman Yes, it was just an example--equal probability is fine.

@KennyLau The OP has confirmed that floating point isn't necessary.

oh I see, dang that sucks

Clojure, 41 37 bytes
(fn[a k](map #(+(*(rand-int 2)k)%)a))

Knocked off a couple of bytes by multiplying by 0 or 1 and dropping the "if". Credit to most all of the other submitters!

An anonymouse function will suffice in this case, but nice answer; welcome to PPCG!

Many times for is shorter than map, see my answer for reference :) Also it avoids having an inner anonymous function so instead of starting the code by (fn[a k] you can use #(.

Jelly, 9 8 7 bytes
From 8 to 7 thanks to @FryAmTheEggman.
+2X’¤¡€

Try it online!
Explanation
+2X’¤¡€
      €   Map over each argument...
 2X           Choose a random number from {1,2}
   ’          Minus 1
    ¤                (grammar stuff)
     ¡        Repeat that number of times...
+                 Add the second input (to the argument being mapped over).

How in the he-double-L do you successfully keyboard in this language?!

@MonkeyZeus Dennis said, it can be entered on Linux using a normal keyboard.

@Bálint The plot thickens, who is Dennis? lol

@MonkeyZeus Ahem.

@Dennis The prophecy has been fulfilled ┗(  ⊙ .⊙  )┛

MATL, 11 bytes
tZy1$rEki*+

Uses floating point random numbers.
Try it online!
Explanation
t      % implicit input (array). Duplicate
Zy     % size (array specifying number of rows and columns)
1$r    % random vector between 0 and 1 with that size
Ek     % duplicate, round down: gives 0 or 1 with the same probability
i      % input (number K to be added)
*      % multiply: gives either 0 or K for each element
+      % add element-wise

Typed from phone. Explanation later

@CatsAreFluffy :-) Done!

Japt, 6 bytes
®+V*Mq

Test it

Explanation
Implicit input of array U and integer V. Map (®) over the array and, to each element, add V multiplied by Mq, which randomly generates either 0 or 1. Implicit output of resulting array.

Python 2, 60 58 bytes
from random import*
lambda a,k:[e+choice([0,k])for e in a]

This program turned out really simple. There aren't many golfing tricks in there, apart from the the obvious "from module import*", using a lambda instead of a regular function and the general lack of whitespace. Other than that it's actually quite idiomatic. If I was writing this for real I'd probably do it in a very similar way:
import random
def running_addition(seq, k):
    return [e + random.choice([0, k]) for e in seq]

Or perhaps something more fancy:
import random
import operator
import functools

def run_through(seq, func):
    def random_func(arg):
        if random.randint(0, 1):
            return func(arg)
        return arg

    return [random_func(e) for e in seq]

def running_addition(seq, k):
    return run_through(seq, functools.partial(operator.add, k))

But that's enough showing off :)
This is the old, 60 byte version from when using a float for randomness was required:
from random import*
lambda a,k:[e+k*(random()<.5)for e in a]

For each element of the list, add k*(random()<.5). Python booleans evaluate to 0 and 1, so this adds 0 to any elements for which the condition isn't true.
Python's random.random() returns floats in [0, 1), so I didn't have to worry about that.

@FryAmTheEggman If the floating point requirement is dropped, the best I can figure out is to forget the multiplication trick entirely and do e+choice([0,k])

Ah quite right, nice way to avoid multiplying. That said the floating point requirement was removed so you can change your answer to that instead.

@FryAmTheEggman Oh haha, I didn't notice. I'll do that now, thanks :)

Julia, 33 29 27 bytes
x->k->x+rand(0:1,endof(x))k

This is an anonymous function that accepts an array with an inner anonymous function that accepts an integer and returns an array. To call it, assign it to a variable and call like f(x)(k).
We generate an array with the same length as the input array consisting of zeros and ones chosen at random with equal probability. We multiply this by the input integer and add that to the input array.
Try it online!
Saved 2 bytes thanks to Dennis!

Ruby, 28 bytes
->a,k{a.map{|e|e+k*rand(2)}}

AWK, 56 bytes
x=NF{for(srand(systime());++i<x;)rand()>.5?$i+=$x:0}NF--

Try it online!
The random number generator in AWK has to be seeded or it will yield the same sequence of numbers every time the script is run.  So that a big chunk of this code.  The code expects the "array" to be a list of space separated numbers as commandline argument.  The A increment value is the last commandline argument.
x=NF{                                              }

Setting x saves some characters, always evals to true and the braces group the code run against the input line.
     for(srand(systime());      )

The code block just one for statement, which starts by seeding the random number generator.
                          ++i<x;

The "should I iterate again" check iterates a counter to process all but the last commandline argument.  The last one is the A value from the challenge, so we need to ignore that.
                                 rand()>.5?$i+=$x:0}NF--

The body of the loop increments the current commandline argument by the A value using a ternary conditioned on the return value from the random number generator.
                                                    NF--

Once all the arguments have been incremented (or not), printing them is just a matter of decrementing the number of commandline arguments by one.  That's always truthy, directs AWK to ignore the last one, and since there's no code block all the arguments are printed.

The argument of srand() is optional. You can remove systime(), and still the random seed will follow the system date/clock. (According to gawk's and mawk's reference)

php 71 bytes
function f($s,$k){foreach($s as $v){$v+=rand(0,2)==0?k:0;echo $v.",";}}

k (12 bytes)
{x+y*(#x)?2}

e.g.
k){x+y*(#x)?2}[0 0 0 0;2]
2 2 2 0

More generally, where f can be passed as an argument for 16 characters
{@[x;&(#x)?2;y]}

e.g.
k){@[x;&(#x)?2;y]}[0 0 0 0;2+]
0 0 2 0

Nice, including a general version!

JavaScript (ES6), 38 bytes

solution=

a=>k=>a.map(n=>Math.random()<.5?n:n+k)

document.write("<pre>"+
[ [[1,2,3,4], 0], [[1,2,3,4], 1], [[0,0,0,0], 2], [[4,22,65,32,91,46,18], 42] ]
.map(c=>"["+c[0]+"],"+c[1]+": "+solution(c[0])(c[1])).join`\n`)

I want to participate in a challenge and...javascript is taken. Seriously, I'll learn unary.

@Bálint i'm pretty sure unary can't generate random floats

@undergroundmonorail I said it because no one uses it (for obvious reasons, like it can't be posted here because it becomes too long)

PowerShell v2+, 34 bytes
param($a,$k)$a|%{$_+$k*(random 2)}

Takes input $a and $k, the array and the int respectively. We then loop through the array and each loop iteration output the current element plus $k times (random 2) which will execute Get-Random -Maximum 2 (i.e., either a 0 or a 1). These are all left on the pipeline and output as an array is implicit.

CJam, 10 bytes
{f{2mr*+}}

Expects the array and the number on top of the stack in that order and replaces them with the new array.
Test it here.

Python 3 152 110 98 bytes
This is my first code golf solution so I don't know any tricks. I tested this using a main function with test cases. The file size is only this function.
from random import*
def a(x,y):
 p=0
 for z in x:
  if random()>.5:x[p]=z+y
  p+=1
 print(x)

Thanks to @Cᴏɴᴏʀ O'Bʀɪᴇɴ for the advice on removing whitespace. Additional praise to @undergroundmonorail for advice that saved 12 bytes.

I count 145 bytes. You can golf it by removing unneeded whitespace, such as between import *, a(x, y), x[ptr]=z+y, etc. You can also replace the 4 spaces with a single space

You can put x[ptr]=z+y on the same line as if random()>0.5 to save 3 bytes of whitespace. In python 2 0.5 can be written as .5 to save a byte, I don't know if that's true in python 3 though. If you rename ptr to p you'll save 6 bytes in all. Also, are you on Windows? Windows stores newlines as two bytes, but since python doesn't care if the newline is one byte or two you can count it as 1, making your current solution only 103 bytes. By the way, welcome to PPCG :)

Clojure, 32 bytes
#(for[i %](+(*(rand-int 2)%2)i))

Thanks you David for rand-int idea, definetely shorter than the if(>(rand)0.5) approach. Here for beats map.

Perl 5, 30 + 1 (-a) = 31 bytes
$,=<>;say.5>rand?$_:$_+$,for@F

Try it online!

Factor, 29 bytes
[ '[ .5 [ _ + ] whenp ] map ]

Try it online!

'[ ... _ ... ] Slot whatever is on top of the data stack (A) into the quotation at the _.
map Apply a quotation to each member of a sequence (K), collecting the results into a sequence of the same length.
.5 [ _ + ] whenp whenp is a version of when that takes a probability instead of a boolean. In other words, there is a 50% chance that whenp's quotation will be called.

Java, 84 bytes
int[]r(int[]A,int K){for(int i=0;i<A.length;A[i++]+=Math.random()>.5?0:K);return A;}

Ungolfed
int[] r(int[] A, int K) {
    for (int i = 0;
         i < A.length;
         A[i++] += Math.random() > .5 ? 0 : K);
    return A;
}

Notes

The afterthought of the loop could also be it's body, there is no difference in size.
The input array is modified but the statement does not contain a restriction regarding this issue. If you would count the modified array as a form of "Output/return", you could shave off another 9 bytes by removing return A;. The return type would need to be changed from int[] to void. This however does not save additional bytes since an additional space is needed between void and r.

Shorter version (As mentioned in the note), 75 bytes
void r(int[]A,int K){for(int i=0;i<A.length;)A[i++]+=Math.random()>.5?0:K;}

Output
[1, 2, 3, 4], 0 => [1, 2, 3, 4]
[1, 2, 3, 4], 1 => [1, 3, 3, 4]
[1, 2, 3, 4], 2 => [3, 2, 3, 4]
[1, 2, 3, 4], 3 => [4, 5, 3, 7]
[1, 2, 3, 4], 4 => [5, 2, 3, 8]
[1, 2, 3, 4], 5 => [6, 2, 8, 9]

Your second version isn't valid, it doesn't output nor return anything.

Please read my post...

Mathcad,  bytes

No formal byte count as Mathcad counting protocol yet to be decided.

Java 108 107 85 82 bytes
void f(int[]s,int k){for(int i:s)System.out.print((i+=Math.random()<.5?k:0)+";");}

14 bytes saved thanks to @TimmyD

@TimmyD The rules say you need to output it. And that rule wasn't like that, when I wrote the answer

I believe you can remove the space after main, String[], int[], and save another few bytes by changing nextFloat()>0.5 to next(1)==0.

@QPaysTaxes I already change new java.util.Random().nextFloat() to Math.random(), as it is much much shorter.

@TimmyD Didn't see that, thanks

This does not work in it's current state. You don't modify s, only the i, the method has return type void but you are trying to return int[]. Also theres a semicolon missing after return s.

Octave, 28 bytes
@(A,R)R*(rand(size(A))<.5)+A

Sample run on ideone.

05AB1E, 10 bytes
Code:
vždÉ²*y+})

Try it online!.


text:
Find the repetend of the decimal representation!
In this challenge 2 years ago, we found the period of a unit fraction (1/n where n is a natural number).
Now, your task is to write a program/function to find the repetend of a unit fraction.
The repetend is the part of the decimal expansion which repeats infinitely, like:

The decimal representation of 1/6 is 0.16666..., then the repetend is 6.
The decimal representation of 1/11 is 0.090909..., then the repetend is 09.
The decimal representation of 1/28 is 0.0357142857142857142857..., then the repetend is 571428.

Specs

Input in any reasonable format.
Output the repetend in decimal, string or list.
For 1/7 (0.142857142857...), you must output 142857 instead of 428571.
For 1/13 (0.076923076923076923...), you must output 076923 instead of 76923.
No brute force, please.

Testcases
Input    Output
1        0
2        0
3        3
7        142857
13       076923
17       0588235294117647
28       571428
70       142857
98       102040816326530612244897959183673469387755
9899     000101020305081321345590463683200323264976260228305889483786241034447924032730578846348115971310233356904737852308313971108192746742095161127386604707546216789574704515607637135064147893726639054449944438832205273259925244974239822204263056874431760783917567431053641781998181634508536215779371653702394181230427315890493989291847661379937367410849580765733912516415799575714718658450348520052530558642287099707041115264168097787655318719062531568845337912920497019901

Scoring
This is code-golf. Shortest solution in bytes win.
No answer would be accepted, because the goal is not to find the language capable of producing the shortest solution, but the shortest solution in each language.
Leaderboard

var QUESTION_ID=78850,OVERRIDE_USER=42854;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"http://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Let us continue this discussion in chat.

How do you decide that the repetend for 13 is 076923 and not 769230?

@aditsu Because 1/13 is 0.076923076923... not 0.769230769230...

Is it okay if the output is supposed to be 0, a blank line is instead returned?

That didn't really answer my question, but I get it: you want the earliest repeating pattern, even if it starts with zero(s). Can you double-check your repetend for 98? Doesn't it start with 10204…?

Openly stating that you will never accept an answer pretty much makes this a catalog. Just don't say anything and never accept an answer.

How is the repetend of 1/17 52941183? To me it seems like there are no repeating sequences in its decimal representation...

@R.Kap The repetend is 0588235294117647.

You could add a stack snippet to show the shortest solution for each language.

Java, 150 bytes:
String p(int n){int a=1,p;String r="";for(;n%10<1;n/=10);for(;n%2<1;n/=2)a*=5;for(;n%5<1;n/=5)a*=2;for(p=a%=n;;){p*=10;r+=p/n;if(a==(p%=n))return r;}}

Added whitespace:
String p(int n){
    int a=1,p;
    String r="";
    for(;n%10<1;n/=10);
    for(;n%2<1;n/=2)
        a*=5;
    for(;n%5<1;n/=5)
        a*=2;
    for(p=a%=n;;){
        p*=10;
        r+=p/n;
        if(a==(p%=n))
            return r;
    }
}

Ungolfed, full program:
import java.util.Scanner;

public class A036275 {
    public static String period(int a,int n){
        if(n%10==0) return period(a,n/10);
        if(n%2==0) return period(a*5,n/2);
        if(n%5==0) return period(a*2,n/5);
        a %= n;
        int pow = a;
        String period = "";
        while(true){
            pow *= 10;
            period += pow/n;
            pow %= n;
            if(pow == a){
                return period;
            }
        }
    }
    public static String period(int n){
        return period(1,n);
    }
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        System.out.println(period(n));
    }
}

for(;;) would be less bytes than while(2<3) though while also being an infinite loop! (and less bytes than while(1) also @Maltysen)

@Marv How could I have forgot that? Thanks!

Put the declarations for a and r in the for loops. Saves bytes!

@CatsAreFluffy It would make them inaccessible...

Python 3.5, 79 74 73 70 bytes
f=lambda n,t=1,q=[],*d:q[(*d,t).index(t):]or f(n,t%n*10,q+[t//n],*d,t)

Saved 3 bytes by keeping track of dividends, an idea I took from @aditsu's CJam answer.
Test it on repl.it.

CJam, 26
riL{_XW$%A*:X|X@-}g_X#>\f/

Try it online
Explanation:
The program builds a series of dividends involved in the calculation of the decimal expansion, until it finds a dividend it has seen before. Then it takes all the dividends starting with that one, and divides them by n to get the digits of the repetend.
ri       read the input and convert to integer (n)
L        push an empty array (will add the dividends to it)
{…}g     do … while
  _      copy the current array of dividends
  X      push the latest dividend (initially 1 by default)
  W$     copy n from the bottom of the stack
  %A*    calculate X mod n and multiply by 10
  :X     store in X (this is the next dividend)
  |      perform set union with the array of dividends
  X@     push X and bring the old array to the top
  -      set difference; it is empty iff the old array already contained X
          this becomes the do-while loop condition
_X#      duplicate the array of dividends and find the position of X
>        take all dividends from that position
\f/      swap the array with n and divide all dividends by n

Jelly, 12 10 bytes
%³×⁵
1ÇÐḶ:

Saved 2 bytes by keeping track of dividends, an idea I took from @aditsu's CJam answer.
Try it online!
How it works
%³×⁵     Helper link. Argument: d (dividend)

%³       Yield the remainder of the division of d by n.
  ×⁵     Multiply by 10.

1ÇÐḶ:    Main link. Argument: n

1        Yield 1 (initial dividend).
 ÇÐḶ     Apply the helper link until its results are no longer unique.
         Yield the loop, i.e., everything from the first repeated result
         up to and including the last unique one.
    :    Divide each dividend by n.

Perl 6, 37 bytes
{(1.FatRat/$_).base-repeating[1]||~0}
~0 max (1.FatRat/*).base-repeating[1]

If you don't care that it will only work with denominators that fit into a 64 bit integer you can remove the method call to .FatRat.
Explanation:
# return ｢"0"｣ if ｢.base-repeating｣ would return ｢""｣
~0

# ｢&infix<max>｣ returns the numerically largest value
# or it's first value if they are numerically equal
max

(
  # turn 1 into a FatRat so it will work
  # with denominators of arbitrary size
  1.FatRat

  # divided by
  /

  # the input
  *

# get the second value from calling the
# method ｢.base-repeating｣
).base-repeating[1]

Test:
#! /usr/bin/env perl6
use v6.c;
use Test;

my &code = ~0 max (1.FatRat/*).base-repeating[1];
# stupid highlighter */
# Perl has never had // or /* */ comments

my @tests = (
  1    => '0',
  2    => '0',
  3    => '3',
  6    => '6',
  7    => '142857',
  11   => '09',
  13   => '076923',
  17   => '0588235294117647',
  28   => '571428',
  70   => '142857',
  98   => '102040816326530612244897959183673469387755',
  9899 => '000101020305081321345590463683200323264976260228305889483786241034447924032730578846348115971310233356904737852308313971108192746742095161127386604707546216789574704515607637135064147893726639054449944438832205273259925244974239822204263056874431760783917567431053641781998181634508536215779371653702394181230427315890493989291847661379937367410849580765733912516415799575714718658450348520052530558642287099707041115264168097787655318719062531568845337912920497019901',
);

plan +@tests;

for @tests -> $_ ( :key($input), :value($expected) ) {
  is code($input), $expected, "1/$input";
}

1..12
ok 1 - 1/1
ok 2 - 1/2
ok 3 - 1/3
ok 4 - 1/6
ok 5 - 1/7
ok 6 - 1/11
ok 7 - 1/13
ok 8 - 1/17
ok 9 - 1/28
ok 10 - 1/70
ok 11 - 1/98
ok 12 - 1/9899

GameMaker Language, 152 bytes
Based on Kenny's answer
n=argument0;a=1r=0while(n mod 2<1){a*=5n/=2}while(n mod 5<1){a*=2n/=5}a=a mod n;p=a;while(1){p*=10r=r*10+p/n;r=r mod $5f5e107;p=p mod n;if(a=p)return r}

I just found a bug in my approach and fixed it, so maybe you would need to update this as well.

Java, 122
String f(int n){String r="";int x=1,a[]=new
int[n*10];while(a[x]++<1)x=x%n*10;do{r+=x/n;x=x%n*10;}while(a[x]<2);return r;}

Similar to my CJam solution.

Pyth, 63 bytes
W!%QT=/QT;J*F+1-PQ,2 5K%*F+1-L7@,2 5PQJ=NKW1=+k/=*NTJIqK=%NJB;k

Try it online!
Direct translation of the answer in Java.

PHP, 169 Bytes
$d=$argv[2];$a[]=$n=$argv[1];while($n%$d&&!$t){$n*=10;$r[]=$n/$d^0;$t=in_array($n%=$d,$a);$a[]=$n;}if($t)echo join(array_slice($r,array_search(end($a),$a),count($a)-1));


text:
hackertyper.net
Introduction
hackertyper.net is a website that simulates "hacking" (as the media portrays it) by outputting complicated code from the crypto section of the Linux kernel onto the screen as you type at a rate of 3 characters per one inputted.
Challenge
Your program/function should either accept a file as a command-line argument, have the file path hard-coded, or accept the text [that would be in the file] as a command-line or function argument, and mimic hackertyper.net by outputting 3 characters onto the screen (STDOUT or equivalent) from the file for each one received through STDIN or equivalent.
Once EOF is reached, the program should start outputting characters from the beginning of the file again (wrap).
Specs
For the purposes of simplicity, you can assume that STDIN has already been set to no buffer and no echo mode, that is not waiting until the user presses enter before passing input to your program and not displaying the characters you type.
The file can contain newlines, while the input will not contain newlines.
For a small example written in C (not golfed) that demonstrates how this works, see this.
Green text and a black background are not required.
Example input and output
The file:
#include <stdio.h>
int main() { }

Input:
hello world

Output:
#include <stdio.h>
int main() { }

The file:
hello

Input:
hello world

Output:
hellohellohellohellohellohellohel

Are functions allowed (that take two strings as an argument and return another string)? 2. Your spec says to output three characters for every input, but the examples only output one for every input.

@Doorknob 1. Yes, and 2. That was a mistake, fixed.

Do we have to take the file information in as a file, or can we also receive that information through a function argument or equivalent? If we have to, what will the name of that file be? Will it be in a specific directory away from our script(s), or in the same one as our script(s)?

@R.Kap Your program/function should either accept a file as a command-line argument or have it hard-coded.  File isn't nessacary.

@R.Kap No, it does not have to be through a file. If it is, you can name it anything you like & put it anywhere you like, or accept it as a command-line argument.

@R.Kap Made an edit which I think will make this more clear.

@Majora320 ah I can't believe someone actually made that website =/ ...

Related.

Bonuses be bad. And plus very few people will get the penalty, and calling it a "bonus" is confusing.

Jelly, 4 bytes
ẋ3ṁ@

Try it online!
How it works
ẋ3ṁ@    Main link. Arguments: s (input string), t (file string)

ẋ3      Repeat s three times.
  ṁ@    Mold; reshape t like the previous result.
        This repeats the elements of t over and over until the length matches that
        of s repeated thrice.

I've always wondered what "mold" means...

@KennyLau I think it means it's time to throw out the bread.

Python 3.5, 77 65 63 bytes:
lambda g,f:''.join((g*len(f))[i:i+3]for i in range(0,len(f)*3,3))

Simple enough. An anonymous function which takes in two arguments, the first one being the "file" (g), and the second being the characters typed in by the user (f). Then this creates a generator containing every three characters in g, which are found by indexing for every i and then i+3 characters in g, where i is in the range of 0=>(length of f)*3. Finally, it returns each object in the generator joined into one big string. You call this function by assigning a variable to it, and then calling the variable wrapped inside a print() expression. So if the function's name was q, it would be executed like print(q(<byte array here>)).
Try it online! (repl.it)

J, 7 bytes
$~(3*#)

Takes two arguments, the text to be repeated and the user's input text.
Usage
The input text is formatted where , means to join and LF is the newline character.
   f =: $~(3*#)
   ('#include <stdio.h>', LF, 'int main() { }') f 'hello world'
#include <stdio.h>
int main() { }
   'hello' f 'hello world'
hellohellohellohellohellohellohel

Try it online. (tryj.tk)

Jelly, 9 bytes
⁴L×3
ẋ¢ḣ¢

Try it online!
⁴L×3     Define nilad as ¢:

 L       length of
⁴        second argument
  ×3     tripled

ẋ¢ḣ¢     Main chain:

         the first argument (implicit)
ẋ        repeated
 ¢       ¢ many times
  ḣ¢     then get the first ¢ characters of it.

I guess you're a bit "jelly" of Dennis' answer?

Jelly is evil..

Haskell, 25 bytes
First argument is what's "typed", the second the source to display
(.cycle).take.(3*).length

Or non-pointfree, for (possibly) better readability:
h a=take(3*length a).cycle

What's cycle?

@CatsAreFluffy cycle takes a list and repeats it infinitely. Eg cycle "hi" == "hihihihi..

Have you considered $?

@CatsAreFluffy I'm not sure where I'd use it, what were you thinking?

Pyth, 10 bytes
s@Ljb.z*3l

Try it online!

JavaScript (ES6), 40 bytes
(s,t)=>s.repeat(l=t.length*3).slice(0,l)

Where s is the data string and t is the user string. Assumes s is nonempty and repeats it l times to ensure that its length is at least l so that it can return the first l characters, where l is three times the length of t.

Jolf, 10 bytes
]*iγl*I30γ

Try it here!
Explanation
]*iγl*I30γ
 *i        repeat string 1
    l*I3    the length of the other string * 3
   γ        γ = (^)
]       0γ  (^).slice(0, γ)

Ruby, 39 bytes
In Ruby, $< reads from the supplied file in the command line arguments instead of $stdin if one is given. (If you forget to supply a file, you get a blank output because it reads everything out of $stdin in $<.read and thus STDIN.read.size will be 0.)
$><<($<.read*s=3*STDIN.read.size)[0,s]

05AB1E, 7 bytes
Code:
3×g©×®£

Explanation:
3×        # Multiply the input string three times.
  g       # Take the length.
   ©      # Copy that to the register.
    ×     # Multiply by the second input.
     ®    # Retrieve the length from the register.
      £   # Only keep [0:length * 3] from the new string.

Try it online!.