# Rosetta Stone Challenge: Find the rule for a series

The goal of a Rosetta Stone Challenge is to write solutions in as many languages as possible. Show off your programming multilingualism!

# The Challenge

Your challenge is to implement a program that will input a list of numbers and output the rule used to generate each successive number in the series, in as many programming languages as possible. You are allowed to use any sort of standard library function that your language has, since this is mostly a language showcase.

## What is a "series?"

A series is an ordered list of integers. Each successive number in the series can be generated by applying a simple rule to the previous number in the series. In this challenge, the rule consists of multiplying the number by a constant, and then adding a second constant. Both of the constants can be any integer. The goal of this challenge is to output those two constants.

For the series 2 5 11, the rule can be written as 2 1. This means that each number is the previous number, times 2, plus 1. An important fact is that most series have exactly one rule. Some series have either an infinite number or none at all, but you will not have to deal with this.

## Input

Input will be a list of three different integers which are the numbers in the sequence. The numbers can be either space, comma, or newline delimited, but please specify which. I am going to be flexible on this limitation because certain languages may have input restrictions. Here are four examples of input:

0 7 14
2 5 11
2 0 -4
5 -19  77


## Output

Output will be two integers which represent the rule used to generate the series. The first number will be the multiplicative constant, while the second number will be the additive constant. The formatting of the output can be space, comma, or newline delimited. I am flexible on this limitation as well. Here are the corresponding examples of output:

1 7
2 1
2 -4
-4 1


# The Objective Winning Criterion

As for an objective winning criterion, here it is: Each language is a separate competition as to who can write the shortest entry, but the overall winner would be the person who wins the most of these sub-competitions. This means that a person who answers in many uncommon languages can gain an advantage. Code-golf is mostly a tiebreaker for when there is more than one solution in a language: the person with the shortest program gets credit for that language.

## Rules, Restrictions, and Notes

Your program can be written in any language that existed prior to April 9th, 2012. I will also have to rely on the community to validate some responses written in some of the more uncommon/esoteric languages, since I am unlikely to be able to test them.

This section will be periodically updated to show the number of languages and who is leading in each.

• AWK (32) - mellamokb
• bash (38) - mellamokb
• Befunge (29) - Howard
• bc (39) - kernigh
• brainfuck (174) - CMP
• C (78) - l0n3_shArk
• Common Lisp (88) - kernigh
• csh (86) - kernigh
• dc (30) - kernigh
• DOS BATCH (55) - mellamokb
• Element (27) - Howard
• es (95) - kernigh
• Factor (138) - kernigh
• Fortran (90) - Howard
• Go (101) - Howard
• GolfScript (16) - Howard
• J (23) - Gareth
• Java (141) - Howard
• JavaScript (47) - mellamokb
• Lua (68) - Howard
• Owl (22) - r.e.s.
• Perl (57) - Gareth
• PHP (62) - mellamokb
• PicoLisp (74) - kernigh
• Piet (82) - CMP
• PostScript (61) - Howard
• Python (40) - Howard
• Q (36) - tmartin
• QBasic (34) - mellamokb
• R (50) - r.e.s.
• Ruby (44) - Howard
• Scala (102) - Gareth
• SQL (57) - Aman ZeeK Verma
• TI-83 BASIC (41) - mellamokb
• Unlimited Register Machine (285) - Paxinum
• VBA (57) - Gaffi
• Whitespace (123) - r.e.s.
• zsh (62) - kernigh

# Current User Rankings (courtesy of mellamokb)

1. Howard (10): Befunge (29),Element (27),Fortran (90),Go (101),GolfScript (16),Java (141),Lua (68),Python (40),Ruby (44),PostScript (61)

2. kernigh (8): bc (39),Common Lisp (88),csh (86),dc (30),es (95),Factor (138),PicoLisp (74),zsh (62)

3. mellamokb (7): AWK (32),bash (38),DOS BATCH (55),JavaScript (47),PHP (62),QBasic (34),TI-83 BASIC (41)

