#Python, 257 264B broken265B
importfrom itertools as Iimport*
T=lambda i:[list(a)for l in range(i)for a in I.product(range(i-l+3),repeat=l+1)if a[-1]>0and sum(a)==i]==i-l]
def f(N):
A,i=[[0]],0
while len(A)<=N:A+=T(i);i+=1
return A[N]
def g(t):
A,i=[[0]],0
while t not in A:A+=T(i);i+=1
return A.index(t)
To list every sequence, for each integer i, for each length l<i, list every sequence whose sum is exactly i, of lenthlegnth at most i, ordered ascending, e.g; NB thanks to zeroes, this it no longer a bijection. Back to the drawing board...
0 : 01
1 : 12
2 : 20 1
3 : 0 23
4 : 10 12
5 : 31 1
6 : 0 30 1
7 : 1 24
8 : 20 13
9: : 0 01 32
10: 0: 1 2 1
11 : 0 20 12
12 : 1 0 21 1
13 : 1 1 0 1
14 : 2 0 0 0 1
15 : 4 5
16 : 0 4
17 : 1 3
18 : 2 2
19 : 3 1
20 : 0 0 43
21 : 0 1 2
22 : 0 2 1
23 : 1 0 2
24 : 1 1 1
25 : 2 0 1
26 : 0 0 0 2
27 : 0 0 1 1
28 : 0 1 0 1
29 : 1 0 0 1
30 : 0 0 0 0 1
so f(256)=[0, 0, 2, 1, 3]=[9]
, and g([4,2,0,3])=7121=2254
. NB that this is SLOW for large numbers.