text:
Virtual Keyboard Text Input
On modern game consoles and other devices without traditional keyboards, trying to input text is a nightmare. Having to type with a few buttons and a joystick on a virtual keyboard is annoying, and I like to make as few movements/button presses as possible.
The keyboard you will be using looks like this:
+---+---+---+---+---+---+---+---+---+---+
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 |
+---+---+---+---+---+---+---+---+---+---+
| q | w | e | r | t | y | u | i | o | p |
+---+---+---+---+---+---+---+---+---+---+
| a | s | d | f | g | h | j | k | l | - |
+---+---+---+---+---+---+---+---+---+---+
| z | x | c | v | b | n | m | _ | @ | . |
+---+---+---+---+---+---+---+---+---+---+

The following operations can be used:

L: move one square to the left on the keyboard (wraps)
R: move one square to the right on the keyboard (wraps)
U: move one square up on the keyboard (wraps)
D: move one square down on the keyboard (wraps)
Y: insert a space
B: move the insertion pointer one space to the left (does nothing if pointer is at the beginning)
F: move the insertion pointer one space to the right (does nothing if pointer is at the end)
C: toggle caps lock
A: insert the selected character at the position of the insertion pointer

Given an input string containing only ASCII characters that can be typed using the above keyboard and commands (matches [a-zA-Z0-9 _@.-]*), output a sequence of commands that will result in the output string. The initial position of the cursor is on the 1 key (the top-left), and caps lock is initially off.
Scoring
For any given string, a naive approach would be, for each character in the string, navigate to the character on the keyboard by the shortest path, toggle caps lock if necessary, and select the character. Such a naive approach would generate a command of length (length of input string) + (sum of Manhattan distances on keyboard between consecutive non-space characters) + (number of times the string alternates between lowercase and uppercase characters) + (1 if string starts with an uppercase letter else 0). For example, the naive approach for 101 would result in ALARA, a length 5 command, and Noob 5 would result in DDDRRRRRCAUURRRCAADDLLLLAYUUUA, a length 30 command.
Your submission, however, seeks to do better than the naive approach. For each input string, your submission will receive points equal to the number of commands the naive approach uses minus the number of commands your submission outputs. Your overall score will be the sum of the individual scores.
Rules

Submissions will be run on a Cloud9 free virtual workspace. The workspace has 512 MB of RAM, 2 GB of disk space, 8 Intel(R) Xeon(R) CPUs @ 2.50 GHz (full CPU info, found by running cat /proc/cpuinfo, can be found here), and is running 64-bit Ubuntu 14.04 Trusty. You may request access to the testing workspace in order to run and score your submission, or I can score it for you.
Submissions will be run once per test case. Storing state between runs is forbidden. Submissions may not write to or read from any files other than the source file (which may not be modified between runs), with the possible exception of reading an input file if required.
Submissions are limited to 1 minute of runtime for each test case. Submissions may output multiple solutions, but only the last valid solution within the allotted time will be used for scoring. Failure to output any valid solutions within the allotted time will result in a score of 0 for that test case.
Please include directions on how to invoke your submission, as well as any tools/libraries that need to be installed that aren't included with a standard Ubuntu 14.04 install.
The winner will be the submission with the largest score. In the event of a tie, the submission with the better algorithmic complexity will win. If the tie is still not resolved, the first submission to reach the score and algorithmic complexity will win.
Submissions may not optimize for the test cases. I reserve the right to change the test cases if I feel there is a need.

Test cases
Format: input string => naive score
(if you see any errors in these, please leave a comment with the correction)
101 => 5
quip => 12
PPCG => 15
Mego => 25
Noob 5 => 26
penguin => 27
867-5309 => 32
2_sPoOkY_4_mE => 60
The Nineteenth Byte => 76
penguins@SouthPole.org => 95
8xM3R__5ltZgrkJ.-W b => 98
correcthorsebatterystaple => 104
verylongRUNSOFCAPSandnocaps => 118
This is an English sentence. => 122
WNtza.akjzSP2GI0V9X .0epmUQ-mo => 131
Programming Puzzles and Code Golf => 140

I got -27 ... never mind

@Mego: I think he's saying that his solution did worse than naive. :P

I agree, gaming console keyboards suck.

What happens if the program does not terminate within one minute but prints out one or more solutions within that time? Is there any penalty for not terminating?

@mIllIbyte The last valid (i.e. results in the correct text) command printed out within the time limit is used. If no valid command is printed out, then the score is 0.

C
The score is 193.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define LEFT 'L'
#define RIGHT 'R'
#define CAPS 'C'
#define UP 'U'
#define DOWN 'D'
#define SPACE 'Y'
#define CURSORLEFT 'B'
#define CURSORRIGHT 'F'
#define APPLY 'A'
#define TABLEX 10
#define TABLEY 4
#define casediff(A,B) (isupper(A)*islower(B)+islower(A)*isupper(B))
typedef struct {int x; int y;} coord;
coord letters[300];
#define initLetter(letter, X, Y) \
letters[letter].x=X, letters[letter].y=Y
#define initAllLetters(); \
initLetter('1',0,0);\
initLetter('1',0,0);\
initLetter('2',1,0);\
initLetter('2',1,0);\
initLetter('3',2,0);\
initLetter('3',2,0);\
initLetter('4',3,0);\
initLetter('4',3,0);\
initLetter('5',4,0);\
initLetter('5',4,0);\
initLetter('6',5,0);\
initLetter('6',5,0);\
initLetter('7',6,0);\
initLetter('7',6,0);\
initLetter('8',7,0);\
initLetter('8',7,0);\
initLetter('9',8,0);\
initLetter('9',8,0);\
initLetter('0',9,0);\
initLetter('0',9,0);\
initLetter('Q',0,1);\
initLetter('q',0,1);\
initLetter('W',1,1);\
initLetter('w',1,1);\
initLetter('E',2,1);\
initLetter('e',2,1);\
initLetter('R',3,1);\
initLetter('r',3,1);\
initLetter('T',4,1);\
initLetter('t',4,1);\
initLetter('Y',5,1);\
initLetter('y',5,1);\
initLetter('U',6,1);\
initLetter('u',6,1);\
initLetter('I',7,1);\
initLetter('i',7,1);\
initLetter('O',8,1);\
initLetter('o',8,1);\
initLetter('P',9,1);\
initLetter('p',9,1);\
initLetter('A',0,2);\
initLetter('a',0,2);\
initLetter('S',1,2);\
initLetter('s',1,2);\
initLetter('D',2,2);\
initLetter('d',2,2);\
initLetter('F',3,2);\
initLetter('f',3,2);\
initLetter('G',4,2);\
initLetter('g',4,2);\
initLetter('H',5,2);\
initLetter('h',5,2);\
initLetter('J',6,2);\
initLetter('j',6,2);\
initLetter('K',7,2);\
initLetter('k',7,2);\
initLetter('L',8,2);\
initLetter('l',8,2);\
initLetter('-',9,2);\
initLetter('-',9,2);\
initLetter('Z',0,3);\
initLetter('z',0,3);\
initLetter('X',1,3);\
initLetter('x',1,3);\
initLetter('C',2,3);\
initLetter('c',2,3);\
initLetter('V',3,3);\
initLetter('v',3,3);\
initLetter('B',4,3);\
initLetter('b',4,3);\
initLetter('N',5,3);\
initLetter('n',5,3);\
initLetter('M',6,3);\
initLetter('m',6,3);\
initLetter('_',7,3);\
initLetter('_',7,3);\
initLetter('@',8,3);\
initLetter('@',8,3);\
initLetter('.',9,3);\
initLetter('.',9,3);
typedef struct {int length; char instr[300];} movement;
movecasefold(char*instr,coord A, coord B){
    register int i=0;int j;
    if(A.x<B.x)
     if(B.x-A.x<=TABLEX/2)
      for(;B.x-A.x!=i;)instr[i++]=RIGHT;
     else
      for(;TABLEX-B.x+A.x!=i;)instr[i++]=LEFT;
    else if(A.x>B.x)
     if(A.x-B.x<=TABLEX/2)
      for(;A.x-B.x!=i;)instr[i++]=LEFT;
     else
      for(;TABLEX-A.x+B.x!=i;)instr[i++]=RIGHT;
    j=i;
    if(A.y<B.y)
     if(B.y-A.y<=TABLEY/2)
      for(;B.y-A.y!=i-j;)instr[i++]=DOWN;
     else
      for(;TABLEY-B.y+A.y!=i-j;)instr[i++]=UP;
    else if(A.y>B.y)
     if(A.y-B.y<=TABLEY/2)
      for(;A.y-B.y!=i-j;)instr[i++]=UP;
     else
      for(;TABLEY-A.y+B.y!=i-j;)instr[i++]=DOWN;
    instr[i]='\0';
    return i;
}
char sentence[50], oldcase, oldletter;
int sentencelength;
typedef struct {
int sentencetoorder[50];
int ordertosentence[50];
int length;
} order;
ordercopy(order*a, order b){
register int i;
for(i=0;++i<sentencelength;) a->sentencetoorder[i]=b.sentencetoorder[i], a->ordertosentence[i]=b.ordertosentence[i];
a->length=b.length;
}
order currentOrder;
movetwo(char*instr,int A, int B){
    register int j; int i=0;
    if(A<B)
    { for(j=A+1;j<B;j++)
      if(currentOrder.sentencetoorder[j]<currentOrder.sentencetoorder[B])
       instr[i++]=CURSORRIGHT;
    }
    else
    { for(j=A;j>B;j--)
      if(currentOrder.sentencetoorder[j]<currentOrder.sentencetoorder[B])
       instr[i++]=CURSORLEFT;
    }
    if(sentence[B]==' '){
        instr[i++]=SPACE;
        instr[i]='\0';
        return i;
    }
    i+=movecasefold(instr+i,letters[oldletter],letters[sentence[B]]);
    oldletter=sentence[B];
    if(casediff(oldcase,sentence[B]))oldcase=sentence[B],instr[i++]=CAPS;
    instr[i++]=APPLY;
    instr[i]='\0';
    return i;
}
moveall(char*instr){
    int j;int i = 0;
    oldcase='a';
    oldletter='1';
    for(j=0;++j<sentencelength;)
        i+=movetwo(instr+i,currentOrder.ordertosentence[j-1],currentOrder.ordertosentence[j]);
    return i;
}
iteration();
main(){
initAllLetters();
gets(sentence+1);*sentence='1';sentencelength=strlen(sentence);
int i;
for(i=0;++i<sentencelength;)currentOrder.sentencetoorder[i]=currentOrder.ordertosentence[i]=i;
char instr[300];
currentOrder.length=moveall(instr);
puts(instr);
while(iteration());
}
#define inside(item, start, stop) (((start)<=(item))&((item)<(stop)))
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
iteration(){
char instr[300];
register int i;
int newstart, start, l;
static order oldorder, neworder;
ordercopy(&oldorder,currentOrder);
ordercopy(&neworder,currentOrder);
for(l=0;++l<sentencelength-1;)
for(start=0;++start<sentencelength-l;)
for(newstart=0;++newstart<sentencelength-l;)
if(start!=newstart){
 for(i=0;++i<sentencelength;)
  if(inside(i,start,start+l))currentOrder.ordertosentence[i-start+newstart]=oldorder.ordertosentence[i];
  else if(inside(i,min(start,newstart),max(start+l,newstart+l)))currentOrder.ordertosentence[newstart<start?i+l:(i-l)]=oldorder.ordertosentence[i];
  else currentOrder.ordertosentence[i]=oldorder.ordertosentence[i];
 for(i=0;++i<sentencelength;) currentOrder.sentencetoorder[currentOrder.ordertosentence[i]]=i;
  currentOrder.length=moveall(instr);
 if(currentOrder.length<neworder.length){
  puts(instr);
  ordercopy(&neworder, currentOrder);
 }
}
ordercopy(&currentOrder, neworder);
return neworder.length<oldorder.length;
}