5. Gareth (3): J (23),Perl (57),Scala (102)

6. r.e.s. (3): Owl (22),R (50),Whitespace (123)

7. CMP (2): brainfuck (174),Piet (82)

8. l0n3_shArk (1): C (78),

9. tmartin (1): Q (36)

10. Paxinum (1): Unlimited Register Machine (285)

11. Gaffi (1): VBA (57)

12. Aman ZeeK Verma (1): SQL (57)

-
It doesn't look like people actually read the tags, or other descriptions... – leftaroundabout Apr 9 '12 at 17:35
@leftaroundabout: Why do you say that? I am aware (for instance) that my solution doesn't take array input and plan to fix it later. And I'm too lazy to post more than one solution at the moment :) According to the Object Winning Criterio, code-golf is the tie-breaker for two posts with the same language, hence I've included the character count for easy reference in case someone else posts a JavaScript solution. This may in fact be one of those rare moments when a question deserves both the code-golf and code-challenge tags. – mellamokb Apr 9 '12 at 17:36
Yeah, you're right: someone has to do the not-unusual languages as well. – leftaroundabout Apr 9 '12 at 18:02
As long as you keep the Current Leaderboard in the same standard format as above, you can use this to generate each user's scores: jsfiddle.net/bk2WM/2 – mellamokb Apr 10 '12 at 14:43
My newest version (jsfiddle.net/bk2WM/4) provides a raw output (in the textarea) you can copy/paste into a post, and formats it like I did in my post. Feel free to change/play with the layout. – mellamokb Apr 11 '12 at 14:26

~1$- 1$3$-/.p@*-  Input is given as space-separated list. ### JavaScript, 56 characters p=prompt;x=alert;a=p();b=p();x(m=(p()-b)/(b-a));x(b-a*m)  Input is given on prompt. ### Ruby, 44 characters a,b,c=eval("[#{gets}]");m=c-b;p m/=b-a,b-m*a  Input is here given as comma-separated list. ### Python, 40 characters a,b,c=input();m=c-b;m/=b-a;print m,b-m*a  Input is again comma-separated. ### Java, 141 characters enum E{E;static int s(){return new java.util.Scanner(System.in).nextInt();}{int a=s(),b=s(),m=s()-b;m/=b-a;System.out.print(m+" "+(b-a*m));}}  Input separated by newline. ### Lua, 51 characters r=io.read a,b=r(),r() m=(r()-b)/(b-a) print(m,b-m*a)  Input separated by newline. ### Go, 101 characters package main import"fmt" var a,b,c int func main(){fmt.Scan(&a,&b,&c) c-=b c/=b-a fmt.Print(c,b-a*c)}  Input separated by newline. ### Fortran, 90 characters  PROGRAM X READ(*,*)I,J,K K=(K-J)/(J-I) WRITE(*,*)K,J-I*K END  Input separated by newline. ### Befunge, 29 characters &01p&:11p:&-01g11g-/:.01g*-.@  ### PostScript, 61 characters 2 5 14 1 index sub 1 index 3 index sub idiv dup = 3 2 roll mul sub =  ### Owl, 23 characters <%<%<$-14'-/%.32)2'*-.


Input separated by newline.

### Element, 27 characters

_-a;_3:'-_+"a~+/2:a~*+\ 


Input separated by newline.

-
Shameless heist of my JavaScript solution ;) – mellamokb Apr 9 '12 at 19:33
Well two can play this game... :P – mellamokb Apr 9 '12 at 22:31
@mellamokb Nice one. But I did already upvote your answer ;-) So what's left for us: beat the 48 characters... – Howard Apr 10 '12 at 4:01
Wow, you golfed in my language. I feel honored. I also feel obligated to beat you. :) – PhiNotPi Apr 11 '12 at 19:50
About your Element solution, it appears that the last  mark isn't needed. Is this an error on your part or an error in my interpreter that I posted on Pastebin? Oh, and I have a 27 character solution. – PhiNotPi Apr 11 '12 at 22:17

