text:
Find the \$\left(n^2\right)^\text{th }n\$-gonal number
Given a non-negative integer, \$n\$, yield the \$(n^2)^\text{th } n\$-gonal number.
Further Detail:
The \$x\$-gonal numbers, or polygonal numbers, are also known as the two-dimensional figurate numbers.
Many people will be familiar with the triangular numbers, these are the \$3\$-gonal numbers:
$$F(3,n)=\sum_{i=1}^{n}(i)=\frac{n(n+1)}{2}$$
The triangular numbers are OEIS A000217:
0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, ...

Probably even more will be familiar with the square numbers, these are the \$4\$-gonal numbers:
$$F(4,n)=\sum_{i=1}^{n}(2i-1)=n^{2}$$
The square numbers are OEIS A000290:
0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, ...

In general the \$k^\text{th }x\$-gonal number is the number of pebbles required to iteratively build up an \$x\$-sided polygon by adding pebbles to \$x-2\$ of the sides, here are a few formulae:
\begin{align}
F(x,k)&=\sum_{i=1}^{k}\left(1+\sum_{j=2}^{i}(x-2)\right) \\
&=\frac{k^2(x-2)-k(x-4)}{2} \\
&=\frac{k(k-1)}{2}(x-2)+k\\
&=(x-3)\sum_{i=1}^{k-1}(i)+\sum_{i=1}^{k}(i)\\
&=(x-2)(k-1)+1+F(x,k-1)
\end{align}
I'm sure there are plenty more.
Note that the last one is recursive but that \$F(x,0)=0\$.
The challenge
...is to golf code for \$G(n)=F(n,n^2)\$ for non-negative \$n\$.
i.e. Given a non-negative integer, \$n\$, yield the \$(n^2)^\text{th } n\$-gonal number.
This is not (currently) in the OEIS:
0, 1, 4, 45, 256, 925, 2556, 5929, 12160, 22761, 39700, 65461, 103104, 156325, 229516, 327825, 457216, 624529, 837540, 1105021, ...

Notes
You may yield a list of these numbers up to and including the required one if preferred.
For example, given an input of 5 you may yield either:

the integer 925, or
the list [0, 1, 4, 45, 256, 925]
...but not [0, 1, 4, 45, 256] or [1, 4, 45, 256, 925]

Results may also be results of floating point calculation and may deviate as such, so long as infinite precision floating point arithmetic would yield correct results.

Win by creating the shortest code in bytes in a language. The overall winner will be the shortest across all languages, but please don't let golfing languages dissuade you from entering in your favourite language - the primary goals are to challenge yourself and have fun!

Results may also be results of floating point calculation and may deviate as such -- are possible integer overflows also acceptable?

@JonathanFrech indeed, that would certainly be a default (the floating point stuff probably is too, but thought it best to say since it's an integer based challenge)

Wolfram Language (Mathematica), 19 bytes
#(4-#-2#^2+#^3)#/2&

Try it online!
Just a golfy version of the second formula.
With PolygonalNumber built-in, 23 bytes
PolygonalNumber[#,#^2]&

Try it online!
As expected, the Mathematica built-in is longer than the golfed version.

Neim, 2 bytes
ᛦℙ

Try it online!
¯\_(ツ)_/¯ First Neim answer, right tool for the job. By the way, the advice I give on my About me page still holds for my own posts: Don't upvote trivial solutions, please.

Finding the right language is a +1 from me :p

Upvoted because when I saw the question I immediately thought "oh, Neim can do this in 2 bytes". But someone beat me to it!

Upvoted because I am oppositional by nature.

Jelly, 8 bytes
²Ḷ×_2$‘S

Try it online!
In short, it generates the range \$[0,1,2,\dots,(n-1)^2]\$, multiplies every integer in that range with \$n-2\$, increments each of them (to avoid adding \$n^2\$ at the end, saving 1 byte), then sums the resulting list.

Ah ha you found the 1-byte save I knew must have been there (had _2×²Ṗ$S+² , ²ṖS×’’$+² and many other 9 variants)

@JonathanAllan Thank you for the edits.

05AB1E, 4 bytes
nsÅU

Try it online!

I thought you'd been really clever for a second there.

@JonathanAllan ¯\(ツ)/¯... Right tool for the job. Actually, give me a second to try Neim :P

Pyth, 14 9 bytes
smh*d-Q2*

Try it online!

shM*R-Q2* saves 5 whole bytes.

@Mr.Xcoder yeah, found a similar 9 byte solution right before you posted that...

Python 2, 31 30 bytes
lambda k:(k*k*(k-2)-k+4)*k*k/2

Try it online!

Saved:

-1 byte, thanks to joH1

30 bytes: lambda k:(k*k*(k-2)-k+4)*k*k/2

JavaScript (ES7), 26 bytes
n=>n**4*(n-2)-n*n*(n-4)>>1

Try it online!

Recursive (ES6), 33 bytes
A quick attempt from mobile. Not really optimized for \$(n,n^2)\$.
x=>(g=k=>k&&(x-2)*--k-~g(k))(x*x)

Try it online!

Golfing from mobile and still FGITW :o (helps having no weird code-page I guess)

It definitely helps. :) (Or I'd need another phone, I guess...)

Haskell, 27 bytes
f k=(k^4*(k-2)-k^2*(k-4))/2

Try it online!
My first attempt at golfing in Haskell, basically same as almost any answer :
Nothing worth explaining here.

Nice. I gave a golfed version to Davide Spataro, since they posted earlier, (my first attempt at golfing Haskell too :))

@JonathanAllan you did better than me, (your formula was better). Seeing there is already an existing Haskell answer, do you want me to delete mine ?

Some people delete if they find the same (or effectively the same) solution, but I think if one finds it independently there is nothing wrong with keeping it.

@JonathanAllan then for now, I'll let it stay :)\

C (gcc), 60 36 34 bytes
-24 bytes thanks to Jonathan Allan
-2 bytes by factorizing again an n*n expression.
g(n){return(n*n*(n-2)-n+4)*n*n/2;}

Try it online!
Factored version of the second formula, uses a single function.
Entry point is function g(n), value is returned as integer.

g(n){return(n*n*n-2*n*n-n+4)*n*n/2;} is 36 bytes (is it golfable?)

@JonathanAllan thanks! I factorized as much as I could, I don't think it can't be golfed down again, at least not using this approach.

Ruby, 25 bytes
->n{(4-n+(n-2)*n*=n)*n/2}

Try it online!

cQuents, 20 bytes
$0:$$+$$/2($$-1)($-2

Try it online!
Explanation
$0                      Zero indexing
  :                     Mode: sequence (output nth term)
                        Each term equals:
   $$+                    index * index +
      $$/2                index * index / 2 *
          ($$-1)($-2      (index * index - 1) * (index - 2
                    )    ) implicit

Charcoal, 17 bytes
Ｉ⊘↨⟦¹±²±¹¦⁴¦⁰¦⁰⟧Ｎ

Try it online! Link is to verbose version of code. Explanation: Uses the second formula expanded into the polynomial \$ \frac{1}{2} ( x^5 - 2x^4 - x^3 + 4x^2 ) \$ which is calculated by treating it as an arbitrary base conversion before halving and casting to string for implicit output.

Physica, 25 bytes
->n:(n^4-n^2)/2*(n-2)+n^2

Try it online!

->n:n^2*(4-n-2*n^2+n^3)/2

Try it online!

->n:n^5/2-n^4-n^3/2+2*n*n

Try it online! | Try all of them at once as a test suite!

Jelly, 11 10 bytes
²µ½_2×’H×+

Try it online!
Uses the formula \$F(x,k)=\frac{k(k-1)}{2}(x-2)+k\$ as given in the challenge.

I have less but don't think I have optimal yet.

Clean, 38 bytes
import StdEnv
$x=x^2*(x^3/2-x^2-x/2+2)

Try it online!

APL (Dyalog), 17 bytes
×⍨×2+×⍨-⍨.5×*∘3-⊢

Try it online!

You may want to include 0 in your test-suite

2+×⍨-⍨ → 2-×⍨-

MATL, 9 bytes
U:qG2-*Qs

Try it online!
This uses Mr. Xcoder's Jelly approach.

FYI the approach is just a small step from the 4th formula (with the two sums), or, indeed, the 3rd (replace the triangle-number-esque formula with a sum) :)

@JonathanAllan Yes, I had noticed about the third, but not about the fourth. Thanks!

K (oK), 23 bytes
{((x-2)*k%2%k-1)+k:x*x}

Try it online!
Prefix function; implementation of the second formula: \$\frac{k(k-1)}{2}(x-2)+k\$
How:
{((x-2)*k%2%k-1)+k:x*x} # Main function, argument x.
                 k:x*x  # def k = n²
 ((x-2)*k%2%k-1)+       # calculate k + (((k/2)/(k-1))*(x-2))

Haskell (31 bytes)
g k=(k*k*k*k*(k-2)-k*k*(k-4))/2

k**4 instead of k*k*k*k.

or k^4. But the equation may be rearranged a little: (k^4*(k-2)-k*k*(k-4))/2 = ((k*k*(k-2)-k+4)*k*k)/2 = ((k^3-2*k-k+4)*k*k)/2 - so this gives the 25 byte version: g k=(k^3-2*k*k-k+4)*k*k/2 Here is an online IDE link - Try It Online!

Pyt, 4 bytes
Đ²⇹ᑭ

Try it online!
Explanation:
        Implicit input
Đ       Duplicate
 ²      Square
  ⇹     Swap top two elements on the stack
   ᑭ    Get the (n^2)th n-gonal number
        Implicit output

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


text:
Find Array Runs
Find the runs inside an array
A run is defined as three or more numbers that increment from the previous with a constant step. For example [1,2,3] would be a run with step 1, [1,3,5,7] would be a run with step 2, and [1,2,4,5] is not a run.
We can express these runs by the notation i to j by s where i is the first number of the run, j is the last number of the run, and s is the step. However, runs of step 1 will be expressed i to j.
So using the arrays before, we get:

[1,2,3] -> "1to3"

[1,3,5,7] -> "1to7by2"

[1,2,4,5] -> "1 2 4 5"

In this challenge, it is your task to do this for arrays that may have multiple runs.
Example Python code with recursion
IO is flexible
Input
Array of sorted positive ints (no duplicates)
Output
String of the runs separated by a space, or a string array of the runs
Does not need to be greedy in a particular direction
Can have trailing whitespace
Test Cases
In: [1000, 1002, 1004, 1006, 1008, 1010]
Out: "1000to1010by2"

In: [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]
Out: "1to3 5 8 13 21 34 55 89 144 233"

In: [10, 20, 30, 40, 60]
Out: "10to40by10 60"

In: [5, 6, 8, 11, 15, 16, 17]
Out: "5 6 8 11 15to17"

In: [1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 15, 30, 45, 50, 60, 70, 80, 90, 91, 93]
Out: "1to7 9to15by2 30 45 50to90by10 91 93"

This is code-golf so least number of bytes wins.

related

Must it be greedy left-to-right? (i.e. can [4, 5, 6, 7, 9, 11, 13, 15] not be 4to6 7to15by2?)

@JonathanAllan No, it does not necessarily need to be left greedy.

I suppose there will be no duplicate entries?

@user71546 Yes, no duplicates.

Is trailing whitespace acceptable?

Only Positive Integers. @Οurous Trailing whitespace acceptable.

Can we expect that the input will have length >1?(at least two integers)

@JayCe No, there could be an input of array size 1

Jelly,  42  40 bytes
-2 thanks to Kevin Cruijssen (filter out twos, ḟ2, rather than replacing twos with zeros, 2,0y)
ŒṖIE×LƲ€ḟ2SƊÞṪµ.ịU,Iḟ1ƊQ€Fż“to“by”ṁṖƊ$)K

