text:
Divisor Rich and Poor Numbers
Introduction
In the strange world of integer numbers, divisors are like assets and
they use to call "rich" the numbers having more divisors than their reversal, while they call "poor" the ones having less divisors than their reversal.
For example, the number \$2401\$ has five divisors : \$1,7,49,343,2401\$, while its reversal, \$1042\$, has only four : \$1,2,521,1042\$.
So \$2401\$ is called a rich number, while \$1042\$ a poor number.
Given this definition, we can create the following two integer sequences of rich and poor numbers :
(here we list the first 25 elements of the sequences)

 Index | Poor | Rich
-------|------|-------
     1 |   19 |   10
     2 |   21 |   12
     3 |   23 |   14
     4 |   25 |   16
     5 |   27 |   18
     6 |   29 |   20
     7 |   41 |   28
     8 |   43 |   30
     9 |   45 |   32
    10 |   46 |   34
    11 |   47 |   35
    12 |   48 |   36
    13 |   49 |   38
    14 |   53 |   40
    15 |   57 |   50
    16 |   59 |   52
    17 |   61 |   54
    18 |   63 |   56
    19 |   65 |   60
    20 |   67 |   64
    21 |   69 |   68
    22 |   81 |   70
    23 |   82 |   72
    24 |   83 |   74
    25 |   86 |   75
   ... |  ... |  ...

Notes :

as "reversal" of a number we mean its digital reverse, i.e. having its digits in base-10 reversed. This means that numbers ending with one or more zeros will have a "shorter" reversal : e.g. the reversal of 1900 is 0091 hence 91
we intentionally exclude the integer numbers having the same number of divisors as their reversal i.e. the ones belonging to OEIS:A062895

Challenge
Considering the two sequences defined above, your task is to write a program or function that, given an integer n (you can choose 0 or 1-indexed), returns the n-th poor and n-th rich number.
Input

An integer number (>= 0 if 0-indexed or >= 1 if 1-indexed)

Output

2-integers, one for the poor sequence and one for the rich sequence, in the order you prefer as long as it is consistent

Examples :
INPUT          |   OUTPUT
----------------------------------
n (1-indexed)  |   poor    rich
----------------------------------
1              |   19      10
18             |   63      56
44             |   213     112
95             |   298     208
4542           |   16803   10282
11866          |   36923   25272
17128          |   48453   36466
22867          |   61431   51794
35842          |   99998   81888

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code (i.e. TIO).
Also, adding an explanation for your answer is highly recommended.

Conjecture: the $n$th poor number is always greater than the $n$th rich number. If someone can prove this, it will probably shave bytes off many answers.

@RobinRyder: I suspect that's true, but proving it is a whole different story :)

@RobinRyder Consider that multiple numbers can map to the same reversed numbers due to leading zeroes (e.g. 51, 510, 5100 all map to 15). For every number $n$, there will be an infinite number of richer corresponding reversed numbers with trailing zeroes (with extra factors of $10,100,1000$,etc.), while only a finite amount of poorer reversed numbers. I don't think this fully proves it (maybe there's a lucky chain of poor numbers somewhere down the line), but it at least specifies that there are far more rich numbers than poor.

@JoKing "...far more rich numbers than poor." Might want to clarify this statement; as written it could be interpreted as saying that the set of rich numbers has greater cardinality than the set of poor numbers. But of course both sets are countably infinite (neither sequence terminates): it suffices to prove that there are infinitely many primes whose first digit is a 2. For this, see Corollary 1.4 at the end of the following paper, with n equal to 19, 199, 1999, ...: http://www.m-hikari.com/ijcms-password/ijcms-password13-16-2006/elbachraouiIJCMS13-16-2006.pdf

05AB1E, 16 bytes
∞.¡ÂÑgsÑg.S}¦ζsè

Try it online!

0-indexed [rich,poor]:
∞                # Push infinite list.
 .¡        }     # Split into three lists by...
   ÂÑgsÑg.S      # 1 if rich, 0 if nothing, -1 if poor.
            ¦ζ   # Remove list of nothings, and zip rich/poor together.
              sè # Grab nth element.

Maybe someone can explain why this version doesn't seem to terminate, but when I click "cancel execution" on TIO it finishes with the correct answer, or if you wait 60 seconds you get the correct answer. For a version that terminates "correctly" you could use: T+nL.¡ÂÑgsÑg.S}¦ζsè +3 bytes

Split-by doesn't seem to work very nicely with infinite lists.

@Emigna personally, I don't have any idea how infinite lists even are possible.

Lazy evaluation. Don't calculate number you don't need. So ∞n5è would only calculate the first 6 numbers. I think when these types of looping/grouping/splitting constructs come in to play, the lazy eval fails and it tries to calculate all items before returning.

I still think there should be a 1-byte builtin for €g.. I used it so often. Would have saved a byte here with the (now equal byte) alternative Â‚Ñ€gÆ.±. Nice answer though! Great usage of .¡!

@KevinCruijssen another 2 byte for that is δg lol.

Â‚ÑDéQ was my other idea but you need to extrapolate the equal case.

JavaScript (ES6),  121 115 113  111 bytes
Input is 1-indexed. Outputs as [poor, rich].
x=>[(s=h=(n,i=x)=>i?h(++n,i-=(g=(n,k=n)=>k&&!(n%k)*~-s+g(n,k-1))(n)>g([...n+''].reverse().join``)):n)``,h(s=2)]

Try it online!
Commented
Helper function
g = (n,                   // g is a helper function taking n and returning either the
        k = n) =>         // number of divisors or its opposite; starting with k = n
  k &&                    // if k is not equal to 0:
    !(n % k)              //   add either 1 or -1 to the result if k is a divisor of n
    * ~-s                 //   use -1 if s = 0, or 1 if s = 2
    + g(n, k - 1)         //   add the result of a recursive call with k - 1

Main
x => [                    // x = input
  ( s =                   // initialize s to a non-numeric value (coerced to 0)
    h = (n,               // h is a recursive function taking n
            i = x) =>     // and using i as a counter, initialized to x
      i ?                 // if i is not equal to 0:
        h(                //   do a recursive call ...
          ++n,            //     ... with n + 1
          i -=            //     subtract 1 from i if:
            g(n)          //       the number of divisors of n (multiplied by ~-s within g)
            >             //       is greater than
            g(            //       the number of divisors of the reversal of n obtained ...
              [...n + ''] //         ... by splitting the digits
              .reverse()  //             reversing them
              .join``     //             and joining back
            )             //       (also multiplied by ~-s within g)
        )                 //   end of recursive call
      :                   // else:
        n                 //   we have reached the requested term: return n
  )``,                    // first call to h for the poor one, with n = s = 0 (coerced)
  h(s = 2)                // second call to h for the rich one, with n = s = 2
]                         // (it's OK to start with any n in [0..9] because these values
                          // are neither poor nor rich and ignored anyway)