## Brainfuck - 174

,>,>,<[>->+>+<<<-]>>>[<<<+>>>-]<<<<[>>>->+<<<<-]>>>>[<<<<+>>>>-]<<[->-
[>+>>]>[+[-<+>]>+>>]<<<<<]>>>[<<<+>>>-]<[-]<[-]<.[>>+<<-]>>[<<<<[>>+>+
<<<-]>>>[<<<+>>>-]>-]<<[<->-]<.


## Piet - 82?

Not sure how to measure competitive golf here. I'm gonna go with total image size (in codels) Mine is 41x2:

## Befunge - 34

&00p&10p&10g-10g00g-/:.00g*10g\-.@


## English - 278

The multiplier is the quotient of the difference of the second
and third values and the second and first values.
To generate a new term, multiply the current term by the multiplier
and add the difference of the first value and the product of the
multiplier and the second value.


Not sure if this counts, but thought I'd give it a shot. It is remarkably difficult to describe even a simple algorithm accurately. Kinda wish English supported some kind of grouping symbol to establish precedence.

-
Link me to an interpreter (a complete one that understands the entire language, and is not just geared towards solving this problem) and I may accept it. – PhiNotPi Apr 10 '12 at 19:37
ummm, bit.ly/IiPCxa ? – CMP Apr 11 '12 at 2:10
It's ok, another person has written a mathematical proof in LaTeX. It didn't count, but adds to the variety. – PhiNotPi Apr 11 '12 at 2:13

## QBasic, 42

INPUT "",a,b,c
m=(c-b)/(b-a)
PRINT m;b-m*a


Requires input with commas, outputs with spaces (is this ok?)

## Mercury, 319

:-module r.
:-interface.
:-import_module io,list,int,char,string.
:-pred main(io::di,io::uo)is det.
:-implementation.


f[a,b,c]|m<-(c-b)div(b-a)=[m,b-m*a]


Now inputs with spaces, outputs with newlines.

## C, 80

main(a,b,c,m){scanf("%d %d %d",&a,&b,&c);m=(c-b)/(b-a);printf("%d %d",m,b-m*a);}


## C++, 96

#include<iostream>
main(){int a,b,c,m;std::cin>>a>>b>>c;m=(c-b)/(b-a);std::cout<<m<<' '<<b-m*a;}


## Nimrod, 146

import strutils
var
q:array[0..3,int]
b,m:int
b=q[1]
m=(q[2]-b)div(b-q[0])
echo($m,",",$(b-m*q[0]))


Input w/ newlines, output comma.

This one won't count, but I feel it still fits in in some way:

## Mathematical theorem, 713 characters of LaTeX

\documentclass{article}\usepackage{amsmath}\usepackage{amsthm}\begin{document}Theorem: for a sequence $(a_i)_i$ of integers with $a_2\neq a_1$ where $a_3-a_2$ is divisible by $a_2-a_1$, $m:=\frac{a_3-a_2}{a_2-a_1},\ p:=a_2-m\cdot a_1$ give rise to a sequence$b_i:=\begin{cases}a_1&\text{for }i=1\\b_{i-1}\cdot m+p&\text{else}\end{cases}$ such that $b_i=a_i\ \forall i\leq 3$.

Proof: $i=1$ is trivial,\begin{aligned}b_2=&b_1\cdot m+p=a_1\frac{a_3-a_2}{a_2-a_1}+a_2-\frac{a_1a_3-a_1a_2}{a_2-a_1}=a_2,\\b_3=&b_2\cdot m+p=\frac{a_2a_3-a_2^2}{a_2-a_1}+a_2-\frac{a_1a_3-a_2^2}{a_2-a_1}\\=&\frac{a_2a_3-a_1a_3+(a_2-a_1)a_2-a_2^2+a_1a_2}{a_2-a_1}\\=&\frac{a_2-a_1a_3+0}{a_2-a_1}=a_3.\end{aligned}\qed\end{document}