A full program printing the result.
(As a monadic Link a list containing a mixture of integers and characters would be yielded)
Try it online!
(Too inefficient for the largest test-case to complete within 60s, so I removed [1,2,3,4].)
How?
ŒṖIE×LƲ€ḟ2SƊÞṪµ.ịU,Iḟ1ƊQ€Fż“to“by”ṁṖƊ$)K - Main Link: list of numbers
ŒṖ                                       - all partitions
           ƊÞ                            - sort by last three links as a monad:
      Ʋ€                                 -   last four links as a monad for €ach:
  I                                      -     incremental differences (of the part)
   E                                     -     all equal?
     L                                   -     length (of the part)
    ×                                    -     multiply
        ḟ2                               -   filter discard twos
          S                              -   sum
             Ṫ                           - tail (gets us the desired partition of the input)
              µ                       )  - perform this monadic chain for €ach:
               .                         -   literal 0.5
                ị                        -   index into (the part) - getting [tail,head]
                 U                       -   upend - getting [head,tail]
                      Ɗ                  -   last three links as a monad:
                   I                     -     incremental differences (of the part)
                     1                   -     literal one
                    ḟ                    -     filter discard (remove the ones)
                  ,                      -   pair -> [[head,tail],[deltasWithoutOnes]]
                       Q€                -   de-duplicate €ach -> [[head,tail],[delta]] or [[head,tail],[]] or [[loneValue],[]]
                         F               -   flatten -> [head,tail,delta] or [head,tail] or [loneValue]
                                     $   -   last two links as a monad:
                                    Ɗ    -     last three links as a monad:
                           “to“by”       -       literal list [['t', 'o'], ['b', 'y']]
                                   Ṗ     -       pop (get flattened result without rightmost entry)
                                  ṁ      -       mould ["to","by"] like that (i.e. ["to","by"] or ["to"] or [])
                         ż               -     zip together
                                       K - join with spaces
                                         - implicit print

'by' should not be used if step = 1

oh Gawwwd :p Thanks for the heads-up!

2,0ySƲÞ can be golfed to ḟ2SƊÞ for -2 bytes.

@KevinCruijssen very true, nice golf, thanks

@KevinCruijssen FYI I remember why that was there now - originally I was trying to do my sorting with a product, P, rather than a sum S and would have needed the zeros.

@JonathanAllan Ah ok, that makes sense. In that case you'd indeed need the zeros. :) Glad I could help.

Swift, 246 bytes
func f(_ a:[Int]){
var c=a.count,m=a+a,z=0,r:String=""
for i in 1..<c{m[i]-=a[i-1];if m[i]==m[i-1]{m[i-1]=0}};m[0]=1
for i in 0..<c{if m[i]==0 {z=1}else if z==0{r+=" \(a[i])"}else{r+="to\(a[i])"+(m[i]>1 ? "by\(m[i])":"");z=0;m[i+1]=1}}
print(r)
}

Try it online!

Welcome to Programming Puzzles & Code Golf! Very nice first answer. I hope you'll stay around because the Swift community here is... really small!

This saves you a couple of bytes

K (ngn/k), 102 bytes
{1_,//${H:" ",h:*x;l:+/&\x=h+(!#x)*d:--/2#x;$[l>2;(H;"to";x l-1;(~d=1)#,"by",d;o l_x);l;H,o 1_x;""]}x}

Try it online!

JavaScript (ES6), 129 bytes
Returns an array of strings.
a=>(a.map((n,i)=>n+[n-a[i+1]||''])+'').replace(/(\d+)(-\d+)(?:,\d+\2)+,(\d+)/g,(_,a,b,c)=>a+'to'+(~b?c+'by'+-b:c)).split(/-\d+,/)

Try it online!
How?
Step #1
We first append to each number a suffix consisting of a leading '-' followed by the difference with the next number, except for the last entry which is left unchanged. This new array is coerced to a string.
(a.map((n, i) => n + [n - a[i + 1] || '']) + '')

Example:
Input : [ 1, 2, 3, 5, 9, 11, 13, 20 ]
Output: "1-1,2-1,3-2,5-4,9-2,11-2,13-7,20"

Step #2
We identify all runs in the resulting string and replace them with the appropriate notation.
.replace(
  /(\d+)(-\d+)(?:,\d+\2)+,(\d+)/g,
  (_, a, b, c) => a + 'to' + (~b ? c + 'by' + -b : c)
)

Example:
Input : "1-1,2-1,3-2,5-4,9-2,11-2,13-7,20"
Output: "1to3-2,5-4,9to13by2-7,20"

Step #3
Finally, we split the string on the remaining suffixes, including the trailing commas.
.split(/-\d+,/)

Example:
Input : "1to3-2,5-4,9to13by2-7,20"
Output: [ '1to3', '5', '9to13by2', '20' ]

R, 238 217 bytes
Thanks @digEmAll for -19 bytes.
function(v,R=rle(diff(v)),L=R$l,S=sum(L|1),Y=0)if(!S)cat(v)else for(i in 1:S){D=R$v[i]
N=L[i]-F
if(N>1){N=N+1
cat(v[Y+1],'to',v[Y+N],'by'[D>1],D[D>1],' ',sep='')
F=1}else{N=N+(i==S)
if(N>0)cat(v[Y+1:N],'')
F=0}
Y=Y+N}

Try it online!

use F instead of n as it's already initialized to 0, which should save a few bytes, I think.

This one is frustrating. You're nearly there by just using split, diff and rle. Unfortunately, the greedy search for runs means a lot of fiddling.

214 bytes Almost there, the only problem is the uncorrect spacing sometimes...

That 'by'[D>1] is a good trick.

This seems to work fine 217 bytes

@digEmAll Does one need to handle single input? Otherwise dropping the first chars of the function brings us to 200 bytes flush.

@JayCe: the question doesn't specified that, but I assumed it needs to since the input is defined as "an array of positive ints". Maybe we can ask...

R, 180 175 bytes
r=rle(c(0,diff(a<-scan())));for(j in 1:sum(1|r$l)){l=r$l[j];v=r$v[j];i=T+l-1;cat("if"(l>2-F,paste0(a[T][!F],"to",a[i],"by"[v>1],v[v>1]," "),c("",a[T:i])[-3^F]));T=i+1;F=l<3-F}

Try it online!
Conceptually, this is a port of my Ruby answer, though obviously quite a bit different technically.
5 bytes saved by JayCe.

I wanted to to something with rle but was too lazy... you can save 1 byte doing sum(1|x) in place of length(x): TIO

Actually you can have just 1 cat  for 175 bytes: TIO

Ruby, 125 118 bytes
->a{i=y=0;a.chunk{|x|-y+y=x}.map{|z,w|2-i<(s=w.size)?"#{w[i*s]}to#{w[~i=0]}"+"by#{z}"*(z<=>1)+' ':' '*i+w*' '*i=1}*''}

Try it online!
Explanation
Ruby's Enumerable has a useful chunk method that does precisely what we need here - it groups items by consecutive runs of the same return value from the block, in our case - the difference between the current (x) and previous (y) value.
The caveat is that such strategy won't capture the first element of the run, e.g. here only the two last elements are grouped together:
Input: [5, 6, 8, 11, 15, 16, 17]
Grouped: [[5, [5]], [1, [6]], [2, [8]], [3, [11]], [4, [15]], [1, [16, 17]]]

Therefore, while mapping to the correctly formatted strings, when we encounter a new potential run (chunk with > 1 item), we must track if the previous item was single (i=1) or already used in another run (i=0). If there is an unused single item, it becomes the starting point of the run, and lowers the chunk size threshold from 3 to 2.

Clean, 208 ... 185 bytes
import StdEnv,Data.List,Text
l=length
$[]=""
$k=last[u<+(if(v>[])("to"<+last v<+if(u<v!!0-1)("by"<+(v!!0-u))"")"")+" "+ $t\\i=:[u:v]<-inits k&t<-tails k|l(nub(zipWith(-)i v))<2&&l i<>2]

Try it online!

JavaScript (Node.js), 177 173 bytes
a=>{for(h=t=p=d=0,o=[];(c=a[t])||h<t;p=c,t++)d||!c?c-p!=d?(o.push(...[[a[h]+"to"+p+(d>1?"by"+d:"")],[p],[p-d,p]][t-h<3?t-h:0]),d=0,h=t--):0:!d&&t-h?d=c-p:0;return o.join` `}

Try it online!

Python 2, 170 166 bytes
def f(a):
 j=len(a)
 while j>2:
	l,r=a[:j:j-1];s=(r-l)/~-j
	if a[:j]==range(l,r+1,s):return[`l`+'to%d'%r+'by%d'%s*(s>1)]+f(a[j:])
	j-=1
 return a and[`a[0]`]+f(a[1:])

Try it online!

I'm not sure if this output format is valid; the runs should all be strings, no?

@EriktheOutgolfer Fixed

Jelly, 41 bytes
ŒṖIE€Ạ$>Ẉ2eƊƲƇṪµ.ịṚj⁾to;IḢ⁾by;ẋ⁻1$ƲƊµḊ¡€K

Try it online!
Full program.

gvm (commit 2612106) bytecode, 108 bytes
Expects the size of the array in one line, then the members each in one line.
Hexdump:
> hexdump -C findruns.bin
00000000  e1 0a 00 10 00 e1 0b 00  ff c8 92 00 f4 f7 10 00  |................|
00000010  01 b0 20 03 00 ff 0a 01  a2 01 c8 92 00 f4 01 c0  |.. .............|
00000020  03 00 ff 0a 02 d0 72 01  0a 03 c8 92 00 f4 05 b0  |......r.........|
00000030  20 a2 02 c0 02 02 6a 03  8b 00 ff f6 06 b0 20 a2  | .....j....... .|
00000040  02 f4 ce 0a 02 c8 92 00  f6 07 6a 03 8b 00 ff f6  |..........j.....|
00000050  f2 b9 66 01 a2 02 00 01  8a 03 f6 05 b9 69 01 a2  |..f..........i..|
00000060  03 92 00 f4 ac c0 74 6f  00 62 79 00              |......to.by.|
0000006c

Test runs:
> echo -e "7\n5\n6\n8\n11\n15\n16\n17\n" | ./gvm findruns.bin
5 6 8 11 15to17
> echo -e "20\n1\n2\n3\n4\n5\n6\n7\n9\n11\n13\n15\n30\n45\n50\n60\n70\n80\n90\n91\n93\n" | ./gvm findruns.bin
1to7 9to15by2 30 45 50to90by10 91 93

Manually assembled from this:
0100  e1        rud                     ; read length of array
0101  0a 00     sta     $00             ; -> to $00
0103  10 00     ldx     #$00            ; loop counter
                  readloop:
0105  e1        rud                     ; read unsigned number
0106  0b 00 ff  sta     $ff00,x         ; store in array at ff00
0109  c8        inx                     ; next index
010a  92 00     cpx     $00             ; length reached?
010c  f4 f7     bne     readloop        ; no -> read next number
010e  10 00     ldx     #$00            ; loop counter
0110  01                                ; 'lda $20b0', to skip next instruction
                  runloop:
0111  b0 20     wch     #' '            ; write space character
0113  03 00 ff  lda     $ff00,x         ; load next number from array
0116  0a 01     sta     $01             ; -> to $01
0118  a2 01     wud     $01             ; and output
011a  c8        inx                     ; next index
011b  92 00     cpx     $00             ; length reached?
011d  f4 01     bne     compare         ; if not calculate difference
011f  c0        hlt                     ; done
                  compare:
0120  03 00 ff  lda     $ff00,x         ; load next number from array
0123  0a 02     sta     $02             ; -> to $01
0125  d0        sec                     ; calculate ...
0126  72 01     sbc     $01             ; ... difference ...
0128  0a 03     sta     $03             ; ... to $03
012a  c8        inx                     ; next index
012b  92 00     cpx     $00             ; length reached?
012d  f4 05     bne     checkrun        ; if not check whether we have a run
012f  b0 20     wch     #' '            ; output space
0131  a2 02     wud     $02             ; output number
0133  c0        hlt                     ; done
                  checkrun:
0134  02 02     lda     $02             ; calculate next ...
0136  6a 03     adc     $03             ; ... expected number in run
0138  8b 00 ff  cmp     $ff00,x         ; compare with real next number
013b  f6 06     beq     haverun         ; ok -> found a run
013d  b0 20     wch     #' '            ; otherwise output space ...
013f  a2 02     wud     $02             ; ... and number
0141  f4 ce     bne     runloop         ; and repeat searching for runs
                  haverun:
0143  0a 02     sta     $02             ; store number to $02
0145  c8        inx                     ; next index
0146  92 00     cpx     $00             ; length reached?
0148  f6 07     beq     outputrun       ; yes -> output this run
014a  6a 03     adc     $03             ; calculate next expected number
014c  8b 00 ff  cmp     $ff00,x         ; compare with real next number
014f  f6 f2     beq     haverun         ; ok -> continue parsing run
                  outputrun:
0151  b9 66 01  wtx     str_to          ; write "to"
0154  a2 02     wud     $02             ; write end number of run
0156  00 01     lda     #$01            ; compare #1 with ...
0158  8a 03     cmp     $03             ; ... step size
015a  f6 05     beq     skip_by         ; equal, then skip output of "by"
015c  b9 69 01  wtx     str_by          ; output "by"
015f  a2 03     wud     $03             ; output step size
                  skip_by:
0161  92 00     cpx     $00             ; length of array reached?
0163  f4 ac     bne     runloop         ; no -> repeat searching for runs
0165  c0        hlt                     ; done
                  str_to:
0166  74 6f 00                          ; "to"
                  str_by:
0169  62 79 00                          ; "by"
016c

Python 2, 138 136 bytes
-2 bytes thanks to Erik the Outgolfer.
r=[];d=0
for n in input()+[0]:
 a=n-([n]+r)[-1]
 if(a-d)*d:
	if r[2:]:r=["%dto"%r[0]+`r[-1]`+"by%s"%d*(1%d)]
	print r.pop(0),
 r+=n,;d=a

Try it online!

05AB1E (legacy), 49 50 bytes
.œʒε¥Ë}P}Σ€g2KO>}¤εD©g≠i¬s¤„toý¬®¥0èDU≠i„byX««]˜ðý

