Skip to main content
added 17 characters in body
Source Link
xigoi
  • 7.3k
  • 2
  • 13
  • 23

Jelly, 1313 12 bytes

Encode, 77 6 bytes

1,0ṁx‘Ḅ2Bṁx‘Ḅ

Try it online!Try it online!

Jelly, 13 bytes

Encode, 7 bytes

1,0ṁx‘Ḅ

Try it online!

Jelly, 13 12 bytes

Encode, 7 6 bytes

2Bṁx‘Ḅ

Try it online!

added 3089 characters in body; added 1619 characters in body
Source Link
xigoi
  • 7.3k
  • 2
  • 13
  • 23

Numbers from 0 to 100 (Try it online!):

0                     []                   
1                     [0]                  
2                     [0, 0]               
3                     [1]                  
4                     [0, 1]               
5                     [0, 0, 0]            
6                     [1, 0]               
7                     [2]                  
8                     [0, 2]               
9                     [0, 1, 0]            
10                    [0, 0, 0, 0]         
11                    [0, 0, 1]            
12                    [1, 1]               
13                    [1, 0, 0]            
14                    [2, 0]               
15                    [3]                  
16                    [0, 3]               
17                    [0, 2, 0]            
18                    [0, 1, 0, 0]         
19                    [0, 1, 1]            
20                    [0, 0, 0, 1]         
21                    [0, 0, 0, 0, 0]      
22                    [0, 0, 1, 0]         
23                    [0, 0, 2]            
24                    [1, 2]               
25                    [1, 1, 0]            
26                    [1, 0, 0, 0]         
27                    [1, 0, 1]            
28                    [2, 1]               
29                    [2, 0, 0]            
30                    [3, 0]               
31                    [4]                  
32                    [0, 4]               
33                    [0, 3, 0]            
34                    [0, 2, 0, 0]         
35                    [0, 2, 1]            
36                    [0, 1, 0, 1]         
37                    [0, 1, 0, 0, 0]      
38                    [0, 1, 1, 0]         
39                    [0, 1, 2]            
40                    [0, 0, 0, 2]         
41                    [0, 0, 0, 1, 0]      
42                    [0, 0, 0, 0, 0, 0]   
43                    [0, 0, 0, 0, 1]      
44                    [0, 0, 1, 1]         
45                    [0, 0, 1, 0, 0]      
46                    [0, 0, 2, 0]         
47                    [0, 0, 3]            
48                    [1, 3]               
49                    [1, 2, 0]            
50                    [1, 1, 0, 0]         
51                    [1, 1, 1]            
52                    [1, 0, 0, 1]         
53                    [1, 0, 0, 0, 0]      
54                    [1, 0, 1, 0]         
55                    [1, 0, 2]            
56                    [2, 2]               
57                    [2, 1, 0]            
58                    [2, 0, 0, 0]         
59                    [2, 0, 1]            
60                    [3, 1]               
61                    [3, 0, 0]            
62                    [4, 0]               
63                    [5]                  
64                    [0, 5]               
65                    [0, 4, 0]            
66                    [0, 3, 0, 0]         
67                    [0, 3, 1]            
68                    [0, 2, 0, 1]         
69                    [0, 2, 0, 0, 0]      
70                    [0, 2, 1, 0]         
71                    [0, 2, 2]            
72                    [0, 1, 0, 2]         
73                    [0, 1, 0, 1, 0]      
74                    [0, 1, 0, 0, 0, 0]   
75                    [0, 1, 0, 0, 1]      
76                    [0, 1, 1, 1]         
77                    [0, 1, 1, 0, 0]      
78                    [0, 1, 2, 0]         
79                    [0, 1, 3]            
80                    [0, 0, 0, 3]         
81                    [0, 0, 0, 2, 0]      
82                    [0, 0, 0, 1, 0, 0]   
83                    [0, 0, 0, 1, 1]      
84                    [0, 0, 0, 0, 0, 1]   
85                    [0, 0, 0, 0, 0, 0, 0]
86                    [0, 0, 0, 0, 1, 0]   
87                    [0, 0, 0, 0, 2]      
88                    [0, 0, 1, 2]         
89                    [0, 0, 1, 1, 0]      
90                    [0, 0, 1, 0, 0, 0]   
91                    [0, 0, 1, 0, 1]      
92                    [0, 0, 2, 1]         
93                    [0, 0, 2, 0, 0]      
94                    [0, 0, 3, 0]         
95                    [0, 0, 4]            
96                    [1, 4]               
97                    [1, 3, 0]            
98                    [1, 2, 0, 0]         
99                    [1, 2, 1]            
100                   [1, 1, 0, 1]         