While we're at writing := definitions...

## Pascal, 90 88

program r;var a,b,c:integer;begin;read(a,b,c);c-=b;c:=c div(b-a);write(c,' ',b-c*a);end.


## Cuda, 301

#include<stdio.h>
main(){int p[3],*q;scanf("%d%d%d",p+2,p,p+1);cudaMalloc(&q,24);cudaMemcpy(q,p,24,cudaMemcpyHostToDevice);r<<<1,1>>>(q);cudaMemcpy(p,q,24,cudaMemcpyDeviceToHost);printf("%d %d",p[1],*p);}

-
You can save two chars in the C solution by eliminating m and reusing c, and another two by using c-=b;c/=b-a; instead of c=(c-b)/(b-a);. – Peter Taylor Apr 10 '12 at 11:46

## AWK, 35 characters

{m=($3-$2)/($2-$1);print m,$2-$1*m}

• Input format: 2 0 -4

## bc, 39 characters

define f(a,b,c){
m=(c-b)/(b-a)
m
b-a*m}

• Input format: z=f(2, 0, -4)
• The input is a bc expression. After bc reads the source file, it reads the standard input. This is why the input must look like a function call.
• I use OpenBSD bc, which requires a newline after the {.

## Common Lisp, 88 characters

(let*((a(read))(b(read))(c(read))(m(/(- c b)(- b a))))(format
t "~A ~A" m (- b(* a m))))

• Input format: 2 0 -4

## csh, 86 characters

set i=(cat)
@ m=($i[3] -$i[2]) / ($i[2] -$i[1])
@ n=$i[2] -$i[1] * $m echo$m $n  • Input format: 2 0 -4 • The 86th character is newline at end of file. csh is the only language for which I count newline at end of file. This is because csh never runs the last command unless newline is there. • set i=($<) does not work, because $< has no word splitting. ## dc, 30 characters ?scsbsalclb-lbla-/psmlblalm*-p  • Input format: 2 0 _4, where _ is the underscore. ## es, 95 characters i=(cat) b=$i(2)
m={expr $$i(3) - b$$ / $$b - i(1)$$}
echo $m {expr$b - $i(1) \*$m}

• Input format: 2 0 -4
• es is the extensible shell by Paul Haahr and Byron Rakitzis.

## Factor, 138 characters

USING: eval formatting io kernel locals math ;
contents eval( -- a b c ) [let :> ( a b c )
c b - b a - / dup a * b swap - "%d %d" printf ]

• Input format: 2 0 -4

## PicoLisp, 74 72 characters

(in()(let(r read a(r)b(r)c(r)m(/(- c b)(- b a)))(print
m (- b(* a m)))))

• Input format: 2 0 -4
• EDIT: Lost 2 characters by changing a(read)b(read)c(read) to r read a(r)b(r)c(r).

## TI-83 BASIC, 63 61 characters

:Input A
:Input B
:Input C
:(C-B)/(B-A)→M
:Disp M
:Disp B-A*M

• Input format: 2 ENTER 0 ENTER ¯4 ENTER, where ¯ is the calculator's unary minus.
• I counted Unicode characters; → (the right arrow) counts as U+2192. For example, the calculator counts Input A as 2 characters, but I count Input A as 7 characters. I also count : as 1 character.
• EDIT: I miscounted: there are 61, not 63, characters.

## zsh, 62 characters

i=(cat)
((b=i[2],m=(i[3]-b)/(b-i[1]),n=b-i[1]*m))
echo $m$n

• Input format: 2 0 -4
-

## AWK (32)

{m=$3-$2;print m/=$2-$1,$2-$1*m}


## bash (38)

awk '{m=$3-$2;print m/=$2-$1,$2-$1*m}'


## DOS/BATCH (54 55)

set/a m=(%3-%2)/(%2-%1)&set/a n=%2-%m%*%1&echo %m% %n%


Takes parameters as space-separated list of arguments.

## Java (143 185)

enum R{R;{int a=0,b=0,c,i=2;for(;(c=new java.util.Scanner(System.in).nextInt()+b*--i)+i>=c;b=c)a+=c*i;c/=b-a;System.out.print(c+" "+(b-a*c));}}

## JavaScript (48 6167)

p=prompt;m=p(b=p(a=p()))-b;alert([m/=b-a,b-a*m])


​ Demo: http://jsfiddle.net/BT8bB/6/

## PHP (61 77)

<?list(,$a,$b,$c)=$argv;$c-=$b;echo($c/=$b-$a).' '.$b-=$c*$a;


## QBasic (34)

INPUT a,b,c
m=(c-b)/(b-a)
?m;b-m*a


## TI-83 Basic (41)

:Prompt A,B,C
:(C-B)/(B-A→M
:Disp M,B-A*M


Yes, the missing right parenthesis is on purpose. It's a well-known optimization technique that closing the parentheses before a STO operation is not necessary in TI-83 Basic programming.

-
The JS one doesn't work for me in Firefox - I get an error that p is undefined. Does the JS spec say that function arguments should be evaluated before the function is resolved? – Peter Taylor Apr 12 '12 at 14:26
Hmm. Yes you are correct. According to the spec, it should not work, as explained in this similar SO question: stackoverflow.com/questions/9941736/…. The functions are supposed to be bound before their arguments are evaluated, and Chrome apparently does it in reverse order. – mellamokb Apr 12 '12 at 15:39
I've tried long and hard to beat the highest Java solution by a completely different approach you can see above. 143 is the closest I've been able to get. Anyone have any ideas, please send my way! – mellamokb Apr 12 '12 at 18:52

## Whitespace, 123





I/O is newline-separated. (To obtain the source code, enter edit mode and copy the whitespace between the preformat tags; or, see the online example at Ideone.)

Explanation, where S,T,L represents Space,Tab,Linefeed:

Pseudocode     Whitespace
----------     ----------
push 0         SS SSL
push 1         SS STL
push 2         SS STSL
dup            SLS
retr           TTT
push 1         SS STL
retr           TTT
-              TSST
push 1         SS STL
retr           TTT
push 0         SS SSL
retr           TTT
-              TSST
/              TSTS
dup            SLS
outn           TLST
push 10        SS STSTSL
outc           TLSS
push 0         SS SSL
retr           TTT
*              TSSL
push 1         SS STL
retr           TTT
swap           SLT
-              TSST
outn           TLST
exit           LLL


## R, 50

x=scan(n=3);y=diff(x);z=y[2]/y[1];c(z,x[2]-x[1]*z)


I/O is space-separated.

## Owl

---22---

< <%<-22-/%.10)2'*-.


I/O is newline-separated.

---19--- (if this version is allowed; but I think it's cheating, since the \ is executable code):

1-13-/%.32)2'*-.


I/O is space-separated. Command-line usage: owl prog 5 19\ 77 (the \ acts as a postfix unary minus in Owl).

-
 With your Owl entry, I can suspend judgement of your 19 char solution since your 22 char solution is already winning for the language. – PhiNotPi Apr 13 '12 at 18:34

## J, 23 characters

(],1{x-0{x*])%~/2-/\x=:


Usage:

   (],1{x-0{x*])%~/2-/\x=: 5 _19 77
_4 1


Negative numbers are represented by underscores in J.

## PHP, 88 characters

<?php
list($x,$y,$z)=split(' ',fgets(STDIN));$a=($z-$y)/($y-$x);
echo$a." ".($y-$a*$x);


## Scala, 102 characters

val x=readLine.split(" ").toList.map(_.toInt)
val a=(x(2)-x(1))/(x(1)-x(0))
print(a+" "+(x(1)-x(0)*a))


s!(.+) (.+) (.+)!$a=($3-$2)/($2-$1);$a." ".($2-$1*$a)!e  Requires the '-p' option, for which I have added 2 characters. Assumes that the input is valid to save some characters. All my answers take space separated numbers. -  About J programs ... Is input allowed to be coded directly in the source file instead of prompting it from the user? – r.e.s. Apr 13 '12 at 16:23 @r.e.s. I've given it just the way I would invoke it on the command line. Adding 1!:1]3on the right of the expression will read the input from STDIN. I think there has been discussion on meta or in comments to some J answers over whether this should be allowed or not. I'm somewhat ambivalent - I enjoy figuring out how to get J to do what I want in the smallest space, I'll take the 6 character penalty for input from STDIN if that's what everyone wants. – Gareth Apr 13 '12 at 16:50 I was thinking that if it's allowed for J, then some other entries might be shortened in a similar way. (BTW, I couldn't get your suggested expression to work, but (],1{x-0{x*])%~/2-/\x=:".1!:1]1 seems ok in console mode.) – r.e.s. Apr 13 '12 at 17:02 @r.e.s. Oh yeah, I forgot to convert from a string to a list of numbers (though the 3 at the end normally works ok for me?) – Gareth Apr 13 '12 at 17:07 ## PHP, 74,72,69 <?fscanf(STDIN,'%d%d%d',$a,$b,$c);echo($d=($c-$b)/($b-$a)).' '.($b-$d*$a);


