[Question]
  [
Given a list of `N` integers, each with `N` digits, output a number which differs from the first number because of the first digit, the second number because of the second digit, etc.
### Example
Given this list:
```
1234
4815
1623
4211
```
The number `2932`'s first digit is different from the first number's first digit, its second digit is different from the second number's second digit, etc. Therefore it would be a valid output.
### Inputs
* You may take both the list and `N` as input, or only the list if you wish.
* Each integer in the list will necessarily have as many digits as the length of the list (`N`)
* Numbers will not have any leading zeroes
* The input list must contain numbers and not strings.
* You may take inputs as function arguments, through `STDIN`, or anything similar.
* You may assume that the list will not be longer than 10 elements (and no number in the list will be bigger than `2147483647`)
### Outputs
* It is not sufficient that the output is not in the list. The digits must differ as explained above.
* You can use any digit selection strategy that respects the constraint of different digits.
* The number cannot have leading zeroes
* You may output the number through `STDOUT`, return it from a function, etc.
### Test cases
```
Input:
12345678
23456789
34567890
45678901
56789012
67890123
78901234
89012345
Possible output: 24680246
Input:
1
Possible output: 2
```
### Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins.
  
[Answer]
## CJam (15 14 bytes)
```
qN/ee{:=i2%)}%
```
[Online demo](http://cjam.aditsu.net/#code=qN%2Fee%7B%3A%3Di2%25)%7D%25&input=12345678%0A23456789%0A34567890%0A45678901%0A56789012%0A67890123%0A78901234%0A89012346)
Thanks to [Adnan](https://codegolf.stackexchange.com/users/34388/adnan) for a one-byte saving.
### Dissection
```
qN/    e# Split input on newlines
ee{    e# Label each line with its index and map:
  :=i  e#   Get the character at the same index (i.e. diagonalise)
  2%)  e#   Compute (ASCII value mod 2) + 1
       e#   Maps 0 1 2 3 4 5 6 7 8 9
       e#     to 1 2 1 2 1 2 1 2 1 2
}%
```
[Answer]
# Python 2, ~~47~~ 45 bytes
```
lambda x,n:int(`x`[1::n+3])%(10**n/2)+10**n/9
```
*Thanks to @xnor for golfing off 2 bytes!*
Test it on [Ideone](http://ideone.com/B7wAft).
### How it works
``x`` yields a string representation of the list **x**.
For the first test case, this gives the *string*
```
[92345678, 23456789, 34567890, 45678901, 56789012, 67890123, 78901234, 89012345]
```
`[1::n+3]` retrieves every **(n + 3)**th character – where **n** is the length of **x** starting with the second one. Accounting **2** characters for `,`, we retrieve the first digit of the first number, the second digit of the second number, etc.
```
[92345678, 23456789, 34567890, 45678901, 56789012, 67890123, 78901234, 89012345]
 ^          ^          ^          ^          ^          ^          ^          ^
```
We now take the number modulo **10n ÷ 2** to map the first digit in the range **[0, 4]**.
For **93579135**, we get **93579135 % 50000000 = 43579135**.
Finally, we add **10n ÷ 9** to the last result, which increments – wrapping around from **9** to **0** – all digits by **1** (no carry) or **2** (with carry).
For **43579135**, we get **43579135 + 11111111 = 54690246**.
[Answer]
# Jelly, ~~8~~ 7 bytes
1 byte saved thanks to Dennis.
```
DŒDḢỊ‘Ḍ
```
[Try it online!](http://jelly.tryitonline.net/#code=RMWSROG4ouG7iuKAmOG4jA&input=&args=OTIzNDU2NzgsMjM0NTY3ODksMzQ1Njc4OTAsNDU2Nzg5MDEsNTY3ODkwMTIsNjc4OTAxMjMsNzg5MDEyMzQsODkwMTIzNDU)
### Explanation
```
DŒDḢỊ‘Ḍ    Main link. Takes list as argument.
D          Convert each integer to decimal.
 ŒD        Get the diagonals.
   Ḣ       Get the first diagonal.
    Ị      Check if every digit <= 1.
     ‘     Increment every digit.
      Ḍ    Convert back to integer from decimal.
```
Converts each digit to `1`, except `0` and `1` becomes `2`.
[Answer]
# MATL, ~~11~~ ~~10~~ 9 bytes
```
VXd9\QV!U
```
Takes only a column vector of integers as input. `N` is not provided.
[**Try it Online**](http://matl.tryitonline.net/#code=VlhkOVxRViFV&input=WzIyMzQ1Njc4OzIzNDU2Nzg5OzM0NTY3ODkwOzQ1Njc4OTAxOzU2Nzg5MDEyOzY3ODkwMTIzOzc4OTAxMjM0Ozg5MDEyMzQ1XQ)
**Explanation**
```
    % Implicity grab input as column vector of numbers
V   % Convert the input column vector into a 2D character array
Xd  % Grab the diagonal elements of the character array
9\  % Take the modulus of each ASCII code and 9
Q   % Add 1 to remove all zeros
V   % Convert the result to a string
!   % Transpose to yield a row vector of characters
U   % Convert back to an integer (as per the rules)
    % Implicitly display result
```
[Answer]
# Pyth, 11 bytes
```
jk.eh!ts@`b
```
Simple loop, change every digit to 1, except 1 becomes 2.
[Answer]
# Java, 93 bytes
```
String k(int n,int[]a){String s="";for(int i=0;i<n;)s+=(a[i]+s).charAt(i++)<57?9:1;return s;}
```
### Ungolfed
```
String k(int n, int[] a) {
    String s = "";
    for (int i = 0; i < n; ) 
        s += (a[i] + s).charAt(i++) < 57 ? 9 : 1;
    return s;
}
```
### Output
```
Input:
12345678
23456789
34567890
45678901
56789012
67890123
78901234
89012345
Output:
99991999
Input:
1234
4815
1623
4211
Output:
9999
```
[Answer]
# Retina, ~~39~~ ~~38~~ 37
```
(?<=(.*¶)*)(?<-1>.)*(.).*¶
$2
T`d`121
```
Saved 1 byte thanks Martin!
Requires a trailing linefeed in the input.
Gets diagonals and translates 0 and 2-9 to 1 and 1 to 2.
The basic idea for getting the diagonals is to push a capture for each row above the current row and then consume a capture to match a character, then keep the next character.
[Try it online](http://retina.tryitonline.net/#code=KD88PSguKsK2KSopKD88LTE-LikqKC4pLirCtgokMgpUYGRgMTIx&input=MTIzNAo0ODE1CjE2MjMKNDIxMAo)
[Answer]
# J, ~~26~~ 22 bytes
```
1+1>:i.@#{"_1"."0@":"0
```
Similar approach to the others using the `<= 1` and `increment` method of the diagonal.
## Usage
Only requires the list of integers as an argument.
```
   f =: 1+1>:i.@#{"_1"."0@":"0
   f 1234 4815 1623 4211
2 1 1 2
   f 92345678 23456789 34567890 45678901 56789012 67890123 78901234 89012345
1 1 1 1 1 2 1 1
```
[Answer]
# Python 2, 54 bytes
```
d,r=1,""
for n in input():r+=`1+-~n/d%9`;d*=10
print r
```
[Answer]
# Java, 94 bytes
```
int c(int[]d){int p=1,r=0,l=d.length,i=0;for(;i<l;p*=10)r+=(d[l-++i]/p%10==1?2:1)*p;return r;}
```
Pure numeric operations for the win! :)
### Sample input/output:
```
8            <-- size
12345678     <-- start of list
23456789
34567890
45678901
56789012
67890123
78901234
89012345     <-- end of list
21111211     <-- result from ungolfed code
21111211     <-- result from golfed code
```
### Full program (with ungolfed code):
```
import java.util.Scanner;
public class Q79444 {
    int cantor_ungolfed(int[] data){
        int power = 1;
        int result = 0;
        for(int i=0;i<data.length;i++){
            result += (((data[data.length-i-1]/power))%10==1? 2 : 1)*power;
            power *= 10;
        }
        return result;
    }
    int c(int[]d){int p=1,r=0,l=d.length,i=0;for(;i<l;p*=10)r+=(d[l-++i]/p%10==1?2:1)*p;return r;}
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] input = new int[n];
        for(int i=0;i<n;i++){
            input[i] = sc.nextInt();
        }
        System.out.println(new Q79444().cantor_ungolfed(input));
        System.out.println(new Q79444().c(input));
        sc.close();
    }
}
```
[Answer]
# Reng v.3.3, 60 bytes
```
k1-#kaiír1ø          ~; !nb$<
1[å{$}k*$k1-#k)9(-#oa$;]o)ks^$
```
For Reng, that was rather simple. [Try it here!](https://jsfiddle.net/Conor_OBrien/avnLdwtq/) Input is a space-separated list of numbers.
## 1: init
```
k1-#kaiír1ø
```
`k` is the number of inputs (number of numbers), and we decrement by 1 and restore for the loop stage. `aií` takes all input. `r` reverses the stack for the processing of input. `1ø` goes to the next line.
## 2: loop
```
1[å{$}k*$k1-#k)9(-#oa$;]o)ks^$
```
`1[` takes the top item off the stack and into a new stack. `å` splits it into digits. `{$}` pushes a code block containing the operation "drop"; this is repeated `k` times (`k*`) and the code block is dropped (`$`. `k1-#k` decrements `k`. `)9(` puts `9` at the STOS, and `-` subtracts TOS from the STOS. `#o` stores this number in `o`, and `a$;` drops all the members of the stack. `]` closes the parent stack. `o` puts `o` back at the top; this is our digit we're saving. `)` moves it to the bottom so that we can continue our looping. `s` usually checks for non-input (i.e., equality to `-1`), but we can use it to break out of our loop when `k == -1`. So `s^` goes up when `k == -1`. `$` drops `k` from the stack, and our loop begins again.
## 3: final
```
                     ~; !nb$<
```
`<` directs the pointer left, and `$` drops `k` from the stack. `b` is a leftway mirror, so we enter through it, but it bounce back when hitting `;`, a stack-condition mirror. `!n` prints a digit if and only if we're going left. `~` ends the program when we're done printing.
[Answer]
# Ruby, 21 bytes
```
$><<$_[$.-1].hex%2+1
```
A full program. Run with the `-n` flag. Uses the following mapping: `n -> n%2+1`.
[Answer]
# Perl, 18 bytes
Includes +1 for `-p`
Run with the input lines on STDIN. Output is 1 except 2 when the diagonal is 1
`cantor.pl`
```
#!/usr/bin/perl -p
pos=$.;$_=/1\G/+1
```
[Answer]
# Pyth, 14 bytes
```
s.e|-\1@bk\2`M
```
[Try it online!](http://pyth.herokuapp.com/?code=s.e|-%5C1%40bk%5C2%60M&input=12345678%2C23456789%2C34567890%2C45678901%2C56789012%2C67890123%2C78901234%2C89012345&debug=0)
[Answer]
# J, 37 bytes
```
f@(9&-@"."0@((>:@#*i.@#){f=:[:,":"0))
```
Can probably be golfed, but I forgot if there was a command for "diagonals".
[Answer]
# Mathematica 52 bytes
```
FromDigits[Mod[#,2]+1&/@Diagonal[IntegerDigits/@#]]&
```
This follows the approach of Peter Taylor and others (without using Ascii codes).
Example
```
FromDigits[Mod[#,2]+1&/@Diagonal[IntegerDigits/@ #]]&[{1234,4815,1623,4211}]
```
> 
> 2112
> 
> 
> 
[Answer]
# ClojureScript, 58 chars
```
#(int(apply str(map-indexed(fn[i x](- 9(get(str x)i)))%)))
```
Type requirements made this a little longer than necessary, and `map-indexed` being so many chars didn't help.
Often my submissions are valid Clojure as well, but this is using some of ClojureScript's leakiness with JavaScript. Subtraction of a number and string coerces the string to a number--that is, `(- 9 "5")` equals `4`.
[Answer]
**PHP, 46/41/40 bytes**
```
while($a=$argv[++$i])echo($b=9-$a[$i-1])?$b:1;
while($a=$argv[++$i])echo$a[$i-1]==7?6:7;
while($a=$argv[++$i])echo($a[$i-1]%2)+1;
```
Various digit selectors for comparison. I thought "9-digit" would be shortest, but the special case needed to keep a zero out of the first digit overwhelms it.
Fed from CLI arguments:
```
php -r "while($a=$argv[++$i])echo($b=9-$a[$i-1])?$b:1;" 12345678 23456789 34567890 45678901 56789012 67890123 78901234 89012345
86421864
```
[Answer]
# JavaScript (ES6), 41
The %9+1 trick is borrowed from Suever's answer. For once, `.reduce` beats `.map`. Note, the `+=` operator is used to avoid parentheses.
```
a=>+a.reduce((t,n,d)=>t+=(n+t)[d]%9+1,'')
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 49 [bitsv2](https://github.com/Vyxal/Vyncode/blob/main/README.md), 6.125 bytes
```
vfÞ/ċ›ṅ
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyJhPSIsIiIsInZmw54vxIvigLrhuYUiLCIiLCIxMjM0XG40ODE1XG4xNjIzXG40MjExIl0=)
Port of Jelly
]