Compile with as "gcc virtualKeyboard.c".
Run it without arguments "./a.out". It reads the input from stdin and writes the output to stdout.

Sorry for the delay - your score is 193.


text:
Need help golfing Python 3 code to calculate volume & surface of spheroids in <150 bytes
I want to write a function golf(C, A) that takes the height (C = 2*c) and the width (A = 2*a) of an oblate (left image) or prolate (right image) spheroid or a sphere as parameters and returns the volume V and the surface area S of the shape as tuple. The output must be rounded to two decimal places.

All input and output numbers are floating point decimals.
The input numbers (A and C) are guaranteed to be greater than 0 and lower than 100.
Here are some example calls of the function (golf(C, A)) in Python 3 and the expected outputs given as test cases:
golf(4, 2)  # expected output (8.38, 21.48)
golf(2, 2)  # expected output (4.19, 12.57)
golf(2, 4)  # expected output (16.76, 34.69)

The challenge requires my code to be smaller than 150 characters.
I could not manage to solve it myself yet, my best solution in Python 3 still takes 220 characters:
from math import *
def golf(C,A):
 c,a,V=C/2,A/2,pi/6*A*A*C;F=c*c/a**2;E=sqrt(1-(F if a>c else 1/F));S=4*pi*a*a if a==c else 2*pi*a*a*(1+(((1-E**2)/E)*atanh(E)if a>c else(c/(a*E))*asin(E)))
 return round(V,2),round(S,2)

The necessary formulas are taken from Wikipedia: Spheroid, here's a summary:

Vall spheroids = 4 π/3 a²c = π/6 A²C as A=2a and C=2c.

This challenge was originally from checkio.org and got refactored into a code-golf challenge for empireofcode.com.

Rounded how? Reference

Were comments purged? Why were all the comments purged?

@cat Most of the comments became obsolete when this was turned into a tips question. The one that didn't didn't get deleted.

122 bytes
from cmath import*
def golf(C,A):e=sqrt(1-A*A/C/C);return round(pi/6*A*A*C,2),round(pi*A*abs(A+(e and C*asin(e)/e-A)/2),2)

The sphere can be special-cased by returning surface area πA² if e = 0.
While there are two different formulae for oblate and prolate spheroids, they are mathematically equivalent. If the involved operations support complex numbers, each formula can be used for both cases.
Since asin(e)/e will return a complex number of the form x+0j for prolate spheroids, abs can be used to turn it into the float x.

Unfortunately, that doesn't save any bytes.

source: Stack Exchange

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

sort: votes


text:
Find the last position in a matrix walking like a spiral
This question will be deleted soon, do not read/answer it
Introduction
Given one matrix A x A and a number of movements N.
You will need to walk like a spiral starting in (1; 1):

right while possible, then
down while possible, then
left while possible, then
up while possible, repeat until got N.

Challenge
You can only take as input the numbers A and N.
You must output the final (row; column) after walking N steps in the conditions explained above. You can not invert the output order.
You can use indexes starting with zero as well. Just state it in your answer.
Program or function allowed.
This is code-golf, shortest answer in bytes wins.
Sample
For input (A = 8; N = 54).

The output should be (5; 6).
Another samples
input: A=8, N=64
output: [5, 4]

input: A=15, N=14
output: [1, 14]

input: A=26, N=400
output: [22, 9]

input: A=1073741824, N=1152921504603393520
output: [536871276, 536869983]

Restrictions
1 <= A <= 230
1 <= N <= (A2 OR the below higher number supported in your language).

And, if you want a generic formula.

About restrictions: there are common languages that cannot handle 60 bits integers. Javascript for instance is limited to 53 bits for numbers stored as IEEE 754 64 bits floating point, or 32 bits for signed integers

@edc65. You can use javascript, I will update

A=2^15 (2^30 cells) will run in reasonable time (seconds or minutes) and memory (gigabytes) if we trace through every cell. A=2^30  (2^60cells) will not. If your intention is to disallow naive algorithms you should state it in the question. Otherwise you should reduce the max size of the matrix

I've voted to close as it is not clear without further clarification whether the existing answer is valid or not: as stated by the poster, it is limited by memory to considerably less than A=2^30. Please clarify

I just stated the size of the number, not about the memory, but I edited with a formula

@WashingtonGuedes But you haven't  stated if explicit methods that are limited by memory are allowed or not

@WashingtonGuedes also, we are discussing a hardware restriction, not a language restriction.

Sorry, for all troubles, I tried deleting this question, but I can not because it has answers.. I will try to make it a community question then

No need for making it CW? Just clarify about the memory

Perhaps we can discuss this in chat: https://chat.stackexchange.com/rooms/240/the-nineteenth-byte

Really there's no need to delete. It's a good question and I upvoted it. No "trouble" caused. The fairest thing to do (as you already have an answer) would be to reduce the max value of A which would let naive solutions work (such as 2^12) or say that the solution should work in theory notwithstanding memory and time constraints. However if you decide to rule that A=2^30 is required, @LuisMendo said he would delete or revise his answer. The purpose of putting on hold is to ensure more answers like Luis's don't come piling in till your intention is clarified.

Another thing you can do is have a main codegolf competition admitting naive solutions, but offer a bounty on the side for the most efficient/elegant algorithm, if that's what you were hoping to see.. An advantage of this is that bounties can be awarded under subjective criteria, whereas the main competition must be objective.

MATL, 24 bytes
This works in release 16.0.0 of the language, which predates the challenge.
2^Q6Y3GYLG2\?!P!}P]-=2#f

Output is 1-based, as in the examples.
A^2 and N are limited to 2^53 as per the language's default data type (double). In addition, since the whole matrix is being generated, memory will limit A to significantly lower values.
Try it online! (In the online version I have changed the order of G and 6Y3 so it works in the new 16.1.0 release)
Explanation
This uses MATL's builtin for generating an outward spiral. To make it inward, a subtraction and a reversal are needed. The direction of reversal depends on whether A is odd or even.
2^Q     % take input A implicitly. Compute A^2+1
6Y3GYL  % outward spiral of side length A
G2\     % is A odd?
?       % if so
  !P!   %   flip matrix horizontally
}       % else
  P     %   flip matrix vertically
]       % end if
-       % compute A^2+1 minus the matrix element-wise, so (1,1) contains 1
=       % take input N implicitly. Set matrix entry that contains that value to true
2#f     % row and column index of that true value

Can this run the last test case? If you're genrating the whole spiral, I doubt you have time or memory for it. See my comment on the last question

@LevelRiverSt Yes, it genererates the whole spiral. Size is limited by memory. I'll state that in the answer. Thanks for the indication. I totally agree with your comment to the challenge BTW. I'm waiting for OP's response, and depending on that I may have to delete my answer (or use a different approach)

When you say "compute A^2-1 minus the matrix element-wise, so (1,1) contains 1", do you mean A^2+1, which was calculated earlier at the beginning of the code?

@poi830 Oops yes, sorry about the confusion. Corrected

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


text:
Draw an indexed fractal
Introduction
In this challenge, a 2×2 matrix is indexed like this:
0 1
2 3

We define a family of fractal-like patterns F(L), where L is a length-n list of these indices and F(L) has size 2n-1 × 2n-1.

If L == [], then F(L) is the 1×1 pattern #.
If L != [], then F(L) is constructed as follows. Let P be the pattern obtained from L with first element removed. Take four grids of size 2n-1-1 × 2n-1-1 filled with periods ., and replace the grid indexed by L[0] with the pattern P. Then, glue the grids together using one layer of hashes # between them. Here are diagrams for the four cases:
L[0]==0  L[0]==1  L[0]==2  L[0]==3
   #...  ...#     ...#...  ...#...
[P]#...  ...#[P]  ...#...  ...#...
   #...  ...#     ...#...  ...#...
#######  #######  #######  #######
...#...  ...#...     #...  ...#
...#...  ...#...  [P]#...  ...#[P]
...#...  ...#...     #...  ...#

Example
Consider the input L = [2,0].
We begin with the 1×1 grid #, and traverse L from the right.
The rightmost element is 0, so we take four copies of the 1×1 grid ., replace the first one by #, and glue them together with hashes.
This results in the 3×3 grid
##.
###
.#.

The next element is 2, so we take four copies of the 3×3 grid of .s, and replace the third one with the above grid.
The four grids are
...  ...  ##.  ...
...  ...  ###  ...
...  ...  .#.  ...

and gluing them together with #s results in the 7×7 grid
...#...
...#...
...#...
#######
##.#...
####...
.#.#...

This is our final output.
Input
Your input is a list L of the indices 0, 1, 2, 3.
You can take it as a list of integers, or a string of digits.
Note that it may be empty, and it may contain duplicates.
The length of L is at most 5.
Output
Your output is the pattern F(L) as a newline-delimited string.
Rules and scoring
You can write a full program or a function.
the lowest byte count wins, and standard loopholes are disallowed.
Test cases
[]
#

[0]
##.
###
.#.

[3]
.#.
###
.##

[2,0]
...#...
...#...
...#...
#######
##.#...
####...
.#.#...

[1,1]
...#.##
...####
...#.#.
#######
...#...
...#...
...#...

[1,2,0]
.......#...#...
.......#...#...
.......#...#...
.......########
.......###.#...
.......#####...
.......#.#.#...
###############
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......

[3,3,1]
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
###############
.......#...#...
.......#...#...
.......#...#...
.......########
.......#...#.##
.......#...####
.......#...#.#.

[0,1,2,3]
.......#...#...#...............
.......#...#...#...............
.......#...#...#...............
.......#########...............
.......#.#.#...#...............
.......#####...#...............
.......#.###...#...............
################...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
###############################
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............

[0,0,1,2,3]
.......#...#...#...............#...............................
.......#...#...#...............#...............................
.......#...#...#...............#...............................
.......#########...............#...............................
.......#.#.#...#...............#...............................
.......#####...#...............#...............................
.......#.###...#...............#...............................
################...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
################################...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
###############################################################
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................

In your example, why do you begin with the 1x1 grid #? L !=[] in that example, as it has 1 or more elements. Does this mean that F(L) is always a # at first?

@R.Kap Okay, the example is not very clear. The definition is recursive, so for L = [2,0], you chop off the head and look at the pattern F([0]), then chop off the head of [0] and look at the pattern F([]), which is the 1x1 grid #. Then you use the chopped-off index 0 on it to build the 3x3 pattern, and use the chopped-off index 2 on that one to build the 7x7 pattern. To answer your question: yes, you always begin with the 1x1 grid since that's the base case of the recursion.