When input is passed as arguments:

<?echo($d=($argv[3]-$argv[2])/($b=$argv[2]-$a=$argv[1])).' '.($b-$d*$a);


Now, as @mellamokb suggested, using $n=$argv:

<?$n=$argv;echo($d=($n[3]-$n[2])/($b=$n[2]-$a=$n[1])).' '.($b-$d*$a);


## C, 77,78

main(a,b,c,d){printf("%d %d",d=(c-b)/(b-a),b-d*a,scanf("%d%d%d",&a,&b,&c));}


^ doesn't work so, here's the stuff: [thanks to @ugoren for bringing it to notice]

main(a,b,c,d){printf("%d %d",d,b-a*(d=(c-b)/(b-a)),scanf("%d%d%d",&a,&b,&c));}

-
+1 Wow, didn't know you could fscanf and scanf without spaces. Awesome! – mellamokb Apr 10 '12 at 15:41
@mellamokb, Thanks! – l0n3_sh4rk Apr 10 '12 at 15:45
In your second PHP solution, couldn't you save a few more characters by renaming $argv, i.e., $n=$argv at the beginning? – mellamokb Apr 10 '12 at 19:24 @mellamokb- yeah! I didn't think about that! thanks! :) – l0n3_sh4rk Apr 11 '12 at 8:30 From what I can tell, this just arbitrarily "happens" to work in most environments (ex: ideone.com/I2cPg), but the order of parameter evaluation in C is undefined behavior, and so technically shouldn't be relied upon: orangejuiceliberationfront.com/… – mellamokb Apr 11 '12 at 13:27 show 3 more comments DOS-BATCH (98) @ECHO OFF&SET/P p=&SET/P q=&SET/P r=&SET/A m=(%r%-%q%)/(%q%-%p%)&SET/A n=%q%-%p%%m%&ECHO %m% %n% Input in separate lines bash 51  m=$((($3 -$2)/($2 -$1))) echo $m$(($2 -$m
$1)) Example : sh prog.sh 2 0 -4 (space separated arguments) perl 84 @s=split(/ /,<STDIN>);$m=($s[2]-$s[1])/($s[1]-$s[0]);print $m." ".($s[1]-$s[0]*$m);