Way too long, but I'm already glad it's working. This challenge is a lot harder than it looks imo.. Can without a doubt be golfed further.
Σ€g2KO>}¤ is a port of 2,0ySƲÞṪ from @JonathanAllan's Jelly answer (thanks!).
Try it online. (NOTE: Times out for the big test cases.)
+1 byte as bug-fix because 0 is always put at a trailing position when sorting.
Explanation:
.œ                       # Get all partions of the (implicit) input-list
                         #  i.e. [1,2,3,11,18,20,22,24,32,33,34]
                         #   → [[[1],[2],[3],[11],[18],[20],[22],[24],[32],[33],[34]],
                         #      [[1],[2],[3],[11],[18],[20],[22],[24],[32],[33,34]],
                         #      [[1],[2],[3],[11],[18],[20],[22],[24],[32,33],[34]],
                         #      ...]
  ʒ     }                # Filter this list by:
   ε  }                  #  Map the current sub-list by:
    ¥Ë                   #   Take the deltas, and check if all are equal
                         #    i.e. [1,2,3] → [1,1] → 1
                         #    i.e. [1,2,3,11] → [1,1,8] → 0
       P                 #  Check if all sub-list have equal deltas
  Σ      }               # Now that we've filtered the list, sort it by:
   €g                    #  Take the length of each sub-list
                         #   i.e. [[1,2,3],[11,18],[20,22,24],[32,33],[34]]
                         #    → [3,2,3,2,1]
                         #   i.e. [[1,2,3],[11],[18,20,22,24],[32,33,34]]
                         #    → [3,1,4,3]
     2K                  #  Remove all 2s
                         #   i.e. [3,2,3,2,1] → ['3','3','1']
       O                 #  And take the sum
                         #   i.e. ['3','3','1'] → 7
                         #   i.e. [3,1,4,3] → 11
        >                #  And increase the sum by 1 (0 is always trailing when sorting)
          ¤              # And then take the last item of this sorted list
                         #  i.e. for input [1,2,3,11,18,20,22,24,32,33,34]
                         #   → [[1,2,3],[11],[18,20,22,24],[32,33,34]]
  ε                      # Now map each of the sub-lists to:
   D©                    #  Save the current sub-list in the register
     g≠i                 #  If its length is not 1:
                         #    i.e. [11] → 1 → 0 (falsey)
                         #    i.e. [18,20,22,24] → 4 → 1 (truthy)
        ¬s¤              #   Take the head and tail of the sub-list
                         #    i.e. [18,20,22,24] → 18 and 24
           „toý          #   And join them with "to"
                         #    i.e. 18 and 24 → ['18to24', '18to20to22to24']
               ¬         #   (head to remove some access waste we no longer need)
                         #    i.e. ['18to24', '18to20to22to24'] → '18to24'
        ®                #   Get the sub-list from the register again
         ¥               #   Take its deltas
                         #    i.e. [18,20,22,24] → [2,2,2]
          0è             #   Get the first item (should all be the same delta)
                         #    i.e. [2,2,2] → 2
            DU           #   Save it in variable `X`
              ≠i         #   If the delta is not 1:
                         #     i.e. 2 → 1 (truthy)
                „byX«    #    Merge "by" with `X`
                         #     i.e. 2 → 'by2'
                     «   #    And merge it with the earlier "#to#"
                         #     i.e. '18to24' and 'by2' → '18to24by2'
                      ]  # Close the mapping and both if-statements
˜                        # Flatten the list
                         #  i.e. ['1to3',[11],'18to24by2','32to34']
                         #   → ['1to3',11,'18to24by2','32to34']
 ðý                      # And join by spaces (which we implicitly output as result)
                         #  i.e. ['1to3',11,'18to24by2','32to34']
                         #   → '1to3 11 18to24by2 32to34'

Retina 0.8.2, 77 bytes
\d+
$*
(1+)(?= \1(1+))
$1:$2
1:(1+) (1+:\1 )+(1+)
1to$3by$1
:1+|by1\b

1+
$.&

Try it online! Link includes test cases. Explanation:
\d+
$*

Convert to unary.
(1+)(?= \1(1+))
$1:$2

Compute consecutive differences.
1:(1+) (1+:\1 )+(1+)
1to$3by$1

Convert runs to to...by syntax.
:1+|by1\b

Remove unconverted differences and by1.
1+
$.&

Convert to decimal.

Perl 5, 154 bytes
{my(@r,$r);@r&&(@$r<2||$$r[1]-$$r[0]==$_-$$r[-1])?push@$r,$_:push@r,$r=[$_]for@_;join" ",map@$_<3?@$_:("$$_[0]to$$_[-1]by".($$_[1]-$$_[0]))=~s/by1$//r,@r}

Same with spaces, newlines, #comments and sub by:
sub by {
  my(@r,$r);
  @r &&                               # if at least one run candidate exists and...
   ( @$r<2                            # ...just one elem so far
     || $$r[1]-$$r[0] == $_-$$r[-1] ) # ...or diff is same
    ? push @$r, $_                    # then add elem to curr. run candidate
    : push @r, $r=[$_]                # else start new run cand. with curr elem
        for @_;
  join " ",
    map @$_<3                                         # is it a run?
    ? @$_                                             # no, just output the numbers
    : ("$$_[0]to$$_[-1]by".($$_[1]-$$_[0]))=~s/by1$//r, # yes, make run, delete by1
    @r                                                # loop run candidates
}

Try it online!
...for passing tests from OP.

source: Stack Exchange

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

sort: votes


text:
Single Perceptron Implementation
Challenge
Train a single perceptron with 2 inputs and 1 output.

Step 1: Initialize the weights
Step 2: Calculate the output
For inputs: [i1, i2, ..., in] and  weights: [w1, w2, ..., wn] the output is:
i1 * w1 + i2 * w2 + ... + in * wn

Step 3: Apply activation function on the output (i.e sigmoid)
Step 4: Update the weights
w(t + 1) = w(t) + r * (desired_output - actual_output)

Where r: learning rate
Step 5 Repeat steps 2, 3 and 4
Input
iterations: how many times you repeat steps 2, 3 and 4
input: a list with 2 input values i.e. [1, 0]
output: the desired output
learning_rate: the learning rate i.e.0.3
Output
It should print the last calculated output. Keep in mind this should be very close to the desired output i.e 0.96564545 for desired output 1
Example
For input (training for XOR):
1000, [1 0], 1, 0.3

The output should be:
0.9966304251639512

Note The output will never be the same even for identical test cases due to random weights initialization.
Here's some non-golfed code in Python for this test case:
Try it Online!
Rules

The inputs and outputs of the perceptron are fixed to: 2 and 1 respectively.
The output needs to be close to the desired output (see example).
You can use any activation function you want, just mention it.

To make the challenge self-contained, can you give examples of activation functions and list the constraints such a function must follow?

It seems that the identity function is an activation function according to Wikipedia; I suspect it would be golfiest to just use that.

Also the constraint "should be very close" is too vague IMO... maybe restrict to a list of activation functions? and I was about to say the same thing as @Giuseppe...

Sorry everyone, this is my first attempt.

@DimChtz no worries! We typically suggest posting challenges in The Sandbox for a while so they can get some feedback. My suggestions for now (unless you want to delete this temporarily and try it there first) are to specify a list of activation functions we're allowed to use, and remove Rule #2 since the final output should be the result of the selected Activation function and the weights.

Actually, I have another question; you say "initialize the weights" -- how are we supposed to do that? Are there constraints on the weights? Your example uses uniform random numbers in [0,1] but could we use a different distribution? etc.

Random? What's the distribution?

JavaScript (Node.js), 121 110  bytes
Same as TFled. A "golfed" version of the example.
-11 bytes from @Arnauld
with(Math)f=(a,[b,B],c,d)=>(g=w=>a--?g(w.map(_=>_+d*(c-(y=1/(1+exp(B*w[1]-b*w[0])))))):y)([random(),random()])

Try it online!

110 bytes. Most bytes are saved by going recursive and splitting the 2nd argument right away. The with(Math)f= trick only saves 1 byte.

Python 2, 136 bytes
from random import*
import math
def f(n,(i,I),o,r):w,W=random(),random();exec"d=1/(1+math.exp(-i*w-I*W));c=r*(o-d);w+=c;W+=c;"*n;print d

Try it online!
Basically just a golfed version of the example


text:
Textbattles KoTH
Textbattles

Textbattles is is strategy game about, well, text.
It consists of a 10x10 grid, where each player has a position on the grid. When it is a player's turn, they can decide whether to move a step in any direction on the grid, or just stay where they are.
If a player moves into another player's spot, they are both put in a battle with each other. They both will generate a piece of text. After generating it, they get a "penalty" stored, which = time in nanoseconds to generate / 80000. Then, each player sends the first n characters of their text to eachother, where n is the penalty. After that, both player have two choices:
1. Guess the other player's text, using the portion given to them.
2. Surrender (this can also be done after trying to guess multiple times)
Surrendering is an instant elimination from the game, guessing before the other player eliminates the other player.
To participate in the challenge you will have to code your player, here is how your code should look in Java:
public class MyPlayer extends Player {
    @Override
    public Move move() {
        return Move.LEFT, Move.RIGHT, Move.UP, Move.DOWN, or Move.NONE
    }
    @Override
    public void guess(String clue, Checker checker) {
        if(checker.guess("I think this is the right one!")) {
            // Got it right!
            return;
        }
        checker.surrender();
    }
    @Override
    public String generate(Deducter ded) {
        ded.use(); // Read below
        return "SecretCode404";
    }
    // Other methods you have access to: getGrid: a 2d-array of booleans, each element being true if there is a player there,
                                         getRandom: a java.util.Random object to generate random numbers, by the rules of this challenge, you aren't allowed to use any other random number generator than this one.
}

Each time you win a battle, you get a point, and the next time you get in to a battle, you have the choice to deduct the amount of points from your penalty as shown above.

FAQ

What stops me from adding the entire Lorem Ipsum to my text?
 Other people can look at your answer and compensate for it by adding Lorem Ipsum too.
What if none of the two battlers never find eachother's text?
 They will. In most cases anyways, if they don't find it in 5 minutes, it is considered a tie and nobody is eliminated
What if all players keep avoiding eachother?
  There are random events that teleport players to eachother.

Comments are not for extended discussion; this conversation has been moved to chat.


text:
A greeting bot for a colleague from work
I have a colleague at work that works from home every Tuesday and Thursday. At around 8:00 AM he sends us a message with the following text:

Hello today I'm working from home

In order to relieve him from the burden of doing this every day he stays at home, we would like to automate this task for him.
The challenge
Write in as few bytes as possible a piece of code that:

Receives the current time: your code may receive values for the current year, month (1-12), day of month (1-31), hour (0-23) and minute (0-59) and the day of the week (you can choose whether this number starts from 0 or 1, and if 0/1 means Sunday, Monday or any other day); alternatively you may receive a structure such as Date, DateTime, Calendar or any other time-related structure, if your language allows it. You can also receive a string with the date in yyyyMMddHHmm if you want, or two separate strings for date and time, and then an integer with the day of week. Feel free.
Returns two consistent truthy and falsey values, indicating if the message must be sent to the work chat or not.

Rules

This piece of code is assumed to be invoked periodically. The exact periodicity is irrelevant, nonetheless.
The truthy value must be returned if the day of week is Tuesday or Thursday and the time is 8:00 AM with an error margin of 10 minutes (from 7:50 to 8:10 inclusive).
The truthy value must be sent only if it is the first time the code is invoked between those hours for the specified day. We don't want the bot to send the same message several times in a row. The way you manage this restriction will be entirely up to you.
Your code may be an independent program executed repeatedly or it may be part of a bigger code that is always running. Your choice.
You may assume that there will be no reboots between executions of the code.
You may assume that the date will always be correct.
Explanations about your code and specifically about the method used to achieve persistence are encouraged.

Examples
(Week starts on Monday: 1, the following invokations will be made in succession)
2018,08,27,08,00,1 = falsey (not Tuesday or Thursday)
2018,08,28,07,45,2 = falsey (out of hours)
2018,08,28,07,55,2 = truthy (first time invoked this day at the proper hours)
2018,08,28,08,05,2 = falsey (second time invoked this day at the proper hours)
2018,08,28,08,15,2 = falsey (out of hours)
2018,08,29,08,00,3 = falsey (not Tuesday or Thursday)
2018,08,29,18,00,3 = falsey (not Tuesday or Thursday)
2018,08,30,07,49,4 = falsey (out of hours)
2018,08,30,07,50,4 = truthy (first time invoked this day at the proper hours)
2018,08,30,07,50,4 = falsey (second time invoked this day at the proper hours)
2018,08,30,08,10,4 = falsey (third time invoked this day at the proper hours)
2018,08,30,08,11,4 = falsey (out of hours)
2018,09,04,08,10,2 = truthy (first time invoked this day at the proper hours)

This is code-golf, so may the shortest code for each language win!

This comes from the sandbox.

Is there any restriction in the input format? Can I take the date as a single parameter like YYYYmmdd and the time as well HHss?

@LuisfelipeDejesusMunoz yes, if you want you may receive the date and time in that format. I have updated the question to make that clear.

May we use a function which is defined once and called several times in a row?

@Arnauld yes, that complies with the rules.

Can we assume that no day is skipped, i. e. there will be no two thursdays in a row?

@NieDzejkob no, you cannot assume that, sorry.

If a language contains a built-in method to obtain the current date/time, is it acceptable to use that instead of the input? Or is it required that the program behave as though the input date is the current date?

@KamilDrakari the program must check the date given as parameter, you cannot take the current date. If you do so it will be impossible to make the code pass a test battery like the one I propose in the question.

So, you're polling a script regularly to be useful at most once a day, 2/7th of the days? If you automate all your tasks like that...

Will the date ever be before the moment the challenge was posted?

@Οurous yes, the first date to pass to your code can be any.

JavaScript (ES6), 43 bytes
f=(D,t,d)=>5>>d&t>749&t<811&&!f[D]*(f[D]=1)

Try it online!
Input

the date as a string in yyyymmdd format
the time as a string in hhmm format
the day of week as a 0-indexed integer, with 0 = Tuesday, 1 = Wednesday, ..., 6 = Monday

Output
Returns 0 or 1.
Commented
f = (            // named function, as the underlying object will be used as storage
  D,             // D = date (string)
  t,             // t = time (string)
  d              // d = day of week (integer)
) =>             //
  5              // 5 is 0000101 in binary, where 1's are set for Tuesday and Thursday
  >> d &         // test the relevant bit for the requested day of week
  t > 749 &      // test whether we are in the correct time slot
  t < 811        //
  && !f[D] *     // make sure that this date was not already invoked at a correct time
  (f[D] = 1)     // and store it in the underlying object of f()

Javascript (and your mastery of it) will always amaze me.

ES6 is fun to golf with :) Is the 2nd input format valid?