Related reading

CJam, 59 47 43 41 40 bytes
Thanks to Sp3000 for saving 1 byte.
Sal~W%{_Bff|a4*I@t2/{zSf*z}:F%F}fI3ff+N*

Test it here.
Explanation
Slightly outdated. Will fix later.
All the dimension reorderings of 4D lists are making me dizzy...
This code implements the specification very literally, using the iterative algorithm from the example section instead of its recursive definition.. One major golfing trick is that I'm using spaces instead of # during the computation and only replace them with # at the end, which simplifies the code in one place and allows me to use S instead of '# or "#" in several.
Sa       e# Push [" "], i.e. a 1x1 grid containing only a space as the
         e# initial fractal.
l~       e# Read and evaluate input.
W%       e# Reverse the list.
{        e# For each list element, assigning the element to variable I...
  _      e#   Duplicate the grid.
  Eff|   e#   Map (OR 14) over each character in the grid, turning spaces into
         e#   periods and leaving periods unchanged.
  a4*    e#   Create an array with four copies of this cleared grid.
  I@t    e#   Replace the Ith element in this list with the previous grid.
  2/     e#   Split this array into a 2x2 grid of subgrids...
         e#   Now it's getting a bit weird... we've got 4 dimensions now, which are:
         e#    - Rows of the 2x2 meta-grid.
         e#    - Cells in each row of the 2x2 meta-grid (i.e. subgrids).
         e#    - Rows of each subgrid.
         e#    - Characters in each row of each subgrid.
  :z     e#   Transpose each outer row, i.e. swap dimensions 2 and 3.
         e#   We've now got in each row of the meta-grid, a list of pairs of
         e#   corresponding rows of the subgrids.
  Sff*   e#   Join those pairs of rows with a single space each. We're now down
         e#   to three dimensions:
         e#    - Rows of the 2x2 meta-grid.
         e#    - Rows of each 1x2 block of the meta-grid.
         e#    - Characters in each row of those blocks.
  :z     e#   Transpose the blocks, i.e. turn the 1x2 blocks into a list of
         e#   columns of their characters.
  z      e#   Transpose the outer grid, i.e. turn it into a list of pairs of
         e#   corresponding columns in the two 1x2 blocks.
  Sf*    e#   Join each pair of columns with a single space. We've now got the
         e#   new grid we're looking for, but it's a list of columns, i.e. transposed.
  z      e#   Fix that by transposing the entire grid once more.
}I
N*       e# Join the rows of the grid with linefeeds.
S'#er    e# Replace all spaces with #.

MATL, 42 41 bytes
'.#'4:He!XIiP"Iq@=wX*1X@WZ(l5MY(]3Lt3$)Q)

Try it online!
Explanation
This works iteratively using a Kronecker product to extend the array in each iteration. The array is built with 0 and 1 instead of . and #, and at the end they are replaced by the appropriate characters.
There will be as many iterations as the input size. Input is processed from right to left. Iteration index starts at 1.
Using the example in the challenge, with input [2,0], the array is initiallized as
1 2
3 4

This corresponds to the initial 1 (#) extended by one row and one column, whose purpose will be clear later. The values in those columns are not important, as they will be overwritten; they could equally be ones:
1 1
1 1

At each iteration, the existing array is Kronecker-multiplied by a 2×2 zero-one array that contains 1 at the position indicated by the current entry of the input, and 0 at the other entries. In the example at iteration i = 1, since the rightmost input entry is 0, the zero-one array is
1 0
0 0

and the Kronecker product of these two arrays is
 1 1 0 0
 1 1 0 0
 0 0 0 0
 0 0 0 0

Next, the row and column with index 2^i are filled with ones:
 1 1 0 0
 1 1 1 1
 0 1 0 0
 0 1 0 0

The first three rows and columns constitute the result of the first iteration. As before, there are an extra row and column, which are useful for extending the array in the next iteration.
At iteration i = 2, since the current input value contains 2 the array above is Kronecker-multiplied by
0 0
1 0

which gives
 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0
 1 1 0 0 0 0 0 0
 1 1 1 1 0 0 0 0
 0 1 0 0 0 0 0 0
 0 1 0 0 0 0 0 0

Filling the 2^i-th row and column with ones gives
 0 0 0 1 0 0 0 0
 0 0 0 1 0 0 0 0
 0 0 0 1 0 0 0 0
 1 1 1 1 1 1 1 1
 1 1 0 1 0 0 0 0
 1 1 1 1 0 0 0 0
 0 1 0 1 0 0 0 0
 0 1 0 1 0 0 0 0

Since this is the last iteration, the extra row and column are removed:
 0 0 0 1 0 0 0
 0 0 0 1 0 0 0
 0 0 0 1 0 0 0
 1 1 1 1 1 1 1
 1 1 0 1 0 0 0
 1 1 1 1 0 0 0
 0 1 0 1 0 0 0

and the character substitution is done to produce the final result:
...#...
...#...
...#...
#######
##.#...
####...
.#.#...

Detailed description of the code follows:
'.#'      % Push this string. Will be indexed into
4:He!     % Push 2×2 array [1 2; 3 4]
XI        % Copy it into clipboard I
iP        % Input array and reverse it
"         % For each entry of the reversed input
  I       %   Push [1 2; 3 4] from clipboard I
  q       %   Subtract 1 to yield [0 1; 2 3]
  @=      %   Compare with current entry of the input. Gives 2×2 array
          %   with an entry equal to `1` and the rest `0`
  wX*     %   Swap. Kronecker product
  1       %   Push 1
  X@      %   Push iteration index, i
  W       %   Compute 2^i
  Z(      %   Write 1 into column 2^i
  l       %   Push 1
  5M      %   Push 2^i again
  Y(      %   Write 1 into row 2^i
]         % End for each
3Lt       % Push [1, -1j] (corresponding to index 1:end-1) twice
3$)       % Apply index. Removes last row and column
Q         % Add 1. Gives an array of values 1 and 2
)         % Index into initial string