Numbers from 0 to 100 (Try it online!):

0                     []                   
1                     [0]                  
2                     [0, 0]               
3                     [1]                  
4                     [0, 1]               
5                     [0, 0, 0]            
6                     [1, 0]               
7                     [2]                  
8                     [0, 2]               
9                     [0, 1, 0]            
10                    [0, 0, 0, 0]         
11                    [0, 0, 1]            
12                    [1, 1]               
13                    [1, 0, 0]            
14                    [2, 0]               
15                    [3]                  
16                    [0, 3]               
17                    [0, 2, 0]            
18                    [0, 1, 0, 0]         
19                    [0, 1, 1]            
20                    [0, 0, 0, 1]         
21                    [0, 0, 0, 0, 0]      
22                    [0, 0, 1, 0]         
23                    [0, 0, 2]            
24                    [1, 2]               
25                    [1, 1, 0]            
26                    [1, 0, 0, 0]         
27                    [1, 0, 1]            
28                    [2, 1]               
29                    [2, 0, 0]            
30                    [3, 0]               
31                    [4]                  
32                    [0, 4]               
33                    [0, 3, 0]            
34                    [0, 2, 0, 0]         
35                    [0, 2, 1]            
36                    [0, 1, 0, 1]         
37                    [0, 1, 0, 0, 0]      
38                    [0, 1, 1, 0]         
39                    [0, 1, 2]            
40                    [0, 0, 0, 2]         
41                    [0, 0, 0, 1, 0]      
42                    [0, 0, 0, 0, 0, 0]   
43                    [0, 0, 0, 0, 1]      
44                    [0, 0, 1, 1]         
45                    [0, 0, 1, 0, 0]      
46                    [0, 0, 2, 0]         
47                    [0, 0, 3]            
48                    [1, 3]               
49                    [1, 2, 0]            
50                    [1, 1, 0, 0]         
51                    [1, 1, 1]            
52                    [1, 0, 0, 1]         
53                    [1, 0, 0, 0, 0]      
54                    [1, 0, 1, 0]         
55                    [1, 0, 2]            
56                    [2, 2]               
57                    [2, 1, 0]            
58                    [2, 0, 0, 0]         
59                    [2, 0, 1]            
60                    [3, 1]               
61                    [3, 0, 0]            
62                    [4, 0]               
63                    [5]                  
64                    [0, 5]               
65                    [0, 4, 0]            
66                    [0, 3, 0, 0]         
67                    [0, 3, 1]            
68                    [0, 2, 0, 1]         
69                    [0, 2, 0, 0, 0]      
70                    [0, 2, 1, 0]         
71                    [0, 2, 2]            
72                    [0, 1, 0, 2]         
73                    [0, 1, 0, 1, 0]      
74                    [0, 1, 0, 0, 0, 0]   
75                    [0, 1, 0, 0, 1]      
76                    [0, 1, 1, 1]         
77                    [0, 1, 1, 0, 0]      
78                    [0, 1, 2, 0]         
79                    [0, 1, 3]            
80                    [0, 0, 0, 3]         
81                    [0, 0, 0, 2, 0]      
82                    [0, 0, 0, 1, 0, 0]   
83                    [0, 0, 0, 1, 1]      
84                    [0, 0, 0, 0, 0, 1]   
85                    [0, 0, 0, 0, 0, 0, 0]
86                    [0, 0, 0, 0, 1, 0]   
87                    [0, 0, 0, 0, 2]      
88                    [0, 0, 1, 2]         
89                    [0, 0, 1, 1, 0]      
90                    [0, 0, 1, 0, 0, 0]   
91                    [0, 0, 1, 0, 1]      
92                    [0, 0, 2, 1]         
93                    [0, 0, 2, 0, 0]      
94                    [0, 0, 3, 0]         
95                    [0, 0, 4]            
96                    [1, 4]               
97                    [1, 3, 0]            
98                    [1, 2, 0, 0]         
99                    [1, 2, 1]            
100                   [1, 1, 0, 1]         
Source Link
xigoi
  • 7.3k
  • 2
  • 13
  • 23

Jelly, 13 bytes

Encode, 7 bytes

1,0ṁx‘Ḅ

Try it online!

Decode, 6 bytes

ȯIBŒɠ’

Try it online!

Encodes positive integers in the run lengths of the binary representation. Since we may have zeros, we increment all numbers. For example, the list [0,1,4] is encoded as 10011111 in binary.