text:
Nightmare Puzzlang translator
Background
Puzzlang is a derivative of Brainfuck, where the symbol X executes a BF command based on three characters on top of it, and anything else does nothing.
The following is the translation table for Puzzlang, where X is the literal X and . stands for anything else:
 >      <      +      -      .      ,      [      ]

..X    X..    XXX    ...    .X.    X.X    XX.    .XX
 X      X      X      X      X      X      X      X

Also, the entire source code wraps around both horizontally and vertically at the translation step. For example, the following code is an infinite loop:
XX X

since you can view the code like this (the dots are where the wrapped X's would go)
... ..
.XX X.

and matching with the translation table gives +[] for the three X's in order.
Nightmare Puzzlang is an evil twin of the regular Puzzlang. In Nightmare Puzzlang, each X translates into a byte based on its eight neighbors. Any non-X characters translate into nothing. The wrapping rule is the same.
Since there is no "official" specification, let's assume that the following pattern (where X denotes the one to translate)
abc
dXe
fgh

translates to abcdefgh in binary (X is one, non-X is zero). Then the following code
XX...
X..X.
X..XX
X..XX
X.XX.

translates to 4a b4 66 03 56 4b bf d2 6e fd c3 2c 70 in hex, or J´fVK¿ÒnýÃ,p as a string. Note that the resulting string will very likely have ASCII unprintables.
Task
Translate the given Nightmare Puzzlang code into a string.
Input & output
For input, you can take 2D array of chars, list of strings, or a single string whose lines are delimited by newlines. You can assume that the input is rectangular in shape, i.e. row lengths are equal.
For output, you can give a single string, a list of chars, or a list of charcodes.
Test Cases
Note that the result must remain the same when any of the dots are replaced with anything else other than the capital X.
X (1 row, 1 column)
String: ÿ
Charcode: [255]

X. (1 row, 2 columns)
String: B
Charcode: [66]

X
. (2 rows, 1 column)
String:
Charcode: [24]

X.
.X
String: ¥¥
Charcode: [165, 165]

X.X
.X.
String: 1Œ¥
Charcode: [49, 140, 165]

X.X
XX.
X.X
String: ÓmÎµv«
Charcode: [211, 109, 206, 181, 118, 171]

X.XX.XXX..XXXX.
String: BkÖkÿÖkÿÿÖ
Charcode: [66, 107, 214, 107, 255, 214, 107, 255, 255, 214]

X.XX.XXX.XXXXX.
XX.X..XX....X..
String: cR){Ö9Z”JµÆïÖç
Charcode: [99, 173, 82, 41, 123, 214, 8, 24, 57, 90, 148, 74, 181, 198, 239, 214, 231]

X
X
X
.
.
X
.
X
X
.
X
String: ÿÿøø
Charcode: [255, 255, 248, 24, 31, 248, 31]

XX
X.
XX
.X
.X
XX
..
XX
XX
..
.X
String: º]ç]ºâG¸Xøø
Charcode: [186, 93, 231, 93, 186, 226, 71, 184, 88, 31, 31, 248, 248, 7]

XX XXX XX  XX
X  X X X X X
X  X X X X XX
X  X X X X X
XX XXX XX  XX

XXX XXX X  XX
X   X X X  X
X X X X X  XX
X X X X X  X
XXX XXX XX X
(11 rows, 13 columns, no extra padding, result has two newlines)
zôª}òªuJ½æbÂb‚cRBBBBJ½ÇCFCDcXH¸PH°H¸

æbÂBcRBBBJ½ÃFCFCbO¾UO¾UN”C
Charcode: [122, 244, 170, 125, 242, 170, 117, 74, 189, 230, 98, 194, 98, 130, 99, 82, 66, 66, 66, 66, 74, 189, 199, 67, 70, 67, 68, 99, 88, 144, 72, 184, 80, 72, 176, 72, 184, 26, 28, 16, 10, 29, 18, 2, 10, 29, 230, 98, 194, 66, 99, 82, 2, 66, 66, 66, 74, 189, 195, 70, 67, 70, 67, 98, 79, 190, 85, 79, 190, 85, 78, 148, 67]

Rules
Standard code-golf rules apply. The shortest submission in bytes wins.

APL (Dyalog Unicode), 57 bytes
¯1~⍨,1↓∘⍉∘⌽⍣4⊢{2 2⌷⍵:2⊥(~¯9↑5↑1)/,⍵⋄¯1}⌺3 3⊢⍉∘(¯1∘↑⍪⊢⍪1∘↑)⍣2⊢'X'=⎕

Try it online!
A full program which takes a binary matrix through STDIN, returns an array of codepoints.
Explanation
x¯1~⍨,1↓∘⍉∘⌽⍣4⊢{2 2⌷⍵:2⊥(~¯9↑5↑1)/,⍵⋄¯1}⌺3 3⊢⍉∘(¯1∘↑⍪⊢⍪1∘↑)⍣2⊢'X'=⎕
⎕ take input
'X'=  boolean matrix where 'X's are 1s
⍉∘(...)⍣2⊢ do the following twice:
¯1∘↑⍪⊢⍪1∘↑ pad each row with its wraparound on both sides
⍉∘ and transpose
{...}⌺3 3⊢ then, do the following for each 3x3 window:
2 2⌷⍵: if the middle element is 1:
2⊥(~¯9↑5↑1)/,⍵ decode the rest of the window as binary
⋄¯1 Otherwise, return ¯1.
⍣4⊢ Do the following 4 times:
1↓∘⍉∘⌽ rotate 90°, drop first row (remove the border cells)
, flatten into a simple array
¯1~⍨ remove all ¯1s