Haskell, 123 122 bytes
unlines.foldr(#)["#"]
n#p=zipWith(++)(r++h:t)$('#':)<$>u++h:s where b='.'<$p<$p;h='#'<$p;(r:s:t:u:_)=drop n$cycle[p,b,b,b]

Usage example:
*Main> putStr $ (unlines.foldr(#)["#"]) [2,3,1]
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
###############
...#...#.......
...#...#.......
...#...#.......
########.......
...#.###.......
...#####.......
...#.#.#.......

How it works:
                ["#"]      -- starting with "#"
        foldr(#)           -- fold the function # from the right into the input
unlines                    -- and join the result with newlines

n#p=                       -- helper function #
                           -- n: next index, p: fractal so far
    zipWith(++)            -- join the left and right part elementwise
       (r++h:t)            -- left part
       ('#':) <$> u++h:s   -- right part (prepend '#' to each line for vertical
                           -- separator

                           -- helper
b='.'<$p<$p                -- b is a blank square of the same size as p
h='#'<$p                   -- h is a line of '#' of the same length as p
(r:s:t:u:_)=               -- drop the first n elements of the infinite
    drop n$cycle[p,b,b,b]  --   list [p,b,b,b,p,b,b,b,p,b,b,b,...] and
                           --   assign the next 4 element to r,s,t,u.
                           --   As r,s,t,u are always inserted at the
                           --   same position in the fractal, we get the
                           --   variants by assigning different values.

Ruby, 143 134 bytes
An anonymous function.
1 byte saved by a rearrangement of the first line. 6 bytes saved by changing the way z is incremented from a formula to a table. 2 bytes saved by eliminating varable w.
->a{r=-1+u=2<<a.size
s=(?.*r+$/)*r
a<<0
z=r*u/2-1
a.each{|i|r/=2
(-r..r).each{|j|s[z+j]=s[z+j*u]=?#}
z+=-r/2*[u+1,u-1,1-u,-u-1][i]}
s}

Ungolfed in test program
f=->a{
  r=w=(u=2<<a.size)-1        #w=length of line excluding newline, u=length of line including newline.
  s=(?.*w+$/)*w              #initialize string s with w rows of w dots terminated by newlines.
  z=w*u/2-1                  #z is the centre of the fractal
  a<<0                       #add a dummy value to the end of a
  a.each{|i|                 #for each element in a
    r/=2                     #r is the radius of the current iteration: ....15,7,3,1
    (-r..r).each{|j|         #for j=-r to r
      s[z+j]=s[z+j*u]=?#     #overwrite . with #, forming horizontal and vertical lines
    }
    z+=-r/2*(u+1)+           #move z to centre of upper left quarter (where it should be if i=0)
      i%2*(q=r+1)+           #move across if i=1,3
      i/2%2*q*u              #and down if i=2,3
  }
s}                           #return string

puts $/,f[[]]

puts $/,f[[0]]

puts $/,f[[3]]

puts $/,f[[2,0]]

puts $/,f[[1,1]]

puts $/,f[[1,2,0]]

puts $/,f[[3,3,1]]

puts $/,f[[0,1,2,3]]

puts $/,f[[0,0,1,2,3]]

JavaScript (ES6), 171 152 bytes
([d,...a],h=`#`,r=`replace`)=>d<4?(s=f(a)[r](/.+/g,s=>(t=s[r](/./g,`.`),d&1?t+h+s:s+h+t)),t=s[r](/.+/g,w=t+h+t),w=`
${w[r](/./g,h)}
`,d&2?t+w+s:s+w+t):h

Takes the result of the recursive call, then replaces each line with itself plus a hash plus a string of dots of the same length, in reverse order if necessary, then from that partial result creates a string of dots except for the newlines and central column of hashes, and also a string of hashes with surrounding newlines, then joins those three strings together in the appropriate order.

Python 3.5, 1151 bytes:
Not much of a code golf, but oh well. Will try to prune it more over time where I can.
def x(s):
 y=[''];l=['#'];k=[' ']
 for z in s[::-1]:y.append(z)
 y=y[::-1]
 for h in range(len(y)):
  if y[-1]!='':u=(int(y.pop())&3)
  else:u=y.pop()
  if len(l)<2:k.append(u);p=((2**(len(k)-1))-1);l.append((('.'*p+'#'+'.'*p+'\n')*p)+'#'*((p*2)+1)+'\n'+(('.'*p+'#'+'.'*p+'\n')*p))
  else:
   if len(l)>2:del l[0]
   p=((2**(len(k)-1))-1);a=[[_+i for i in range(p)]for _ in range(len(l[1]))if _%((p*2)+2)==0 and _!=(((p*2)+2)*(p))];b=[[_+i for i in range(p)]for _ in range(len(l[1]))if _%(int(((p*2)+2)/2))==0 and _!=(int(((p*2)+2)/2)*((p)*2))and _ not in[g for i in a for g in i]];W=[g for i in a[:len(a)-(int(len(a)/2)):1]for g in i];B=[g for i in b[:len(b)-(int(len(b)/2)):1]for g in i];C=[g for i in a[len(a)-(int(len(a)/2)):len(a):1]for g in i];T=[g for i in b[len(b)-(int(len(b)/2)):len(b):1]for g in i];f=list(l[1])
   for i in list(''.join(l[0].split())):
    if u==0:f[W[0]]=i;del W[0]
    elif u==1:f[B[0]]=i;del B[0]
    elif u==2:f[C[0]]=i;del C[0]
    elif u==3:f[T[0]]=i;del T[0]
   del l[0];k.append(u);p=((2**(len(k)-1))-1);l.append(''.join(f));l.append((('.'*p+'#'+'.'*p+'\n')*p)+'#'*((p*2)+1)+'\n'+(('.'*p+'#'+'.'*p+'\n')*p))
 print(l[-2])

A pretty naive way to do this, but, nonetheless, currently works perfectly and, as you can see, uses no external modules/libraries. Additionally, it can take on way more than 5 items in the provided list s without losing any accuracy (that is, if your hardware can handle it). It satisfies all the requirements, and I could not be happier with what I got. :)
It can also now not only accept any number within the range 0=>3 as any of the values, but any number, period, thanks to the & bitwise operator ! You can read more about them here. Now, for instance, [4,4,1,2,3] as the input list is the same as [0,0,1,2,3].
Note: Input must be provided as a list
Ungolfed with explanation:
def x(s):
 # Create 3 lists:
 # `y` is for the values of `s` (the list provided) and an empty element for the
 # first pattern
 # `l` is reserved for the pattersn created through each item in list `y`
 # `k` is created for the value of `p` which is the main value through which the
 # pattern is created.
 y=[''];l=['#'];k=[' ']
 # Reverse s, and then add each element from `s` to `y`
 # (in addition to the empty element)
 for z in s[::-1]:
     y.append(z)
 # `y` should now equal the list created, but reversed
 # If not reversed, then, if, for instance, the input is `0,1,2` and list `y`
 # therefore contains `'',2,1,0`, the empty element will be called at the end,
 # which is NOT what we want.
 y=y[::-1]
 # The main loop; will be iterated through the length of `y` number of times
 for h in range(len(y)):
  # Here is where each element from the end of `y` is recieved as `u` for
  # use in the pattern in each iteration.
  # As you can also see, a bitwise operator (`&`) is used here so that
  # ALL numbers can be accepted. Not just those in the range `0-4`.
  # However, that will happen only if the value of y[-1] (the last elment in y) is
  # NOT ''.
  if y[-1]!='':
      u=(int(y.pop())&3)
  else:
      u=y.pop()
  # If the length of list `l` is less than 2
  # (which means it only contains `#`), then do the following:
  if len(l)<2:
      # Append `u` to `k`
      k.append(u)
      # Use the length of `k` as `n` in the operation `(2^(n-1)-1)` to get the
      # length of the dot filled part of the new pattern.
      p=((2**(len(k)-1))-1)
      # Add that pattern to the list (currently empty,
      # i.e. containing no other pattern in any other quadrant)
      l.append((('.'*p+'#'+'.'*p+'\n')*p)+'#'*((p*2)+1)+'\n'+(('.'*p+'#'+'.'*p+'\n')*p))
  # Now, if the length of l is >=2, do the following:
  else:
   # If the length of l is >2, then delete the first element in list `l`
   # (this will happen only once, when the `#` is still the first element)
   if len(l)>2:
       del l[0]
   # Again, use the length of `k` as `n` in the operation `(2^(n-1)-1)`
   # to get the length of the dot filled part of the pattern.
   p=((2**(len(k)-1))-1)
   # Create a list with all the index values of all the dot elements on the left hand
   # side of the grid l[-1], and the index value + i where i is every integer in
   # the range `0-p` (this way, it will create lists within a list, each
   # which contain `p` number of integers, which are all indexes of all the dots on
   # the very left side of the grid)
   a=[[_+i for i in range(p)]for _ in range(len(l[1]))if _%((p
      *2)+2)==0 and _!=(((p*2)+2)*(p))]
   # Create another list with all the index values of the dots using the same
   # strategy as above, but this time, those in the right half of the grid.
   b=[[_+i for i in range(p)]for _ in range(len(l[1]))if _%(int(((p*2)+2)/2))==0
      and _!=(int(((p*2)+2)/2)*((p)*2))and _ not in[g for i in a for g in i]]
   # Create 4 lists, each containing index values specific to each of the
   # 4 quadrants of the grid.
   # W is the list, based on A, containing all the indexes for the 1st quadrant of
   # the grid in l[-1] containing dots (index 0 in the grid)
   W=[g for i in a[:len(a)-(int(len(a)/2)):1]for g in i]
   # B is the list, this time based on b, containing all indexes for the 2nd
   # dot-filled quadrant of the grid l[-1] (index 1 in the grid)
   B=[g for i in b[:len(b)-(int(len(b)/2)):1]for g in i]
   # C is the list, also, like W, based on a, containg all the index values for
   # the 3rd dot-filled quadrant of the grid in l[-1] (index 2 in the grid)
   C=[g for i in a[len(a)-(int(len(a)/2)):len(a):1]for g in i]
   # T is the final list, which, also like B, is based on b, and contains all the
   # index values for the final (4th) dot-filled quadrant of the grid in l[-1]
   T=[g for i in b[len(b)-(int(len(b)/2)):len(b):1]for g in i];f=list(l[1])
   # Finally, in this `for` loop, utilize all the above lists to create the new
   # pattern, using the last two elements in list `l`, where each character of grid
   # l[-2] (the second to last element) is added to the correct index of grid l[-1]
   # based on the value of `u`
   for i in list(''.join(l[0].split())):
    if u==0:
        f[W[0]]=i
        del W[0]
    elif u==1:
        f[B[0]]=i
        del B[0]
    elif u==2:
        f[C[0]]=i
        del C[0]
    elif u==3:
        f[T[0]]=i
        del T[0]
   # Delete the very first element of `l`, as it is now not needed anymore
   del l[0]
   # Append `u` to list`k` at the end of the loop this time
   k.append(u)
   # Update the value of `p` with the new value of length(k)
   p=((2**(len(k)-1))-1)
   # Append the new patter created from the for-loop above to list `l`
   l.append(''.join(f))
   # Append a new, empty pattern to list `l` for use in the next iteration
   l.append((('.'*p+'#'+'.'*p+'\n')*p)+'#'*((p*2)+1)+'\n'+(('.'*p+'#'+'.'*p+'\n')*p))
 # When the above main loop is all finished, print out the second-to-last elment in
 # list `l` as the very last element is the new, empty grid created just in case
 # there is another iteration
 print(l[-2])

Broader & far more visually appealing explanation:
For a broader and far more visually appealing explanation, consider the second time going through the "main"-loop in the above code, in which the input list is [0,2]. In this case, the elements in the "main" list l would be:
.#.
###
##.

and
...#...
...#...
...#...
#######
...#...
...#...
...#...

and list y would only contain 0. Taking advantage of Python's way of indexing the last element of grid l[-1], we can label the very left elements of the grid like so:
 0 ...#...\n 7
 8 ...#...\n 15
16 ...#...\n 23
   #######\n <- Ignore this as it is nothing but `#`s and a new line
32 ...#...\n 39
40 ...#...\n 47
48 ...#...\n 55

What pattern do you see? Every index on the very left of the grid is a multiple of 8, and since, using the equation 2^(n-1)-1 yields the length of each segment of dots in the grid, we can do ((2^(n-1)-1)*2)+2 to find the length of the top edge of the grid as a whole (+2 to include the middle #s and the \n at the end). We can use that equation, which we will call i to find the index values of each element on the left side of a grid of any size by creating a list, and appending to the list every integer, which we will call _, in the range 0=>length of grid l[-1], such that that item is a multiple of i, AND also such that _ does NOT equal i*(2^(n-1)-1), so that we can exclude the middle segment of #s separating the top half from the lower half. But we want ALL the dot elements from the left, and not only the elements on the very left side. Well, there is a fix to that, and that would be to simply append to the list a list containing i+h where h is every integer in the range 0=>2^(n-1) each time a value from range 0=>length of grid l[-1] is added to the list, so that each time, there will be as many number of values added to the list as the length of one quadrant of dots. And that is list a.
But now, how about the dots on the right half? Well, let us look at the indexing a different way:
   0 ...# 4  ...\n 7
   8 ...# 12 ...\n 15
  16 ...# 20 ...\n 23
     #######\n <- Ignore this as it is nothing but `#`s and a new line
  32 ...# 36 ...\n 39
  40 ...# 44 ...\n 47
  48 ...# 52 ...\n 55

          ^
          |

          These are the values we are looking at now

As you can see, the values now in the middle are those that we need, as they are the beginning of the index of every segment of dots on the right hand side of the grid. Now, what is the pattern here? Well, if it's not already obvious enough, now the middle values are all multiples of i/2! With that information, we can now create another list, b, to which the multiples of i/2 are added from the range 0=>length of grid l[-1] such that each integer from that range, which we will again call _, is NOT equal to (i/2)*(p*2) to exclude the line of #s separating the top and lower halves, AND such that _ is NOT already in list a, since we don't really need 8,16,32,etc. in list b. And now, again, we don't only want those specific indexes. We want ALL the dot characters on the right side of the grid. Well, just like we did in list a, here we can also add to list b lists of _+h where h is each integer in the range 0=>2^(n-1).
Now, we have both lists a and b packed and ready to go. How would we bring these together now? This is where lists W, T, G, and C come in. They will hold the indexes to each specific quadrant of dots in grid l[-1]. For instance, let us reserve list W as the list for all the indexes equal to quadrant 1 (index 0) of the grid. In this list, we would then add the first 2^(n-1) lists from list a, since list a contains all the indexes for dots in the left half of the grid, and then split them all up so that W now contains (2^(n-1))*(2^(n-1)) elements. We would do the same for list T, but with the difference that T would contain elements from list b, since Tis reserved for quadrant 2 (index 1). List G would be the same as list W, except it would contain the rest of the elements from list a, and list C is the same as list T, except it now contains the rest of the elements from list b. And, that's it! We now have out index values for every quadrant containing dots in the grid, all split up into four lists corresponding to each quadrant. We can now use these 4 lists (W,T,G,C) to tell the program which characters it should replace in grid l[-1] with each character from grid l[0], which is the very first element of list l. Since the value is 0 here, it would replace all the dots in the first quadrant (index 0) with grid l[0] utilizing list W.
Therefore, we finally have the following:
.#.#...
####...
##.#...
#######
...#...
...#...
...#...

Whew! Long process, isn't it? However, it works perfectly, and, again, I could not be happier. :)

Ruby, 150 bytes
Anonymous function. Uses a recursive call to build a list of strings, one string per line, then joins them all together at the end.
->i{f=->l{s=2**l.size-1;g=[[?.*s]*s]*4;m=->x,y{x.zip(y).map{|a,b|a+?#+b}}
s<1?[?#]:(g[l.shift]=f[l];m[*g[0,2]]+[?#*(2*s+1)]+m[*g[2,2]])}
f[i].join"
"}


text:
Primes in Different Bases
Challenge:
You are given a base 10 number.  For each base from 10 counting down to base 2:

Take the original input number as a base 10 string, and remove any
digits of the number which are invalid for the base.
Interpret the resulting number string in the that base. If this gives 1 or 0, terminate the whole process.
Output or print its largest prime factor, as decimal number.

The output can be an array of the largest prime factors.
Sample cases:
Input:
987654321

Output:
379721
10593529
1091
179
1493
293
19
7

Alternately:
[379721,10593529,1091,179,1493,293,19,7]

This prints the largest prime factors of \$987654321\$, \$87654321_9 = 42374116_{10}\$, \$7654321_{8} = 2054353_{10}\$, and so on until it reaches \$1_2\$, where it stops.

I'm unclear on the process. I could probably figure it out from the example, but you should have clear instructions so this isn't needed. So we convert to a lower base, remove invalid digits, then print the largest prime factor? What base do we print this factor in? Do we then do the same process with the largest prime factor and a base one lower? Or do we do it with the number we factored? Do we start with 10 or 9?

Welcome to the site!

I tried rewriting the challenge to make it clearer. I hope this is what you intended. If not, feel free to change it.

I find the largest-prime-factor step rather tacked on to the main operation is base conversion. Many languages just do it directly with a prime-factorization built-in, and the rest basically have to do a second separate challenge. Base conversion is also built-in-or-bust. When operations come as built-ins, you expect them to be well-trodden ground for golfs, and indeed factorization and base conversion are. Still, good for a first challenge, but things to keep in mind for next time.

Any chance this was inspired by Google Code Jam?

This is definitely inspired by Google Code Jam.

Pyth, 25 bytes
sfTm>1PiFdC,.u-N`tYKrT1zK

                       z   get input as a string
            .u      rT1    cumulative reduce over [10,9,...,2]
              -N`tY        remove one minus the number (10,9,...) from the input
          C,       K    K  pair each step along the chain with corresponding base
   m                       map over [["987654321", 10],...]:
       iFd                   apply the base-conversion (splat over i)
      P                      prime factorization, smallest to largest
    >1                       take [the last element], or [] if empty (1 or 0)
 fT                        remove the []s from 0s or 1s
s                          join the one-element arrays together

Try it here.

MATL, 17 15 bytes
9:PQ"G@ZAYfXzX>

This takes the number as a string with quotes, which is allowed by default.
Try it online!
Explanation
9:PQ     % Push array [10, 9, ..., 2]
"        % For each number in that array. These are the bases to be considered
  G      %   Push input. Forces for input to be taken implicitly first time
  @      %   Push current base
  ZA     %   Convert from that base to base 10, discarding non-valid digits
  Yf     %   Prime factors. Gives empty for input 1, and 0 for input 0
  Xz     %   Non-zero values. Gives empty if previous result was 0, or else
         %   leaves it as it was
  X>     %   Maximum of array. For empty input gives empty
         % Implicitly end for each
         % Implicitly display. Empty arrays are not displayed

This one outputs a 0 at the end for inputs not ending in 1.

For the inputs '98765432' and '98765' (random examples), it output the correct numbers then 0 before terminating.

@poi830 Solved now

Pyth - 16 bytes
V_S9#ePi~-z`NhNB

Try it online here.
There are sometimes a few blank lines on inputs without all the digits, lemme know if that's a problem.

Mathematica, 83 bytes
FactorInteger[Select[IntegerDigits@#,#<a&]~FromDigits~a][[-1,1]]~Table~{a,10,2,-1}&

Anonymous function, returns a list. Not that complicated, to be honest.

Julia, 101 bytes
f(s,x=[],b=10)=(t=filter(c->c<=47+b,s))>"1"&&b>1?f(s,[x;maximum(keys(factor(parse(Int,t,b))))],b-1):x

This is a recursive function that accepts the input as a string and returns an array.
Ungolfed:
function f(s, x=[], b=10)
    # Filter the string down to only the digits valid for base b
    t = filter(c -> c <= 47 + b, s)

    # If the filtered string isn't "1" or "0" and b is a valid base
    if t > "1" && b > 1
        # Call the function again, appending the maximum prime factor
        # of t in base b to the argument x and decrementing the base
        f(s, [x; maximum(keys(factor(parse(Int, t, b))))], b-1)
    else
        # Otherwise return the array
        x
    end
end

Jelly, 14 bytes
D<ƇḅṛɗⱮ⁵ÆfṀ€t0

Try it online!
How it works
D<ƇḅṛɗⱮ⁵ÆfṀ€t0 - Main link. Takes an integer n on the left
D              - Cast n to digits, D
     ɗ         - Previous 3 links as a dyad f(D, k):
 <Ƈ            -   Keep elements of D less than k
    ṛ          -   Yield k
   ḅ           -   Convert to base k
       ⁵       - 10
      Ɱ        - Yield the range 1 ≤ k ≤ 10 and map f(D, k) over each
        Æf     - Prime factors
          Ṁ€   - Maximum of each, or 0 if empty list
            t0 - Trim zeros

Ruby, 120 bytes
Recursive function, takes the input as a string.
f=->n,b=2{require'prime';i=n.tr([*b.to_s..?9].join,"").to_i(b)
b>10?[]:f[n,b+1]+[*i>1?Prime.prime_division(i).max[0]:p]}

You can save some bytes by using the -rprime command line flag instead of require.

-rprime doesn't work for me for some reason...

Pyke, 19 bytes, noncompeting
(add splat_node functon)
DTAbPe
;1TtD=T`"":r

Try it here!
Takes input in quotes, exits with an error.
Explanation (newline replaced with \n):
D                    - Duplicate the first item on the stack (And get it from input first time)
 TAb                 - Convert input to base (whatever's in T, 10 default)
    Pe               - get the highest prime factor of the number
      \n;1           - print it out and get rid of it
          TtD=T      - T -= 1
               `"":  - input = input.replace(str(t), "")
                   r - GOTO start

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


text:
Generate the minimal remainder sequence
Every number can be represented using an infinitely long remainder sequence.  For example, if we take the number 7, and perform 7mod2, then 7mod3, then 7mod4, and so on, we get 1,1,3,2,1,0,7,7,7,7,.....
However, we need the shortest possible remainder subsequence that can still be used to distinguish it from all lower numbers.  Using 7 again, [1,1,3] is the shortest subsequence, because all of the previous subsequences don't start with [1,1,3]:
0: 0,0,0,0...
1: 1,1,1,1...
2: 0,2,2,2...
3: 1,0,3,3...
4: 0,1,0,4...
5: 1,2,1,0...
6: 0,0,2,1...

Note that [1,1] doesn't work to represent 7, because it can also be used to represent 1.  However, you should output [1] with an input of 1.
Input/Output
Your input is a non-negative integer.  You must output a sequence or list of the minimal-length sequence of remainders as defined above.
Test cases:
0: 0
1: 1
2: 0,2
3: 1,0
4: 0,1
5: 1,2
6: 0,0,2
7: 1,1,3
8: 0,2,0
9: 1,0,1
10: 0,1,2
11: 1,2,3
12: 0,0,0,2
30: 0,0,2,0
42: 0,0,2,2
59: 1,2,3,4
60: 0,0,0,0,0,4
257: 1,2,1,2,5,5
566: 0,2,2,1,2,6,6
1000: 0,1,0,0,4,6,0,1
9998: 0,2,2,3,2,2,6,8,8,10
9999: 1,0,3,4,3,3,7,0,9,0

Here are the first 10,000 sequences, in case you are interested (the line numbers are off by 1).
This is a code-golf, so make it as short as you can in your favorite language.  Fake bonus points for any answers that are fast!

Related

@nimi we talked about that in chat, and I decided that sequences need to be at least 1 element long.

I'm slightly surprised you didn't limit it to prime remainders.

Is it okay if the output is returned in a list?

@neil, I also considered that, but because remainders are different with composite numbers, I voted to keep it

List output is totally fine

Well, it makes a difference for the prime powers; other composite numbers don't give you any extra information.

Jelly, 14 bytes
‘Ræl\>iṠ2»2r⁸%

This uses the fact a the solution (if any) of a system of linear congruences is unique modulo the LCM of the moduli. Try it online! or verify all test cases.
How it works
‘Ræl\>iṠ2»2r⁸%  Main link. Argument: n

‘               Increment; yield n+1.
 R              Range; yield [1, ..., n+1].
  æl\           Cumulatively reduce by LCM.
                This yields [LCM(1), ..., LCM(1, ..., n+1)].
     >          Compare all LCMs with n.
      iṠ        Find the first index of sign(n).
                This yields the first m such that LCM(2, ..., m) > n if n > 0, and
                0 if n == 0.
        2»      Take the maximum of the previous result and 2, mapping 0 to 2.
          2r    Yield the range from 2 up to and including the maximum.
            ⁸%  Compute n modulo each integer in that range.

Mathematica, 60 53 bytes
#~Mod~FirstCase[2~Range~#&/@Range[#+2],x_/;LCM@@x>#]&

Somewhat fast (it handles 10000 in ~0.1 second, but will likely run out of memory for 100000).
The code throws an error but computes the result correctly.
Explanation
We've found earlier in chat that the required divisors can always be determined as the shortest list {1, 2, ..., n} whose least common multiple exceeds the input. A short argument for why that is: if the LCM is less than the input, then subtracting the LCM from the input would leave all the divisors unchanged, so the representation is not unique. However, for all inputs less than the LCM, the remainders will be unique, otherwise the difference between two numbers with equal remainders would be a smaller multiple of all divisors.
As for the code... as usual the reading order of golfed Mathematica is a bit funny.
Range[#+2]

This gets us a list [1, 2, 3, ..., n+2] for input n. The +2 is to ensure that it works correctly for 0 and 1.
2~Range~#&/@...

Map 2~Range~# (syntactic sugar for Range[2,#]) over this list, so we get
{{}, {2}, {2,3}, ..., {2,3,...,n+2}}

These are candidate divisor lists (of course in general that's a lot more than we'll need). Now we find the first one of them whose LCM exceeds the input with:
FirstCase[...,x_/;LCM@@x>#]

More syntax: x_ is a pattern which matches any of the lists and calls it x. The /; attaches a condition to that pattern. This condition is LCM@@x># where @@ applies the function to the list, i.e. LCM@@{1,2,3} means LCM[1,2,3].
Finally we simply get all the remainders, making use of the fact that Mod is Listable, i.e. it automatically maps over a list if one of the arguments is a list (or if both of them are lists of the same length):
#~Mod~...

MATL, 24 bytes
Thanks to @nimi for pointing out an error in a previous version of this answer (now corrected)
Q:qtQ!\t0Z)tb=YpsSP2):Q)

This runs out of memory in the online compiler for the two largest test cases (but it works on a computer with 4 GB RAM).
Try it online!
Explanation
This applies the definition in a straightforward manner. For input n it computes a 2D array containing mod(p,q) with p from 0 to n and q from 1 to n+1. Each p is a column, and each q is a row. For example, with input n=7 this array is
0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1
0 1 2 0 1 2 0 1
0 1 2 3 0 1 2 3
0 1 2 3 4 0 1 2
0 1 2 3 4 5 0 1
0 1 2 3 4 5 6 0
0 1 2 3 4 5 6 7

Now the last column, which contains the remainders of n, is element-wise compared with each column of this array. This yields
1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1
0 1 0 0 1 0 0 1
0 0 0 1 0 0 0 1
0 0 1 0 0 0 0 1
0 1 0 0 0 0 0 1
1 0 0 0 0 0 0 1
0 0 0 0 0 0 0 1

where 1 indicates equality. The last column is obviously equal to itself and thus contains all ones. We need to find the column that has the largest number of initial ones, other than the last column, and take note of that number of initial ones, m. (In this case it's the second column, which contains m=3 initial ones). To this end, we compute the cumulative product of each column:
1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1
0 1 0 0 0 0 0 1
0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 1

then the sum of each column
1 3 1 2 1 2 1 8

and then sort non-increasingly and take the second value, which is 3. This is the desired m, which indicates how many remainders we need to pick.
Q:q    % take input n implicitly. Generare row array [0 1 ... n]
tQ!    % duplicate. Transform into column array [1; 2; ...; n-1]
\      % modulo, element-wise with broadcast. Gives the 2D array
t0Z)   % duplicate. Take last column
tb     % duplicate, bubble up
=      % test for equality, element-wise with broadcast
Yp     % cumumative product of each column
s      % sum of each column. This gives the number of initial coincidences
SP2)   % sort in decreasing order and take second value: m
:Q     % generate range [2 3 ... m+1]
)      % apply as index into array of remainders of n. Implicitly display

Jelly, 13 11 bytes
r¬µ%€R‘$ḟ/Ṫ

This won't win any velocity brownie points... Try it online! or verify the smaller test cases.
How it works
r¬µ%€R‘$ḟ/Ṫ  Main link. Argument: n

r¬           Range from n to (not n).
             This yields [n, ..., 0] if n > 0 and [0, 1] otherwise.

  µ          Begin a new, monadic chain. Argument: A (range)

       $     Combine the previous two links into a monadic chain:
     R         Range; turn each k in A into [1, ..., k] or [] if k == 0.
      ‘        Increment to map k to [2, ..., k+1].
   %€        Take each k in A modulo all the integers in the 2D list to the right.
        ḟ/   Reduce by filter-not; sequentially remove all remainder sequences of
             n-1, ..., (not n) from the remainder sequences of n.
          Ṫ  Tail; take the last remainder sequence.
             This gives the shortest sequence for descending A and the longest one
             (i.e., [0]) for ascending A.

Why have you included two answers???

Because they're two completely different approaches. While this on is 3 bytes shorter, the other one is actually fast enough to compute all test cases.

If I were you, I wouldn't have done it... except if it was an up/down vote thing.

Different languages/approaches go in different answers. That was my very first meta question.

Haskell, 66 60 51 50 bytes
f i=mod i<$>[2..2+sum[1|l<-scanl1 lcm[2..i],l<=i]]

Usage example: f 42-> [0,0,2,2]. It's the algorithm described in @Martin Büttner's answer.
I'll keep the previous version for reference, because it's pretty fast:
Haskell, 51 bytes
f i=mod i<$>[[2..x]|x<-[2..],foldl1 lcm[2..x]>i]!!0

It takes 0.03s for f (10^100) on my five year old laptop.
Edit: @xnor found a byte to save. Thanks!

Saving a byte by counting the indices until the lcm gets too high: h i=mod i<$>[2..2+sum[1|l<-scanl1 lcm[2..i],l<=i]]

Python 3.5, 117 95 78 bytes
import sympy
r=lambda n,m=2,M=1,*l:M>n and l or r(n,m+1,sympy.lcm(m,M),*l,n%m)

Requires Python 3.5 and sympy (python3 -m pip install --user sympy). Credit to @Dennis to notify me that Python 3.5 allows the *l trick with default arguments.

With SymPy 0.7.5, you can shorten M>n and l to l*(M>n).

Python 2, 73 70 69 65 bytes
i=l=1
n=input()
while l<=n|1:
 i+=1;a=l;print n%i
 while l%i:l+=a

A full program. @Dennis saved 4 bytes by improving the way zero is handled.

Pyth, 51 Bytes 66 Bytes
IqQZ[Z).q)IqQ1[1))IqQ2,0 1))FdhhQJu/*GHiGHtUd1I>JQVQ aY%QhN)<tYd.q

Try it out!
Much higher speed 39 byte version (does not work for 0-2):
FdhhQJu/*GHiGHtUd1I>JQVtd aY%QhN)<tYd.q

It seems to work for absurdly large numbers like 10103
Note: this answer does not work for 0, 1, and 2.  Fixed!

JavaScript (ES6), 81 77 bytes
f=(n,r=[n%2],l=i=2,g=(j,k)=>j?g(k%j,j):k)=>l>n?r:f(n,[...r,n%++i],i/g(i,l)*l)

This recursively builds up the answer until the LCM exceeds the original number. The GCD is also calculated recursively, of course.
Edit: Saved 4 bytes thanks to @user81655.

@user81655 That's just underhanded...

Julia, 36 33 bytes
\(n,k=2)=lcm(2:k)>n?n%(2:k):n\-~k

Try it online!

Ruby, 52 bytes
->n{m=t=1;a=[];(a<<n%m)until n<t=t.lcm(m+=1);a<<n%m}

This solution checks every possible m starting from 2 that be the remainder that makes the sequence unique. What makes the last m unique is not the remainder itself, but that the m is the last member of the smallest range (2..m) where the least common multiple (LCM) of that range is greater than n. This is due to the Chinese Remainder Theorem, where to uniquely determine what number n is with a number of remainders, the LCM of those remainders must be greater than n (if selecting n from (1..n); if selecting n from a..b, the LCM needs only be greater than b-a)
Note: I put a<<n%m at the end of the code because until n<t=t.lcm(m+=1) short-circuits before a has received the last element to make it unique.
If anyone has any golfing suggestions, please let me know in the comments or in PPCG chat.
Ungolfing:
def remainder_sequence(num)
  # starting with 1, as the statements in the until loop immediately increments divisor
  divisor = 1
  # starts with 1 instead of 2, as the statements in the until loop
  # immediately change product to a new lcm
  product = 1
  remainders = []

  # this increments divisor first then checks the lcm of product and divisor
  # before checking if num is less than this lcm
  until num < (product = product.lcm(divisor = divisor + 1))
    remainders << num % divisor
  end

  # until always short circuits before the last element is entered
  # so this enters the last element and returns
  return remainders << num % divisor
end

Python 3.5, 194 181 169 152 149 146 bytes:
(Thanks to @Sherlock9 for 2 bytes!)
def r(o,c=0):
 y=[[j%i for i in range(2,100)]for j in range(o+1)]
 while 1:
  c+=1;z=y[-1][:c]
  if z not in[f[:c]for f in y[:-1]]:break
 print(z)

Works perfectly, and is also pretty quick. Calculating for the minimal remainder sequence of 100000 outputs [0, 1, 0, 0, 4, 5, 0, 1, 0, 10, 4, 4] and took only about 3 seconds. It was even able to calculate the sequence for the input 1000000 (1 million), output [0, 1, 0, 0, 4, 1, 0, 1, 0, 1, 4, 1, 8, 10, 0, 9], and took about 60 seconds.
Explanation
Basically what this function does is firstly create a list, y, with all j mod i where j is every integer in the range 0=>7 (including 7) and i is every integer in the range 0=>100. The program then goes into an infinite while loop and compares the same number of contents of each sublist within the first through second-to-last sublists of y (y[:-1:]) with the same number of items in the last sublist (y[-1]) of list y. When sublist y[-1] is different than any other sublist, the loop is broken out of, and the correct minimal remainder sequence is returned.
For instance, if the input is 3, y would be:
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]

Then, when it enters into the while loop, it compares each sublist in list y[:-1:] with the same number of items in sublist y[-1]. For example, it would first compare [[0],[1],[0]] and [1]. Since the last sublist is in the rest of y, it would continue on and then compare [[0,0],[0,1],[0,2]] and [1,0]. Since [1,0] is now NOT in the rest of y in that specific order, that is the minimal reminder sequence, and therefore, [1,0] would be correctly returned.

To save bytes, y[:c:] is the same as y[:c]

C89, 105 bytes
g(a,b){return b?g(b,a%b):a;}main(n,m,M){scanf("%d",&n);for(m=M=1;(M=++m*M/g(m,M))<=n;)printf("%d ",n%m);}

Compiles (with warnings) using gcc -std=c89. Takes a single number on stdin, and outputs the sequence of remainders separated by spaces on stdout.

This doesn't print anything when n=0

C, 89 bytes
a,i=2;main(l,n){for(n=atoi(gets(n))?:!puts(n);n/l;printf("%d ",n%i++))for(a=l;l%i;l+=a);}

Compile with gcc. Try it online: n=59, n=0.


text:
How can I shorten this python code analyzing a 3d grid?
My Python 3 function golf(...) should take a list of lists of lists of strings representing a solid cube and return whether there are any places in which two equal strings are directly next to each other on the x, y or z axis (not diagonally).
If there are no adjacent duplicates, True shall be returned, else False.
The input list and all of its sublists have the same length as they represent a cube, and their length is greater than 1 but lower than or equal to 5. The only possible values for the Strings inside the nested lists are "X" and "Z".
The maximum code length should be less than 200 bytes.
This is an example test case:
golf([[["X", "Z"],
       ["Z", "X"]],
      [["Z", "X"],
       ["X", "Z"]]]) == True
golf([[["X", "Z"],
       ["Z", "X"]],
      [["X", "Z"],
       ["Z", "X"]]]) == False

My current solution has 234 bytes:
def golf(c):
 r=range(len(c));R=[(a,b)for a in r for b in r];j="".join
 return all("XX"not in l and"ZZ"not in l for l in[j(c[x][y][z]for x in r)for y,z in R]+[j(c[x][y][z]for y in r)for x,z in R]+[j(c[x][y][z]for z in r)for x,y in R])

How can I golf this code any further to save another 35 bytes?

Are you sure this is a valid Python 3 code? E.g. [a,b  should throw SyntaxError.

@vaultah: That's a list comprehension.

@El'endiaStarman: yes. I just said that [a,b for a, b in ...] doesn't work.

@vaultah and @FryAmTheEggman, I opened up a Python shell and it looks like you guys are right. Changing a,b to (a,b) fixes that syntax error, but the function still doesn't work (I get a TypeError complaining that indices must be slices or integers, not tuples.)

Sorry, I pasted the wrong version. Now I updated the question with a fixed and working code and I already removed some more spaces as suggested by @FryAmTheEggman

You can define j=''.join once and than use j(c[x]...). Should save a few bytes.

@Jakube Thanks, that saved 8 bytes. 36 more to go.

you don't need a space in ) for

Also, as a golfing suggestion: golf is a 4 byte function name.  Try g.

Python 3, 108 107 bytes
Since the cube only contains the strings "X" and "Z", there are only two valid cube patterns. The one that starts with XZXZX... and the one that starts with ZXZXZ....
My solutions generates these 2 cubes and checks if the inputted cube is one of them.
def golf(l):L=len(l);r=range(L);return l in[[[list("XZ"*L)[(i+j+k)%2:][:L]for j in r]for k in r]for i in r]
i iterates over the possible cubes. Since the dimension is at least 2, we can reuse r instead of writing for i in(0,1).

With length 2, don't the cube patterns start with XZZX or ZXXZ?

@Sparr Yes. With "The one that starts with XZXZX..." I meant only the first row of the top layer. In the case of length 2 it starts with "XY".

Python 3, 60 bytes
golf=g=lambda l:all(g(a)*g(b)*(a!=b)for a,b in zip(l,l[1:]))

The function recursively decides whether an N-dimensional array is alternating by checking if:

Any two adjacent elements are unequal
Each element is alternating

This successfully bottoms out for the strings 'X' and 'Z' because their length is 1, so the all is taken of an empty list.

Python 3 with NumPy, 125 bytes
import numpy
def golf(a):a=numpy.array(a);return(a[:-1]!=a[1:]).all()&(a[:,:-1]!=a[:,1:]).all()&(a[:,:,:-1]!=a[:,:,1:]).all()

Python 3, 146 128 bytes
e=lambda x,y:x!=y
z=lambda f:lambda*l:all(map(f,*l))
u=lambda f,g:lambda a:z(f)(a,a[1:])&z(g)(a)
golf=u(z(z(e)),u(z(e),u(e,id)))

Great, thank you! The test environment unfortunately did not contain NumPy, but the other solution works like a charm.

@ByteCommander if this is on your computer, opening terminal/cmd type pip install numpy.  Then try again after it finishes.

@EasterlyIrk No, it was an online challenge. I have no way to alter the environment.

@ByteCommander you should get python anyway.


text:
Box-256 Assembly - BIG SQUARE II
I'd like to start a series of challenges for http://box-256.com/ starting with the first challenge, “BIG SQUARE II”. After this one I'll add another for "CHECKERBOARD" and so on.

Rules:

Complete the BIG SQAURE II challenge in the Box-256 emulator (either on the website or download the program if you run Windows)
Post back here a screenshot of your working answer
You MUST include the code in plain text so that others can easily copy and very it’s operation.

Scoring:
The winner will be the least amount of instructions used (just the instruction calls, either by name or opcode, the arguments to them are not counted as JMP takes one argument but MOD can take three).
I think in the future contests we can add some additional bonus points for use of coding tricks and we could include the argument count too. I wanted to start basic to get the ball rolling.
Winning
I think we should put a stake in the ground and say two weeks from today we announce the winner(s, there maybe be mutliple entries with the same instruction count).

I'm confused It says BIGSQUARE in the title but you should solve BIGSQUARE2??

@CatsAreFluffy Thanks for pointing that out, I have amended the title. It should have been BIG SQUARE II since the first BIG SQUARE challenge is already solved on the box-256 homepage with a very efficient answer.

How about we score by memory rows?

Do we have to post a screenshot?

@CatsAreFluffy - I think we should, reason being is that it shows that you have the correct answer/code without anyone having to run it. Site users may wish to vote on you answer but probably don't want to have to check them all by hand?

Or enter them in manually. That shouldn't be too hard now, but I definitely wouldn't want to enter 128 bytes of packed data...

@CatsAreFluffy - I don't understand you most recent comment?

How else do you solve Mario?

@CatsAreFluffy You asked about uploading a screen shot and I responded, why are you talking about solving Mario?

@jwbensley please can you clairify the scoring. 1) will data lines with no instruction / opcode count towards the score? 2) will overlapping / misaligned code count as the number of instructions they actually execute or the number of lines they occupy?

@jwbensley 3) does executing empty memory / invalid instructions count towards the score? (e.g. if I leave off the final JMP at the end of the code and let the program execute the unused memory before returning to 00)

All good points, I have opened a Meta question so we can discuss in detail, we need to sort this out if we want to do more Box256 puzzles: http://meta.codegolf.stackexchange.com/questions/9012/how-to-score-box-256-answers

Isn't the goal to solve it in the fewest cycles? Or should that be if the challenge is fastest-code?

As per the link above, put your idea forward on the Meta link! :)

Please can you clarify the scoring (are we counting data lines as instructions) as the challenge is due to end within the next few hours and I'd like to change my answer if necessary.

Under the rules this question was originally asked, I have marked @orlp's question as "answer" / "winner". Under the meta question regarding scoring Martin Büttner's answer was the most favoured so for future questions I aks I will use that scoring method.

1 instruction
This solution is to illustrate that counting instructions is not a proper way of scoring for BOX-256.
JMP 002 072 00C
002 000 013 00C
001 00C 055 002
010 000 000 000
011 012 013 014
015 016 017 018
019 01A 01B 01C
01D 01E 021 022
023 024 025 026
027 028 029 02A
02B 02C 02D 02E
0D1 0D2 0D3 0D4
0D5 0D6 0D7 0D8
0D9 0DA 0DB 0DC
0DD 0DE 0E1 0E2
0E3 0E4 0E5 0E6
0E7 0E8 0E9 0EA
0EB 0EC 0ED 0EE
031 041 051 061
071 081 091 0A1
0B1 0C1 032 042
052 062 072 082
092 0A2 0B2 0C2
03D 04D 05D 06D
07D 08D 09D 0AD
0BD 0CD 0ED 03E
04E 05E 06E 07E
08E 09E 0AE 0BE
0CE 000 000 000

Do you need JMP 002?

@CatsAreFluffy Sadly it's not possible to directly set the instruction pointer in BOX-256 as an initial parameter, so you need an initial instruction.

Hmm...Well how do you get the plaintext version of the programs?

@orlp How did you come to the conclusion it's one instruction, from the original question:The winner will be the least amount of instructions used (just the instruction calls, either by name or opcode - You have used one instruction my name "JMP" and then many by opcode, have you not?

@CatsAreFluffy You can download the program as a windows executable and use CTRL+C/CTRL+V to copy paste to/from the editor to a notepad. See this URL: http://box-256.com/manual/

@jwbensley There is one by name (which I thought the scoring was), but the same program can be done with just 3 instructions by opcode (PIX, ADD, JMP), while hardcoding the coordinates (mind you - these are not instruction opcodes).

@orlp If you can do it in three I suggest you update your answer to show that, and then you'd take the lead on this challenge! For now (I am the person that has down voted your answer because it does not illustrate that counting instructions is not a proper way of scoring - because it seems you have misunderstood the scoring. Please correct me if I am wrong.

For clarification I would say you answer is currently 3 instrutions, JMP, 0x72 (PIX), 0x13 (ADD) and 0x55 (JMP again, but as with the first JMP it's the same JMP using @ operator, so it compiles to the same opcode).

JMP with @ ≠ JMP with 0 ≠ JMP with *

You need to include the data in the line count otherwise you can solve every Box256 problem with the same three-five lines of code by just varying the data.

@orlp can you beat (or match) 9 LOC if we score by LOC (as counted by Box256) instead of opcodes?

@impomatic Maybe, I haven't tried :) But LOC is still wrong. We should just score by bytes.

I think you should take a screenshot of the answer after executing it, not before.

8 instructions
My smallest solution to the Big Square II challenge is 8 lines of code. There's a simple loop which cycles through a table of 8 pixel locations.
; Big Square II in 0x08h instructions
; John Metcalf

PIX @18 002 000
ADD @16 @18 @18
MOV @18 @20 001
MOV @19 @18 008
FLP @16 @17 001
JMP @00 001 010
011 031 021 032
0D3 01D 0E3 01E

Welcome to Programming Puzzles & Code Golf! Since this challenge scores by number of instructions, please include your instruction count in the post. With some more text, perhaps an explanation, you should be able to add the code and pass the spam filter.

You really need to include the code. If the system isn't letting you, include a link to a GitHub Gist and a higher-rep user like myself can edit it in for you.

Thanks for the suggestion. I've added an external link to the code.

I edited in the code for you as well as the number of instructions (assuming I'm interpreting your code correctly as 9 instructions).

You can reply to people by using a @ sign and then their name, like @AlexA.

Going off of orlp's answer, I believe this is 5 instructions

This comment belongs on the original question or on @orlp.'s answer but I haven't got enough reputation to comment there. I believe the scoring should be restated as "the lowest lines of code as counted by the Box-256 emulator" so tables of data, hand-assembled instructions and misaligned instructions count towards the total.

@AlexA. I have a solution in 8 LOC now. Should I edit this answer or create a new one?

@impomatic You should edit this post with your new solution.

11 instructions, 12 lines
PIX 011 002 000
ADD @01 @2C @01
ADD @03 001 @03
JGR 00D @03 @00
MOV 000 @03 000
ADD @06 001 @06
JGR 030 @06 @00
MOV 022 @01 000
MOV 02C @06 000
MOV 00B @0D 000
JMP @00 000 000
001 010 -01 -10

Any bonus for self-modification?
(Note the differences between the memory and the command line, specifically in locations @01 @06, @0D.)

I think my answer is probably what you were suggesting @orlp ?
I've used 3 instrutions, PIX, ADD and JMP, the rest are the co-ordinates (however the instructions and coordinates are spaced out below for easier reading):
000 000 000 000
000 000 000 000
PIX @2C 002 000
ADD 001 @09 @09
JMP @08 000 000
000 000 000 000
000 000 000 000
000 000 000 000
000 000 000 000
000 000 000 000
000 000 000 000
011 012 013 014
015 016 017 018
019 01A 01B 01C
01D 01E 021 022
023 024 025 026
027 028 029 02A
02B 02C 02D 02E
031 032 03D 03E
041 042 04D 04E
051 052 05D 05E
061 062 06D 06E
071 072 07D 07E
081 082 08D 08E
091 092 09D 09E
0A1 0A2 0AD 0AE
0B1 0B2 0BD 0BE
0C1 0C2 0CD 0CE
0D1 0D2 0D3 0D4
0D5 0D6 0D7 0D8
0D9 0DA 0DB 0DC
0DD 0DE 0E1 0E2
0E3 0E4 0E5 0E6
0E7 0E8 0E9 0EA
0EB 0EC 0ED 0EE

Yes, this is why I don't think counting instructions is a good idea.

@orlp - Can you expand a bit more on why? I want to gather up all the feedback from this question/challenge to make the next one better.

Big data tables rake 3 instructions but many more bytes, but the 9 instruction solution spends around 8 bytes on tables.

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


text:
In-between fractions
In-between fractions
The challenge:
You will need to create code that takes atleast 3 inputs; 2 integers and "a fraction representation" - whichever type suits your language for representing the fraction increments) ie. If you choose string the input would be "1/4" or you could choose 2 extra integer inputs or a tuple or w/e.
Input can be anywhere reasonable (STDIN, function arguments, from a file, etc.), and so can output (STDOUT, function return value, to a file, etc.)
Rules:

The input "fraction" will always be a valid fraction, less than 1; example "1/4"
The second input integer will always have a higher value than the first integer. I.E the first input integer will always have a lower value than the second.
The input integers can be negative.
Outputted fractions should be reduced as much as possible (simplified)

The code will need to output every "fraction step" between the 2 numbers in increments of the input fraction.
The code should be a program or function as stated here
Example 1:
Input: -2,3,"1/2"
Output:
 -2
 -3/2
 -1
 -1/2
  0
  1/2
  1
  3/2
  2
  5/2
  3

Example 2:
Input: 1,2,"2/3"
Output:
1
5/3
2

or
1
4/3
2

Note: Counting can start from either direction (thank you @Mego)
This is code-golf, so the shortest answer in bytes wins.

Could the fraction be taken as 2 integer inputs, making 4 total inputs?

I think ill keep the restraint of maximum of 3 inputs - I would like to see the code for 4 inputs aswell

In that case, what about having a list/tuple/array/some other iterable type containing two integers for the third input? That's not fundamentally different than 4 integer inputs. You should also clarify that the fraction will not be equal to 0.

@Mego After thinking it through, I can't see why it shouldn't be allowed
Changed to "code that takes atleast 3 inputs"

It seems that the rule 4 is the only critical point (for languages that don't have a native fraction or rational type)

@edc65 I agree... I thought it to be harder tbh. (next ill create a similar challenge, but restrict answers to not rely on internal fraction features of certain languages :) - on the other hand, it's nice not to see a plethora of cjam answers < 3 bytes :)

Can you clarify what constitutes "a fraction representation"? I took this to mean two distinct values expressing the numerator and denominator, but would this include a numeric expression, such as btw(-2, 3, 1/2) where 1/2 automatically evaluates to 0.5? (Even if this is the case I would still expect output to be num / den.)

Is inbetween supposed to be 2 words, in between? I usually see it separated.

@beaker as long as the output is correct and the input comes from atleast 2 integers, the rest is up to you :) - i've kept the input part pretty openended, to see different answers

You should change the first example input to be -2,3,"3/6"

Can c be a symbolic variable? That is a data type used for symbolic computations

Octave, 34 30 bytes
@(a,b,c)rats(union([a:c:b],b))

Now takes the fraction as a numeric expression rather than separate numerator and denominator.
Sample on ideone

So why can't you use @(a,b,c)rats(union([a:c:b],b))?

@LuisMendo I can if mathematical expressions are acceptable inputs (the effective result of 1/2 as a numeric rather than string input), but that's not the way I interpreted "a fraction representation". If the OP agrees, I'll be glad to shave off 4 bytes.

Oh, I see. Well, I'm using that in my Matlab answer. So does the Mathematica answer apparently, unless "rational number" is a specific data type

@beaker i did actually respond

@VisualBean Code already updated.

@LuisMendo Code updated.

Mathematica, 16 bytes
Range@##⋃{#2}&

An unnamed function that takes two integers and a rational number and returns a list of numbers, e.g.:
Range@##⋃{#2}&[-2, 3, 1/2]
(* {-2, -(3/2), -1, -(1/2), 0, 1/2, 1, 3/2, 2, 5/2, 3} *)

Mathematica's Range does exactly what the challenge asks, except that it omits the upper bound if the difference between lower and upper bound isn't exactly a multiple of the step size. Therefore we take the Union (using ⋃) with the list containing only the upper bound which ensures that it appears exactly once. Note that Union will sort the result but we want it sorted anyway, since the step size is always positive. Also since we're working with rationals, they're automatically reduced as much as possible.

T-SQL 2012+, 831 535 477 270 246 240 219 bytes
Please note this is a one liner - sql doesn't have build in function to reduce the fraction.
May not be the best language for this type of question. It is human readable(kind of - compared to some of the other languages).
DECLARE @f INT=-5,@t INT=3,@n INT=3,@ INT=8;

WITH C as(SELECT
top((@t*@-@f*@)/@n+1)ROW_NUMBER()OVER(ORDER BY @)M
FROM sys.messages)SELECT(SELECT
IIF(V%@=0,LEFT(V/@,9),CONCAT(V/MAX(M),'/',ABS(@)/MAX(M)))FROM c
WHERE V%M=0AND @%M=0)FROM(SELECT
@f*@+@n*~-M V FROM c)k

Try it online

Isn't the language called T-SQL, and not "Sqlserver"?

@DavidConrad the language is TSQL, but there are different versions of sqlserver and the TSQL for this will work for sqlserver 2012 because of the keyword IIF. Which would use the keyword CASE in older versions. Added your suggestion

Good Job.  You can save a few by changing either @n or @d to plain @.  Your CTE query for N could be N AS(SELECT N FROM(VALUES(1),(1),(1),(1),(1),(1),(1),(1),(1),(1))M(N)) or N AS(SELECT 1N FROM sys.all_views).  Given that there is almost guaranteed to be a few hundred in this view, you could reduce the cross joins as well.  ISNULL is shorter than COALESCE and should work

@MickyT thanks to your suggestions and a few of my own, I managed to reduce the length by 296 bytes,

Great work there

Python 2, 81 bytes
from fractions import*
a,b,c=map(Fraction,input())
while a<b:print a;a+=c
print b

Try it online

Ruby, 32 54 48 bytes
->a,b,c{(a..b).step(c){|x|p x%1>0?x:x.to_i};p b}

This solution is based on Mego's Python answer and assumes that c will always be a Rational, Ruby's fraction format. Try it online!
Edit: Fixed a bug where integers weren't presented like integers. -6 bytes thanks to Not That Charles and MegaTom.
The functions are called in this way:
> f=->a,b,c{(a..b).step(c){|x|p x%1>0?x:x.to_i};p b}
> f[1,4,Rational(2,3)]
1
(5/3)
(7/3)
3
(11/3)
4

(3/1) should not be simply 3?

The simplest Rational form of 3 in Ruby is (3/1)

.step(b,c).map should reduce the byte count here

(a==a.to_i) can be a%1==0 for -4 bytes.

-2,3,1/2r (example 1) prints the last 3 twice.

Switching to (a...b) should probably fix the test case for example 1 at the cost of +1 byte.

Haskell, 31 26 bytes
f a b c=min[b]$a:f(a+c)b c

Lazy evaluation FTW!  Demo:
*Main> import Data.Ratio
*Main Data.Ratio> f (-2) 3 (1%2)
[(-2) % 1,(-3) % 2,(-1) % 1,(-1) % 2,0 % 1,1 % 2,1 % 1,3 % 2,2 % 1,5 % 2,3 % 1]
*Main Data.Ratio> f 1 2 (2%3)
[1 % 1,5 % 3,2 % 1]

(I was initially tempted by Haskell’s [a,a+c..b] notation, but it has some quirks that necessitate something like f a b c|l<-[a,a+c..b-c/2]=l++[b|last l<b] for 41 bytes or f a b c=[x|x<-[a,a+c..],x<b]++[b] for 33.)

I like your solution! However I think you need to include import Data.Ratio in your byte count too, I think you cannot use f without that, right?

@flawr: nice edge case: you don't need Data.Ratio for f itself, because it's polymorphic for all numeric types. However, when you want to call it with values of type Ratio, then you need the import. The challenge only requires to "create code that ...", not to use it. I think it's fine without the import.

More precisely, you only need the import for the % operator to create the test fractions 1 % 2 and 2 % 3. I’m not cheating here: you can really put those 26 bytes in a file by themselves, run the interpreter on that module, and have the interaction I displayed.
(You could even avoid typing import Data.Ratio in the demo interaction, if you instead spell % as Data.Ratio.%.)

MATL, 16 15 bytes
3$:3Gvu9X10ZGZD

This may fail for very large denominators. I hope output format is acceptable.
Try it online!
3$:    % take three inputs and generate range
3G     % push third input again
v      % vertically concatenate. Gives vertical array as output
u      % get unique elements (i.e. remove the last one if it is repeated)
9X1    % predefined literal 'rat'
0ZG    % set rational format
ZD     % display using that format

Matlab with Symbolic Toolbox / Octave with SymPy, 27 bytes
Thanks to @sanchises for pointing out an error, now corrected
@(a,b,c)sym(union(a:c:b,b))

This is an anonymous function. To call it, assign it to a variable or use ans.
Example:
>> @(a,b,c)sym(union(a:c:b,b))
ans =
    @(a,b,c)sym(union(a:c:b,b))
>> ans(-2,3,1/2)
ans =
[ -2, -3/2, -1, -1/2, 0, 1/2, 1, 3/2, 2, 5/2, 3]

This does not conform to the spec, since the upper bound is not always included (try example 2).

@sanchises Thanks! Corrected now

And also, I think for c you can use, I quote, whichever type suits your language for representing the fraction increments [...] or w/e. I think it's pretty clear that symbolic is a logical and allowed (@VisualBean might want to confirm this) choice. The result of the colon operator is then 'upgraded' to a symbolic array, which means you can get rid of the sym() call altogether.

@sanchises Thanks, I've asked for clarification

Julia, 14 bytes
f(a,b,c)=a:c:b

This is similar to the Mathematica answer, except that Julia's ranges are already in the desired format, so it is even shorter. Also returns a collection of numbers. Example output:
11-element StepRange{Rational{Int64},Rational{Int64}}:
 -3//1,-5//2,-2//1,-3//2,-1//1,-1//2,0//1,1//2,1//1,3//2,2//1

Note that the integers are displayed with 1 in the denominator, and a double-slash is used for fractions. To get the output exactly as defined in the question requires some more code:
f(a,b,c)=map(x->println(x.num,x.den<2?"":"/$(x.den)"),a:c:b)

Javascript, 108 90 86  81 bytes
(a,b,n,d)=>{var s="";for(a=a*d;a<b*d;a+=n)s+=(a%d?a+"/"+d:a/d)+" ";s+=b;return s}

An anonymous function. After assignment to a named variable with white space:
var f=(a,b,n,d)=>
{ var s="";
  for(a=a*d; a<b*d; a+=n)
    s+= (a%d ? a + "/" + d : a/d) + " ";
  s+=b;
  return s
}

Test examples:
console.log(f(1,2,1,8)); //writes:
1 9/8 10/8 11/8 12/8 13/8 14/8 15/8 2

console.log(f(-3,3,4,7)); // writes:
-3 -17/7 -13/7 -9/7 -5/7 -1/7 3/7 1 11/7 15/7 19/7 3

An imperative approach using javascript, no recursion, library or functional programming.

Smalltalk – 89 bytes
For once Smalltalk is almost competitive!
Number extend[p:e q:i[|h|self to:e by:i do:[:x|h:=x. x printNl].h=e ifFalse:[e printNl]]]

Call like this:
> 2 p:5 q:1/2
2
5/2
3
7/2
4
9/2
5

> 1 p:2 q:2/3
1
5/3
2

R - 71 bytes
Assumes you have already installed the MASS package
f=function(x,y,z)MASS::fractions(union(seq(x,y,eval(parse(text=z))),y))

> f(1, 2, '1/3')
[1]   1 4/3 5/3   2
> f(2, 5, '1/2')
[1]   2 5/2   3 7/2   4 9/2   5

Pyret, 56 bytes
{(b,e,n,d):link(e,map(_ / d,range(b * d, e * d))).sort()}

Takes in beginning (b), end (e), numerator (n), and denominator (d). Creates a range of integers, divides those through and appends the end to the list (by linking and then sorting).