JAVA 297
import java.util.*;public class A{public static void main(String a[]){StringTokenizer s=new StringTokenizer(new Scanner(System.in).nextLine());int i=4;int[] p=new int[i];while(i-->1)p[3-i]=Integer.parseInt(s.nextToken());p[3]=(p[2]-p[1])/(p[1]-p[0]);System.out.print(p[3]+" "+(p[1]-p[0]*p[3]));}}

Space separated input, space separated output.

SQL 57
 select (&3-&2)/(&2-&1),&2-((&3-&2)/(&2-&1)*&1) from dual 
This is a sad entry, but 'just' solves the purpose. The query binds input at runtime 1,2,3 are variables in order of input.

-
 Even though others have already beat your bash solution, I just wanted to suggest you could have removed all those extra spaces and saved 6 characters. – mellamokb Apr 12 '12 at 12:53 Thanks mellamokb, I did realize that, I just sort of ignored it later. Also, I hate myself of not thinking your dos/batch solution, that should have clicked my head..args ahh! – Aman ZeeK Verma Apr 12 '12 at 15:04

### bash (42 chars)

Pure bash:

((m=($3-$2)/($2-$1),c=$2-m*$1));echo $m$c


### bash (31 chars)

Shelling out to something else:

owl -p"<%<%<\$-14'-/%.32)2'*-."