Wolfram Language (Mathematica), 152 bytes
(a=b=k=1;m=n={};p=AppendTo;While[a<=#||b<=#,#==#2&@@(s=0~DivisorSigma~#&/@{k,IntegerReverse@k++})||If[#<#2&@@s,m~p~k;a++,n~p~k;b++]];{m[[#]],n[[#]]}-1)&

Try it online!
If the conjecture is true, then this 140 bytes solution also works
(a=k=1;m=n={};p=AppendTo;While[a<=#,#==#2&@@(s=0~DivisorSigma~#&/@{k,IntegerReverse@k++})||If[#<#2&@@s,m~p~k;a++,n~p~k]];{m[[#]],n[[#]]}-1)&

Try it online!
Here is poor vs rich plot

What's that point where they come really close?

@JoKing I believe it is a(27635)= {70003, 65892}

Great! BTW, this is probably one of the few solutions (maybe the only one) able to reach n=35842 on TIO :)

Jelly, 22 bytes
ṚḌ;⁸Æd
Ç>/$Ɠ©#żÇ</$®#Ṫ

Try it online!
A full program taking 1-indexed \$n\$ on stdin and returning a list of the n-th poor and rich integers in that order.
Explanation
ṚḌ;⁸Æd | Helper link: take an integer and return the count of divisors fof its reverse and the original number in that order

Ṛ      | Reverse
 Ḍ     | Convert back from decimal digits to integer
  ;⁸   | Concatenate to left argument
    Æd | Count divisors

Ç>/$Ɠ©#żÇ</$®#Ṫ | Main link

    Ɠ©          | Read and evaluate a line from stdin and copy to register
   $  #         | Find this many integers that meet the following criteria, starting at 0 and counting up
Ç               | Helper link
 >/             | Reduce using greater than (i.e. poor numbers)
       ż        | zip with
           $®#  | Find the same number of integers meeting the following criteria
        Ç       | Helper link
         </     | Reduce using less than (i.e. rich numbers)
              Ṫ | Finally take the last pair of poor and rich numbers

Python 2, 158 153 bytes
 -2 bytes thanks to shooqie

n=input()
p=[];r=[];c=1
while min(len(p),len(r))<=n:[[],r,p][cmp(*[sum(x%-~i<1for i in range(x))for x in c,int(str(c)[::-1])])]+=[c];c+=1
print p[n],r[n]

Try it online!
Input is 0-indexed. Outputs as poor rich.

Would +=[c] instead of .append(c) work?

@shooqie It would

Perl 6, 81 bytes
{(*>*,* <*).map(->&c {grep
{[[&c]] map {grep $_%%*,1..$_},$_,.flip},1..*})»[$_]}

Try it online!

* > * is an anonymous function that returns true if its first argument is greater than its second.  Similarly for * < *.  The former will select numbers that belong to the rich sequence, the latter will select those that belong to the poor sequence.
(* > *, * < *).map(-> &c { ... }) produces a pair of infinite sequences, each based on one of the comparator functions: the rich sequence and the poor sequence, in that order.
»[$_] indexes into both of those sequences using $_, the argument to the top-level function, returning a two-element list containing the $_th member of the rich sequence and the $_th member of the poor sequence.
grep $_ %% *, 1..$_ produces a list of the divisors of $_.
map { grep $_ %% *, 1..$_ }, $_, .flip produces a two-element list of the divisors of $_, and the divisors of $_ with its digits reversed ("flipped").
[[&c]] reduces that two-element list with the comparator function &c (either greater-than or less-than), producing a boolean value indicating whether this number belongs to the rich sequence of the poor sequence.

1..$_ can be ^$_. You can also move the [$_] to inside the map function. 78 bytes

Python 2, 142 141 bytes
f=lambda i,n=1,a=[[],[]]:zip(*a)[i:]or f(i,n+1,[a[j]+[n]*(cmp(*[sum(x%y<1for y in range(1,x))for x in int(`n`[::-1]),n])==1|-j)for j in 0,1])

Try it online!

Non-recursive alternative (very similar to the other Python answers)
Python 2, 143 bytes
i=input()
a=[[],[]];n=1
while~i+len(zip(*a)):([[]]+a)[cmp(*[sum(x%i<1for i in range(1,x))for x in int(`n`[::-1]),n])]+=n,;n+=1
print zip(*a)[i]

Try it online!

R, 152 137 bytes
-12 bytes thanks to Giuseppe
-3 bytes thanks to digEmAll
n=scan()
F=i=!1:2
`?`=sum
while(?n>i)if(n==?(i[s]=i[s<-sign((?!(r=?rev((T=T+1)%/%(e=10^(0:log10(T)))%%10)*e)%%1:r)-?!T%%1:T)]+1))F[s]=T
F

Try it online!
T is the integer currently being tried; the latest poor and rich numbers are stored in the vector F.
The shortest way I could find of reversing an integer was converting it to digits in base 10 with modular arithmetic, then converting back with powers of 10 inverted, but I expect to be outgolfed on this and other fronts.
Explanation (of previous, similar version):
n=scan() # input
i=0*1:3  # number of poor, middle class, and rich numbers so far
S=sum
while(S(n>i)){ # continue as long as at least one of the classes has less than n numbers
  if((i[s]=i[
    s<-2+sign(S(!(           # s will be 1 for poor, 2 for middle class, 3 for rich
      r=S((T<-T+1)%/%10^(0:( # reverse integer T with modular arithmetic
        b=log10(T)%/%1       # b is number of digits
        ))%%10*10^(b:0))
      )%%1:r)-               # compute number of divisors of r
      S(!T%%1:T))            # computer number of divisors of T
    ]+1)<=n){                # check we haven't already found n of that class
    F[s]=T
  }
}
F[-2] # print nth poor and rich numbers

146 bytes; no idea what digEmAll's response is

@Giuseppe Thanks! I love the use of nchar.

142 bytes; I had trouble with the operator precedence before but puzzled it out.

@Giuseppe Well done! I tried that as well but also got stuck by the precedence, and (unlike you) gave up without managing to untangle it.

Great job! 140 changing the reverse strategy

@digEmAll 138 bytes going back to log10!

@Giuseppe @ digEmAll You guys are good!

137 using sum alias instead of matrix multilplication

127 applying some of the current tricks to my original idea to call a function twice

APL (Dyalog Unicode), 34 bytes
{⍵⌷⍉1↓⊢⌸{×-/{≢∪⍵∨⍳⍵}¨⍵,⍎⌽⍕⍵}¨⍳1e3}

Try it online!
Thanks to Adám and ngn for helping me golf this monstrosity.
TIO times out for the bigger indices (which require ⍳1e5 or ⍳1e6) , but given enough time and memory the function will terminate correctly.

Ruby, 128 bytes
Input is zero-indexed. Outputs as [poor, rich].
->n,*a{b=[];i=0;d=->z{(1..z).count{|e|z%e<1}};(x=d[i+=1];y=d[i.digits.join.to_i];[[],b,a][x<=>y]<<i)until a[n]&b[n];[a[n],b[n]]}

Explanation
->n,*a{                             # Anonymous function, initialize poor array
       b=[];i=0;                    # Initialize rich array and counter variable
    d=->z{(1..z).count{|e|z%e<1}};  # Helper function to count number of factors
    (                               # Start block for while loop
     x=d[i+=1];                     # Get factors for next number
     y=d[i.digits.join.to_i];       # Factors for its reverse
                                    # (digits returns the ones digit first, so no reversing)
     [[],b,a][x<=>y]                # Fetch the appropriate array based on
                                    #  which number has more factors
                    <<i             # Insert the current number to that array
    )until a[n]&b[n];               # End loop, terminate when a[n] and b[n] are defined
    [a[n],b[n]]                     # Array with both poor and rich number (implicit return)
}                                   # End function

Try it online!

Perl 6, 76 bytes
{classify({+(.&h <=>h .flip)},^($_*3+99)){-1,1}[*;$_]}
my&h={grep $_%%*,^$_}

Try it online!
I didn't see Sean's Perl 6 answer, but this works in a different way. Note that I've hardcoded the upperbound as n*3+99, which is probably not strictly correct. However, I could replace the *3 with ³ for no extra bytes, which would make the program far less efficient, if more correct.

Python 2, 152 bytes
def f(n):
 a,b=[],[];i=1
 while not(a[n:]and b[n:]):[[],b,a][cmp(*[sum(m%-~i<1for i in range(m))for m in i,int(`i`[::-1])])]+=[i];i+=1
 return a[n],b[n]

Try it online!
Ends up being pretty similar to Rod's answer. Returns zero-indexed nth poor, rich tuple.

148 bytes using default function parameters and the zip function.

Icon, 180 175 bytes
procedure f(n)
a:=[];b:=[];k:=1
while{s:=t:=0
i:=1to k+(m:=reverse(k))&(k%i=0&s+:=1)|(m%i=0&t+:=1)&\x
s>t&n>*a&push(a,k)
s<t&n>*b&push(b,k)
k+:=1;n>*a|n>*b}
return[!b,!a];end

Try it online!

JavaScript (Node.js), 190 180 bytes
Outputs as [poor, rich].
n=>{let p,r,f=h=i=0;while(f<n){k=d(i),e=d(+(i+"").split``.reverse().join``);if(k<e){p=i;f++}if(k>e&&h<n){r=i;h++}i++}return[p,r]}
d=n=>{c=0;for(j=1;j<=n;j++)if(n%j==0)c++;return c}

Try it online!
Explanation
d(n) Function
This helper finds the number of factors that a number has.
d=n=>{              // Equivalent to `function d(n) {
  c=0;              // Counter
  for(j=1;j<=n;j++) // Check every integer from 1 to n
    if(n%j==0)c++;  // If the number is a factor, add 1 to the counter
  return c
};

Main Function
n=>{
  let p,r,f=h=i=0; // p -> the poor number, r -> the rich number, f -> the number of poor numbers found, h -> the number of rich numbers found, i -> the current number being checked
  while(f<n){ // While it's found less than n poor numbers (assumes that it will always find the rich number first)
    k=d(i),        // k -> number of factors of i
    e=d(+((i+"").split``.reverse().join``)); // e -> number of factors of reversed i
    if(k<e){p=i;f++}  // If it hasn't found enough poor numbers and i is poor, save it and count it
    if(k>e&&h<n){r=i;h++}  // If it hasn't found enough rich numbers and i is rich, save it and count it
    i++
  };
  return[p,r]
}

C# (Visual C# Interactive Compiler), 221 bytes
n=>{int g,h,i,j=9,k,l,m,o,r,p;m=o=r=p=0;while(m<n||o<n){k=g=h=0;l=++j;while(l!=0){k=k*10+l%10;l/=10;}for(i=2;i<j+k;i++){if(j%i<1&&i<j)g++;if(k%i<1&&i<k)h++;}if(g<h&&o<n){o++;p=j;}if(g>h&&m<n){m++;r=j;}}return new{n,p,r};}

Try it online!

205 bytes


text:
Parse a C++14 integer literal
According to http://en.cppreference.com/w/cpp/language/integer_literal, integer literals consist of a decimal/hex/octal/binary literal and a optional integer suffix, that is obviously completely unnecessary, wastes precious bytes and is not used in this challenge.
A decimal literal is a non-zero decimal digit (1, 2, 3, 4, 5, 6, 7, 8, 9), followed by zero or more decimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9).
A octal literal is the digit zero (0) followed by zero or more octal digits (0, 1, 2, 3, 4, 5, 6, 7).
A hexadecimal literal is the character sequence 0x or the character sequence 0X followed by one or more hexadecimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, A, b, B, c, C, d, D, e, E, f, F) (note the case-insensitivity of abcdefx).
A binary literal is the character sequence 0b or the character sequence 0B followed by one or more binary digits (0, 1).
Additionally, there may optionally be some 's as a digit separator. They have no meaning and can be ignored.
Input
A string that represents a C++14 integer literal or an array of its charcodes.
Output
The number represented by the input string in base 10, with an optional trailing newline. The correct output never will exceed 2*10^9
Winning criteria
The GCC contributors need over 500 lines of code to do this, therefore our code must be as short as possible!
Test cases:
0                       ->    0
1                       ->    1
12345                   ->    12345
12345'67890             ->    1234567890
0xFF                    ->    255
0XfF                    ->    255
0xAbCdEf                ->    11259375
0xa'bCd'eF              ->    11259375
0b1111'0000             ->    240
0b0                     ->    0
0B1'0                   ->    2
0b1                     ->    1
00                      ->    0
01                      ->    1
012345                  ->    5349
0'123'4'5               ->    5349

Sandbox link

Will there be combined cases like 0b10xA

@LuisfelipeDejesusMunoz No; how did you expect that to be parsed?

Since binary literals starts with 0b and hexadecimal starts with 0x we can assume that 0b10xA can be 110 (just a suggestion for another challenge)

I assume simply writing a function in C++14 would be cheating, right?  Since the compiler already does it automatically (even if it is internally 500+ lines of code...)

@DarrelHoffman You couldn't just do it with "a function in C++14" though, since that wouldn't take a string input. Maybe with some script that invokes a C++ compiler.

The string 0 might be a good test case to add (it revealed a bug in one of my recent revisions).

Note that the rules do allow '0' as a valid octal literal.

@DarrelHoffman: C++ has no eval. The language model is designed around strictly ahead-of-time compilation. Of course interpreting or JIT implementations are possible, but there are no language built-ins for getting new source code parsed at run-time. C++ is one of the more complicated languages to parse (full of near ambiguities between operator vs. template or function declaration vs. whatever: the most vexing parse), and compiling template / constexpr code can require arbitrary amounts of computation.

The correct output never will exceed 2*10^9 does this mean the test cases won't exceed 2000000000 or does it mean we need to over/underflow?

That means the test cases never exceed 2'000'000'000.

Japt, 6 bytes
OxUr"'

OxUr"'  Full Program. Implicit Input U
  Ur"'  Remove ' from U
Ox      Eval as javascript

Try it online!

How does this work?

@lirtosiast Basically the same as my js answer. I Remove ' from the input and then evaluate it as Js

x86 (32-bit) machine code, 59 57 bytes
This function takes esi as a pointer to a null-terminated string and returns the value in edx.  (Listing below is GAS input in AT&T syntax.)
        .globl parse_cxx14_int
        .text
parse_cxx14_int:
        push $10
        pop %ecx                # store 10 as base
        xor %eax,%eax           # initialize high bits of digit reader
        cdq                     # also initialize result accumulator edx to 0
        lodsb                   # fetch first character
        cmp $'0', %al
        jne .Lparseloop2
        lodsb
        and $~32, %al           # uppercase letters (and as side effect,
                                # digits are translated to N+16)
        jz .Lend                # "0" string
        cmp $'B', %al           # after '0' have either digit, apostrophe,
                                # 'b'/'B' or 'x'/'X'
        je .Lbin
        jg .Lhex
        dec %ecx
        dec %ecx                # update base to 8
        jmp .Lprocessdigit      # process octal digit that we just read (or
                                # skip ' if that is what we just read)
.Lbin:
        sub $14, %ecx           # with below will update base to 2
.Lhex:
        add $6, %ecx            # update base to 16
.Lparseloop:
        lodsb                   # fetch next character
.Lparseloop2:
        and $~32, %al           # uppercase letters (and as side effect,
                                # digits are translated to N+16)
        jz .Lend
.Lprocessdigit:
        cmp $7, %al             # skip ' (ASCII 39 which would have been
                                # translated to 7 above)
        je .Lparseloop
        test $64, %al           # distinguish letters and numbers
        jz .Lnum
        sub $39, %al            # with below will subtract 55 so e.g. 'A'==65
                                # will become 10
.Lnum:
        sub $16, %al            # translate digits to numerical value
        imul %ecx, %edx
#        movzbl %al, %eax
        add %eax, %edx          # accum = accum * base + newdigit
        jmp .Lparseloop
.Lend:
        ret

And a disassembly with byte counts - in Intel format this time, in case you prefer that one.
Disassembly of section .text:

00000000 <parse_cxx14_int>:
   0:   6a 0a                   push   0xa
   2:   59                      pop    ecx
   3:   31 c0                   xor    eax,eax
   5:   99                      cdq
   6:   ac                      lods   al,BYTE PTR ds:[esi]
   7:   3c 30                   cmp    al,0x30
   9:   75 16                   jne    21 <parse_cxx14_int+0x21>
   b:   ac                      lods   al,BYTE PTR ds:[esi]
   c:   24 df                   and    al,0xdf
   e:   74 28                   je     38 <parse_cxx14_int+0x38>
  10:   3c 42                   cmp    al,0x42
  12:   74 06                   je     1a <parse_cxx14_int+0x1a>
  14:   7f 07                   jg     1d <parse_cxx14_int+0x1d>
  16:   49                      dec    ecx
  17:   49                      dec    ecx
  18:   eb 0b                   jmp    25 <parse_cxx14_int+0x25>
  1a:   83 e9 0e                sub    ecx,0xe
  1d:   83 c1 06                add    ecx,0x6
  20:   ac                      lods   al,BYTE PTR ds:[esi]
  21:   24 df                   and    al,0xdf
  23:   74 13                   je     38 <parse_cxx14_int+0x38>
  25:   3c 07                   cmp    al,0x7
  27:   74 f7                   je     20 <parse_cxx14_int+0x20>
  29:   a8 40                   test   al,0x40
  2b:   74 02                   je     2f <parse_cxx14_int+0x2f>
  2d:   2c 27                   sub    al,0x27
  2f:   2c 10                   sub    al,0x10
  31:   0f af d1                imul   edx,ecx
  34:   01 c2                   add    edx,eax
  36:   eb e8                   jmp    20 <parse_cxx14_int+0x20>
  38:   c3                      ret

And in case you want to try it, here is the C++ test driver code that I linked with it (including the calling convention specification in GCC asm syntax):
#include <cstdio>
#include <string>
#include <iostream>

inline int parse_cxx14_int_wrap(const char *s) {
    int result;
    const char* end;
    __asm__("call parse_cxx14_int" :
            "=d"(result), "=S"(end) :
            "1"(s) :
            "eax", "ecx", "cc");
    return result;
}

int main(int argc, char* argv[]) {
    std::string s;
    while (std::getline(std::cin, s))
        std::printf("%-16s -> %d\n", s.c_str(), parse_cxx14_int_wrap(s.c_str()));
    return 0;
}

-1 byte due to comment by Peter Cordes
-1 byte from updating to use two decrements to change 10 to 8

Only you're missing tests for overflows... Too large a number gets reported by compilers.

Can you swap your register usage for rdx and rbx?  Then you can use 1-byte cdqto zerordxfromeax`.

This should be either list the byte count of your assembly, or be labelled as 59 bytes of x86 machine code.

@PeterCordes Thanks, didn't know about that one.  (Also, on looking at it again, I noticed that changing the base from 10 to 8 could be 2 bytes - from two decrement instructions - instead of 3 bytes.)

@DanielSchepler: See Tips for golfing in x86/x64 machine code.  Another nice way to generate constants is lea 10(%eax), %edx 3 bytes given a known constant, same as push/pop but more efficient.

@Potato44 Fair enough, I changed the title to "machine code".

@AlexisWilke It also doesn't test for invalid format (e.g. digits out of range of the given base) which compilers would also do.  But according to the problem statement, the input is guaranteed to be valid and not to overflow a 32-bit signed integer.

You could make this 64-bit code again without losing bytes by using 2-byte mov $8, %cl instead of 2x dec %ecx.  That code is only reached with ECX=10 so we know the upper bytes are already zero.  (Fun fact: that's better for performance on Haswell and newer, and non-Intel CPUs.  Only P6-family has partial-register stalls when reading the full reg later.)

NVM we do still want 32-bit mode. dec %ecx / loop .Lprocessdigit is even better, folding dec+jmp into a 2-byte dec-and-branch that's going to be taken because --ecx != 0.  And yes, loop can jump forward; it uses a regular signed rel8.

For decoding B vs. X vs. octal, B is 01000010 (low bits = 2) while X is 01011000 (one of the set bits = 1<<4 = 16).  After excluding al<'B' with a jl .Lparseloop2 (which will check for a terminator), we can do and $0b0010010, %al (2 bytes) / xchg %eax, %ecx (1 byte) and fall into the loop.  This leaves the upper bytes of both EAX and ECX still zero, as required, because we have that guarantee before xchg.

Yup, that helped.  46 bytes.  https://godbolt.org/z/6epa8_. (and tested with the question's test cases on my desktop, with your handy C++ caller).  I also restructured the main loop with the loop branch at the bottom because I thought I was going to be able to fall into it or use dec / loop, but that didn't happen.  So it ended up being neutral for code size, saving a jmp at the bottom but adding another jmp to enter it.

44 bytes, removing an add from inside the digit loop by redoing the checks with a more normal sub/cmp range check.  https://godbolt.org/z/x7SFvq.  BTW, I was expecting it would take more instructions to turn 'B' and 'X' into integers, like maybe an add and a right-shift as well.  I was really surprised that just one AND does the trick.

I posted my version as a separate answer; I think the AND trick is different enough to justify it.  Thanks for the starting point and test harness, would upvote again if I could. :)

JavaScript (Babel Node), 26 bytes
lol x2
_=>eval(_.split`'`.join``)

Try it online!

This isn't BabelJS exclusive, it works from ES6 onwards

@BassdropCumberwubwubwub, the header was probably copied from TIO.

Nice, I first tried to use Number because it handles binary and hex, but apparently not octal Number("010") === 10

C++ (gcc), 141 138 134 120 bytes
This is a function that takes an array of characters (specified as a pair of pointers to the start and end - using the pair of iterators idiom) and returns the number.  Note that the function mutates the input array.
(This does rely on the behavior of gcc/libstdc++ that #include<cstdlib> also places the functions in global scope.  For strictly standard compliant code, replace with #include<stdlib.h> for a cost of one more character.)
Brief description: The code first uses std::remove to filter out ' characters (ASCII 39).  Then, strtol with a base of 0 will already handle the decimal, octal, and hexadecimal cases, so the only other case to check for is a leading 0b or 0B and if so, set the base for strtol to 2 and start parsing after the leading 2 characters.
#import<algorithm>
#import<cstdlib>
int f(char*s,char*e){e=s[*std::remove(s,e,39)=1]&31^2?s:s+2;return strtol(e,0,e-s);}

Try it online.

Saved 3 bytes due to suggestion by ceilingcat and some more golfing that followed.
Saved 4 bytes due to suggestions by grastropner.
-2 bytes by Lucas
-12 bytes by l4m2

134 bytes

Incorporated, thanks.

132 bytes by using the deprecated #import instead of #include?

If invalid input is undefined behavior, no need to check if 1st char is 0 for base 2

so 124

122

120

Nice!  Thanks, I'll incorporate that.

I do -12B, other 2 come from Lucas

99

Python 2, 32 bytes
lambda a:eval(a.replace("'",""))

Try it online!
lol
(needs Python 2 because Python 3 changed octal literals to 0o(...)).

we've truly gone full circle at this point

x86-64 machine code, 44 bytes
(The same machine code works in 32-bit mode as well.)
@Daniel Schepler's answer was a starting point for this, but this has at least one new algorithmic idea (not just better golfing of the same idea): The ASCII codes for 'B' (1000010) and 'X' (1011000) give 16 and 2 after masking with 0b0010010.
So after excluding decimal (non-zero leading digit) and octal (char after '0' is less than 'B'), we can just set base = c & 0b0010010 and jump into the digit loop.
Callable with x86-64 System V as unsigned __int128 parse_cxx14_int(int dummy, const char*rsi);  Extract the EDX return value from the high half of the unsigned __int128 result with tmp>>64.
        .globl parse_cxx14_int
## Input: pointer to 0-terminated string in RSI
## output: integer in EDX
## clobbers: RAX, RCX (base), RSI (points to terminator on return)
parse_cxx14_int:
        xor %eax,%eax           # initialize high bits of digit reader
        cdq                     # also initialize result accumulator edx to 0
        lea 10(%rax), %ecx      # base 10 default
        lodsb                   # fetch first character
        cmp $'0', %al
        jne .Lentry2
    # leading zero.  Legal 2nd characters are b/B (base 2), x/X (base 16)
    # Or NUL terminator = 0 in base 10
    # or any digit or ' separator (octal).  These have ASCII codes below the alphabetic ranges
    lodsb

    mov    $8, %cl              # after '0' have either digit, apostrophe, or terminator,
    cmp    $'B', %al            # or 'b'/'B' or 'x'/'X'  (set a new base)
    jb   .Lentry2               # enter the parse loop with base=8 and an already-loaded character
         # else hex or binary. The bit patterns for those letters are very convenient
    and    $0b0010010, %al      # b/B -> 2,   x/X -> 16
    xchg   %eax, %ecx
    jmp  .Lentry

.Lprocessdigit:
    sub  $'0' & (~32), %al
    jb   .Lentry                 # chars below '0' are treated as a separator, including '
    cmp  $10, %al
    jb  .Lnum
    add  $('0'&~32) - 'A' + 10, %al   # digit value = c-'A' + 10.  we have al = c - '0'&~32.
                                        # c = al + '0'&~32.  val = m+'0'&~32 - 'A' + 10
.Lnum:
        imul %ecx, %edx
        add %eax, %edx          # accum = accum * base + newdigit
.Lentry:
        lodsb                   # fetch next character
.Lentry2:
        and $~32, %al           # uppercase letters (and as side effect,
                                # digits are translated to N+16)
        jnz .Lprocessdigit      # space also counts as a terminator
.Lend:
        ret

The changed blocks vs. Daniel's version are (mostly) indented less than other instruction.  Also the main loop has its conditional branch at the bottom.  This turned out to be a neutral change because neither path could fall into the top of it, and the dec ecx / loop .Lentry idea for entering the loop turned out not to be a win after handling octal differently.  But it has fewer instructions inside the loop with the loop in idiomatic form do{}while structure, so I kept it.
Daniel's C++ test harness works unchanged in 64-bit mode with this code, which uses the same calling convention as his 32-bit answer.
g++ -Og parse-cxx14.cpp parse-cxx14.s &&
./a.out < tests | diff -u -w - tests.good

Disassembly, including the machine code bytes that are the actual answer
0000000000000000 <parse_cxx14_int>:
   0:   31 c0                   xor    %eax,%eax
   2:   99                      cltd
   3:   8d 48 0a                lea    0xa(%rax),%ecx
   6:   ac                      lods   %ds:(%rsi),%al
   7:   3c 30                   cmp    $0x30,%al
   9:   75 1c                   jne    27 <parse_cxx14_int+0x27>
   b:   ac                      lods   %ds:(%rsi),%al
   c:   b1 08                   mov    $0x8,%cl
   e:   3c 42                   cmp    $0x42,%al
  10:   72 15                   jb     27 <parse_cxx14_int+0x27>
  12:   24 12                   and    $0x12,%al
  14:   91                      xchg   %eax,%ecx
  15:   eb 0f                   jmp    26 <parse_cxx14_int+0x26>
  17:   2c 10                   sub    $0x10,%al
  19:   72 0b                   jb     26 <parse_cxx14_int+0x26>
  1b:   3c 0a                   cmp    $0xa,%al
  1d:   72 02                   jb     21 <parse_cxx14_int+0x21>
  1f:   04 d9                   add    $0xd9,%al
  21:   0f af d1                imul   %ecx,%edx
  24:   01 c2                   add    %eax,%edx
  26:   ac                      lods   %ds:(%rsi),%al
  27:   24 df                   and    $0xdf,%al
  29:   75 ec                   jne    17 <parse_cxx14_int+0x17>
  2b:   c3                      retq

Other changes from Daniel's version include saving the sub $16, %al from inside the digit-loop, by using more sub instead of test as part of detecting separators, and digits vs. alphabetic characters.
Unlike Daniel's every character below '0' is treated as a separator, not just '\''.  (Except ' ': and $~32, %al / jnz in both our loops treats space as a terminator, which is possibly convenient for testing with an integer at the start of a line.)
Every operation that modifies %al inside the loop has a branch consuming flags set by the result, and each branch goes (or falls through) to a different location.

Do you even need the initialization of eax given that AIUI in 64-bit mode opcodes with small destination will reset the higher bits to 0?

@Daniel: writing a 32-bit register zero-extends to 64-bit.  Writing an 8 or 16-bit register keeps the behaviour from other modes: merge into the existing value.  AMD64 didn't fix the false dependency for 8 and 16-bit registers, and didn't change setcc r/m8 into setcc r/m32, so we still need a stupid 2-instruction xor-zero / set flags / setcc %al sequence to create a 32/64-bit 0 or 1 variable, and it needs the zeroed register before the flag-setting.  (Or use mov $0, %eax instead, or use movzx on the critical path).

R, 79 71 69 bytes
`+`=strtoi;s=gsub("'","",scan(,""));na.omit(c(+s,sub("..",0,s)+2))[1]

Try it online!
strtoi does everything except for the base 2 conversions and ignoring the ', so there's quite a lot of bytes just to fix those things.
Thanks to Aaron Hayman for -6 bytes, and inspiring -4 more bytes (and counting!)
Verify all test cases (old version)

can save a byte replacing sub("0b|B" with sub("b|B", since the leading "0" will not affect the value. Can get another by renaming strtoi

74 bytes: Try it online!

@AaronHayman wow, I've never seen na.omit before. Super handy here, and I golfed a bit more off :-)

If we assume every fail of the first strtoi is a binary, you can use substring instead of sub to save another byte: Try it online!

@AaronHayman we can strip off the first 2 characters of s using sub instead with sub('..','',s) which is another byte shorter!

Perl 5 (-p), 14 bytes
y/'/_/;$_=eval

TIO

05AB1E, 16 14 bytes
Saved 2 bytes thanks to Grimy
''KlÐïK>i8ö}.E

Try it online!
or as a Test Suite
Explanation
''K                # remove "'" from input
   l               # and convert to lower-case
    Ð              # triplicate
     ï             # convert one copy to integer
      K            # and remove it from the second copy
       >i  }       # if the result is 0
         8ö        # convert from base-8 to base-10
            .E     # eval

-2 bytes

And here's a fake 13 (passes all the test cases, but fails on e.g. 0010).

@Grimy: Thanks! Cool use of ï!

Excel, 115 bytes
=DECIMAL(SUBSTITUTE(REPLACE(A1,2,1,IFERROR(VALUE(MID(A1,2,1)),)),"'",),VLOOKUP(A1,{"0",8;"0B",2;"0X",16;"1",10},2))

Input from A1, output to wherever you put this formula. Array formula, so use Ctrl+Shift+Enter to enter it.
I added a couple test cases you can see in the image - some early attempts handled all given test cases correctly but got rows 16 and/or 17 wrong.

Is it against the rules to omit the final two closing parentheses and take advantage of the fact that the “compiler” (pressing return or tab) will error-correct for you?

In my personal opinion, yes. I don't think there's a site consensus. Excel adding the parentheses feels like the equivalent of a code-completion feature in another language's IDE, which should be ignored for byte counting. (But, I think "?" should be counted as 1 byte in BASIC even though it will be silently expanded to "PRINT" so maybe I'm not entirely consistent here).

Octave, 29 21 20 bytes
@(x)str2num(x(x>39))

Try it online!
-8 bytes thanks to @TomCarpenter

For 22 bytes: @(x)str2num(x(x~="'"))

Which becomes for 21 bytes: @(x)str2num(x(x~=39))

Octal doesn't appear to be working (at least on TIO)... for example, f=("077") returns ans = 77 when it should be 63. Or, as in the test case in OP f=("012345") should return 5349 but instead ans = 12345

Bash, 33 bytes
x=${1//\'};echo $[${x/#0[Bb]/2#}]

TIO
Zsh, 29 27 bytes
-2 bytes thanks to @GammaFunction
<<<$[${${1//\'}/#0[Bb]/2#}]

TIO

Clever! I would have thought setopt octalzeroes would be necessary for Zsh.

You can save 2 bytes in Zsh with <<<$[...] instead of echo $[...]

thanks, i didn't know that zsh empty command with redirection could display output, i don't know much about zsh, i know a lot better bash

i knew that bash automatically interpret numbers with leading zero to octal, and must be removed for example in date / time

J, 48 bytes
cut@'0x 16b +0b 2b +0 8b0 '''do@rplc~'+',tolower

Try it online!
Eval after string substitution.
0XfF -> +16bff -> 255
0xa'bCd'eF -> +16babcdef -> 11259375
0B1'0 -> +2b10 -> 2
0 -> 8b0 -> 0
01 -> 8b01 -> 1
0'123'4'5 -> 8b012345 -> 5349

It doesn't seem to work correctly with hexadecimals containing 0b: https://tio.run/##FcwxCsIwFAbg/Z3ip8szNJQXB5FAJVMnD@CcNEGkEAlV26FePdbvAN@jjhmc@o41NiuwUsNrdiwLzMlDPI4ereDswcxjduU5hS@3rOc85U8sVVEM93y46I6x68G6MWisS4jvWFYF7ON1wD8nQ7KIJ7mlgUjVHw

@GalenIvanov nice find, fixed

Retina, 96 bytes
T`'L`_l
\B
:
^
a;
a;0:x:
g;
a;0:b:
2;
a;0:
8;
[a-g]
1$&
T`l`d
+`;(\d+):(\d+)
;$.($`*$1*_$2*
.+;

Try it online! Link includes test suite. Explanation:
T`'L`_l

Delete 's and convert everything to lower case.
\B
:

Separate the digits, as any hex digits need to be converted into decimal.
^
a;
a;0:x:
g;
a;0:b:
2;
a;0:
8;

Identify the base of the number.
[a-g]
1$&
T`l`d

Convert the characters a-g into numbers 10-16.
+`;(\d+):(\d+)
;$.($`*$1*_$2*

Perform base conversion on the list of digits. $.($`*$1*_*$2* is short for $.($`*$1*_*$2*_) which multiplies $` and $1 together and adds $2. ($` is the part of the string before the ; i.e. the base.)
.+;

Delete the base.

I appreciate the literal programming approach you took to explain the code :-)

Perl 6, 29 bytes
{+lc S/^0)>\d/0o/}o{S:g/\'//}

Try it online!
Perl 6 requires an explicit 0o prefix for octal and doesn't support uppercase prefixes like 0X.
Explanation
                   {S:g/\'//}  # remove apostrophes
{                }o  # combine with function
     S/^0)>\d/0o/    # 0o prefix for octal
  lc  # lowercase
 +    # convert to number

Go, 75
import "strconv"
func(i string)int64{n,_:=strconv.ParseInt(i,0,0);return n}

This doesn't appear to work for binary literals, nor for single-quote digit delimiters.

Oh crap. I'll fix it soon. Completely forgot about the delimiters

JavaScript (ES6), 112 bytes
n=>+(n=n.toLowerCase().replace(/'/g,""))?n[1]=="b"?parseInt(n.substr(2),2):parseInt(n,+n[0]?10:n[1]=="x"?16:8):0

Jelly, 27 bytes
ØDiⱮḢ=1aƲȦ
ṣ”';/Ḋ⁾0o;Ɗ¹Ç?ŒV

Try it online!
Almost all of this is handling octal. Feels like it could be better golfed.

Java, 158 154 bytes
This just waiting to be outgolfed. Just tries regexes until something works and default to hex.

-4 bytes thanks to @ValueInk
n->{n=n.replace("'","");var s=n.split("[bBxX]");return Long.parseLong(s[s.length-1],n.matches("0[bB].+")?2:n.matches("0\\d+")?8:n.matches("\\d+")?10:16);}

Try it online

Using ScriptEngine, 92 87 bytes
Eval train coming through. Technically this is passing the torch to JS, so it's not my main submission.
n->new javax.script.ScriptEngineManager().getEngineByName("js").eval(n.replace("'",""))

TIO

Use [bBxX] and 0[bB].+ for some quick regex optimizations.

That's, not an Integer it's a Long, the title clearly says Integer, a single or double precision IEEE754 could become incorrect due to the method used to save the number when due to the decimal place system in IEEE754 https://en.wikipedia.org/wiki/IEEE_754#Roundings_to_nearest, it also supports a number higher than 2 trillion (0x9999999999)

@MartinBarker it's allowed to use Long instead of Integer for golfing purposes. Also, if you are correct, Python can't compete because it has effectively arbitrary-precision integers. Also, a long in Java is an integer represented with 64 bits instead of 32. There are no decimal places.

The Long thing was just you're using long not an integer and you're wrong about the golfing purposes, The correct output never will exceed 2*10^9 it quite clearly states that meaning that long can't be used on its own because I can give it 0x9999999999 and it will produce a number higher than 2*10^9 whereas C++ it would create a memory overflow issue because your using more than 32 bits on memory when you have allocated only 32 bits of memory to this number

@MartinBarker I 100% disagree. Just because my submission can exceed 2*10^9 doesn't mean it's invalid. If it was, all the "normal" int answers would be invalid as well since they go to (2^31)-1, which is larger.

Ruby with -n, 17 bytes
Just jumping on the eval train, really.
p eval gsub(?'){}

Try it online!

Java (JDK), 101 bytes
n->{n=n.replace("'","");return n.matches("0[bB].+")?Long.parseLong(n.substring(2),2):Long.decode(n);}

Try it online!
Long.decode deals with all kinds of literals except the binary ones.
Template borrowed from Benjamin's answer

Nice. I need to look more at the functions primitive wrappers have

C (gcc), 120 118 bytes
-1 byte thanks to ceilingcat
f(char*s){int r=0,c=s[1]&31,b=10;for(s+=2*(*s<49&&(b=c^24?c^2?8:2:16)-8);c=*s++;)r=c^39?r*b+(c>57?c%32+9:c-48):r;c=r;}

Try it online!

C (gcc), 101 97 83 bytes
*d;*s;n;f(int*i){for(s=d=i;*d=*s;d+=*s++>39);i=wcstol(i+n,0,n=!i[1]||i[1]&29?0:2);}

Try it online

C (gcc) / Bash / C++, 118 bytes
f(i){asprintf(&i,"echo \"#import<iostream>\nmain(){std::cout<<%s;}\">i.C;g++ i.C;./a.out",i);fgets(i,i,popen(i,"r"));}

Try it online!

I have golfed some code. Then I have realized there is no reason at all for it to work, but it seems to work; 158 bytes.

@someone, it's nasty, but I like it!

148 bytes by merging popen and system. G++ has a flag, I think -x, to read from stdin. That might be shorter than fopen stuff, but I don't know how to invoke with stdin in C.

@someone, Everything is now merged into the popen command

printf -> echo seems to work. You're going to be programming in bash soon.

I'm not going down that rabbit hole :) It occurred to me that one can use Python for the inner program, something like this: system("python -c 'print(0b11)'");

PHP - 43 Byte
eval("return ".str_replace($a,"'","").";");

Same method as https://codegolf.stackexchange.com/a/185644/45489

C++, G++, 189 bytes
#include<fstream>
#include<string>
void v(std::string s){{std::ofstream a("a.cpp");a<<"#include<iostream>\nint main(){std::cout<<"<<s<<";}";}system("g++ -std=c++14 a.cpp");system("a.exe");}

No need for tests
Requires installation of g++ with C++14 support
Now, explanations :

 It writes a file called a.cpp, uses GCC to compile it and gives a file that output the number

175 bytes

Pyth, 27 bytes
Jscz\'?&qhJ\0}@J1r\0\7iJ8vJ

Try it online!
Unlike the previous (now deleted) Pyth answer, this one passes all test cases in the question, though it is 3 bytes longer.

Welcome to the site!

source: Stack Exchange

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

sort: votes


text:
Convert a number into "bracket" numerals
"Bracket" numerals are a type of 'numerals' I made up once, and thought would be a nice challenge here. Basically, you convert the input number into base 6, and then transliterate the 012345 respectively with ()[]{}†, so every 0 becomes (, every 1 becomes ), etc.
You don't have to use ()[]{} per se. As long as you specify what characters you use, you can use any other characters (except for digits, otherwise just converting to base-6 would have been enough!)
Since this is tagged code-golf, the score is in bytes, where the least amount of bytes wins.
A few examples: 6 = )(. 100200 = [(})}[(. 44790 = }{][)(.
Here is some lengthy JavaScript code which accomplishes what I described above. Since it's a snippet (using variable x) instead of a function or full program, it isn't valid however:
var [x,q,w] = [0,0,0];q = x.toString('6');w = q.replace(/0/g, '(');q = w.replace(/1/g, ')');w = q.replace(/2/g, '[');q = w.replace(/3/g, ']');w = q.replace(/4/g, '{');q = w.replace(/5/g, '}');console.log(q);

Yes, that is 207 bytes. You probably can do better! I will accept an answer on June 1st, 2019, but you can continue to post answers afterwards of course.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call. So you aren't allowed to have a var x like I did in my example JavaScript snippet.
Default Loopholes are forbidden.

The contest ended 2 weeks ago? Can you give some sample inputs/outputs and test cases?

Penalties and bonuses generally don't make challenges more fun. That said, I think you intended to make using a variable as input penalised but it actually gives an unbeatable score of zero? I'd recommend just removing them but if you want to keep them then that definitely needs to change.

As long as you specify what characters you use, you don't need to use brackets: so we can just convert to base 6?

I would actually remove the 2nd "bonus" entirely rather than turning it into a penalty. Languages that can take dynamic input almost always will, be it from args, stdin, or function params, and it's unfair to penalize languages that can't take dynamic input

Do we need to support $n=0$?

I disagree that this is unclear. It may be a bad challenge that has a lot of loopholes that can be downvoted, but that doesn't make it unclear.

I've edited your challenge to make it more in line with other challenges. If you see anything incorrect after my edit, feel free to change it again. I've also added a rule that digits are disallowed completely in your characters of choice, which automatically disqualifies simply converting to base-6.

If you choose to keep @KevinCruijssen's changes then be sure to inform all existing solutions that simply converting to base-6 is no longer permitted. (I'll hold off on updating my own solution until you do so).

Whether or not 0 needs to be handled as input still needs to be addressed. Also, can we use unprintable characters in the replacement?

Japt, 4 bytes
Uses [objec.
s6îM

Try it
Alternative 4 bytes
Uses the (unprintable) characters at codepoints 1-6.
s6õd

Try it
Or, if that's not allowed:
5 bytes
Using !"#$%&.
s6õdH

Try it
Or, also (using wander):
s`æ`â

Try it
If I can figure out a 6 letter word that Shoco can compress to a single character then that last one can be golfed to 3 bytes.

;sF¯6 also works for 5

@EmbodimentofIgnorance, that's different enough to post yourself. I was deliberately avoiding the alt. variables 'cause having to add 25% to my score with ; was annoying me!

05AB1E, 11 10 5 4 bytes
All three programs below will return a list of characters instead of a joined string.
žOÅв

Uses aeiouy instead of ()[]{} for 0123456 respectively.
Try it online.

Answers which actually use ()[]{}:
11 10 8 bytes:
žu„<>мÅв

Try it online
8 bytes alternative by @Grimy:
…([{º{Åв

Try it online.
Explanation:
žO        # Push string builtin "aeiouy"
  Åв      # Convert the (implicit) input to this custom base-"aeiouy"
          # (which is output implicitly as result)

žu        # Push string builtin "()<>[]{}"
  „<>м    # Remove the "<>" from this string: "()[]{}"
      Åв  # Convert the (implicit) input to this custom base-"()[]{}"
          # (which is output implicitly as result)

…([{      # Push string "([{"
    º     # Mirror it vertically to "([{}])"
     {    # Sort the characters in the string: "()[]{}"
      Åв  # Convert the (implicit) input to this custom base-"()[]{}"
          # (which is output implicitly as result)

There's a builtin which pushes ()<>[]{}? Just why?

@EmbodimentofIgnorance it could be because ()<>[]{} are all the typeable "bracket" characters on your keyboard i.e. all of them are used to enclose something. Maybe the purpose is so you can do what @KevinCruijssen did here and crop out some characters so you have some else.

Alternative 8-byter using ()[]{}: …({[º{Åв. (Or drop the { for a 7 byter using the same characters but in a different order).

@Grimy Ah, I indeed tried with both …({[ and º as well to see if I could make something shorter, but ended up at 10 bytes. Didn't realize the sort would put them in the desired ()[]{} order. :)

JavaScript (ES6),  36  34 bytes
Saved 2 bytes thanks to @Shaggy
Character set: [,o,b,j,e and c.
f=n=>(n>5?f(n/6|0):'')+({}+0)[n%6]

Try it online!

34 bytes, using alternative characters.

So you saved -28 bytes? I think you replaced the wrong digit.

Bash, 65 63 60 bytes
Using STDIN and not command line arguments:

while read n;do echo "obase=6;$n"|bc|tr 012345 '()[]{}';done

Try it online!

Nice one. You may try dc, is often shorter than bc: while read n;do dc<<<6o$n\ p|tr 012345 '()[]{}';done.

Ahh!  Don't use dc very much -- cannot stand RP notation :-), reminds me of very old steam powered calculators.  Thanks for the tip mind.  And yes, I could have removed the first pair of ' ' but habit means I left them in.

Rejected post approved by answerer (me) as I forgot to login when I amended it.  Removed 3 bytes by deleting superfluous 'bc' option.

Charcoal, 8 bytes
⍘Ｎ()[]{}

Try it online! Link is to verbose version of code. Explanation:
 Ｎ          Input as a number
⍘           Base convert using specified characters
  ()[]{}    Literal string of required characters

5 bytes using the letters a-f (or A-F also works):
⍘Ｎ…β⁶

Try it online! Link is to verbose version of code. Explanation:
 Ｎ      Input as a number
⍘       Base convert using
  … ⁶   First six characters of
   β    Lowercase alphabet

Wolfram Language (Mathematica), 64 bytes
#~IntegerDigits~6/.Table[k->StringTake["()[]{}",{k+1}],{k,0,5}]&

Try it online!

41 bytes

PHP, 53 bytes
<?=strtr(base_convert($argn,10,6),'012345','()[]{}');

Try it online!
I'll be honest, I still don't understand the bonus, but here's a PHP version.

Huh.. How are you able to post an answer when it's closed as unclear for more than an hour?

@KevinCruijssen, you can still post from the SE app after a question has been closed if you loaded it before it was closed or had a draft saved.

@kevincruijssen, I just posted this from the web version. Possibly I hadn't refreshed the page since the question was closed and it doesn't check for it. Smells like a SE bug report!

C# (Visual C# Interactive Compiler), 47 bytes
n=>m=>{do m[0]+="()[]{}"[n%6];while((n/=6)>0);}

Try it online!

Jelly, 3 bytes
ṃØỵ

Try it online!
Uses ‘aeiouy’ for ‘01235’.

APL (Dyalog Extended), 13 bytes
'()[]{}'⊇⍨6∘⊤

Try it online!
Pretty straightforward tacit function. Test cases used are 15 randomly selected integers between 0 and 999.
Uses ⎕IO←0.
Thanks to @Adám for 2 bytes
How:
'()[]{}'⊇⍨6∘⊤ ⍝ Tacit function
          6∘⊤ ⍝ Convert input to base 6
        ⊇     ⍝ Index the right argument with the indices in the left argument
         ⍨    ⍝ With arguments swapped
'()[]{}'      ⍝ Character vector

Ruby, 28 bytes
Uses abcdef in place of 012345.
->x{x.to_s(6).tr'0-5','a-f'}

Try it online!

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


text:
Gambler's Fallacy Dice
The gambler's fallacy is a cognitive bias where we mistakenly expect things that have occurred often to be less likely to occur in the future and things that have not occurred in a while to be more likely to happen soon. Your task is to implement a specific version of this.
Challenge Explanation
Write a function that returns a random integer between 1 and 6, inclusive. The catch: the first time the function is run, the outcome should be uniform (within 1%), however, each subsequent call will be skewed in favor of values that have been rolled fewer times previously. The specific details are as follows:

The die remembers counts of numbers generated so far.
Each outcome is weighted with the following formula: \$count_{max} - count_{die} + 1\$

For instance, if the roll counts so far are \$[1, 0, 3, 2, 1, 0]\$, the weights will be \$[3, 4, 1, 2, 3, 4]\$, that is to say that you will be 4 times more likely to roll a \$2\$ than a \$3\$.
Note that the formula means that a roll outcome of \$[a, b, c, d, e, f]\$ is weighted the same as \$[a + n, b + n, c + n, d + n, e + n, f + n]\$

Rules and Assumptions

Standard I/O rules and banned loopholes apply
Die rolls should not be deterministic. (i.e. use a PRNG seeded from a volatile source, as is typically available as a builtin.)
Your random source must have a period of at least 65535 or be true randomness.
Distributions must be within 1% for weights up to 255

16-bit RNGs are good enough to meet both the above requirements. Most built-in RNGs are sufficient.

You may pass in the current distribution as long as that distribution is either mutated by the call or the post-roll distribution is returned alongside the die roll. Updating the distribution/counts is a part of this challenge.
You may use weights instead of counts. When doing so, whenever a weight drops to 0, all weights should increase by 1 to achieve the same effect as storing counts.

You may use these weights as repetitions of elements in an array.

Good luck. May the bytes be ever in your favor.

It appears you can comply with all the rules and banned loopholes by starting with a random number n, then outputting (n++ % 6).

@Fax This problem specifies explicitly and exactly what the distribution of the $k$th number should be given the first $k-1$ numbers.Your idea gives obviously the wrong distribution for the second number given the first number.

@JiK I disagree, as that argument could be used against any other code that uses a PRNG as opposed to true random. My proposal is a PRNG, albeit a very simplistic one.

@JiK Assuming you're talking about theoretical distribution, that is. Measured distribution is within the required 1% for a $k$ large enough to have statistical significance.

@Fax Your random source doesn't have a period of at least 65535, so it's not a PRNG sufficient for this problem. Also I don't understand what you mean by "measured distribution".

@JiK That is false, the period of n++ is limited only by its implementation. As for "measured distribution", I meant frequency distribution as opposed to "theoretical distribution", i.e. probability distribution.

What do you mean by frequency distribution in this case? How do you show that your frequency distribution corresponds to the distribution that is wanted in this problem?

@JiK It doesn't. I was thinking how serial rolls converge towards uniform probability, and it took me a while to realize that you have to perform parallel rolls and group by previous output to get the measurement desired in rule #3. My original proposal doesn't meet that requirement (nor does any solution that uses a fixed seed).

@Fax technically that would not be a correct distribution if you simply cycle through die rolls; the distribution would be 100/0/0/0/0/0 for the first roll. I just explicitly banned that technique anyway.

R, 59 bytes
function(){T[o]<<-T[o<-sample(6,1,,max(T)-T+1)]+1
o}
T=!1:6

Try it online!
Keeps the counts in T, which is then transformed to be used as the weights argument to sample (which then most likely normalizes them to sum to 1).
The [<<- operator is used to assign a value to T in one of the parent environments (in this case, the only parent environment is .GlobalEnv).

Nice use of global assignment. Any reason you called your variable T? (Apart from making the code harder to read!)

@RobinRyder I think my original idea was to use T or F internally to the function, and then I was too lazy to change it once I realized I needed global assignment.

@RobinRyder: I am surprised you are not proposing a Wang-Landau solution!

@Xi'an I did start working on one! But the byte count was way too high when using package pawl.

Python 3, 112 99 bytes
from random import*
def f(C=[0]*6):c=choices(range(6),[1-a+max(C)for a in C])[0];C[c]+=1;print(c+1)

Try it online!
Explanation
# we only need the "choice" function
from random import*

      # C, the array that holds previous choices, is created once when the function is defined
      # and is persisted afterwards unless the function is called with a replacement (i.e. f(C=[0,1,2,3,4,5]) instead of f() )
      C=[0]*6
# named function
def f(.......):
                  # generate weights
                  [1-a+max(C)for a in C]
# take the first item generated using built-in method
c=choices(range(6),......................)[0]
    # increment the counter for this choice
    C[c]+=1
    # since the array is 0-indexed, increase the number by 1 for printing
    print(c+1)

Edit: Saved 13 bytes. Thanks, attinat!

99 bytes

@attinat You can drop 2 bytes by using tuple unpacking (c,= and dropping [0]). Also worth noting that choices is Python 3.6+

05AB1E, 13 bytes
Z>αāDrÅΓΩ=Q+=

Try it online!
Takes the list of counts as input. Outputs the roll and the new counts.
Explanation:
Z                 # maximum
 >                # plus 1
  α               # absolute difference (vectorizes)
                  # the stack now has the list of weights
ā                 # range(1, length(top of stack)), in this case [1..6]
 D                # duplicate
  r               # reverse the entire stack
   ÅΓ             # run-length decode, using the weights as the run lengths
     Ω            # pick a random element
                  # the stack is now: counts, [1..6], random roll
=                 # output the roll without popping
 Q                # test for equality, vectorizing
  +               # add to the counts
   =              # output the new counts

APL (Dyalog Unicode), 32 bytesSBCS
-4 bytes using replicate instead of interval index.

{1∘+@(⎕←(?∘≢⌷⊢)(1+⍵-⍨⌈/⍵)/⍳6)⊢⍵}

Try it online!
Defined as a function that takes the current distribution as an argument, prints the resulting die roll, and returns the updated distribution. First run on TIO is 100 invocations starting with [0,0,0,0,0,0], second run is heavily biased towards 1 with [0,100,100,100,100,100], and the last run is heavily biased towards 6 in the same manner.

JavaScript (ES8), 111 bytes
_=>++C[C.map((v,i)=>s+=''.padEnd(Math.max(...C)-v+1,i),s=''),n=s[Math.random()*s.length|0]]&&++n;[,...C]=1e6+''

Try it online!
How?
This is a rather naive and most probably suboptimal implementation that performs the simulation as described.
We keep track of the counts in \$C\$. At each roll, we build a string \$s\$ consisting of each die \$i\$ repeated \$max(C)-C_i+1\$ times and pick a random entry in there with a uniform distribution.

Perl 6, 31 bytes
{--.{$/=.pick}||++«.{1..6};$/}

Try it online!
Accepts the current weight distribution as a BagHash, starting with one where all weights are 1.  The distribution is mutated in-place.
The BagHash pick method selects a key at random using the associated weights; the weight of that key is then decremented by one.  If that weight is thereby made zero, ++«.{1..6} increments the weights of all numbers 1-6.

Wolfram Language (Mathematica), 91 bytes
w=1~Table~6
F:=Module[{g},g=RandomChoice[w->Range@6];w[[g]]++;w=Array[Max@w-w[[#]]+1&,6];g]

Try it online!

Javascript (ES6+), 97 bytes
d=[1,2,3,4,5,6]
w=[...d]
r=x=>(i=~~(Math.random()*w.length),k=w[i],w.concat(d.filter(x=>x!=k)),k)

Explanation
d=[1,2,3,4,5,6]                   // basic die
w=[...d]                          // weighted die
r=x=>(                            // x is meaningless, just saves 1 byte vs ()
  i=~~(Math.random()*w.length),   // pick a random face of w
  k=w[i],                         // get the value of that face
  w.concat(d.filter(x=>x!=k)),    // add the faces of the basic die that aren't the value
                                  // we just picked to the weighted die
  k                               // return the value we picked
)

Note this will eventually blow up if w exceeds a length of 232-1, which is the max array length in js, but you'll probably hit a memory limit before then, considering a 32-bit int array 232-1 long is 16GiB, and some (most?) browsers won't let you use more than 4GiB.

Perl 6, 49 bytes
{($!=roll (1..6 X=>1+max 0,|.{*})∖$_:),$_⊎$!}

Try it online!
Takes the previous rolls as a Bag (multiset). Returns the new roll and the new distribution.
Explanation
{                                            }  # Anon block taking
                                                # distribution in $_
                     max 0,|.{*}  # Maximum count
                   1+             # plus one
           1..6 X=>  # Pair with numbers 1-6
          (                     )∖$_  # Baggy subtract previous counts
     roll                            :  # Pick random element from Bag
 ($!=                                 )  # Store in $! and return
                                       ,$_⊎$!  # Return dist with new roll

Pyth, 22 20 bytes
Xt
hOs.e*]kh-eSQbQQ1

Try it online!
Input is the previous frequencies as a list, outputs the next roll and the updated frequencies separated by a newline.
Xt¶hOs.e*]kh-eSQbQQ1   Implicit: Q=eval(input())
                       Newline replaced with ¶
      .e         Q     Map elements of Q, as b with index k, using:
             eSQ         Max element of Q (end of sorted Q)
            -   b        Subtract b from the above
           h             Increment
        *]k              Repeat k the above number of times
                       Result of the above is nested weighted list
                       e.g. [1,0,3,2,1,0] -> [[0, 0, 0], [1, 1, 1, 1], [2], [3, 3], [4, 4, 4], [5, 5, 5, 5]]
     s                 Flatten
    O                  Choose random element
   h                   Increment
  ¶                    Output with newline
 t                     Decrement
X                 Q1   In Q, add 1 to the element with the above index
                       Implicit print

Jelly, 12 bytes
’ạṀJx$X,Ṭ+¥¥

Try it online!
A monadic link which takes a single argument, the current count list, and returns a list of the number chosen and the updated count list.
Jelly, 18 bytes
0x6+ɼṀ_®‘Jx$XṬ+ɼṛƊ

Try it online!
As an alternative, here’s a niladic link which returns the number chosen and keeps track of the count list in the register.

authors: Xi'an ні війні