Python 3, 166 162 161 bytes
lambda p,r=range:[chr(int(''.join(str(+([n*2for n in p+p][y+i//3-1][x+i%3-1]=='X'))for i in r(9)if i-4),2))for y in r(len(p))for x in r(len(p[0]))if'X'==p[y][x]]

Takes as input a list of strings and returns a character array.
Try It Online!
Ungolfed (sorta):
def f(p):
    chars = []
    for y in range(len(p)):
        for x in range(len(p[0])):
            if p[y][x] != 'X':
                continue
            bits = []
            for i in range(9):
                if i == 4:
                    continue
                bit_x = x + i%3 - 1
                bit_y = y + i//3 - 1
                char_at_cell = [n*2for n in p+p][bit_y][bit_x]
                bit = str(+(char_at_cell=='X'))
                bits.append(bit)
            char_code = int(''.join(bits), 2)
            chars.append(chr(char_code))
    return chars

Edit: made shorter by 5 bytes thanks to Jo King and Jonathan Frech

Since the function ins't recursive, you don't need to assign the lambda. 162 bytes

oh nice, didn't know that you could remove that, cheers. Just writing up the ungolfed version and will add in your changes

Note that the slash's orientation matters. You used / -- a slash -- to continue a line in C-style, use a backslash: \ .

You can golf your one != to a -.

JavaScript (ES6), 159 bytes
Takes input as a 2D array of characters. Returns an array of character codes.
f=M=>M.map((r,y)=>r.map((v,x)=>v>f&&o.push([...'22211000'].map((k,j)=>s|=(M[(y+h+~-k)%h][(x+w+~-'21020'[j%5])%w]>f)<<j,h=M.length,w=M[s=0].length)|s)),o=[])&&o

Try it online!
Commented
f = M =>                        // f = main function taking the input matrix
                                //     it is named because we are later using '>f'
  M.map((r, y) =>               // for each row r[] at position y in M[]:
    r.map((v, x) =>             //   for each value v at position x in r[]:
      v > f &&                  //     ignore this cell if v is not equal to 'X'
      o.push(                   //     otherwise, push a new value in o[]:
        [...'22211000']         //       iterate over dy values (+1)
        .map((k, j) =>          //       for each value k at position j in this array:
          s |= (                //         update s:
            M[(y + h +          //           compute the row
              ~-k)              //           by adding dy = k - 1
              % h]              //           and applying a modulo h
            [(x + w +           //           compute the column
              ~-'21020'[j % 5]) //           by adding dx = [2,1,0,2,0,2,1,0][j] - 1
              % w]              //           and applying a modulo w
            > f                 //           test whether this cell is a 'X'
          ) << j,               //         and set the corresponding bit in s if it is
          h = M.length,         //         initialize h = matrix height
          w = M[s = 0].length   //         initialize w = matrix width and s = bitmask
        ) | s                   //       end of map() over dy; yield s
      )                         //     end of push()
    ),                          //   end of map over r[]
    o = []                      //   initialize o = output array
  ) && o                        // end of map over M[]; return o

Jelly, 19 bytes
=”Xµ-r1p`ẸƇ+ⱮŒṪœịµḄ

A monadic Link that accepts a list of the lines and yields a list of code-points.
Try it online!
How?
=”Xµ-r1p`ẸƇ+ⱮŒṪœịµḄ - Link: lines
 ”X                 - character = 'X'
=                   - equals? -> binary matrix from lines with X:1 and .:0
   µ             µ  - monadic chain - f(v=that):
    -               -   -1
      1             -   1
     r              -   inclusive range = [-1, 0, 1]
        `           -   use as both arguments of:
       p            -     Cartesian product
                               = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,0],[0,1],[1,-1],[1,0],[1,1]]
          Ƈ         -   keep those for which:
         Ẹ          -     any? = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
             ŒṪ     -   multidimensional truthy indices (v)
            Ɱ       -   map across these with:
           +        -     add
               œị   -   index into (v)
                  Ḅ - convert from binary


text:
Build a Board of Napier's Bones

This proposal had few attention for 8 months (though an answer was posted in the sandbox at that time), so I decided to post it anyway.

Introduction
Napier's bones is a calculation tool, which helps speeding up the calculation of multiplication, division and digit-by-digit square root extraction by turning n-digit-by-1-digit multiplications into table look-ups. Napier's bones consists of rods marked with the multiples of a single-digit number, and a board with a set of numbers on the left, on which the rods can be arranged. The board and the rods look like this (All appearances of the rods are in the Sample section):
Rod    Board
       +-----------------------------------------------+
       |   +------------------------------------------+|
+---+  |   |                                          ||
| 4 |  |   |                                          ||
+---+  |   |                                          ||
|0 /|  |   |                                          ||
| / |  | 1 |                                          ||
|/ 4|  |   |                                          ||
+---+  |   |                                          ||
|0 /|  |   |                                          ||
| / |  | 2 |                                          ||
|/ 8|  |   |                                          ||
+---+  |   |                                          ||
|1 /|  |   |                                          ||
| / |  | 3 |                                          ||
|/ 2|  |   |                                          ||
+---+  |   |                                          ||
|1 /|  |   |                                          ||
| / |  | 4 |                                          ||
|/ 6|  |   |                                          ||
+---+  |   |                                          ||
|2 /|  |   |                                          ||
| / |  | 5 |                                          ||
|/ 0|  |   |                                          ||
+---+  |   |                                          ||
|2 /|  |   |                                          ||
| / |  | 6 |                                          ||
|/ 4|  |   |                                          ||
+---+  |   |                                          ||
|2 /|  |   |                                          ||
| / |  | 7 |                                          ||
|/ 8|  |   |                                          ||
+---+  |   |                                          ||
|3 /|  |   |                                          ||
| / |  | 8 |                                          ||
|/ 2|  |   |                                          ||
+---+  |   |                                          ||
|3 /|  |   |                                          ||
| / |  | 9 |                                          ||
|/ 6|  |   |                                          ||
+---+  |   |                                          ||
       |   +------------------------------------------+|
       +-----------------------------------------------+

Challenge
This challenge is to write a function or program which receives a natural number as input, and outputs the arrangement of the rods, as if a calculation were in progress, on the board as an ASCII art, according to the input, having the code as short as possible. The top row of the rods will assemble that number you have inputted.
Requirements

The input can be an argument of the function or program, or an input from STDIN. Please indicate your choice of input format. Accepted formats are as follows:

An integer representing the number;
A string representing the number; or
A list of characters representing the digits of the number.

The output can be directly printed to STDOUT, or returned from the function as a string. Please refer to the Sample section.
You can assume that the input will always be a valid representation of the number, i.e. the number matches the regex [1-9][0-9]*.
You must support all valid inputs in the range [1, 2147483648). Larger ranges are absolutely welcomed.
You must leave no space around the rods.
Standard loopholes apply.

Sample Input/Output
Input: 1234567890
Output:
+-------------------------------------------------------+
|   +--------------------------------------------------+|
|   |+---++---++---++---++---++---++---++---++---++---+||
|   || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 0 |||
|   |+---++---++---++---++---++---++---++---++---++---+||
|   ||0 /||0 /||0 /||0 /||0 /||0 /||0 /||0 /||0 /||0 /|||
| 1 || / || / || / || / || / || / || / || / || / || / |||
|   ||/ 1||/ 2||/ 3||/ 4||/ 5||/ 6||/ 7||/ 8||/ 9||/ 0|||
|   |+---++---++---++---++---++---++---++---++---++---+||
|   ||0 /||0 /||0 /||0 /||1 /||1 /||1 /||1 /||1 /||0 /|||
| 2 || / || / || / || / || / || / || / || / || / || / |||
|   ||/ 2||/ 4||/ 6||/ 8||/ 0||/ 2||/ 4||/ 6||/ 8||/ 0|||
|   |+---++---++---++---++---++---++---++---++---++---+||
|   ||0 /||0 /||0 /||1 /||1 /||1 /||2 /||2 /||2 /||0 /|||
| 3 || / || / || / || / || / || / || / || / || / || / |||
|   ||/ 3||/ 6||/ 9||/ 2||/ 5||/ 8||/ 1||/ 4||/ 7||/ 0|||
|   |+---++---++---++---++---++---++---++---++---++---+||
|   ||0 /||0 /||1 /||1 /||2 /||2 /||2 /||3 /||3 /||0 /|||
| 4 || / || / || / || / || / || / || / || / || / || / |||
|   ||/ 4||/ 8||/ 2||/ 6||/ 0||/ 4||/ 8||/ 2||/ 6||/ 0|||
|   |+---++---++---++---++---++---++---++---++---++---+||
|   ||0 /||1 /||1 /||2 /||2 /||3 /||3 /||4 /||4 /||0 /|||
| 5 || / || / || / || / || / || / || / || / || / || / |||
|   ||/ 5||/ 0||/ 5||/ 0||/ 5||/ 0||/ 5||/ 0||/ 5||/ 0|||
|   |+---++---++---++---++---++---++---++---++---++---+||
|   ||0 /||1 /||1 /||2 /||3 /||3 /||4 /||4 /||5 /||0 /|||
| 6 || / || / || / || / || / || / || / || / || / || / |||
|   ||/ 6||/ 2||/ 8||/ 4||/ 0||/ 6||/ 2||/ 8||/ 4||/ 0|||
|   |+---++---++---++---++---++---++---++---++---++---+||
|   ||0 /||1 /||2 /||2 /||3 /||4 /||4 /||5 /||6 /||0 /|||
| 7 || / || / || / || / || / || / || / || / || / || / |||
|   ||/ 7||/ 4||/ 1||/ 8||/ 5||/ 2||/ 9||/ 6||/ 3||/ 0|||
|   |+---++---++---++---++---++---++---++---++---++---+||
|   ||0 /||1 /||2 /||3 /||4 /||4 /||5 /||6 /||7 /||0 /|||
| 8 || / || / || / || / || / || / || / || / || / || / |||
|   ||/ 8||/ 6||/ 4||/ 2||/ 0||/ 8||/ 6||/ 4||/ 2||/ 0|||
|   |+---++---++---++---++---++---++---++---++---++---+||
|   ||0 /||1 /||2 /||3 /||4 /||5 /||6 /||7 /||8 /||0 /|||
| 9 || / || / || / || / || / || / || / || / || / || / |||
|   ||/ 9||/ 8||/ 7||/ 6||/ 5||/ 4||/ 3||/ 2||/ 1||/ 0|||
|   |+---++---++---++---++---++---++---++---++---++---+||
|   +--------------------------------------------------+|
+-------------------------------------------------------+

Victory Condition
This is a code-golf, so the shortest code wins.

Can you link to the original Sandbox post?

@Neil https://codegolf.meta.stackexchange.com/a/14555/71546 (Now deleted sandbox post)

Ah yes, I seem to have outgolfed myself quite handily, thanks!

Python 2, 424 314 304 305 303 298 bytes
n=map(int,input());l=len(n)
a,b='+'+'-'*5*-~l+'+','|   +'+'-'*5*l+'+|'
x='+---+'*l
y='|   |%s||\n'
j=''.join
print'\n'.join([a,b,j([(y+'| %s |%s||\n'+y+y)%(j('|%d /|'%(c*i/10)for c in n),i,'| / |'*l,j('|/ %d|'%(c*i%10)for c in n),x),3*y%(x,j('| %s |'%c for c in n),x)][i<1]for i in range(10))+b,a])

Try it online!
-2 bytes, thanks to Kevin Cruijssen

That was quick, and with just 1 additional byte. +1 from me! Oh, and one small thing to golf: (3*y)% can be 3*y%.

@KevinCruijssen Thanks :)

Java 11, 352 344 340 309 bytes
a->{int l=a.length,i=0;String Z="+"+"-".repeat(l*5),A=Z+"-----+\n",Y="|   ",B=Y+Z+"+|\n",X="||\n",D=Y+="|",C=Y+"+---+".repeat(l)+X,r=A+B+C,t,u,v;for(int d:a)D+="| "+d+" |";for(r+=D+X;i++<9;r+=C+t+X+u+X+v+X){t=v=Y;u="| "+i+" |";for(int d:a){d*=i;t+="|"+d/10+" /|";u+="| / |";v+="|/ "+d%10+"|";}}return r+B+A;}

-4 bytes thanks to @ShieruAsakoto
-32 bytes thanks to @ceilingcat.
Try it online.
Explanation:
a->{                 // Method with digit-array as parameter and String return-type
  int l=a.length     //  Amount of digits in the input
      i=0;           //  Index-integer
  String
    Z="+"+"-".repeat(l*5),
                     //  String `Z` for the "+------..." of the four lines
    A=Z+"-----+\n",  //  String `A` for the "+---...---+" of the first and last lines
    Y="|   ",        //  String `Y` for "|   "
    B=Y+Z+"+|\n",    //  String `B` for the second and next to last lines
    X="||\n",        //  String `X` for "||" + newline
    D=Y+="|",        //  String `D` starting with "|   |"
                     //  (and change `Y` to this as well now)
    C=Y+"+---+".repeat(l)+X,
                     //  String `C` for the third and fifth lines
    r=A+B+C,         //  Result-String, starting at the first three lines
    t,u,v;           //  Three temp Strings, uninitialized for now
  for(int d:a)       //  Loop over the input-digits
    D+="| "+d+" |";  //   Append `D` with "| d |" where `d` is the digit
  for(r+=D+X;        //  Append `X` to `D`, and then `D` to the result-String
      i++<9;         //  Loop `i` in the range [1, 9]
      r+=            //    After every iteration, append the result-String with:
         C           //     line `C`
         +t+X        //     and line `t` with a trailing `X`
         +u+X        //     and line `u` with a trailing `X`
         +v+X){      //     and line `v` with a trailing `X`
    t=v=Y;           //   Reset `t` and `v` to `Y`
    u="| "+i+" |";   //   and `u` to "| i |" where `i` is the `i` from the loop
    for(int d:a){    //   Inner loop over the input-digits
      d*=i;          //    Multiply the current digit with `i`
      t+="|"         //    Append `t` with "|"
         +d/10       //     and the first of two digits for the multiplication result
         +" /|";     //     and " /|"
      u+="| / |";    //    Append `u` with "| / |"
      v+="|/ "       //    Append `v` with "|/ "
         +d%10       //    and the second of two digits for the multiplication result
         +"|";}}     //    and "|"
  return r           //  And finally return the result-String,
         +B+A;}      //   appended with lines `B` and `A`

Seems that the parentheses around d/10 and d%10 are not necessary thanks to operation precedence?

@ShieruAsakoto Ah, of course, thanks! If the integer-calculations are at the start of a String no parenthesis are necessary, so I added them because they are in the middle here  (i.e. String s=i+1+" some text"; is possible, but String s="some text"+i+1; or String s="some"+i+1+"text"; should be (i+1) instead). But completely forgot that they are / and % here, instead of the usual + and -, so then operator precedence indeed kicks in, so thanks for -4 bytes. :)

Charcoal, 78 bytes
Ｂ⁺⁷×⁵Ｌθ⁴³↓↘↘Ｐ↓⭆⁹◧Ｉ⊕ι⁴↗↗Ｂ⁺²×⁵Ｌθ⁴¹↘Ｆθ«Ｂ⁵¦³↘→←ι↙ＦＥ⁹×Ｉι⊕κ«ＵＲ⁵↘↘Ｉ÷κχ↘↑Ｉ﹪κχ↑↙³»Ｍ⁵±³⁸

Try it online! Link is to verbose version of code. Explanation:
Ｂ⁺⁷×⁵Ｌθ⁴³↓↘↘

Draw the outer box.
Ｐ↓⭆⁹◧Ｉ⊕ι⁴↗↗

Pad the digits 1-9 and print them vertically.
Ｂ⁺²×⁵Ｌθ⁴¹↘

Draw the inner box.
Ｆθ«

Loop over the bones.
Ｂ⁵¦³↘→←ι↙

Draw the small box at the top of the bone with the current digit.
ＦＥ⁹×Ｉι⊕κ«

Multiply the current digit with the digits 1-9 and loop over the result.
ＵＲ⁵↘↘Ｉ÷κχ↘↑Ｉ﹪κχ↑↙³»

Draw a square and insert the digits of the product and the diagonal line.
Ｍ⁵±³⁸

Move to the start of the next bone.

Nice answer! Didn't realize that Move(:DownRight);Move(:DownRight); / ↘↘ is actually shorter than Move(2, :DownRight); / Ｍ²↘ in this case. Btw, is Move with two num inputs not in the github docs yet? Never seen Move(5, Negate(38)); / Ｍ⁵±³⁸ before..

@KevinCruijssen I've corrected the documentation; it used to have the wrong succinct code and only one verbose alias.

Ah, so it's an alias for Jump when using two num inputs. I see. That makes sense.

JavaScript (ES8), 250 241 bytes
Takes input as an array of digit characters of any size.
s=>[...'0123'.padEnd(40,2456)+210].map((v,y)=>`+----0-+,|   +0+|,71||,72||,73||,| 6 |4||,75||`.split`,`[v].replace(/\d/g,n=>[Y=y>>2,'|   |'][n-6]||s.map(X=>`-----+---+| ${X} ||${X*Y/10|0} /|| / ||/ ${X*Y%10}|`.substr(n*5,5)).join``)).join`
`

Try it online!
How?
The board consists of 43 rows of 7 distinct types, which are represented below with an ID in \$[0..6]\$:
00: +---------------+ --> 0 >--- outer board header
01: |   +----------+| --> 1 >--- inner board header
02: |   |+---++---+|| --> 2 \___ rod header
03: |   || X || X ||| --> 3 /
04: |   |+---++---+|| --> 2 \
05: |   ||X /||X /||| --> 4  \__ first row
06: | X || / || / ||| --> 5  /
07: |   ||/ X||/ X||| --> 6 /
..  .               .
..  .               .
36: |   |+---++---+|| --> 2 \
37: |   ||X /||X /||| --> 4  \__ last row
38: | X || / || / ||| --> 5  /
39: |   ||/ X||/ X||| --> 6 /
40: |   |+---++---+|| --> 2 >--- rod footer
41: |   +----------+| --> 1 >--- inner board footer
42: +---------------+ --> 0 >--- outer board footer

The code '0123'.padEnd(40,2456)+210 (see this tip) generates the following string of 43 row IDs over which we are going to iterate:
"0123245624562456245624562456245624562456210"

Each ID is replaced with a temporary encoded string which, in turn, contains other IDs in \$[0..7]\$:
 ID | String
----+------------
  0 | "+----0-+"
  1 | "|   +0+|"
  2 | "71||"
  3 | "72||"
  4 | "73||"
  5 | "| 6 |4||"
  6 | "75||"

Finally, each new ID is replaced with a 5-character string which is appended as many times as there are digits in the input array, except the last two ones which are just inserted as-is:
 ID | String            | Repeated
----+-------------------+----------
  0 | `-----`           |   Yes          where:
  1 | `+---+`           |   Yes            X = horizontal digit
  2 | `| ${X} |`        |   Yes            Y = vertical digit
  3 | `|${X*Y/10|0} /|` |   Yes
  4 | `| / |`           |   Yes
  5 | `|/ ${X*Y%10}|`   |   Yes
  6 | Y                 |   No
  7 | `|   |`           |   No

source: Stack Exchange

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

sort: votes


text:
No trailing but(t)s please!
This challenge was inspired by Yeah But No But Yeah.

maxb´s colleague recently sent him the following piece of JavaScript as a joke:
let butScript = (nrOfButs) => {
    for(var i = 0; i < nrOfButs; i++){
        if(i % 3 == 0){
            console.log("Yeah")
        }
        if(i % 2 == 0){
            console.log("But")
        }
        if(i % 3 == 1){
            console.log("No")
        }
    }
}

Since the code is not only overly long but also incorrect, I´ll suggest to maxb´s boss to fire that guy and hire one of you folks instead.
I can´t guarantee anything; but I reckon there´ll be a decent wage, health insurance and possibly a company car in it. All You have to do is
A) correct the code, so the Number of Buts printed is the same as asked in the parameter
B) correct the grammar. (see below)
C) make it as short as possible.
He might as well block my calls after that because he doesn´t like pennypickers; but who knows.
Input
a non-negative integer, in any convenient way
Output
Yeah and No, mostly separated by Buts. The code above and the examples below should clarify the pattern.
Output should never end in a But.
And a sentence should always end with a stop (.) or exclamation mark; i.e. put one after every No that is directly followed by a Yeah (without a But) and one at the end of the output.
A single trailing "Yeah." may be printed (if you want to think positive), but that´s not a must.
You may print the output or return a list of strings.
Trailing blanks are acceptable, as well as a single leading or trailing newline.
examples (input => possible output)
input 0:

Yeah.

input 1:

Yeah
But
No.

input 2:

Yeah
But
No
But
Yeah.

input 3:

Yeah
But
No
But
Yeah
But
No.
Yeah!       <optional>

...

input 5:

Yeah
But
No
But
Yeah
But
No.
Yeah
But
No
But
Yeah.

These programs should be able to be a bit shorter, though the period could add 2-3 bytes depending on the language. I'll have to create my own solution in MathGolf, but I don't think I'll be able to beat Jelly and 05AB1E for this one.

So if I understand correctly: 1. A dot should be added between every No Yeah or Yeah No. 2. A dot should be added at the very end. 3. A single line only containing Yeah or No should be removed. 4. When a sentence ends with a But the But should be removed? (not sure about this fourth one)

@KevinCruijssen I think you're overcomplicating it. You just have to output $2n+1$ lines of "Yeah\nBut\nNo\nBut\nYeah\nBut\nNo\nBut..." and end with a period.

@maxb Then what is that dot between No and Yeah doing there in test case n=5? And the trailing Yeah. is gone for n=3.

@KevinCruijssen my bad, I completely missed the $n=5$ thing. I'm a bit confused about it too. It would make the challenge more interesting though, in my opinion.

Hmm, shouldn't the output for n=0 be empty?.. It won't go into the for(var i = 0; i < nrOfButs; ... loop, so won't print anything there. And there is also the rule "A single trailing "Yeah." should be avoided." to consider. There are a bit too many unanswered questions, so I've voted to close as unclear for now.. Might change after some clarification and better (bullet-point) specified rules or step-by-step examples of the given test cases.

@KevinCruijssen I´ll have to think that through once more. Wasn´t sure if I should allow the additional Yeah.; and I mentioned that in the sandbox; but nobody seemed to care. A single Yeah. somehow makes sense; yet a trailing one ... on the other hand: think positive. ... give me a minute.

talking about grammar ... Does english allow capital words in the middle of a sentence?

@Titus Usually not, unless it's a name, city, etc. Only German capitalizes all nouns if I recall correctly. :)

I believe that the correct grammar for the English pro-sentences you specify would be "Yeah, but no.", and "Yeah, but no, but yeah." (or maybe "Yeah, but no ...but yeah."), plus the optional "Yeah."

^ Oh, I just noticed that "Yeah." is not always optional.

Wonder if I should add that additional grammar. But I guess that would mean quite a lot additional work for the three four existing answers. Is there any agreement on that in meta?

Typo: output for 3 ends with "Yeah!" shouldn't it be "Yeah." ?

@JayCe Apparently either is fine: "And a sentence should always end with a stop (.) or exclamation mark"

@KevinCruijssen my bad thanks for clarifying. So a mix of both is allowed I guess.

Very loosely related:https://codegolf.stackexchange.com/q/171168/55735 :D

@maxb: The example for 5 contradicts your instruction to "output 2n+1 lines of "Yeah\nBut\nNo\nBut\nYeah\nBut\nNo\nBut..." and end with a period".  It has a "Yeah" followed by a "No".  The samples also don't match the provided reference implementation.  I'm left still not understanding the task.

@recursive The "reference implementation" is for the original challenge, which has no punctuation at all. Should my description be unclear, let me know and I´ll try to clarify. If in doubt, follow the examples: The longest sentence is Yeah But No But Yeah But No.; shorter sentences only at the end of the output.

@recursive I left another comment stating that I'd misunderstood the challenge. From my understanding, the order of the words should be the same as for my original challenge. However, the input dictates how many times "but" is present in the output. The output never ends in "but", and there needs to be a period between "yeah" and "no" if there's no "but" in-between

JavaScript (Node.js), 80 bytes
a=>{s='';for(i=0;i<a+1;i++)s+=(i%2==0?'yeah':'no')+(i<a?'\nbut\n':'.');return s}

Try it online!

please give explanation why you downvote my answer so i can improve in another chance

Hi, welcome to PPCG! I'm not the one who downvoted, but I completely agree with your comment above that people should leave an explanation of why they downvote!.. Anyway, I think one reason is because the i%2==0 check isn't really correct in comparison to the code in the challenge description. I admit that the challenge description is a bit vague tbh (as I mentioned in the comments below it). I can only guess here, but the downvote is most likely due to a different than expected output. (PS: And the yeah, no, but should be Titlecase instead of lowercase, but that's an easy fix. ;) ).

Some more general tips not related to this challenge: You might want to add a Try-it-online link with test code for your answers. In this case this could be a possible TIO-link. In addition, Tips for golfing in JavaScript and Tips for golfing in  might be interesting to read through; I see a few parts you can golf in your current answer. :) Don't let this downvote discourage you, and enjoy your stay!

RE: the downvote: The post automatically went onto the low quality post queue due to it's length and content (a post from a new user with only a code-block will trigger this). Then when it is edited to actually fix that a downvote is automatically applied - the community here views this "feature" as a bug (it's not a very friendly welcome!). Please ignore it; check the format of the edited post too (I've also added a language tag for the code-block to add syntax highlighting).

thank you for your reply guys, i learn from my mistake

@Vico Welcome to the page. I added a TIO link for your answer. Please notice that test case 5 is wrong. You must fix it or your answer will be not valid for this challenge.

Btw, 73 bytes here

@LuisfelipeDejesusMunoz 72 bytes :)

Downvotes have nothing to do with being welcoming, again... it's just that somebody (the Community bot) thinks the post is low-quality, that's all.

Incorrect for N>3. There should be a new sentence after every "Yeah But No But Yeah But No."

Python 2, 105 81 bytes
f=lambda n,s=1:(n|s)*' 'and'\nBut\n'.join((['Yeah','No']*2)[:n+1])+'.\n'+f(n-3,0)

Try it online!
- 24 bytes, thanks to ovs

Retina, 48 47 bytes
.+
*
L$`__?_?|^
Yeah$&.
__
_¶But¶Yeah
_
¶But¶No

Try it online! Explanation:
.+
*

Convert to unary.
L$`__?_?|^
Yeah$&.

Match up to three _s at a time. Also handle the zero edge case as a match. Each match results in at least a Yeah with a trailing ..
__
_¶But¶Yeah

A match of 2 or 3 _s results in a But Yeah in the second position.
_
¶But¶No

The other _s turn into But No.
52 bytes in Retina 0.8.2:
.+
$*
M!`11?1?
%`^.*
Yeah$&.
11
1¶But¶Yeah
1
¶But¶No

Try it online! Explanation:
.+
$*

Convert to unary.
M!`11?1?

Match up to three 1s at a time.
%`^.*
Yeah$&.

Add a leading Yeah and trailing . for each match. The ^.* allows it to work for the zero case too.
11
1¶But¶Yeah
1
¶But¶No

Add in the But Yeah and/or No as above.

05AB1E,  44  42 34 31 bytes
Crossed out  44  is no longer regular 44 :)
[Ðd_#3‚ßÝ„¥æ€¸#sè'€³¶.øý'.«™,3-

Also prints the optional Yeah..
Try it online or verify all test cases.
Explanation:
[               # Loop indefinitely:
 Ð              #  Triplicate the top value
                #  (which is the implicit input `n` in the first iteration)
  d_            #  Pop one copy, and if it's negative:
    #           #   Stop the infinite loop
  3‚ß           #  Take the max `m` of another copy of `n` and 3
     Ý„¥æ€¸#sè  #  Create an alternating list of "yeah" and "no" of size `m`
  '€³¶.ø       '#  Push "\nbut\n"
        ý       #  Join the alternating list with this as delimiter
  '.«          '#  Append a trailing "."
     ™          #  Titlecase each word in this string
      ,         #  Pop and print it with trailing newline
  3-            #  Decrease `n` by 3 for the next iteration

See this 05AB1E tips of mine (section How to use the dictionary?) to understand why „¥æ€¸ is "yeah no" and '€³ is "but".

Your indents seem kinda broken :) Though maybe it's just me

@seadoggie01 Hmm, do you have a screenshot perhaps? For me it looks like this. Although I do see messed up indentations with APL answers a lot, so I can imagine it happens with 05AB1E as well when using a font with different widths.

https://imgur.com/a/x5vSNql I think that's not how it's supposed to look?

Oh... I just read your comment all the way through and saw the link, sorry. ("ADHD much?" "Yeah")

@seadoggie01 The indentation is intended this time. It's too long to put all after one-another, and this seems kinda logical to me. The highlighting color is due to the ' (single quote) unfortunately. I could remove the highlighting completely if that's better, but then everything including the comments is just black. I wish there was a hightlighting specific for 05AB1E, but unfortunately I have to use the Python one, which doesn't work very well when I use single quotes, as you can see. ;)

JavaScript (Node.js), 82 bytes
_=>_>3?f(3)+f(_-3):[...Array(_+1)].map((a,i)=>i%2?'No':'Yeah').join`\nBut\n`+'.\n'

Try it online!

@Titus there is a new sentence. Check it out again and compare to the given test case

Maybe I got the TiOs mixed up. Approved.

C (clang), 80 74 bytes
f(a,i){for(i=0;-i>~a;)printf("%s%s\n","YeahNo"+i%2*5,i++<a?"\nBut":".");}

-6 bytes thanks to @Jonathan Frech
Try it online!

74 bytes.

Not working for n=5 case.

Incorrect for N>3. There should be a new sentence after every "Yeah But No But Yeah But No."

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


text:
Quadratic residues are so much fun!
Definitions
Quadratic residues
An integer \$r\$ is called a quadratic residue modulo \$n\$ if there exists an integer \$x\$ such that:
$$x^2\equiv r \pmod n$$
The set of quadratic residues modulo \$n\$ can be simply computed by looking at the results of \$x^2 \bmod n\$ for \$0 \le x \le \lfloor n/2\rfloor\$.
The challenge sequence
We define \$a_n\$ as the minimum number of occurrences of the same value \$(r_0-r_1+n) \bmod n\$ for all pairs \$(r_0,r_1)\$ of quadratic residues modulo \$n\$.
The first 30 terms are:
$$1, 2, 1, 1, 1, 2, 2, 1, 1, 2, 3, 1, 3, 4, 1, 1, 4, 2, 5, 1, 2, 6, 6, 1, 2, 6, 2, 2, 7, 2$$
This is A316975 (submitted by myself).
Example: \$n=10\$
The quadratic residues modulo \$10\$ are \$0\$, \$1\$, \$4\$, \$5\$, \$6\$ and \$9\$.
For each pair \$(r_0,r_1)\$ of these quadratic residues, we compute \$(r_0-r_1+10) \bmod 10\$, which leads to the following table (where \$r_0\$ is on the left and \$r_1\$ is on the top):
$$\begin{array}{c|cccccc}
& 0 & 1 & 4 & 5 & 6 & 9\\
\hline
0 & 0 & 9 & 6 & 5 & 4 & 1\\
1 & 1 & 0 & \color{blue}7 & 6 & 5 & \color{green}2\\
4 & 4 & \color{magenta}3 & 0 & 9 & \color{red}8 & 5\\
5 & 5 & 4 & 1 & 0 & 9 & 6\\
6 & 6 & 5 & \color{green}2 & 1 & 0 & \color{blue}7\\
9 & 9 & \color{red}8 & 5 & 4 & \color{magenta}3 & 0
\end{array}$$
The minimum number of occurrences of the same value in the above table is \$2\$ (for \$\color{green}2\$, \$\color{magenta}3\$, \$\color{blue}7\$ and \$\color{red}8\$). Therefore \$a_{10}=2\$.
Your task

You may either:

take an integer \$n\$ and print or return \$a_n\$ (either 0-indexed or 1-indexed)
take an integer \$n\$ and print or return the \$n\$ first terms of the sequence
take no input and print the sequence forever

Your code must be able to process any of the 50 first values of the
sequence in less than 1 minute.

Given enough time and memory, your code must theoretically work for any positive integer supported by your language.

This is code-golf.

Grats on getting a sequence published on OEIS!

@AdmBorkBork Thanks. :) (As a matter of fact, I usually avoid posting an OEIS sequence as-is as a challenge, but I guess that's OK for this one.)

Doesn't the +n inside the (...)mod n have no effect? If so it's very weird that is part of the definition.

@JonathanAllan Actually, I made a similar remark in the draft version of the sequence and suggested that it was removed. But I didn't find any clear consensus, nor did I get any feedback about that. (And I seem to recall having seen other sequences with (some_potentially_negative_value + n) mod n.) I think it's better to have it in a programming challenge, though, since the sign of the result depends on the language.

@Arnauld Could you not choose some_potentially_negative_value < -n?

@JonathanFrech This can't happen here, since both $r_0$ and $r_1$ are in $[0..n-1]$. But generally speaking, yes: this formula holds only for $x\ge -n$.

@Arnauld I think $r_1$ is only defined modulo $n$.

I've tried to find a direct formula without success. The sequence is multiplicative and on primes it equals a_p = round(p/4), which gives us the values for all squarefree numbers. But the situation seems complicated on powers of primes, and the 3 mod 4 and 1 mod 4 cases need to be handled separately.

$(r_0-r_1+n)\mod n=(r_0-r_1)\mod n$, no?

Looking forward to your JS solution to this; just tried it myself after a long night's work and gave myself brainache! Probably doesn't help that I still don't fully the challenge.

@EriktheOutgolfer, not in all languages - e.g., JavaScript

@Shaggy Yeah, some languages don't follow the definition exactly.

MATL, 14 bytes
:UG\u&-G\8#uX<

Try it online! Or verify the first 30 values.
Explanation
:      % Implicit input. Range
U      % Square, element-wise
G      % Push input again
\      % Modulo, element-wise
u      % Unique elements
&-     % Table of pair-wise differences
G      % Push input
\      % Modulo, element-wise
8#u    % Number of occurrences of each element
X<     % Minimum. Implicit display

Japt -g, 22 20 bytes
Spent too long figuring out what the challenge was actually about, ran out of time for further golfing :\
Outputs the nth term in the sequence. Starts struggling when input >900.
õ_²uUÃâ ïÍmuU
£è¥XÃn

Try it or check results for 0-50

Explanation
                  :Implicit input of integer U
õ                 :Range [1,U]
 _                :Map
  ²               :  Square
   uU             :  Modulo U
     Ã            :End map
      â           :Deduplicate
        ï         :Cartesian product of the resulting array with itself
         Í        :Reduce each pair by subtraction
          m       :Map
           uU     :  Absolute value of modulo U
\n                :Reassign to U
£                 :Map each X
 è                :  Count the elements in U that are
  ¥X              :   Equal to X
    Ã             :End map
     n            :Sort
                  :Implicitly output the first element in the array

Jelly,  13  10 bytes
-1 thanks to Dennis (forcing dyadic interpretation with a leading ð)
-2 more also thanks to Dennis (since the pairs may be de-duplicated we can avoid an R and a 2)
ðp²%QI%ĠẈṂ

A monadic link accepting a positive integer which yields a non-negative integer.
Try it online! Or see the first 50 terms.
How?
ðp²%QI%ĠẈṂ - Link: integer, n                   e.g. 6
ð          - start a new dyadic chain - i.e. f(Left=n, Right=n)
 p         - Cartesian product of (implicit ranges)  [[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[4,1],[4,2],[4,3],[4,4],[4,5],[4,6],[5,1],[5,2],[5,3],[5,4],[5,5],[5,6],[6,1],[6,2],[6,3],[6,4],[6,5],[6,6]]
  ²        - square (vectorises)                     [[1,1],[1,4],[1,9],[1,16],[1,25],[1,36],[4,1],[4,4],[4,9],[4,16],[4,25],[4,36],[9,1],[9,4],[9,9],[9,16],[9,25],[9,36],[16,1],[16,4],[16,9],[16,16],[16,25],[16,36],[25,1],[25,4],[25,9],[25,16],[25,25],[25,36],[36,1],[36,4],[36,9],[36,16],[36,25],[36,36]]
   %       - modulo (by Right) (vectorises)          [[1,1],[1,4],[1,3],[1,4],[1,1],[1,0],[4,1],[4,4],[4,3],[4,4],[4,1],[4,0],[3,1],[3,4],[3,3],[3,4],[3,1],[3,0],[4,1],[4,4],[4,3],[4,4],[4,1],[4,0],[1,1],[1,4],[1,3],[1,4],[1,1],[1,0],[0,1],[0,4],[0,3],[0,4],[0,1],[0,0]]
    Q      - de-duplicate                            [[1,1],[1,4],[1,3],[1,0],[4,1],[4,4],[4,3],[4,0],[3,1],[3,4],[3,3],[3,0],[0,1],[0,4],[0,3],[0,0]]
     I     - incremental differences (vectorises)    [0,3,2,-1,-3,0,-1,-4,-2,1,0,-3,1,4,3,0]
      %    - modulo (by Right) (vectorises)          [0,3,2,5,3,0,5,2,4,1,0,3,1,4,3,0]
       Ġ   - group indices by value                  [[1,6,11,16],[10,13],[3,8],[2,5,12,15],[9,14],[4,7]]
        Ẉ  - length of each                          [3,2,2,4,2,2]
         Ṃ - minimum                                 2

05AB1E, 22 20 15 13 bytes
LnI%êãÆI%D.m¢

-2 bytes thanks to @Mr. Xcoder.
Try it online or verify the first 99 test cases (in about 3 seconds). (NOTE: The Python legacy version is used on TIO instead of the new Elixir rewrite. It's about 10x faster, but requires a trailing ¬ (head) because .m returns a list instead of a single item, which I've added to the footer.)
Explanation:
L       # Create a list in the range [1, (implicit) input]
 n      # Square each
  I%    # And then modulo each with the input
    ê   # Sort and uniquify the result (faster than just uniquify apparently)
 ã      # Create pairs (cartesian product with itself)
  Æ     # Get the differences between each pair
   I%   # And then modulo each with the input
D.m     # Take the least frequent number (numbers in the legacy version)
   ¢    # Take the count it (or all the numbers in the legacy version, which are all the same)
        # (and output it implicitly)

Ýns%ÙãÆI%D.m¢. (not in legacy, in the new version)

@Mr.Xcoder Ah, I'm an idiot to use Dâ instead of ã.. >.> And didn't knew the .m acted differently in the Elixir rewrite. I originally had the new version, but switched to the legacy after I noticed the ¥ wasn't working (which you've fixed with the Æ). I still use the legacy on TIO though, because it's way faster for this challenge.

C (gcc), 202 200 190 188 187 186 bytes

Saved two twelve fourteen fifteen bytes thanks to ceilingcat.
Saved a byte.

Q(u,a){int*d,*r,A[u],t,i[a=u],*c=i,k;for(;a--;k||(*c++=a*a%u))for(k=a[A]=0,r=i;r<c;)k+=a*a%u==*r++;for(r=c;i-r--;)for(d=i;d<c;++A[(u+*r-*d++)%u]);for(t=*A;++a<u;t=k&&k<t?k:t)k=A[a];u=t;}

Try it online!

@ceilingcat Cool; declaring another integer actually allows to save another byte.

@ceilingcat I think those expressions are not equivalent as I need the smallest positive modulo residue.

Python 2, 97 bytes
def f(n):r={i*i%n for i in range(n)};r=[(s-t)%n for s in r for t in r];return min(map(r.count,r))

Try it online!

K (ngn/k), 29 bytes
{&/#:'=,/x!r-\:r:?x!i*i:!x}

Try it online!
{ } function with argument x
!x integers from 0 to x-1
i: assign to i
x! mod x
? unique
r: assign to r
-\: subtract from each left
r-\:r matrix of all differences
x! mod x
,/ concatenate the rows of the matrix
= group, returns a dictionary from unique values to lists of occurrence indices
#:' length of each value in the dictionary
&/ minimum

Wolfram Language (Mathematica), 64 bytes
Min[Last/@Tally@Mod[Tuples[Union@Mod[Range@#^2,#],2].{1,-1},#]]&

Try it online!

Ruby, 88 bytes
->n{(z=(w=(0..n).map{|x|x*x%n}|[]).product(w).map{|a,b|(a-b)%n}).map{|c|z.count(c)}.min}

Try it online!

APL (Dyalog Unicode), 28 24 bytes
{⌊/⊢∘≢⌸∊⍵|∘.-⍨∪⍵|×⍨⍳⍵+1}

Try it online!
Prefix direct function. Uses ⎕IO←0.
Thanks to Cows quack for 4 bytes!
How:
{⌊/⊢∘≢⌸∊⍵|∘.-⍨∪⍵|×⍨⍳⍵+1} ⍝ Dfn, argument ⍵

                   ⍳⍵+1 ⍝ Range [0..⍵]
                 ×⍨     ⍝ Squared
               ⍵|       ⍝ Modulo ⍵
              ∪         ⍝ Unique
          ∘.-⍨          ⍝ Pairwise subtraction table
       ∊⍵|              ⍝ Modulo ⍵, flattened
      ⌸                 ⍝ Key; groups indices (in its ⍵) of values (in its ⍺).
   ⊢∘≢                  ⍝ Tally (≢) the indices. This returns the number of occurrences of each element.
 ⌊/                      ⍝ Floor reduction; returns the smallest number.

Couple of small byte-shavings, 2*⍨ → ×⍨, r←¨⊂r → ∘.-⍨, {≢⍵} → ⊢∘≢


text:
I won't not use no double negatives
The goal is to simplify sentences containing multiple negatives.
Like with multiplying negative numbers, two negative words annihilate each other until at most one is left (doesn't matter which one). While some words disappear without a trace, other leave behind a positive part
The affected words are:
no
not
couldn't    could
wouldn't    would
shouldn't   should
don't       do
doesn't     does
didn't      did
isn't       is
aren't      are
weren't     were

You will notice that I conveniently forgot to include some rules like shan't/shall, won't/will, nothing/something, impossible/possible.
Hunting down all the exceptions is a nightmare and would make it yet another string compression challenge.
But if including some additional rules that are not listed, yet are in the spirit of the challenge would make your code shorter (looking at you, Mathematica built-ins), by all means, go for it.
Examples
Input
Move along
Nothing to see here
This sentence will stay the same
You dont put Nosferatu's donut knot in the cantaloupe cannon without an apostrophe.

Don't change this sentence.
This one will also not change
So far no inputs were changed

We don't need no education!
No, don't say that!
Wouldn't it be nice if people weren't fighting?

I don't not use no double negatives.
This isn't not the usual way to not express yourself not
We don't not have no time to not don't solve this
I don't not even know if this isn't not making no sense anymore, it wouldn't be so bad if it weren't for not all these not words which not shouldn't be not there in the first place

Output (either of the elements is valid)
["Move along"]
["Nothing to see here"]
["This sentence will stay the same"]
["You dont put Nosferatu's donut knot in the cantaloupe cannon without an apostrophe."]

["Don't change this sentence."]
["This one will also not change"]
["So far no inputs were changed"]

["We do need education!"]
[", do say that!", "do say that!", "Do say that!"]
["Would it be nice if people were fighting?"]

["I don't use double negatives.", "I do not use double negatives.", "I do use no double negatives."]
["This is the usual way to express yourself"]
["We don't have time to do solve this", "We do not have time to do solve this", "We do have no time to do solve this", "We do have time to not do solve this", "We do have time to don't solve this"]
["I do even know if this is making sense anymore, it would be so bad if it were for all these words which should be there in the first place"]

related: https://codegolf.stackexchange.com/questions/165753/use-that-goodnt-meme
https://codegolf.stackexchange.com/questions/148739/aint-no-thang-or-is-it

Shouldn't it be would instead of will in your example?

@RushabhMehta sorry i dont see which will you mean, would you suggest an edt, then i can reject or approve it

I'm confused as to when to remove the whole word (as in your We don't need no education example) or when to replace the word with its complement (as in your Wouldn't it be nice example).

Are we really supposed (or at least allowed) to replace won't with wo as one of the examples suggest? If the rule is just remove n't, then this is inconsistent with can't: according to the table, it must be replaced with can rather than ca.

I'm temporarily voting to close as unclear. Please ping me when it's clarified so that I can retract my vote or vote to reopen.

I removed can't and won't from the requirements and tests and allow undefined behaviour in those cases instead of overcomplicating it

In We don't need no education, would We need no education/We do need no education also be valid?

Retina 0.8.2, 44 bytes
i`(\bnot?\W+|n't\b)(.*?)(\bnot?\W+|n't\b)
$2

Try it online! Link includes test cases.

It is apparently allowed to replace won't with wo (!), but the table suggests that can't should be replaced with can rather than ca. (I think this needs to be clarified in the challenge, anyway.)

@Arnauld Like this?

Yes, but let's see how this is clarified by the OP.


text:
Russian BS - Submissions accepted until October 13th
The ChatRoom is here
I love playing the card game BS, but sometimes, it just doesn't have enough oomph for my short attention span. Instead, let's play some Russian BS.
Rules
Here is a quick guide to the rules.

The game begins with a random player declaring the card type of the round (out of 14 options: A,2,3...10,J,Q,K,j where the j stands for joker)
The same player starts the round, placing down as many cards as he or she wants, which all have to be of the declared card type.
Any player can call BS on the play. If multiple players call BS, the player closest to the player who put down the cards to the right will be the one to call BS
If BS is called on the play, then the cards played there are checked by the moderator. If the cards were indeed valid (i.e., all of the declared type or jokers), the player who called BS will take all of the cards played in the round. Otherwise, the player who played the invalid cards will take all of them.
If no BS is called, the next player is up to play, and must also play the declared card type.
We also allow players to pass their turn if they don't wish to play. However, if they pass, they are not allowed to play for the rest of the round (although they can call BS)
If every player passes, then the round ends, and the player who played the last cards will start the next round by declaring the card type.
If BS is called, the player who played the cards will start the next round and declare if he played valid cards, else the player who called BS will start.
The player who has no cards at the end of the game wins.

I like these rules because they don't force you to lie, but usually, players tend to lie more than in the original version of BS
Challenge
This challenge will be a king-of-the-hill challenge, with submissions providing bots to play the game. The bots will be written in Python 3, although I'll try my best to accommodate all submissions.
The submissions should consist of the following three functions:
CallBS - determines whether you seek to call BS or not on a play
PlayCards - determines what cards you want to play
StartRound - determines what the declared type of the round is, if you are chosen to pick it.

The submitted functions should be named such that their names are ***_CallBS, ***_PlayCards, and ***_StartRound, where *** is the name of your bot.
Below are example functions that describe the inputs and outputs:
def example_CallBS(self,pos,player,handSize,currCard,numCards,numPile):
    '''This function will output True if the bot seeks to call BS on the
       current move, or False if not. The parameters are
       - self: class variable
       - pos: int - how many positions away you are to the right of the player (Note: if
         your function got called, that means everyone to your left before the player decided
         not to call BS)
       - player: str - holds the name of the bot who just played cards
       - handSize: int - how many cards playing bot holds
       - currCard: str - current card in play (One of A,2,3,4,5,6,7,8,9,10,J,Q,K,j)
       - numCards: int - number of cards just played by player
       - numPile: int - number of cards in the pile (not including played cards this turn)
    '''
    return True
def example_PlayCards(self,currCard,numPile,stillPlaying):
    '''This function will output a sublist of the hand of the bot to play this turn, or None to pass.
       The parameters are
       - self: class variable
       - currCard: str - current card in play (One of A,2,3,4,5,6,7,8,9,10,J,Q,K,j)
       - numPile: int - number of cards in the pile
       - stillPlaying: list of str - players who haven't passed this round
    '''
    return self.hand[:]
def example_StartRound(self):
    '''This function will output a string representing the card that will be played for the coming round (One of A,2,3,4,5,6,7,8,9,10,J,Q,K,j)
       The parameters are
       - self: class variable
    '''
    return 'A'

In addition, you will be provided with the following utilities
self.obj - A blank object for your usage to store knowledge between calls
self.hand: list of card objects - Your current hand in card objects (calling card.val gives you the str value of the card)
self.numBots: int - number of competitors you have
self.getRandom(): function - outputs a random number from 0 to 1.

If you want to use any sort of randomness, you must use the self.getRandom() function provided. You may not edit any of these objects except for self.obj
Parameters and more Rules

The cards in this game (you'll see the class that the cards belong to in the controller below) don't have a suit since suits don't matter to this game.
The number of cards in the game will be 14*number of bots (numBots of each type of card)
In the output of PlayCards, you must output cards that are in your hand. The program will not like you otherwise. You also must output card objects, not strings.
You may take at most 10 ms on average over 5 turns for StartRound, 50 ms averaged over 5 turns for PlayCards, and 20 ms averaged over 5 turns for CallBS.

Controller
In this Controller, you add your functions to the top of the program, then add a tuple of all three functions, in the order of (CallBS, PlayCards, StartRound) to the list BotParams. The Controller should take it from there.
Below is the controller with the example bot from earlier. This bot will not be participating, nor will any bots that obviously aren't aiming the win the competition.
import random as rn
rn.seed(12321)#Subject to change

def example_CallBS(self,pos,player,handSize,currCard,numCards,numPile):
    return True
def example_PlayCards(self,currCard,numPile,stillPlaying):
    return self.hand[:]
def example_StartRound(self):
    return 'A'

#This is how you add your bot to the competition. Add the tuple of all three of your functions to BotParams
BotParams = [(example_CallBS,example_PlayCards,example_StartRound)]

#This is the controller
class Obj:
    pass
class card:
    def __init__(self, val):
        self.val=val
    def __eq__(self,other):
        return (self.val==other or self.val=='j')
    def __str__(self):
        return self.val
class BSgame:
    def __init__(self,BotParams):
        self.numBots = len(BotParams)
        self.AllCards = ['A','J','Q','K','j']+[str(i) for i in range(2,11)]
        x=[card(j) for j in self.AllCards*self.numBots]
        rn.shuffle(x)
        self.hands = [x[14*i:14*i+14] for i in range(self.numBots)]
        rn.shuffle(BotParams)
        self.BotList = [BSBot(self.hands[i],len(BotParams),*BotParams[i]) for i in range(self.numBots)]
        self.play = []
        self.pile = []
        self.isRound = False
        self.isTurn = 0
        self.currCard = None
        self.winner=None
        self.GameSummary = [str(i) for i in self.BotList]
    def results(self):
        print("The winner is "+self.winner)
        print("Final Standings:")
        for i in self.BotList:
            print(i)
    def checkBS(self, caller):
        if min([i==self.currCard for i in self.play]):
            self.BotList[caller].hand.extend(self.pile)
            self.BotList[caller].hand.extend(self.play)
            self.GameSummary.append(self.BotList[caller].name+" called BS but was wrong!")
            if self.BotList[self.isTurn].hand==[]:
                self.winner=self.BotList[self.isTurn].name
                self.GameSummary.append(self.BotList[self.isTurn].name+" has won the game!")
        else:
            self.BotList[self.isTurn].hand.extend(self.pile)
            self.BotList[self.isTurn].hand.extend(self.play)
            self.GameSummary.append(self.BotList[caller].name+" called BS and was right!")
            self.isTurn=caller
        self.isRound=False
        self.pile=[]
    def isBS(self):
        for i in range(1,self.numBots):
            if self.BotList[(i+self.isTurn)%self.numBots].callBS(i,self.BotList[self.isTurn].name,len(self.BotList[self.isTurn].hand),self.currCard,len(self.play),len(self.pile)):
                self.checkBS(i)
                break
        if self.isRound:
            if self.BotList[self.isTurn].hand==[]:
                self.winner=self.BotList[self.isTurn].name
                self.GameSummary.append(self.BotList[self.isTurn].name+" has won the game!")
            self.pile.extend(self.play)
    def startRound(self):
        self.currCard = self.BotList[self.isTurn].startRound()
        for i in self.BotList:
            i.inRound = True
        self.isRound=True
        self.GameSummary.append(self.BotList[self.isTurn].name+" started the round by picking "+self.currCard+" for the round.")
    def __iter__(self):
        return self
    def __next__(self):
        if not self.isRound:
            self.startRound()
        passList = [i.name for i in self.BotList if i.inRound]
        self.play =self.BotList[self.isTurn].playCards(self.currCard,len(self.pile),passList)
        if self.play == None:
            self.BotList[self.isTurn].inRound=False
            self.GameSummary.append(self.BotList[self.isTurn].name+" passed its turn.")
        else:
            try:
                for i in self.play:
                   self.BotList[self.isTurn].hand.remove(i)
            except:
                raise Exception("You can't play a card you don't have, you dimwit")
            self.GameSummary.append(self.BotList[self.isTurn].name+" played "+",".join(i.val for i in self.play)+".")
            self.isBS()
        if self.winner!=None:
            raise StopIteration
        if set(passList)!={False}:
            while True:
                self.isTurn=(self.isTurn+1)%self.numBots
                if self.BotList[self.isTurn].inRound:
                    break
        else:
            self.GameSummary.append("Everyone passed. "+self.BotList[self.isTurn].name+" starts the next round.")
            self.isRound=False
        return(None)
class BSBot:
    def __init__(self,myHand,numBots,CallBS,PlayCards,StartRound):
        self.obj=Obj()
        self.hand = myHand
        self.numBots = numBots
        self.name = CallBS.__name__.split('_')[0]
        self.callBS = lambda pos, player, handSize, currCard, numCards, numPile: CallBS(self,pos,player, handSize, currCard, numCards, numPile)
        self.playCards = lambda currCard, numPile, stillPlaying: PlayCards(self,currCard, numPile, stillPlaying)
        self.startRound= lambda:StartRound(self)
    def __str__(self):
        if self.hand==[]:
            return(self.name+': WINNER!')
        return(self.name+": "+", ".join(str(i) for i in self.hand))
    def getRandom(self):
        return rn.random()
Mod = BSgame(BotParams)
for i in Mod:
    pass
Mod.results()

Additionally, if you want to see a summary of the game, type in the following command at the end of the program:
print("\n".join(Mod.GameSummary))

Is self.numBots including yourself or not?

I thought this was going to be a pre-US midterm election social media analysis challenge.

@Quintec yes and ngm, lmaooo

In the controller, in the isBS function,
"if self.BotList[(i+self.isTurn)%self.numBots].callBS(i,self.BotList[self.isTurn].name,len(self.BotList[isTurn].hand),self.currCard,len(self.play),len(self.pile)):"
should be
"if self.BotList[(i+self.isTurn)%self.numBots].callBS(i,self.BotList[self.isTurn].name,len(self.BotList[self.isTurn].hand),self.currCard,len(self.play),len(self.pile)):"
It's just missing a self.  Apologies for the formatting; I'm not sure how to make it nicer.

Also in the checkBS function, you should add a default in the min() because otherwise it throws a 'ValueError: min() arg is an empty sequence' error.

@Spitemaster ok will do!

Did you ever determine winner of this?

@Quintec Nope! I'll do it this weekend. I've been crazy busy, my apologies.

Bump, I'm curious :P

@Quintec Sorry, I'll do it tonight. God I've been so busy.

I'm voting to close this question because it is already de-facto closed to new answers ("Submissions accepted until October 13th [2018]").

Naive Bot
def naive_CallBS(self,pos,player,handSize,currCard,numCards,numPile):
    return False
def naive_PlayCards(self,currCard,numPile,stillPlaying):
    return [card(currCard)] * self.hand.count(currCard)
def naive_StartRound(self):
    return self.hand[0].val

Never calls BS, never lies, and lets the game play out, while trying its best to win. Will always play all of the current card, and will start the round with the first card in its hand.

naive_StartRound() should return string. Change it to self.hand[0].val

Asshole
def asshole_CallBS(self,pos,player,handSize,currCard,numCards,numPile):

    if not hasattr(self.obj, "flag"):
        self.obj.flag2 = False
        self.obj.flag = False
    if len(self.hand) < self.numBots * 14 * 1.5 / 4 and self.obj.flag:
        self.obj.flag = False
        if len(set(self.hand)) * self.numBots * 3.0 / 4 < len(self.hand):
            self.obj.flag2 = True
    if len(self.hand) < self.numBots * 14 * 3.0 / 4:
        if not self.obj.flag:
            self.obj.flag = True
        return False
    else:
        return self.hand.count(currCard) * 1.0 / self.numBots > 0.75
def asshole_PlayCards(self,currCard,numPile,stillPlaying):
    if not hasattr(self.obj, "flag"):
        self.obj.flag2 = False
        self.obj.flag = False
    if not self.obj.flag:
        return [card(currCard)] * self.hand.count(currCard) if len(self.hand) > self.numBots * 14 * 3.0 / 4 else self.hand
    else:
        if self.obj.flag2 and len(self.hand) < 3:
            return self.hand
        return [card(currCard)] * self.hand.count(currCard)
def asshole_StartRound(self):
    if not hasattr(self.obj, "flag"):
        self.obj.flag2 = False
        self.obj.flag = False
    card = ""
    max_cards = 0
    for i in "A,2,3,4,5,6,7,8,9,10,J,Q,K,j".split(","):
        if self.hand.count(i) > max_cards:
            max_cards = self.hand.count(i)
            card = i
    return card

Have you ever been that one player in BS who tries to get all the cards? No? Just me? Well, let me tell you it's just as fun. Trust me, this is a legitimate winning strategy.

In asshole_PlayCards() line 4 you should change if times < 3 and not self.obj.flag: to if self.obj.times < 3 and not self.obj.flag:

@DobromirM good catch, thanks. i need to rework a bit of the endgame logic of this bot after this anyway :)

In your StartRound function, you probably don't want to return i - I'm guessing you would rather return card. ;)

@Spitemaster thanks :) my brain is malfunctioning

Moniathan
def moniathan_CallBS(self, pos, player, handSize, currCard, numCards, numPile):
    if numCards > self.numBots * 0.5:
        return True
    if self.hand.count(currCard) == self.numBots:
        return True
    if self.hand.count(currCard) + numCards > self.numBots * 0.5:
        return True
    if numPile > self.numBots * 2:
        return True
    return False

def moniathan_PlayCards(self, currCard, numPile, stillPlaying):
    cards = [c.val for c in self.hand]

    if cards.count(currCard) > 1:
        return cards.count(currCard) * [card(currCard)]

    if cards.count(currCard) == 1:
        if len(self.hand) > 1:
            add_more = self.getRandom() > 0.75
            if add_more:
                return [card(currCard), [c for c in self.hand if c.val != currCard][0]]
            else:
                return [card(currCard)]
        else:
            return [card(currCard)]
    else:
        if self.getRandom() > 0.5:
            if self.getRandom() > 0.5 and len(self.hand) > 1:
                return [self.hand[0], self.hand[1]]
            else:
                return [self.hand[0]]
        else:
            return []

def moniathan_StartRound(self):
    return max(self.hand, key=lambda x: self.hand.count(x.val)).val

It mostly tries to play safe but sometimes it will take small risks to get ahead.

if self.hand.count(currCard) > self.numBots:
This will never trigger, as you can't have more cards of that type than there are in the game. :)

Yes it should be ==. Thank you!

Halfwit
def halfwit_CallBS(self,pos,player,handSize,currCard,numCards,numPile):
    # Call if I know he's lying
    if numCards + self.hand.count(currCard) > self.numBots:
        return True
    # Call if he'd win otherwise
    if handSize == 0:
        return True
    # Call if that would be more than half of the remaining cards, more than 3, and he's got lots of cards
    if handSize > 14 and numCards > 3 and numCards + self.hand.count(currCard) > (self.numBots - numPile) / 2:
        return True
    return False
def halfwit_PlayCards(self,currCard,numPile,stillPlaying):
    # If I have this card, play all that I've got.
    if self.hand.count(currCard) > 0:
        return [card(currCard)] * self.hand.count(currCard)
    # If more than half of the cards of this value are allegedly already out, play nothing
    if numPile * 2 >= self.numBots:
        return
    # Play the smallest stack I've got.
    counts = [self.hand.count(i) for i in "A,2,3,4,5,6,7,8,9,10,J,Q,K,j".split(",")]
    choice = "A,2,3,4,5,6,7,8,9,10,J,Q,K,j".split(",")[counts.index(min([x if x != 0 else 100 for x in counts]))]
    return [card(choice)] * min([x for x in counts if x != 0])
def halfwit_StartRound(self):
    # Play the card I have the most of
    return max(self.hand, key=lambda x: self.hand.count(x.val)).val

Halfwit always plays something - and he cheats if he doesn't have any of the right cards to play.  Right now there's a few issues with the controller and with the bot and I'm not sure which is which, so I'll have to come back and fix some bugs later.