Yes, I already specified that in the text of the question.

APL (Dyalog Unicode), 61 53 50 48 37 36 bytesSBCS
Anonymous infix lambda. Called with YYYYMMDD f hhmm and then prompts for weekday number; 2 and 4 are Tuesday and Thursday. Redefines the global D to remember dates.
D←⍬
{≢D,←⍺/⍨(⎕∊2 4)∧(⍺∊D)<30≥|780-⍵}

Try it online!
D←⍬ initialise D to be an empty set
{…} anonymous lambda; ⍺ is YYYYMMDD, ⍵ is hhmm
 780-⍵ difference between 780 (mean of 0750 and 0810) and the time
 | absolute value of that
 30≥ is 30 greater or equal to that?
 (…)< and it is not true that:
  ⍺∊D the date is a member of D
 (…)∧ and it is true that:
  ⎕∊2 4 the prompted for weekday is a member of the set {2,4}
 ⍺/⍨ use that to compress the date (i.e. gives {} if false, {date} if true)
 D,← append that to D
 ≢ and return its tally (i.e. 0 or 1, which are APL's false and true)

Python 3, 69 bytes
f=lambda w,r,*t,l={0}:r not in l!=w in(2,4)<(7,49)<t<(8,11)!=l.add(r)

Try it online!
Takes input as f(day of the week, date, hours, minutes), where date can be in any consistent format.

R, 114 106 bytes
function(D,y=D:"%D",u=D$h==7&D$mi>49|D$h==8&D$mi<11&D$w%in%2^4&!y%in%L,`:`=format,`^`=c){L<<-L^y[u];u}
L=F

Try it online!
Persistence:
Date is checked against L, the list of dates where the code returned TRUE. When the code returns TRUE, today's date is appended to this list. Otherwise the list is not modified.
Saved 6 bytes thanks to @Giuseppe!
Made the code actually work and saved 2 bytes thanks to @digEmAll!

This method takes the current time instead of receiving it as a parameter, doesn't it?

@Charlie looks I I should have read the challenge more carefully... would have made my life easier ! I will update.

^ has higher precedence than %any% but * has lower precedence than %any%, so using ^ you can get rid of some parentheses, and I golfed a few more down, too! Pretty sure it works for 108 bytes

You could also use : instead of ^, for the fun of it, and so your code has a million : in it.

@Giuseppe It does have a ton of : now!

I think POSIXlt objects are allowed as input :
104 Bytes  (also, you should use <<- in order to modify a list external to the function)

@digEmAll Thanks! I should have realized I wasn't updating F. I feel like initializing L needs to be counted as part of the bytecount so I initialized it to F.

Excel formula, 85 bytes
=IF(AND(MID(WEEKDAY(A1)/0,684;3;1)="3";A1-INT(A1)>=0,32638;A1-INT(A1)<=0,34028);TRUE)
Weekday with no parameters are from 1 (Sunday) to 7 (Saturday). The days we want are 3 and 5. Dividing all numbers from 1 to 7 for 0,648, only 3 and 5 gives a result where the first decimal is 3 (Got it by dividing with rand())
Input is inserted on Cell A1

You could use MID(WEEKDAY(A1)/0,29;5;1)="4" and also ;1;) instead of ;TRUE)

Clean, 343 326 303 279 216 bytes
Clean is so ill-suited to this it's like trying to paint a fence with a chainsaw.
import StdEnv,System.Environment,System._Unsafe
?(y,x,z)=y*480+x*40+z
$y h m d=(d-3)^2==1&&((h-8)*60+m)^2<121&&appUnsafe(setEnvironmentVariable"l"(fromInt(?y)))(maybe 0toInt(accUnsafe(getEnvironmentVariable"l")))< ?y

Try it online!
Golfing then explaination.

+1 Just for the painting a fence with a chainsaw reference! :D

C (gcc),  78   50  49 bytes
D;f(d,w,t){w=d-D&&w<4&&w%2&&t>749&&t<811&&(D=d);}

Try it online!
The expected inputs are:

d: the date, as a single number yyyymmdd
w: the day of the week, starting with Monday (0)
t: the time, as a single number hhmm

Explanation
D;                                      // the date we last said hello.
f(d,                                    // date
    w,                                  // day of the week
      t)                                // time
{
  w=                                    // replaces return
    d-D                                 // if we did not say hello today
       &&w<4&&w%2                       // and we are Tuesday(1) or Thursday(3)
                 &&t>749&&t<811         // and time is between 7:50 and 8:10, inclusive
                               &&(D=d); // then we say hello (evaluated to true) and update D
}

Edits

Saved 28 bytes thanks to Adám
Saved 1 more byte, since abs() was actually not helping with the new version

Why not take YYYYMMDD and hhmm as single numbers?

@Adám Indeed... I'll try that when I have some time

Suggest w<4&w%2&t>749&t<811 instead of w<4&&w%2&&t>749&&t<811

Batch, 109 bytes
@if %3 neq 2 if %3 neq 4 exit/b1
@if %2 geq 07:50 if %2 leq 08:10 if .%1 neq .%l% set l=%1&exit/b0
@exit/b1

Takes input in the form date time dow e.g. 2018-09-04 08:10 2 and outputs via exit code. Explanation: The environment variable l (or any other single letter would work) is used to store the last successful date that passes the test. (The date format itself does not matter as long as it is consistent and does not contain spaces.)

Perl 6, 33 bytes
{811>$^t>749>5+>$^w%2>(%){$^d}++}

Try it online!
Heavily inspired by Arnauld's solution. Uses the same input format.

C#, 121 Bytes
int[] d=new int[]{2,4};
double s=>Now.TimeOfDay.TotalSeconds;
bool h=>d.Contains((int)Now.DayOfWeek)&&s>=470&&s<=490;

Moving all three to the same line reduces size to 117 bytes. h is used as a property, just read the value prior to sending the message:
if (h) SendMessage();

F#, 119 bytes
let f w d h m l = if not(l|>Seq.contains d)&&[3;5]|>Seq.contains w&&(h=7&&m>49||h=8&&m<11)then(l@[d],true)else(l,false)