(Based on Howard's OWL implementation)

-

This is (non-optimized) code for the unimited register machine, described here: http://www.proofwiki.org/wiki/Definition:Unlimited_Register_Machine

The input should be in register 1,2 and 3, and the output will be in register 1, 2 after the program is done. Non-negative and non-integer numbers are not handled, but inputs 0,7,14 and 2,5,11 are handled correctly.

 Zero[8] Trans[2,11] Jump[3,11,7] Succ[11] Succ[8] Jump[11,11,3] Zero[5] Trans[1,12] Jump[2,12,13] Succ[12] Succ[5] Jump[12,12,9] Zero[17] Trans[8,13] Jump[13,17,25] Zero[16] Trans[5,14] Jump[13,14,22] Succ[14] Succ[16] Jump[14,14,18] Succ[9] Trans[16,13] Jump[17,17,15] Zero[6] Zero[20] Jump[9,6,40] Zero[7] Trans[1,21] Jump[20,7,36] Succ[21] Trans[21,19] Trans[19,21] Succ[7] Jump[7,7,30] Trans[21,18] Trans[18,20] Succ[6] Jump[6,6,27] Trans[20,4] Zero[10] Trans[4,15] Jump[2,15,47] Succ[15] Succ[10] Jump[15,15,43] Trans[9,1] Trans[10,2] 

EDIT: by removing brackes, and shortening instruction names:

URM 285

 Z8 T2,11 J3,11,7 S11 S8 J11,11,3 Z5 T1,12 J2,12,13 S12 S5 J12,12,9 Z17 T8,13 J13,17,25 Z16 T5,14 J13,14,22 S14 S16 J14,14,18 S9 T16,13 J17,17,15 Z6 Z20 J9,6,40 Z7 T1,21 J20,7,36 S21 T21,19 T19,21 S7 J7,7,30 T21,18 T18,20 S6 J6,6,27 T20,4 Z10 T4,15 J2,15,47 S15 S10 J15,15,43 T9,1 T10,2 

-
 (+1) But ... "Non-negative and non-integer numbers are not handled" ... I think you mean to say that negative numbers are not handled. (The OP says all input & output is integer.) – r.e.s. Apr 11 '12 at 10:53 Ah, did not read that output was integer... – Paxinum Apr 11 '12 at 11:07 Should I count this by character count or by the number of instructions? – PhiNotPi Apr 11 '12 at 13:20 Maybe count the characters in the edited version... – Paxinum Apr 11 '12 at 20:32

## VBA, 57 characters

Sub x(a,b,c)
y=(c-b)/(b-a)
MsgBox y & " " & b-a*y
End Sub


(This is basically the same as the other 'BASIC' functions, but I didn't see any VBA submissions out there already.)

-

# Q, 36

{a,x[2]-x[1]*a:%[x[2]-x 1;x[1]-x 0]}


usage

q){a,x[2]-x[1]*a:%[x[2]-x 1;x[1]-x 0]}each(0 7 14;2 5 11;2 0 -4;5 -19 77)
1  7
2  1
2  -4
-4 1

-