let f w d h m l =
declare function called f with parameters w (day of week) d (date) h (hour) m (minute) l (list of dates it's run on)
if not(l|>Seq.contains d)
if the list of dates doesn't contain the passed date
&&[3;5]|>Seq.contains w and the day is Tuesday (3) or Wednesday (5)
&&(h=7&&m>49||h=8&&m<11) and the time is between (exclusive) 7:49 and 8:11
then(l@[d],true) then return a tuple containing the list of dates with the current date appended, and true
else(l,false) else return a tuple containing the list of dates without today and false


text:
Let's golf a BIBABOBU decoder
While I was traveling in the future, I noticed a funny game among kids circa 2275. When they don't want their great-great-great-great-grand parents to understand what they're saying, they use the BIBABOBU speak. Obviously, I couldn't understand anything either with my pre-cyborg era brain and I felt (or technically: I will feel) really silly. So, I'd need a decoder for my next visit.
BIBABOBU?
While it's been deprecated for a long time, ASCII is still commonly used in the pop culture of 2275 and this language is based upon it.
A string is BIBABOBU-encoded that way:

Convert all characters to their ASCII codes.
Take the 2-digit hexadecimal representation of each code and convert them using the following table:
0: BI  4: BIDI  8: BADI  C: BODI
1: BA  5: BIDA  9: BADA  D: BODA
2: BO  6: BIDO  A: BADO  E: BODO
3: BU  7: BIDU  B: BADU  F: BODU

Example
"Hello!" → 48 65 6C 6C 6F 21 → "BIDIBADI BIDOBIDA BIDOBODI BIDOBODI BIDOBODU BOBA"

However, the corresponding input would be given without any space to mimic the monotonous intonation that kids are using to make this even harder to understand without implants:
"BIDIBADIBIDOBIDABIDOBODIBIDOBODIBIDOBODUBOBA"

Clarifications and rules

Remember that I need a decoder, not an encoder.
Decoded characters are guaranteed to be in the range [ 32...126 ].
The input is guaranteed to contain en even number of BIBABOBU-encoded hexadecimal digits.
You may take input in either full lowercase or full uppercase. Mixed cases are not allowed.
Because bit flips are quite common during a time travel, this is code-golf in order to minimize the risks.

Test cases
NB: Linefeeds are used below for formatting purposes only. You are not supposed to handle them.
Input:
BIDABIDIBIDOBIDABIDUBUBIDUBIDI

Output:
Test

Input:
BIDABIDUBIDOBIDABIDOBODIBIDOBUBIDOBODUBIDOBODABIDOBIDABOBIBIDUBIDIBIDOBODUBOBIBUBOBUBOBUBI
DUBUBIDABOBA

Output:
Welcome to 2275!

Input:
BIDIBADIBIDOBIDABIDOBODIBIDOBODIBIDOBODUBOBODIBOBIBIDABIDIBIDOBADABIDOBODABIDOBIDABOBIBIDA
BIDIBIDUBOBIDOBABIDUBIDOBIDOBIDABIDOBODIBIDOBIDABIDUBOBOBABOBIBIDABADABIDOBODUBIDUBIDABOBI
BIDOBODIBIDOBODUBIDOBODUBIDOBADUBOBIBIDUBUBIDOBODUBOBIBIDOBIDOBIDUBIDABIDOBODOBIDOBODOBIDU
BADABOBA

Output:
Hello, Time Traveler! You look so funny!

Input:
BIDIBABIDOBODOBIDOBIDIBOBIBIDUBADABIDOBODUBIDUBIDABOBIBIDOBIDIBIDOBODUBIDOBODOBOBIDUBIDUBI
DIBOBIBIDUBIDABIDOBODOBIDOBIDIBIDOBIDABIDUBOBIDUBUBIDUBIDIBIDOBABIDOBODOBIDOBIDIBOBIBIDUBI
DUBIDOBADIBIDOBABIDUBIDIBOBIBIDIBADABOBIDUBIDOBODABOBIBIDUBUBIDOBABIDUBADABIDOBADABIDOBODO
BIDOBIDUBOBODIBOBIBIDOBIDIBIDOBODUBOBIBIDUBADABIDOBODUBIDUBIDABUBODUBOBIBIDIBADIBIDOBABOBI
BIDOBADIBIDOBABOBIBIDOBADIBIDOBABOBA

Output:
And you don't understand what I'm saying, do you? Ha ha ha!

I like the challenge, but I would have liked it slightly better if the encoding was lexicographically sorted.

@StewieGriffin These damn kids are mischievous... :-/

By the way, I find the story really really unlikely! I wouldn't be surprised if it was just a dream you had... might you have a CO leak in your house?

Ah... That would also explain the ponies riding rainbows in my living room!

"Because bit flips are quite common during a time travel" - err shouldn't it be radiation-hardened then?

Do you need a decoder for the actual BIBABOBU speak, or just for the written down version?

@MrLister The written down version is fine. :)

... but not nearly as great a challenge.

@MrLister That would be another kettle of fish indeed. Here is the only voice decoding challenge I've been able to find.

One could argue that golfed code increases the severity of a bit-flip (less redundancy within the code) even if it decreases the frequency of a bit-flip... but whatever :) - Nice challenge!

@JayCe True. I was more thinking along the lines: the smaller the code, the more redundancy you can get by storing multiple copies.

^ Of course... this makes sense.

Of course, this implies that immortality will be invented circa or before 2125.

@JonathanAllan If that solves the problem, then those bit flips would be pretty weird, since they would always restrict themselves to one byte.

Sorry, I want to like this challenge, but the premise of the question is clearly ridiculous. ASCII will never be deprecated.

It is bugging me that the encoding table is not a Huffman tree (properly organized to use the shortest phonemes for the most common symbols, of course).

I’m pretty sure that technically you willan on-when presooning on-feelenta silly in this situation; the correct tense to use here is surely the Future Subinverted Plagal Retropast.

05AB1E, 36 35 33 bytes
Saved 1 byte thanks to Mr.Xcoder
Saved 2 bytes thanks to KevinCruijssen
ć©¡®ì®D…IAO©â'D«‚˜®'U«âJskh2ôJHçJ

Try it online!
or as a Test Suite
Explanation
ć©¡                                 # extract the head ("B") and split input on it
   ®ì                              # prepend "B" to each
     ®D                            # push 2 copies of "B"
       …IAO©â                      # cartesian product with "IAO"
             'D«                   # append "D" to each
                ‚˜                 # add the leftover "B" to the list
                  ®'U«â            # cartesian product with "IAOU"
                       J           # join each to string
                        sk         # get the index of each word of the input in this list
                          h        # convert each to hex
                           2ôJ     # format as pairs of chars
                              H    # convert to int
                               çJ  # convert from ascii-codes to string

I believe 'B©¡¦®ì®D…IAO©â'D«‚˜®'U«âJskh2ôJHçJ works for 35 bytes.

@Mr.Xcoder: Ah, of course. Nice reuse of ©. Thanks :)

-2 bytes changing the leading 'B to ć and removing the ¦, since the input will always start with a 'B'.

@KevinCruijssen: Ooh, good idea. I hadn't considered ć. Thanks!

Now let's get back at those kids and see if they understand that !

Grrr... you beat me by 2. Oh, and I did the challenge wrong, so, in reality, by 7. I never stood a chance xD.

So we now have a partial traduction of THE magical song.. What does
Bibbidi-bobbidi, bibbidi-bobbidi, bibbidi-bobbidi-boo.  really mean?

Jelly, 26 24 23 22 20 17 15 bytes
ṣḢO^1%9%4Ḅḅ⁴b⁹Ọ

Try it online!
How it works
ṣḢO^1%9%4Ḅḅ⁴b⁹Ọ  Main link. Argument: s (string)

 Ḣ               Head; remove and yield the first character of s.
ṣ                Split s at occurrences of the result ('B').
  O              Ordinal; map "IAOUD" to A1 := [73, 65, 79, 85, 68].
   ^1            Bitwise XOR 1; map A1 to A2 := [72, 64, 78, 84, 69].
     %9          Modulo 9; map A2 to A3 := [0, 1, 6, 3, 6].
       %4        Modulo 4; map A3 to A4 := [0, 1, 2, 3, 2].
                 So far, we've mapped "BX" to [x] and "BXDY" to [x, 2, y],
                 where x/y = 0, 1, 2, 3 when X/Y = I, A, O, U.
         Ḅ       Unbinary; map [x] to x and [x, 2, y] to 4x + 2×2 + y = 4(x + 1) + y.
          ḅ⁴     Convert the resulting array from base 16 to integer.
            b⁹   Convert the resulting integer to base 256.
              Ọ  Unordinal; replace code points with their characters.

Perl 6, 58 bytes
{S:g{(B.[D.]?)**2}=chr :16[$0».&{:2[.ords»³X%87 X%4]}]}

Try it online!
Heavily inspired by Dennis' Jelly solution. Uses a different magic function x³ % 87 % 4 which also maps the ASCII codes of IAOUBD to 012302.
Alternative 75 74 bytes version
-1 byte thanks to Jo King
{pack('H',.trans((<B BID BAD BOD>X~ <I A O U>)=>(^16)».base(16))).decode}

Try it online!
Alternative 85 bytes version
{S:g[....]=chr :4(~$/)*2+|221+^:4(~$/)+^238}o{TR:d/UIAOBD/0123/}o{S:g[B.<![D]>]=0~$/}

Try it online!

How about (^16)>>.base(16) for -1 byte

Python 2, 100 97 96 95 bytes
-1 byte thanks to ovs
-1 byte thanks to G B

lambda w:''.join(' 1023546798abdcef'[int(c,35)/7%77%18]for c in w.split('B')[1:]).decode("hex")

Try it online!

05AB1E (legacy), 68 65 60 59 bytes
.•5Ç¿ÆΓ•2ô.•1ÒKá ¸ΓìŸÆt`ô_zTºγ„KRI‰ιë†½òι•4ô«I¬©¡®ìkh2ôJHçJ

Input is in lowercase.
-3 bytes implicitly thanks to @Emigna changing 'b¡εg>}s£ to 'b©¡®ì.
Try it online or verify all test cases.
Also, can definitely be golfed with something smarter than the huge compressed strings. Will take another look later on. Shorter answer already provided by @Emigna, so make sure to upvote him!
Explanation:
.•5Ç¿ÆΓ•      # Compressed string "bibabobu"
        2ô    # Split in parts of 2
              #  → ["bi","ba","bo","bu"]
.•1ÒKá ¸ΓìŸÆt`ô_zTºγ„KRI‰ιë†½òι•
              # Compressed string "bidibidabidobidubadibadabadobadubodibodabodobodu"
        4ô    # Split in parts of 4
              #  → ["bidi","bida","bido","bidu","badi","bada","bado","badu","bodi","boda","bodo","bodu"]
«             # Merge both lists together
              #  → ["bi","ba","bo","bu","bidi","bida","bido","bidu","badi","bada","bado","badu","bodi","boda","bodo","bodu"]
I¬©¡          # Take the input and split on the head (always 'b')
              #  i.e. "bidibadibidobidabidobodibidobodibidoboduboba"
              #   → ["idi","adi","ido","ida","ido","odi","ido","odi","ido","odu","o","a"]
    ®ì        # And prepend a 'b' to each item again
              #  i.e. ["idi","adi","ido","ida","ido","odi","ido","odi","ido","odu","o","a"]
              #   → ["bidi","badi","bido","bida","bido","bodi","bido","bodi","bido","bodu","bo","ba"]
k             # Map each item to the index of the first list
              #   i.e. ["bidi","badi","bido","bida","bido","bodi","bido","bodi","bido","bodu","bo","ba"]
              #    → [4,8,6,5,6,12,6,12,6,15,2,1]
 h            # Convert everything to hexadecimal
              #  i.e. [4,8,6,5,6,12,6,12,6,15,2,1]
              #   → ["4","8","6","5","6","C","6","C","6","F","2","1"]
  2ôJ         # Split it in parts of 2 and join them together
              #  i.e. ["4","8","6","5","6","C","6","C","6","F","2","1"]
              #   → ["48","65","6C","6C","6F","21"]
     H        # Convert that from hexadecimal to an integer
              #  i.e. ["48","65","6C","6C","6F","21"] → [72,101,108,108,111,33]
      ç       # And take its ASCII value
              #  i.e. [72,101,108,108,111,33] → ["H","e","l","l","o","!"]
       J      # Then join everything together (and output implicitly)
              #  i.e. ["H","e","l","l","o","!"] → "Hello!"

Perl 6, 88 86 84 bytes
{S:g{B(.*?)B(.D.|.)}=chr :16[$/.map:{first :k,~$_,("",|<ID AD OD UD>X~ <I A O U>)}]}

Try it online!

Perl 5 -p, 67 bytes
for$p(<{B,0D,1D,2D}{I,A,O,U}>){s/$p/chr$i+48/ge;$i++}$_=pack'H*',$_

Try it online!

Japt, 43 29 28 bytes
Unsurprisingly,  a port of Dennis' Jelly solution works out much shorter.
Outputs an array of characters.
Åqbu)®¬®c ^1 %9%4Ãì2Ãò ®ìG d

Try it

Original, 42 bytes
Åqb £`bbidbad¾d`ò3n)ï`ia`q)m¬bXibÃò ®ìG d

Try it
Explanation
Åqb £`bbidbad¾d`ò3n)ï`ia`q)m¬bXibÃò ®ìG d
Å                                              :Slice off the first character
 qb                                            :Split on "b"
    £                                          :Map
     `bbidbad¾d`                               :  Compressed string "bbidbadbod"
                ò3n)                           :  Partition at every 3rd character from the end (["b","bid","bad","bod"])
                    ï                          :  Cartesian product
                     `ia`                      :   Compressed string "iaou"
                          q                    :   Split
                           )                   :  End Cartesian product
                            m                  :  Map
                             ¬                 :   Join
                              b                :  Index of
                               X               :   Current element
                                ib             :   Prepend "b"
                                  Ã            :End map
                                   ò           :Partition at every second element
                                     ®         :Map
                                      ìG       :  Convert from base-16 digit array to base-10 integer
                                         d     :  Get the character at that codepoint

R, 141 135 bytes
function(x,y="I":"A":"O")intToUtf8(matrix(match(el(strsplit(gsub("D","",x),"B"))[-1],paste0(rep("":y,e=4),y:"U"))-1,,2,T)%*%16:1)
":"=c

Try it online!
Thanks to JayCe for saving 6 bytes!
Using some modular magic is likely to be shorter, but I'm pretty happy with this as a naive first pass.

Nice ! My favorite trick saves 6 bytes - inspired by your comment to an answer of mine the other day.

@JayCe very nice and neat! Even using it with the precedence over %*% I see. :-) You can also put \:`` as a function argument in case you wanted to use this in tandem with something else!

That's right - I always tend to forget about the backquotes.

C (gcc), 181 138 136 bytes
Hopefully there will be a C compiler in the future to compile this! :-)
Thanks to Max Yekhlakov and ceilingcat for the suggestions.
v,t,c,d;f(char*s){for(v=t=c=0;d=*s++;)t+=d==66?v=v*16+t,++c>2?v=!putchar(v),c=1:0,-t:d-65?d-79?d-68?d-85?0:3:4+t*3:2:1;putchar(v*16+t);}

Try it online!

In case the C compiler of the future only understands BIBABOBU-ified ASCII :-)
BIDUBIDOBOBODIBIDUBIDIBOBODIBIDOBUBUBADUBIDOBIDOBOBADIBIDOBUBIDOBADIBIDOBABIDUBOBOBADOBIDUBUBOBADABIDUBADUBIDOBIDOBIDOBODUBIDUBOBOBADIBIDUBIDOBUBODABIDUBIDIBUBODABIDOBUBUBODABUBIBUBADUBOBADOBIDUBUBUBADUBIDUBUBOBADUBOBADUBOBADABIDUBIDIBOBADUBUBODABOBADOBIDUBUBUBODABUBODABUBIDOBUBIDOBUBODUBIDUBIDOBUBODABIDUBIDOBOBADOBUBABUBIDOBOBADUBIDUBIDIBOBODIBOBADUBOBADUBIDOBUBUBODOBUBOBUBODUBIDUBIDOBUBODABOBABIDUBIBIDUBIDABIDUBIDIBIDOBUBIDOBADIBIDOBABIDUBOBOBADIBIDUBIDOBOBADABOBODIBIDOBUBUBODABUBABUBADOBUBIBOBODIBOBODABIDUBIDIBUBADOBOBADOBIDUBUBOBODABUBIDOBUBIDABUBODUBOBADOBIDUBUBOBODABUBIDUBUBADABUBODUBOBADOBIDUBUBOBODABUBIDOBUBADIBUBODUBOBADOBIDUBUBOBODABUBADIBUBIDABUBODUBUBIBUBADOBUBUBUBADOBUBIDIBOBADUBIDUBIDIBOBADOBUBUBUBADOBUBOBUBADOBUBABUBADUBIDUBIBIDUBIDABIDUBIDIBIDOBUBIDOBADIBIDOBABIDUBOBOBADIBIDUBIDOBOBADOBUBABUBIDOBOBADUBIDUBIDIBOBADABUBADUBIDUBODA

(Encoder Try it online!)

179 bytes - Try it online!

Suggest c=printf(&v),v=0 instead of v=!putchar(v),c=1

JavaScript (Node.js), 131 128 bytes
s=>unescape(s.replace(/B.(D.)?/g,(f,s)=>(-~g(f[1])*4*!!s+g((s||f)[1])).toString(16),g=c=>'IAOU'.search(c)).replace(/../g,'%$&'))

Try it online! Link includes test cases. Alternative version, also 131 bytes:
s=>unescape(s.replace(/B.(D.)?/g,s=>(-~g(s[1])*4*!!s[3]+g(s[3]||s[1])).toString(16),g=c=>'IAOU'.search(c)).replace(/../g,'%$&'))

Try it online! Link includes test cases. Edit: Saves 3 bytes thanks to @Shaggy.

Using unescape() is a nice idea.

indexOf -> search to save a byte.

Also, it doesn't look like you need to assign the RegEx to r.

@Shaggy Whoops, that's a left-over from a previous iteration. Thanks!

Scala, 305 bytes
Well, I'm pretty sure this can be golfed out. But still, it exists. Takes input lowercase. f prints out the result in stdout.
EDIT: -8 chars thanks to me not being dumb anymore (spaces);
-13 chars thanks to crater2150
var k=Seq("bi","ba","bo","bu")
k++=k.init.flatMap(a=>Seq("di","da","do","du").map(a+_))//Putting "bu" here instead of at line 1, and in place of using init, would be interesting... if it did not cause a typing problem
var m=Seq[String]()
def g(a:Seq[String],b:Int)=k.indexOf(a(b)).toHexString
def f(a:String){a.split('b').drop(1).foreach(x=>m:+="b"+x)
var i=0
while(i<m.length){print(Integer.parseInt(g(m,i)+g(m,i+1),16).toChar)
i+=2}}

Try it online!

You can replace dropRight(1) with init, Seq("").drop(1) with Seq[String](), and map(b=>a+b) with map(a+_)

@crater2150 thanks! my compiler did not want map(a+_) to work but I knew I could do that. thanks for other tips!

Bash + common Linux utilities, 75 bytes
sed $(printf `printf %s s/{B{O,A,I}D,B}{U,O,A,I}/%x/g\;` {15..0})|xxd -r -p

Try it online!

Dyalog APL, 74 72 bytes
Beginner level solution in Dyalog APL (just started learning this a couple of days ago!).  Defines a dfn that takes one right argument (the input).  72 characters, 72 bytes when using the dyalog encoding.  Based on Emigna's solution in 05AB1E .
{⎕UCS 16⊥¨(1 0⍴⍨≢t)⊂1-⍨(,('B',('B'∘.,'IAO'),¨'D')∘.,'IAOU')⍳t←('B'⍷⍵)⊂⍵}

Welcome to PPCG and to the world of APL golfing. This is amazing after only a couple of days of learning APL. You may enjoy the APL golfing tips. Feel free to participate in The APL Orchard too!

Python 2, 142 139 127 118 bytes
lambda s:''.join(chr(16*a+b)for a,b in zip(*[iter(4*F(l[:-2])+F(l[-1])-1for l in s.split('B')[1:])]*2));F=' IAOU'.find

Try it online!

Python 2, 93 bytes
lambda w:''.join('c60238e4d1_b7f95a'[hash(x)%3046%17]for x in w.split('B')[1:]).decode('hex')

Try it online!

I love answers that abuse the hash value of sufficiently small lists

Ruby, 86 75 bytes
->s{[s.gsub(/B[^B]+/){|x|"546798ABDCEF1023"[x.to_i(31)/7%38%20]}].pack'H*'}

Try it online!

Java (JDK 10), 199 bytes
s->{var z="";for(var x:s.substring(1).split("B")){int d=-1;for(var y:x.split("D"))d=-~d*4+"IAOU".indexOf(y);z+=(char)(d>9?d+55:d+48);}return new String(new java.math.BigInteger(z,16).toByteArray());}

Try it online!
Credits

-2 bytes thanks to Arnauld

Could you use -~d instead of (d+1)?

Yep, thanks! I had those in my first version, then I toyed with the idea of using chars instead and when I came back to my first version, I totally forgot it again. ;)

Jelly, 39 bytes
®+“IAO”+”D®;p“IAOU”Ẏ€
=”B©œṗµḊ¢iⱮ’s2ḅ⁴Ọ

Try it online!
The technique used is very similar to Emigna's. I will golf this further soon, hopefully.

05AB1E, 30 bytes
ć¡Ç1^9%4%εDg≠i421øP]€OžvβžzвçJ

Port of @Dennis' insane Jelly answer (just with less convenient builtins). So make sure to upvote him!
Try it online or verify all test cases.
Explanation:
ć¡             # Split the input-string on its first character ('B')
               #  i.e. "BIDABIDIBIDOBIDABIDUBUBIDUBIDI"
               #   → ["IDA","IDI","IDO","IDA","IDU","U","IDU","IDI"]
  Ç            # Convert each character to it's ordinal value
               #  → [[73,68,65],[73,68,73],[73,68,79],[73,68,65],[73,68,85],85,[73,68,85],[73,68,73]]
   1^          # XOR it by 1
               #  → [[72,69,64],[72,69,72],[72,69,78],[72,69,64],[72,69,84],84,[72,69,84],[72,69,72]]
     9%        # Take modulo-9
               #  → [[0,6,1],[0,6,0],[0,6,6],[0,6,1],[0,6,3],3,[0,6,3],[0,6,0]]
       4%      # Take Modulo-4
               #  → [[0,2,1],[0,2,0],[0,2,2],[0,2,1],[0,2,3],3,[0,2,3],[0,2,0]]
ε         ]    # Now map it to:
 Dg≠i          # If the length is not 1:
               #  i.e. [0,2,1] → 3 → 1 (truthy)
               #  i.e. 3 → 1 → 0 (falsey)
     421øP     # Multiply the first number by 4, second by 2, and third by 1
               #  i.e. [0,2,1] and [4,2,1] → [[0,4],[2,2],[1,1]] → [0,4,1]
           €O  # Then sum every inner list
               #  [[0,4,1],[0,4,0],[0,4,2],[0,4,1],[0,4,3],3,[0,4,3],[0,4,0]]
               #   → [5,4,6,5,7,3,7,4]
žvβ            # Convert this list from base-16 to base-10
               #  → 1415934836
   žzв         # Convert this integer from base-10 to base-256
               #  → [84,101,115,116]
      ç        # Convert this number to ASCII characters
               #  → ["T","e","s","t"]
       J       # Join the characters together (and output implicitly)
               #  → "Test"

Wondered how you snipped 3 off emignas score. Jeebus this is complex +1 for the effort on the port-- never used XOR or that base conversion before! Will keep in mind from now on!

@MagicOctopusUrn Yeah, Dennis' answer is something I would have never came up with myself.. And in Jelly this is done way more efficient, since his answer is 15 bytes and mine is 30. Just figured it was worth posting as well however, even though it's a port. I've only used XOR once myself, and Base conversion pretty often.

Brain-Flak, 178 bytes
{(([((((()()()()){}){}){}()){}]{}){{}<>(({}){}){}(<>)}{}<({}(<>))(<>)((()()()())({})()){{(({})){({}[()])<>}{}}<>({}<>)<>{}}{}><>{}{})<>}<>([]){{}({}(((({}){}){}){}){}<>)<>([])}<>

Try it online!
Explanation
# Step 1: convert to hex.
# For each pair of letters in the input:
{

  (

    # Compare first letter to B
    ([((((()()()()){}){}){}()){}]{})

    # If not B, pop previous output, multiply by 4, and put on third stack.
    # 4 is added automatically from pushing/popping the difference
    # between the letters B and D.
    {{}<>(({}){}){}(<>)}{}

    <

      # Push second letter in pair to other stack
      ({}(<>))

      # Push 4 and 9
      (<>)((()()()())({})())

      # Compute 3-((8-(n mod 9)) mod 4)
      # (same as (n-1) mod 9 mod 4)
      {{(({})){({}[()])<>}{}}<>({}<>)<>{}}{}

    >

    # Add result to third stack (either 0 or 4*previous+4)
    <>{}{}

  # Push onto second stack
  )

<>}

# Step 2: Pair up hex digits.
# While digits remain on right stack:
<>([]){{}

  # Push top of stack + 16*second on stack to left stack
  ({}(((({}){}){}){}){}<>)<>

([])}

# Switch to left stack for output.
<>

VBA (Excel), with an amazing 322 244 bytes

Yeah, and I LOVE hexadecimal. (There's no sarcasm font yet, so I'm using italics for now) I'll add comments if someone wants, but I think it's self explanatory. Golfing happened.
Sub b(s)
For Each c In Split(Replace(s,"D",""),"B")
c=Application.Match(c,Array("I","A","O","U","II","IA","IO","IU","AI","AA","AO","AU","IO","OA","OO","OU"),0)
If Not IsError(c)Then d=d &c-1:If Len(d)=2Then e=e &Chr("&h"&d):d=""
Next
Debug.?e
End Sub

With Comments:
Sub b(s)
  'For each string between B's (Remove the D's first)
  For Each c In Split(Replace(s,"D",""),"B")
    'Get the index of the element in the array (Can cause error if empty)
    c = Application.Match (c,Array("I","A","O","U","II","IA","IO","IU","AI","AA","AO","AU","IO","OA","OO","OU"),0)
    'If c isn't an error
    If Not IsError(c) Then
      'Subtract 1 from c and add to d  --> Array index is 1 based
      d = d & (c-1)
      'If d is 2 characters
      If Len(d)=2 Then
        'Add the char from the hex value of d   --> &h forces Hex
        e = e & Chr("&h" & d)
        'Reset d
        d = ""
      End if
    End if
  Next
  'Print the output
  Debug.Print e
End Sub

I really tried to get this into the VB Immediate Window, but it doesn't seem to work there... that would cut 11 characters I think. I also wanted to put the Match statement into brackets, but that causes a silent error everytime. Help is appreciated :D

Welcome to PPCG!

Thanks! I've been here for a while, just never been able to post anything :)

Array("I","A","O","U","II","IA","IO","IU","AI","AA","AO","AU","IO","OA","OO","OU") ->
Split("I A O U II IA IO IU AI AA AO AU IO OA OO OU") and Not IsError(c) -> IsError(c)=0

Haxe, 228 bytes
s->{var l=(u,i)->((i=u.charCodeAt(i))&8==8?0:1)|((i>>1)&2),p=s.split("B"),i=-1,q,o;[while((i+=2)<p.length)String.fromCharCode(l(q=p[i+1],o=q.length-1)+((o>1?l(q,0)+1:0)+((l(q=p[i],o=q.length-1)+o*(l(q,0)+1)*2)*4))*4)].join("");}

Not the best, standard library function names are too large :(
Try it online!

Pyth, 35 bytes
mCid16cm+4imx"IAOU"k.[N2d4tc-Q\D\B2

Outputs as a list of characters.
Try it here
Explanation
mCid16cm+4imx"IAOU"k.[N2d4tc-Q\D\B2
                          tc-Q\D\B   Get the vowels associated with each digit.
       m            .[N2d            Pad with a quote.
           mx"IAOU"k                 Find each character's position.
        +4i              4           Convert to base 4 and add 4.
      c                           2  Split the result into pairs.
mCid16                               Get the associated ASCII characters.

Charcoal, 36 bytes
ＦＳ≡ιB⊞υ⁰D⊞υ×⁴⊕⊟υ⊞υ⁺⊟υ⊕⌕AOUι⭆⪪υ²℅↨ι¹⁶

Try it online! Link is to verbose version of code. Explanation:
ＦＳ≡ι

Loop over each input character and switch.
B⊞υ⁰

If it's a B then push 0 to the predefined empty list.
D⊞υ×⁴⊕⊟υ

If it's a D then pop the last value, increment it, multiply by 4, and push it again.
⊞υ⁺⊟υ⊕⌕AOUι

Otherwise, find the index in the string AOU, increment it, and add to the last value.
⭆⪪υ²℅↨ι¹⁶

Split the list into pairs of values, decode as base 16, convert to ASCII, and implicitly print.

Clean, 145 134 bytes
import StdEnv                   // import things like addition and comparison
?c=(743rem(toInt c))/16         // magical formula that maps ['IAOU'] to [0,1,2,3]
@[_,b,'D',d:t]=[?d+ ?b*4+4: @t] // convert B#D#
@[_,b:t]=[?b: @t]               // convert "B#"
@_=[]                           // handle base case
$[u,v:t]=[u<<4+v: $t]           // turn the digits into 2-digit numbers
$e=e                            // handle base case

toString o$o@                   // convert to string (make numbers (make digits))

Try it online!
Explained:

PHP, 119 bytes
foreach(explode(B,$argn)as$i=>$m)($v=$v*16+4*strpos(XIAO,$m[-3]?:B)+strpos(IAOU,$m[-1]?:B))?$i&1||print chr($v&=255):0;

assumes uppercase input. Run as pipe with -nR or try it online.
requires PHP 7.1
for older PHP, use substr($m,-3,1) and substr($m,-1) instead of $m[-<x>] (+16 bytes);
for younger PHP, put B, XIAO and IAOU in quotes to avoid warning messages (+10 bytes).

05AB1E, 40 bytes
'B"IAOU"©âÐUs'D®ââJ)˜sXíDεSðý}:#khJ2ôHçJ

Try it online!

PHP, 163 bytes
function f($s){$t=[I=>0,A=>1,O=>2,U=>3];for($q=explode(B,$s);$a=&$q[++$i];){$a=($a[1]?($t[$a[0]]+1)*4:0)+$t[$a[2*($a[1]==D)]];$i%2?:print(chr(($q[$i-1]<<4)+$a));}}

Call f(string $s) with the appropriate string of bibabobu-encoded characters, and it will print the decoded string.

Python 3, 199 bytes
import re
lambda s:''.join(eval(re.sub(r'(\d+), (\d+)',r'chr(16*\1+\2)',str(eval(s.replace('I','1').replace('A','2').replace('O','3').replace('U','4').replace('B',',-1+').replace('D','*4+')[1:])))))

Not the shortest but without loops.


text:
Convert a percentage to a "simple" ratio
You run a political website, and have determined that people have a better intuitive understanding when the chance of winning or losing an election is expressed as a ratio ("5 in 7") than when it is expressed as a percentage ("71%").
But you also don't want to display confusing ratios like "58 in 82", you'd like them to be more easily understood, even if they aren't quite as precise.
So, given a percentage between 0.1% and 99.9%, return the closest "easy-to-understand" ratio "x in y", using the following rules:

Most values (see exceptions below) should return the closest ratio out of 10 or lower. 55% should return "5 in 9", not "11 in 20".
Ratios should be reduced to their lowest terms. 65% should return "2 in 3", not "4 in 6".
Values under 10% should return the closest ratio of the form "1 in n" where n is one of (10,12,15,20,30,40,50,60,70,80,90,100). For example,  6% should return "1 in 15".
Values over 90% should return the closest ratio of the form "n-1 in n" where n is one of (10,12,15,20,30,40,50,60,70,80,90,100). For example, 98.7% should return "79 in 80".
Values under 1% should return "<1 in 100"
Values over 99% should return ">99 in 100"

Or, to think about it another way, your program should return the closest ratio from the following possible outputs (I've included their approximate values for your convenience):
<1 in 100
 1 in 100  = 1.00%
 1 in 90   = 1.11%
 1 in 80   = 1.25%
 1 in 70   = 1.43%
 1 in 60   = 1.67%
 1 in 50   = 2.00%
 1 in 40   = 2.50%
 1 in 30   = 3.33%
 1 in 20   = 5.00%
 1 in 15   = 6.67%
 1 in 12   = 8.33%
 1 in 10   = 10.00%
 1 in 9    = 11.11%
 1 in 8    = 12.50%
 1 in 7    = 14.29%
 1 in 6    = 16.67%
 1 in 5    = 20.00%
 2 in 9    = 22.22%
 1 in 4    = 25.00%
 2 in 7    = 28.57%
 3 in 10   = 30.00%
 1 in 3    = 33.33%
 3 in 8    = 37.50%
 2 in 5    = 40.00%
 3 in 7    = 42.86%
 4 in 9    = 44.44%
 1 in 2    = 50.00%
 5 in 9    = 55.56%
 4 in 7    = 57.14%
 3 in 5    = 60.00%
 5 in 8    = 62.50%
 2 in 3    = 66.67%
 7 in 10   = 70.00%
 5 in 7    = 71.43%
 3 in 4    = 75.00%
 7 in 9    = 77.78%
 4 in 5    = 80.00%
 5 in 6    = 83.33%
 6 in 7    = 85.71%
 7 in 8    = 87.50%
 8 in 9    = 88.89%
 9 in 10   = 90.00%
 11 in 12  = 91.67%
 14 in 15  = 93.33%
 19 in 20  = 95.00%
 29 in 30  = 96.67%
 39 in 40  = 97.50%
 49 in 50  = 98.00%
 59 in 60  = 98.33%
 69 in 70  = 98.57%
 79 in 80  = 98.75%
 89 in 90  = 98.89%
 99 in 100 = 99.00%
>99 in 100

Other stipulations:

Numeric input can be in the range of 0.1 to 99.9 or in the range of 0.001 to 0.999, whichever is more convenient. You must handle at least 3 significant digits.
You must output a ratio ("3 in 4"), not the equivalent fraction ("3/4").
If there are two ratios equally close to the input, your program can return either one. 7.5% could return "1 in 12" or "1 in 15".
Leading/trailing white space and/or new lines are fine

Examples:
Input  :   Output
 0.5   :  <1 in 100
 1.0   :   1 in 100
 1.5   :   1 in 70
 7.5   :   1 in 15  or  1 in 12 (either is acceptable)
 9.2   :   1 in 10
13.1   :   1 in 8
29.2   :   2 in 7
29.3   :   3 in 10
52.7   :   1 in 2
52.8   :   5 in 9
72.0   :   5 in 7
73.9   :   3 in 4
88.8   :   8 in 9
90.8   :   9 in 10
94.2   :  19 in 20
98.7   :  79 in 80
98.9   :  89 in 90
99.0   :  99 in 100
99.1   : >99 in 100

This is a code-golf challenge, shortest code in each language wins.
(Similar to, but not duplicate of: Convert a decimal to a fraction, Closest fraction, Approximate floating point number with n-digit precision)

If there are two ratios equally close to the input, your program can return either one. 7.5% could return "1 in 12" or "1 in 15" Does that mean that we can return 7 in 100 as well? Btw, 1 in 14 is closer to the input in this case.

@DimChtz No, as that violates rule 3 (values under 10% should be expressed as "1 in n", for specific possible values of n).

Ohh, I didn't notice this. Okay.

I'd like it if we could just output the numerator and denominator as any format like a tuple/list or something, but there are already competing answers so I suppose it's too late for this challenge. For future challenges though, I'd consider a more flexible I/O format because some languages lose more competitiveness than others when you require string handling.

@BradC - LOL. I was just at 538, and I was all "Wow! I gotta make a golfing challenge out of this!"

T-SQL, 385 bytes
SELECT TOP 1IIF(i>.99,'>',IIF(i<.01,'<',''))+n+' in '+d
FROM t,(SELECT ISNULL(PARSENAME(value,2),'1')n,PARSENAME(value,1)d FROM
STRING_SPLIT('100,90,80,70,60,50,40,30,20,15,12,10,9,8,7,6,5,2.9,4,2.7,3.10,3,3.8,2.5,3.7,4.9,2,5.9,4.7,3.5,5.8,2.3,7.10,5.7,3.4,7.9,4.5,5.6,6.7,7.8,8.9,9.10,11.12,14.15,19.20,29.30,39.40,49.50,59.60,69.70,79.80,89.90,99.100',','))m
ORDER BY ABS(i-ABS(n)/d)

Input is via pre-existing table t with numeric field i, per our IO standards.
That input table is joined with an in-memory table parsed from a string via STRING_SPLIT (which separates rows) and PARSENAME (which separates numerator and denominator via .).
The table is sorted by distance from the input value i, and returns the top row, formatted appropriately.

JavaScript (ES7), 164 159 144 bytes
Expects an input ratio in \$]0,1[\$.
r=>(g=m=>--n+11?g((q=n>1?n*10:n+10-~'13'[n],d=((p=r<.1?1:r>.9?q-1:n<0&&r*q+.5|0)/q-r)**2)>m?m:(o=p+' in '+q,d)):r<.01?'<'+o:r>.99?'>'+o:o)(n=11)

Try it online!
How?
We try all possible ratios \$p/q\$. For each of them, we compute:
$$d=(p/q-r)^2$$
We update the best score \$m\$ (the lower, the better) each time \$d\$ is lower than or equal to \$m\$.
We go from the highest value of \$q\$ to the lowest one, so that a smaller denominator is preferred in case of a tie.
Commented
r => (g = m =>               // r = input; g() = recursive function, taking m = best score
  --n + 11 ?                 // decrement n; if n is still greater than or equal to -10:
    g(                       //   do a recursive call to g():
      ( q =                  //     compute q = denominator:
        n > 1 ?              //       if n is greater than 1:
          n * 10             //         q = n * 10 (20, 30, ..., 100)
        :                    //       else:
          n + 10 - ~'13'[n], //         q = 12 if n = 0, 15 if n = 1, n + 11 if n < 0
        d = ((               //     compute d = (p / q - r)²:
          p =                //       compute p = numerator:
          r < .1 ?           //         if r is less than 0.01:
            1                //           p = 1
          :                  //         else:
            r > .9 ?         //           if r is greater than 0.90:
              q - 1          //             p = q - 1
            :                //           else:
              n < 0 &&       //             if n is negative (i.e. q is in [1,10]):
              r * q + .5 | 0 //               p = round(r * q)
                             //             otherwise: p = 0 (which will be ignored)
          ) / q - r          //       compute p / q - r
        ) ** 2               //       and square the result (cheaper than absolute value)
      ) > m ?                //     if d is greater than m:
        m                    //       leave m unchanged
      : (                    //     else:
        o = p + ' in ' + q,  //       update the output string o
        d                    //       and update m to d
    ))                       //   end of recursive call
  :                          // else (all possible ratios have been tried out):
    r < .01 ? '<' + o :      //   if r is less than 0.01, prefix with '<'
    r > .99 ? '>' + o :      //   if r is greater than 0.99, prefix with '>'
    o                        //   otherwise, just return o
)(n = 11)                    // initial call to g() with m = n = 11

Charcoal, 84 bytes
ＮθＦ¹¹«Ｆ⊖ι⊞υ⟦⊕κι⟧≔⎇⊖ι∨×χι¹²¦¹⁵ιＦ²⊞υ⟦∨κ⊖ιι⟧»≔Ｅυ↔⁻θ∕§ι⁰§ι¹η≔⌕η⌊ηη×<‹θ·⁰¹×>›θ·⁹⁹⪫§υη in

Try it online! Link is to verbose version of code. Takes input as a decimal rather than a percentage. Explanation:
Ｎθ

Input the fraction.
Ｆ¹¹«

Run from \$ n = 0 \$ to \$ n = 10 \$.
Ｆ⊖ι⊞υ⟦⊕κι⟧

Generate ratios for \$ \frac 1 n \$ to \$ \frac {n - 1} n \$.
≔⎇⊖ι∨×χι¹²¦¹⁵ι

Get the \$ n^{th} \$ element of the list \$ 12, 15, 20 ... 100 \$ into \$ n \$.
Ｆ²⊞υ⟦∨κ⊖ιι⟧»

Generate ratios for \$ \frac {n - 1} n \$ and \$ \frac 1 n \$.
≔Ｅυ↔⁻θ∕§ι⁰§ι¹η

Calculate the decimal values of all the ratios and take the absolute difference with the original input.
≔⌕η⌊ηη

Find the index of the least absolute difference. In case of a tie (e.g. \$ \frac 1 2 \$ and \$ \frac 2 4 \$), take the ratio generated first.
×<‹θ·⁰¹

Print a < if the input is less than \$ 0.01 \$.
×>›θ·⁹⁹

Print a > if the input is greater than \$ 0.99 \$.
⪫§υη in

Join the numerator and denominator of the appropriate ratio with in and print.

Python 2, 261 278 261 237 177 bytes
lambda n:' <>'[(n<.01)-(n>.99)]+'%d in %d'%min([(a,b)for b in[[12,15]+r(10,110,10),r(1,11)][.1<n<.9]for a in r([1,b-1][n>.9],[b,2][n<.1])],key=lambda(a,b):abs(1.*a/b-n))
r=range

Try it online!

Doesn't Python support semicolons? You could replace '\n ' with ';'... unless I'm wrong.

@BradC Fixed :)

Jelly, 58 bytes
⁵R×⁵;12,15µ’,1,€)Ẏ;⁵Œc¤ð÷/ạ¥ÞḢj“ in ”
”<”>“”>.99$?<.01$?;Ç

Try it online!
-16 bytes thanks to Arnauld (can just prepend the < and > instead of rewriting the whole phrase)
-6 bytes and bug-fixes thanks to Jonathan Allan

@Arnauld Oh you're right, never thought about that :P Thanks!

0.3 should result in 3 in 10 not 2 in 7

You should just remove the µµ, no? EDIT - and then golf ÐṂṂ to ÞḢ

changing 9 to ⁵ should resolve the bug I believe.

@JonathanAllan Oh whoops, yep I wasn't using 10 as a valid denominator. Thanks. And no, removing the double mu doesn't work because then the "minimum" is attached to the right side of the dyadic link-min function which is definitely not what I want, but only putting one mu doesn't seem to fix it. Thanks for the golf though :D

Removing the double mu from the previous seems to work fine ...although I noticed another bug - namely 0.999 results in >1 in 1 - which can be fixed by replacing ⁵R¤p¤with⁵Œc¤` this also saves another two bytes :)

µ€ -> ) saves another

@JonathanAllan Oh cool, thanks! Is the mu-euro => ) a new thing?

Fairly new, been there since May. You left in a redundant ¤ by the way.

@JonathanAllan Ah ok, that's about when I last used Jelly :( :P and oh yeah, thanks, I was wondering where the third byte you saved went lol.

Jelly,  53  52 bytes
_.01,.99Ṡµ<0ịØ<ḣE⁵Ż×⁵+12,5Ṡ,’Ɗż€$Ẏ;⁵Œc¤÷/ạ¥Þ³Ḣj“ in

A full program which prints the result.
Try it online!
Or see the test-suite
Note that the test-suite is altered to make the code a monadic link by:

using the register keep a track of the current "program input", with
³ to ®; and
closing the list of characters code for " in ", with
“ in  to “ in ”

How?
Starts with code that forces any necessary printing of the < or > sign and then code which constructs all the numerator-denominator pairs (with some redundant not simplified form versions, all after their simplified form) and prints the minimally different division-evaluated entry using a stable sort joined with  in .
_.01,.99Ṡµ<0ịØ<ḣE⁵Ż×⁵+12,5Ṡ,’Ɗż€$Ẏ;⁵Œc¤÷/ạ¥Þ³Ḣj“ in  - Main Link: number in [0,1], n
 .01,.99                                             - literal pair = [0.01, 0.99]
_                                                    - subtract -> [n - 0.01, n - 0.99]
        Ṡ                                            - sign (vectorises) (-1 if <0; 1 if >0; else 0)
         µ                                           - start a new monadic link
                                                     -   call that X
          <0                                         - less than zero? (vectorises)
             Ø<                                      - literal list of characters = "<>"
            ị                                        - index into (vectorises) ("<<" if n < 0.01; ">>" if n >= 0.99; else "><")
                E                                    - all (of X) equal? (1 if ((n < 0.01) OR (n > 0.99)) else 0
               ḣ                                     - head to index ("<" if n < 0.01; ">" if n > 0.99; else "")
                                                     -   (the following nilad forces a print of that)
                 ⁵                                   - literal 10
                  Ż                                  - zero-range -> [0,1,2,3,4,5,6,7,8,9,10]
                   ×⁵                                - multiply by 10 -> [0,10,20,30,40,50,60,70,80,90,100]
                      12,5                           - literal pair = [12,5]
                     +                               - add -> [12,15,20,30,40,50,60,70,80,90,100]
                                $                    - last two links as a monad
                             Ɗ                       -   last three links as a monad
                          Ṡ                          -     sign -> [1,1,1,1,1,1,1,1,1,1,1]
                            ’                        -     decrement -> [11,14,19,29,39,49,59,69,79,89,99]
                           ,                         -     pair -> [[1,1,1,1,1,1,1,1,1,1,1],[11,14,19,29,39,49,59,69,79,89,99]]
                              ż€                     -   zip with for €ach -> [[[1,12],[1,15],[1,20],[1,30],[1,40],[1,50],[1,60],[1,70],[1,80],[1,90],[1,100]],[[11,12],[14,15],[19,20],[29,30],[39,40],[49,50],[59,60],[69,70],[79,80],[89,90],[99,100]]]
                                 Ẏ                   - tighten -> [[1,12],[1,15],[1,20],[1,30],[1,40],[1,50],[1,60],[1,70],[1,80],[1,90],[1,100],[11,12],[14,15],[19,20],[29,30],[39,40],[49,50],[59,60],[69,70],[79,80],[89,90],[99,100]]
                                      ¤              - nilad followed by link(s) as a nilad:
                                   ⁵                 -   literal 10
                                    Œc               -   unordered pairs -> [[1,2],[1,3],[1,4],[1,5],[1,6],[1,7],[1,8],[1,9],[1,10],[2,3],[2,4],[2,5],[2,6],[2,7],[2,8],[2,9],[2,10],[3,4],[3,5],[3,6],[3,7],[3,8],[3,9],[3,10],[4,5],[4,6],[4,7],[4,8],[4,9],[4,10],[5,6],[5,7],[5,8],[5,9],[5,10],[6,7],[6,8],[6,9],[6,10],[7,8],[7,9],[7,10],[8,9],[8,10],[9,10]]
                                  ;                  - concatenate -> [[1,12],[1,15],[1,20],[1,30],[1,40],[1,50],[1,60],[1,70],[1,80],[1,90],[1,100],[11,12],[14,15],[19,20],[29,30],[39,40],[49,50],[59,60],[69,70],[79,80],[89,90],[99,100],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7],[1,8],[1,9],[1,10],[2,3],[2,4],[2,5],[2,6],[2,7],[2,8],[2,9],[2,10],[3,4],[3,5],[3,6],[3,7],[3,8],[3,9],[3,10],[4,5],[4,6],[4,7],[4,8],[4,9],[4,10],[5,6],[5,7],[5,8],[5,9],[5,10],[6,7],[6,8],[6,9],[6,10],[7,8],[7,9],[7,10],[8,9],[8,10],[9,10]]
                                           Þ         - sort by:
                                          ¥          -   last two links as a dyad:
                                                     -       ...(with right argument of
                                            ³        -           the program input, n)
                                        /            -     reduce by:
                                       ÷             -       division
                                         ạ           -     absolute difference
                                             Ḣ       - head
                                               “ in  - literal list of characters " in "
                                              ;      - concatenate
                                                     - implicit print

Clean, 224 198 197 bytes
import StdEnv,Data.List,Text
t=toReal
$p=if(p<1.0)"<"if(p>99.0)">"""+snd(minimum[(abs(p-t n*1E2/t d),n<+" in "<+d)\\i<-[10,12,15:[20,30..100]],(n,d)<-[(1,i),(i-1,i):diag2[1..10][1..10]]|gcd n d<2])

Try it online!
Explained:
t = toReal                              // give `toReal` a shorter name
$ p
 = if(p < 1.0)                          // if the percentage is less than 1%
  "<"                                   // prepend "<"
 if(p > 99.0)                           // if the percentage is > 99%
  ">"                                   // prepend ">"
  ""                                    // otherwise prepend nothing
 + snd (                                // to the second element of
  minimum [                             // the smallest item in a list composed of
   (                                    // pairs of
    abs (                               // the absolute value of
     p -                                // the difference between the percentage
     t n*1E2 / t d                      // and the ratio
    )
   ,                                    // associated with
    n <+ " in " <+ d                    // the string representation of the ratio
   )                                    // in the form of a tuple
   \\ i <- [10, 12, 15: [20, 30..100]]  // for every special denominator `i`
   , (n, d) <- [(1, i), (i - 1, i): diag2 [1..10] [1..10]]
                                        // for every ratio `n` : `d`
   | gcd n d < 2                        // where `n` / `d` cannot be further simplified
  ]
 )

Perl 6, 118 bytes
{'<'x(.01>$_)~'>'x($_>.99)~(|(1..9 X ^11),|map({|(1,$_-1 X$_)},12,15,|(^11 X*10))).min({abs $_-[/] @^a}).join(' in ')}

Try it online!