title: Let's design a digit mosaic

text:
# Question
Title: Let's design a digit mosaic
## Challenge

Given a positive integer \\$N\\$, repeat each of its digits \\$d\_1, d\_2, d\_3, \cdots, d\_n\\$ a number of times corresponding to its position in \\$N\\$. In other words, each digit \\$d\_k\\$ should be repeated \\$k\\$ times (for each \\$1\le k\le n\\$, 1-indexed), thus creating the new number:

$$\overline{d\_1d\_2d\_2d\_3d\_3d\_3\cdots\underbrace{d\_nd\_nd\_n\cdots d\_n}\_{n\text { times}}}$$

Then, write it down both horizontally and vertically and fill in the blanks with copies of the digit that corresponds to the greater index between the column index and the row index of the blank space. The final output should look like this:

$$\begin{bmatrix} \color{red}{d\_1} \color{green}{d\_2 d\_2} \color{blue}{d\_3 d\_3 d\_3} \cdots \\ \color{green}{d\_2 d\_2 d\_2} \color{blue}{d\_3 d\_3 d\_3} \cdots \\ \color{green}{d\_2 d\_2 d\_2} \color{blue}{d\_3 d\_3 d\_3} \cdots \\ \color{blue}{d\_3 d\_3 d\_3 d\_3 d\_3 d\_3} \cdots \\ \color{blue}{d\_3 d\_3 d\_3 d\_3 d\_3 d\_3} \cdots \\ \color{blue}{d\_3 d\_3 d\_3 d\_3 d\_3 d\_3} \cdots \\ \vdots \end{bmatrix}$$

---

## Specs

You may take \\$N\\$ as an integer, a string, a list of digits or a list of characters representing the digits. The output can be a newline-separated string, a list of strings / integers or a list of lists of characters / digits, but please include a pretty-print version too, if possible. If the output is a newline-separated string, it is also acceptable to:

* have leading / trailing whitespace, as long as the visual appearance of the output doesn't change
* separate the columns using a consistent amount spaces or the rows with a consistent (non-zero) amount of newlines

You can take input and provide output through any standard method, while taking note that these loopholes are forbidden by default. This is , so try to complete the task in the least bytes you can manage in your language of choice.

## Test cases

```
65:

655
555
555

---------------

203:

200333
000333
000333
333333
333333
333333

--------------

233:

233333
333333
333333
333333
333333
333333

---------------

5202:

5220002222
2220002222
2220002222
0000002222
0000002222
0000002222
2222222222
2222222222
2222222222
2222222222

---------------

12345:

122333444455555
222333444455555
222333444455555
333333444455555
333333444455555
333333444455555
444444444455555
444444444455555
444444444455555
444444444455555
555555555555555
555555555555555
555555555555555
555555555555555
555555555555555

```

# Answer
# JavaScript (ES7), 70 bytes

Takes input as a string. Returns a string with a trailing linefeed.

```
s=>(g=x=>(c=s[(x>y?x:y)**.5-1>>1])?c+g(x+8):x>y?`
`+g(1,y+=8):'')(y=1)

```

Try it online!

## How?

### Method

We build the output character by character by walking through a square matrix and converting each cell into an index \\$i\_{x,y}\\$ into the input string.

### Coordinates to string index

The upper bound \\$u\_{n}\\$ of the \\$n^{th}\\$ digit area (0-indexed) along each axis is given by A000096:

$$u\_{n} = \frac{n(n+3)}{2}$$ $$u\_{0}=0,u\_{1}=2,u\_{2}=5,u\_{3}=9,u\_{4}=14,u\_{5}=20,\dots$$

Given an integer \\$k\\$, we can find out in which area \\$n=\lfloor{x}\rfloor+1\\$ it is located by solving:

$$x²+3x-2k=0$$

Leading to:

$$x = \frac{\sqrt{1+8k}-3}{2}$$ $$n = \left\lfloor\frac{\sqrt{1+8k}-3}{2}\right\rfloor+1=\left\lfloor\frac{\sqrt{1+8k}-1}{2}\right\rfloor$$

For each cell \\$(x, y)\\$, we define:

$$v\_{x,y} = \max(1+8x,1+8y)$$

These values \\$v\_{x,y}\\$ are converted into indices \\$i\_{x,y}\\$ into the input string by doing:

$$i\_{x,y} = \left\lfloor\frac{\sqrt{v\_{x,y}}-1}{2}\right\rfloor$$

```
 v(x,y) |  0  1  2  3  4  5  6  7  8  9        i(x,y) |  0  1  2  3  4  5  6  7  8  9
--------+-------------------------------      --------+-------------------------------
    0   |  1  9 17 25 33 41 49 57 65 73           0   |  0  1  1  2  2  2  3  3  3  3
    1   |  9  9 17 25 33 41 49 57 65 73           1   |  1  1  1  2  2  2  3  3  3  3
    2   | 17 17 17 25 33 41 49 57 65 73           2   |  1  1  1  2  2  2  3  3  3  3
    3   | 25 25 25 25 33 41 49 57 65 73           3   |  2  2  2  2  2  2  3  3  3  3
    4   | 33 33 33 33 33 41 49 57 65 73   -->     4   |  2  2  2  2  2  2  3  3  3  3
    5   | 41 41 41 41 41 41 49 57 65 73           5   |  2  2  2  2  2  2  3  3  3  3
    6   | 49 49 49 49 49 49 49 57 65 73           6   |  3  3  3  3  3  3  3  3  3  3
    7   | 57 57 57 57 57 57 57 57 65 73           7   |  3  3  3  3  3  3  3  3  3  3
    8   | 65 65 65 65 65 65 65 65 65 73           8   |  3  3  3  3  3  3  3  3  3  3
    9   | 73 73 73 73 73 73 73 73 73 73           9   |  3  3  3  3  3  3  3  3  3  3

```

### Halting conditions

We know that we've reached:

* the right boundary of the matrix when the character at \\$i\_{x,y}\\$ does not exist and we have \\$x \> y\\$
* the bottom boundary of the matrix when the character does not exist and we have \\$x \le y\\$
> 9 votes

# Answer
# , 16 15 bytes

-1 byte thanks to FrownyFrog!

```
{~#\<:@>./~@##\

```

Try it online!

Takes `N` as a string.

## Explanation of th initial solution:

```
              #\   finds the length of the successive prefixes of the input (1 2 3...)
            #~     copies each digit as many times (1 2 2 3 3 3...)
       >./~@       and creates a table of the max of the row/col numbers
  [:<:@            then subtract 1 from each element (for indexing)
{~                 select the corresponding digit from the input

```

Test session with input `203`:

```
   #\ '203'
1 2 3

   #~#\ '203'
1 2 2 3 3 3

   >./~@#~#\ '203'
1 2 2 3 3 3
2 2 2 3 3 3
2 2 2 3 3 3
3 3 3 3 3 3
3 3 3 3 3 3
3 3 3 3 3 3

   <:@>./~@#~#\ '203'
0 1 1 2 2 2
1 1 1 2 2 2
1 1 1 2 2 2
2 2 2 2 2 2
2 2 2 2 2 2
2 2 2 2 2 2

   ({~[:<:@>./~@#~#\) '203'
200333
000333
000333
333333
333333
333333

```
> 7 votes

# Answer
# Jelly, 7 bytes

```
Jx`»þ`ị

```

Try it online!

Clarified output.
> 6 votes

# Answer
# Haskell, ~~60~~ ~~59~~ 58 bytes

```
f x|s<-do(n,_)<-zip[0..]x;n<$[0..n]=[(x!!).max a<$>s|a<-s]

```

Try it online!

---

### Point-free version (68 bytes)

```
(map=<<(.((snd.).max)).flip map).((\t@(n,c)->t<$[1..n])=<<).zip[1..]

```

Try it online!
> 6 votes

# Answer
# , 59 bytes

```
function(a){m=outer(x<-rep(g<-seq(a),g),x,pmax);m[]=a[m];m}

```

Try it online!

* I noticed that taking a vector of digits is acceptable, and this allowed me to save 21 bytes :)
* -2 bytes thanks to @Giuseppe suggestion to accept only character vector
* -2 bytes assigning in arguments definition
> 6 votes

# Answer
# Python 2, 71 bytes

```
i=j=0;r=''
for x in input():i+=1;r+=x*i
for c in r:print j*c+r[j:];j+=1

```

Try it online!

First generates the first row `r`, then iterates over `r` to print each line.
> 6 votes

# Answer
# APL (Dyalog Classic), 16 bytes

```
{⍵[∘.⌈⍨(/⍨⍳⍴⍵)]}

```

I'm separating this solution from the post with my J answer, as suggested by Jo King

Try it online!
> 5 votes

# Answer
# 05AB1E, ~~14~~ ~~11~~ 10 bytes

Saved 1 byte thanks to *Magic Octopus Urn* / *Adnan*

```
ƶJDv¬N×?=¦

```

Try it online!

**Explanation**

```
ƶ            # repeat each element its index (1-based) times
 J           # join to string
  Dv         # for N in [0 ... len(string)-1] do
    ¬N×      # push the head repeated N times
       ?     # print without newline
        =    # print the rest of the string without popping
         ¦   # remove the head

```
> 5 votes

# Answer
# Python 2, 74 bytes

```
i=1;a=[]
for c in input():exec"a=zip(*a+[c*-~len(a)]);"*i;i+=2+i%2
print a

```

Try it online!
> 3 votes

# Answer
# Excel VBA, 95 bytes

An anonymous VBE immediate window funtion that takes input from `[A1]` and outputs to the console

```
n=[len(A1)]:For y=1To n:For l=1To y:?:For x=1To n:?String(x,Mid([A1],IIf(x>y,x,y)));:Next x,l,y

```

### Ungolfed and commented

```
n=[len(A1)]                         ''  Get Length
For y=1To n                         ''  Iterate down input
For l=1To y                         ''  Iterate down repeat lines
?                                   ''  Print Newline
For x=1To n                         ''  Iterate accross input
?String(x,Mid([A1],IIf(x>y,x,y)));  ''  Print x of the `max(x,y)`th digit in input
Next x,r,y                          ''  Loop, Loop, Loop

```
> 3 votes

# Answer
# MATL, ~~15~~ 12 bytes

```
tftY"t!2$X>)

```

Try it online!

I suspect this can be shortened, but it's not so bad...

```
          % implicit input, '230'
t         % duplicate input. Stack: ['230','230']
f         % indices of nonzero values. Stack: ['230',[1,2,3]]
t         % duplicate. Stack: ['230',[1,2,3],[1,2,3]]
Y"        % run-length decoding. Stack: ['230',[1,2,2,3,3,3]]
t         % duplicate. Stack: ['230',[1,2,2,3,3,3],[1,2,2,3,3,3]]
!         % transpose. Stack: ['230',[1,2,2,3,3,3],[1;2;2;3;3;3]]
2$X>      % elementwise maximum of 2 inputs, with broadcast.
          % Stack:
          % ['230',
          % [1, 2, 2, 3, 3, 3;
          %  2, 2, 2, 3, 3, 3;
          %  2, 2, 2, 3, 3, 3;
          %  3, 3, 3, 3, 3, 3;
          %  3, 3, 3, 3, 3, 3;
          %  3, 3, 3, 3, 3, 3]]
 )        % index into G
          % implicit end, display stack contents
```
> 2 votes

# Answer
# Add++, 35 bytes

```
L,bLRdBcB]£X¦Ω+d‽b>1€Ω_A€Ω:AbLR¦+$T

```

Try it online!

## How it works

We take input as a list of digits, while prevents us from a) having to cast to digits with `BD`, and also from having to save the digits, which would take two bytes.

First, we generate a range from **\[1 ... len(input)\]** with `bLR`, then we repeat each element \\$n\\$ in the range \\$n\\$ times. As automatic vectorisation doesn't exist in Add++, we zip it with itself, `dBcB]`, to create a list of pairs \\$\[\[1, 1\], \[2, 2\] ... \[n, n\]\]\\$. We then apply *starmap*, coupled with repetition over the pairs: `£X` before concatenating them into one flat array (`¦Ω+`).

Next, we duplicate this array and table it by maximum, `d‽b>`. I.e. each element in the array is paired with each other element from the second array and the *dyadic maximum* command is run over the pair. For an example input of **\[6 5\]**, this creates the array **\[1 2 2 2 2 2 2 2 2\]**, which is a flattened version of the mosaic, as the indexes for the array. Unfortunately, Add++ uses 0-indexed arrays, so we need to decrement each element: `1€Ω_`.

Then, we index into the input list, by pushing the input again (`A`), which again saves bytes by taking input as a list. Index into the list with `€Ω:` before chopping the array into the appropriately lengthed pieces. If the number of digits in the input is denoted by \\$x\\$, then the piece size is

$$\frac{x(x - 1)}{2}$$

or the \\$x^{th}\\$ triangular number. We generate that by pushing the input's length, calculating the range from **1** to that value, then taking the sum with `AbLR¦+`. Now, the stack, for an input of **\[6 5\]**, looks like **\[\[6 5 5 5 5 5 5 5 5\] 3\]**. `T` chops the array into pieces of size \\$n\\$, but the arguments are currently in the wrong order, so we swap them with `$` before chopping and returning with `T`.
> 2 votes

# Answer
# Python 2, ~~76~~ 73 bytes

-3 bytes thanks to Lynn.

```
l=0;m=[]
for k in input():l+=1;m=[r+l*k for r in m]+l*[l*-~l/2*k]
print m

```

Try it online!
> 1 votes

# Answer
# Charcoal, 17 bytes

```
Ｆ⮌…ＬθＵＯ⊕⊘×ι⁺³ι§θι

```

Try it online! Explanation:

```
Ｆ⮌…Ｌθ

```

Loop over the indices of the characters in reverse order.

```
⊕⊘×ι⁺³ι

```

Calculate the size of the square.

```
ＵＯ...§θι

```

Draw the square using the current character.
> 1 votes

# Answer
# Canvas, 12 bytes

```
ø╶｛；ｌ└²＋：＊；ｎ

```

Try it here!
> 1 votes

# Answer
# Charcoal, 14 bytes

```
Ｅ⭆θ×⊕κι×⊕κι‖Ｏ↗

```

**Try it online!**

### How?

```
Ｅ⭆θ×⊕κι×⊕κι‖Ｏ↗ - implicitly print the result of...
Ｅ                - map:
  ⭆              -   over: string map:
    θ             -     over: first input
     ×            -     using: repeat
        ι         -       what: ι (loop value)
      ⊕κ          -       by: incremented κ (loop counter)
         ×        -   using: repeat
            ι     -     what: ι (loop value)
          ⊕κ      -     by: incremented κ (loop counter)
             ‖Ｏ  - Reflect with overlap:
                ↗ -   direction: up-right

```

...can this method be golfed?
> 1 votes

# Answer
# QBasic 1.1, 127 bytes

```
INPUT S$
FOR X=1TO LEN(S$)
K=K+X
R$=R$+STRING$(X,MID$(S$,X,1))
NEXT
FOR C=1TO K
?STRING$(C-1,MID$(R$,C,1))RIGHT$(R$,K-C+1)
NEXT

```

-4 thanks to DLosc.

Uses a modified version of xnor's Python 2 algorithm.

Input is an unquoted string. Output is `\n`-separated without extra spaces or `\n`s.
> 1 votes

# Answer
# Stax, 12 bytes

```
ü°√¿«│⌠º₧@\τ

```

Run and debug it

Using this algorithm.

Explanation:

```
c%R:BXm]i*xit+ Full program, implicit input
c%             Length of input
  R            1-based range
   :B          Repeat each element according to the range ("123" -> "122333")
     X         Save to X register
      m        Map:
       ]         Character -> string
        i*       Repeat by iteration index
          xit    Trim first <iteration index> elements from X
             +   Concatenate
                 Implicit output with newline

```

### Stax, ~~20~~ ~~19~~ ~~18~~ 16 bytes

```
ù↔‼i,ÑΓæ☺=╘‼æ↕4╝

```

Run and debug it

Explanation:

```
c%R:BX%mYx%{y|Mvx@m Full program, implicit input
c%                  Length of input
  R                 1-based range
   :B               Repeat each element according to the range ("123" -> "122333")
     X              Save to X register
      %             Length
       m            Map over 1-based range:
        Y             Save index to Y register
         x%           Push length of X register
           {      m   Map over 1-based range:
            y|M         Maximum of both indices
               v        1-based -> 0-based (decrement)
                x@      Index into X register
                      Implicit output with newline

```
> 1 votes

# Answer
# Attache, 34 bytes

```
{_[Table[Max,Flat!{_&_}=>1:#_]-1]}

```

Try it online!

## Explanation

Works similarly to Galen Ivanov's J answer.

```
{_[Table[Max,Flat!{_&_}=>1:#_]-1]}
{                                }   anonymous function: _ is input, array of digits
                                     example: _ := [2, 0, 3]
                         1:#_        the range 1 to Size[_]
                                     > e.g.: [1, 2, 3]
                  {   }=>            over each number N:
                   _&_                   map to N repeated N times
                                     > e.g.: [[1], [2, 2], [3, 3, 3]]
             Flat!                   flatten it
                                     > e.g.: [1, 2, 2, 3, 3, 3]
   Table[Max,                ]       create a "max" table with it
                                     > e.g.:
                                       1 2 2 3 3 3
                                       2 2 2 3 3 3
                                       2 2 2 3 3 3
                                       3 3 3 3 3 3
                                       3 3 3 3 3 3
                                       3 3 3 3 3 3
                              -1     subtract 1 from each
                                     > e.g.:
                                       0 1 1 2 2 2
                                       1 1 1 2 2 2
                                       1 1 1 2 2 2
                                       2 2 2 2 2 2
                                       2 2 2 2 2 2
                                       2 2 2 2 2 2
 _[                             ]    index the original array with this matrix
                                     > e.g.:
                                       2 0 0 3 3 3
                                       0 0 0 3 3 3
                                       0 0 0 3 3 3
                                       3 3 3 3 3 3
                                       3 3 3 3 3 3
                                       3 3 3 3 3 3

```
> 1 votes

# Answer
# K (ngn/k), 16 bytes

```
{x@i|\:i:&1+!#x}

```

Try it online!
> 1 votes

# Answer
# C (gcc), ~~130~~ 126 bytes

-4 bytes thanks to ceilingcat

Who needs fancy maths when you can bruteforce?

```
n,l;R(n,c){for(;n--;)putchar(c);}f(s){for(char*p=s,*q;*p++;)for(n=l=p-s;l--;R(1,10))for(R(n*-~n/2,p[-1]),q=p;*q;)R(++q-s,*q);}

```

Try it online!
> 1 votes

# Answer
# QBasic, 111 bytes

An anonymous function that prompts for input and outputs to the console.

```
INPUT s$
n=LEN(s$)
FOR y=1TO n
FOR l=1TO y
?
FOR x=1TO n
z=x
IF y>x THEN z=y
?STRING$(x,MID$(s$,z));
NEXT x,l,y

```
> 1 votes

# Answer
# Vyxal, 13 bytes

```
Þżṅ:ẏ(:hnẋ₴…Ḣ

```

Try it Online!

## How?

```
Þżṅ:ẏ(:hnẋ₴…Ḣ
Þż            # Repeat each character in the (implicit) input its 1-based index amount of times
  ṅ           # Join by nothing
   :          # Duplicate
    ẏ(        # Loop over [0...length), where the current iteration = n
      :h      # Duplicate and get the first character
        nẋ    # Repeat it n amount of times
          ₴   # Print without a trailing newline
           …  # Print without popping with a trailing newline
            Ḣ # Remove the first item

```
> 1 votes

# Answer
# Php 7.1, 163 bytes

Via CLI providing the number as an argument:

```
<?foreach(str_split($argv[1])as$k=>$d)$a[]=array_fill(0,$s+=$k+1,array_fill(0,$s,$d));foreach(array_replace_recursive(...array_reverse($a))as$v)echo join($v)."\n";

```

Not so golfed:

```
$n = 123;

foreach(str_split($n) as $k => $d) {
    $s += $k + 1;
    $a[] = array_fill(0, $s, array_fill(0, $s, $d));
}

foreach(array_replace_recursive(...array_reverse($a)) as $v)
    echo implode('', $v) . "\n";

```

Output:

```
122333
222333
222333
333333
333333
333333

```

Method:

Basically build multi-dimensional array squares consisting of the digit, and then superimpose all of them (array\_replace\_recursive).

(Yes, I know this is embarrassingly long.)
> 0 votes

# Answer
# Ruby, 80 bytes

```
->n{s=(1..n.size).map{|i|n[i-1]*i}*"";(0...s.size).map{|i|s[i]*i+s[i..-1]}*"\n"}

```

Try it online!

Similar to ovs answer
> 0 votes

# Answer
# Japt, 12 bytes

Takes input as a string, outputs an array of strings.

```
Ë+pE
¬£h°YçX

```

Try it

---

## Explanation

```
            :Implicit input of string U
Ë           :Map each character D at 0-based index E
  pE        :  Repeat D E times
 +          :  Append to D
\n          :Reassign to U
¬           :Split to character array
 £          :Map each element X at 0-based index Y
   °Y       :  Increment Y
     çX     :  Repeat X Y times
  h         :  Replace the first Y characters in U with that

```
> 0 votes

# Answer
# Yabasic, 108 bytes

An anonymous function that takes input from STDIN and outputs to STDOUT

```
Input""s$
n=len(s$)
For y=1To n
For r=1To y
For x=1To n
For c=1To x?Mid$(s$,max(x,y),1);Next
Next
?Next
Next

```

Try it online!
> 0 votes

# Answer
# uBASIC, 120 bytes

An anonymous function that takes input foprm STDIN and outputs to STDOUT

```
0Input"",S$:N=Len(S$):ForY=1ToN:ForL=1ToY:ForX=1ToN:ForC=1ToX:Z=X:IfY>XThenZ=Y
1?Mid$(s$,z,1);:NextC:NextX:?:NextL:NextY

```

Try it online!
> 0 votes

# Answer
# Visual Basic .NET (VBC), 198 bytes

A `Sub`routine that takes input from STDIN and outputs to STDOUT.

Couldn't seem to get StrDup to work :/

```
Module M
Sub Main
Dim c,s,n,l,x,y
s=Console.readLine()
n=Len(s)
For y=1To n
For l=1To y
For x=1To n
For c=1To x
Console.Write(Mid(s,IIf(x>y,x,y),1)&IIf(c=n,vbLf,""))
Next c,x,l,y
End Sub
End Module

```

Try it online!
> 0 votes

# Answer
# Lua, 149 140 bytes

Function which accepts a list of digit strings and prints the result to stdout. This is my first attempt at code golf (and the language choice isn't helping either) so bear with me :)

Try it online!

```
function(a)F,s=0,""for b=1,#a do s=s..a[b]:rep(b)end;for b=1,#a do io.write((s.."\n"):rep(b))F,z=F+b,a[b+1]or""s=z:rep(F)..s:sub(F+1)end end

```

Ungolfed:

```
G = function(p)
    F,s = 0,""
    for i=1,#p do
        s=s..p[i]:rep(i)
    end
    for i=1, #p do
        io.write((s.."\n"):rep(i))
        F,z = F+i, p[i+1]or""
        s = z:rep(F)..s:sub(F+1)
    end
end
-- allows to pass the argument list from stdin
-- example: {"1", "2", "3", "4", "5"}
G(load("return " .. io.read())())

```
> 0 votes

# Answer
## Perl 5 \+ `-nalF -M5.010`, 67 bytes

```
s/./$&x++$-/ge;eval'eval"say;"x++$i;$x+=$i;s/.{$x}/$F[$i]x$x/e;'x@F

```

Try it online!
> 0 votes

# Answer
# Uiua <sup>SBCS</sup>, 11 bytes

```
⊏⊞↥.▽+1.⇡⧻.

```

Try it!
> 0 votes

---
Tags: code-golf, string, ascii-art, integer
---


title: Making an acronym

text:
# Question
Title: Making an acronym
# Objective

Your goal is to make a program that converts an input to its acronym. Your input is guaranteed to have only letters and spaces. The input will have exactly one space between words. You must output the acronym of the input.

# Rules

* Your code cannot be case-sensitive(e.g. `foo` and `Foo` are the same)
* Your code must ignore the following words and not put them in the acronym: `and or by of`
* You **cannot** assume that the words are all lowercase.
* The output must be entirely capitalised, with no separation between characters.
* A trailing newline is accepted but not necessary.
* If your language has an acronym function builtin, you may **not** use it.

## Examples

(inputs/outputs grouped)

```
United States of America
USA

Light Amplification by Stimulation of Emitted Radiation
LASER

united states of america
USA

Jordan Of the World
JTW

```

# Scoring

This is a challenge so the shortest code wins.

# Leaderboard

```
var QUESTION_ID=75448,OVERRIDE_USER=8478;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```

```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```

# Answer
# Pyth, ~~25~~ ~~21~~ 20 bytes

```
shM-crz1dc4."@YK½¼

```

Try it here!

Thanks to @Jakube for saving one byte!

## Explanation

```
shM-crz1dc4."@YK½¼  # z = input

     rz1               # convert input to uppercase
    c   d              # split input on spaces
         c4."@YK½¼     # create a list of the words from a packed string which shall be ignored
   -                   # filter those words out
 hM                    # only take the first letter of all words
s                      # join them into one string

```

The packed string becomes `ANDBYOROF`
> 12 votes

# Answer
## Jelly, ~~21~~ 20 bytes

```
,“°ɲịĊs°gɗ»ṣ€⁶Œuḟ/Ḣ€

```

Try it online!

*(-1 thanks to @Dennis.)*

```
,“°ɲịĊs°gɗ»              Pair input with the string "OR OF by AND"
           ṣ€⁶           Split both by spaces
              Œu         Uppercase
                ḟ/       Reduce filter (removing ignored words from input)
                  Ḣ€     Keep first letters of remaining words

```

Jelly's dictionary is a bit weird in that it has `AND` in uppercase yet `by` in lowercase...
> 10 votes

# Answer
## Retina, 29 ~~31~~ ~~36~~ bytes

```
T`l`L
 |(AND|OR|BY|OF)\b|\B.

```

Intended newline at the end.

Thanks to Martin Büttner for saving 5 bytes

Try it online

```
T`l`L                  # Replace lowercase with uppercase
 |(AND|OR|BY|OF)\b|\B. # Regex match, it doesn't matter if we match 'AND' in SHAND
                       #   since the 'SH' will still become 'S' or am I missing something?
                       # Replace with nothing

```
> 8 votes

# Answer
## vim, 46

```
gUU:s/ /\r/g<cr>:g/\vAND|OR|OF|BY/d<cr>:%s/.\zs.*\n<cr>

```

```
gUU                      make line uppercase
:s/ /\r/g<cr>            replace all spaces with newlines
:g/\vAND|OR|OF|BY/d<cr>  remove unwanted words
:%s/.\zs.*\n<cr>         remove all non-initial characters and newlines

```

I particularly like that last bit. The first `.` in the regex matches the first character of the line. Then we use `\zs` to start the "actually-being-replaced" part, effectively *not* replacing the initial character. `.*` matches the rest of the line, and `\n` matches the trailing newline. Since we don't specify a replace string, vim simply removes everything in the match, leaving only initials.
> 7 votes

# Answer
# JavaScript (ES6), 56 bytes

Saved a byte thanks to @edc65.

```
s=>s.toUpperCase().replace(/\B.| |(AND|O[RF]|BY)\b/g,"")

```

## Explanation

The code is self explanatory, I'll just explain the regex:

```
\B.          // Matches any character (`.`), that's not the start of a word
|            // Matches spaces
|(...)\b     // Matches all the words that should be ignored

```

It removed all of these matched characers and uppercases the word
> 7 votes

# Answer
# JavaScript, ~~61~~ ~~64~~ ~~66~~ 63 bytes

```
a=>a.toUpperCase().replace(/(AND|O[FR]|BY|(\w)\w+)( |$)/g,"$2")

```

It uses a Regular Expression to find get words that aren't from the list: `and, or, of, by`, and captures the first letter. It then capitalizes the resulting string of letters.

**EDIT:** 64 Bytes - Fixed for words start with `of,or,by,and`

**EDIT:** 66 Bytes - Fixed to check all words including last word.

**EDIT:** 63 Bytes - Saved 3 Bytes thanks to @edc65 and @Cyoce!
> 5 votes

# Answer
# CJam, ~~28~~ ~~24~~ 22 bytes

```
qeuS/"AOBONRYFD"4/z-:c

```

Try it online. Thanks to Sp3000 for pointing out a bug and suggesting a fix, and to Dennis for saving ~~4~~ 6(!) bytes.

### Explanation

```
qeuS/  e# Convert the input to uppercase and split on spaces
"AOBONRYFD"4/z  e# Push the array of short words. See more below
-      e# Remove each short word from the input words
:c     e# Cast the remaining words to characters, which is a
       e# shorter way of taking the first letter

```

Dennis suggested this trick for shortening the word list: Splitting `AOBONRYFD` into chunks of four, we get

```
AOBO
NRYF
D

```

Transposing columns into rows with the `z` operator, we get the proper words!
> 4 votes

# Answer
# Julia, ~~72~~ ~~63~~ ~~61~~ 55 bytes

```
s->join(matchall(r"\b(?!AND|OR|OF|BY)\S",uppercase(s)))

```

This is an anonymous function that accepts a string and returns a string. To call it, assign it to a variable.

We convert the string to `uppercase`, select each match of the regular expression `\b(?!AND|OR|OF|BY)\S` as an array, and `join` it into a string.

Saved 8 bytes thanks to Dennis!
> 4 votes

# Answer
## Perl, 32 bytes

```
say uc=~/\b(?!AND|OR|OF|BY)\S/g

```

+1 byte for the `-n` flag.

Algorithm stolen from @AlexA's Julia answer.
> 4 votes

# Answer
# MATL, ~~34~~ 27 bytes

*1 byte fewer thanks to @AandN*

```
KkYb'OF AND OR BY'YbX-c1Z)!

```

**Try it online!**

```
Xk                  % convert to uppercase
Yb                  % split by spaces. Gives a cell array of input words
'AND OR BY OF'      % ignored words separated by spaces
Yb                  % split by spaces. Gives a cell array of ignored words
X-                  % setdiff: remove ignored words (result is stable)
c                   % convert to 2D char array, padding words with spaces
1Z)                 % take first column
!                   % transpose into a row

```
> 3 votes

# Answer
# JavaScript, ~~104~~ 85 bytes

Saved 19 bytes thanks to *@Aplet123*.

Splits the string by spaces then checks if it is the words of, or, and, or by. If it is, it ignores it, otherwise it takes the first letter of it. It then joins the array and makes the string uppercase.

```
a=_=>_.split` `.map(v=>/\b(o(f|r)|and|by)\b/i.test(v)?"":v[0]).join("").toUpperCase()

```

Ungolfed:

```
function a(_) {
       _ = _.split` `; //Split on spaces
       _ = _.map(function(v){return new RegExp("\b(o(f|r)|and|by)\b","i").test(v)}); //Check if the banned words are in the result
       _ = _.join(""); //Join it into a string
       _ = _.toUpperCase(); //Convert it to uppercase
};

```
> 3 votes

# Answer
# Ruby, ~~45~~ 43 bytes

```
->s{s.upcase.scan(/\b(?!AND|OR|OF|BY)\S/)*''}

```

This is a lambda function that accepts a string and returns a string. To call it, assign it to a variable and do `f.call(input)`.

It uses the same approach as my Julia answer, namely convert to uppercase, get matches of the regular expression `\b(?!AND|OR|OF|BY)\S`, and join into a string.

Try it here

Saved 2 bytes thanks to manatwork!
> 3 votes

# Answer
# PHP, 92 bytes

First attempt at code golf.

```
foreach(explode(" ",str_replace(["AND","OR","BY","OF"],"",strtoupper($s)))as$x){echo$x[0];}

```

The variable `$s` is the phrase to be converted: `$s = "United States of America"`.

Requires PHP 5.4 or above for short array syntax to work.
> 3 votes

# Answer
## Python, 81 bytes

```
lambda s:''.join(c[0]for c in s.upper().split()if c not in'AND OF OR BY'.split())

```
> 3 votes

# Answer
# Bash + GNU coreutils, ~~103~~ 76 bytes

```
for i in ${@^^};do grep -qE '\b(AND|OR|BY|OF)\b'<<<$i||echo -n ${i:0:1};done

```

Run with

```
./codegolf.sh Light Amplification BY Stimulation of Emitted Radiationofo

```

either with single argument quoted or with multiple arguments.

(I distorted the last word to contain *of*).

---

# 60 bytes

Thanks to @manatwork.

```
for i in ${@^^};{ [[ $i = @(AND|OR|BY|OF) ]]||printf %c $i;}

```
> 3 votes

# Answer
# JavaScript, ~~80~~ ~~72~~ ~~55~~ 53 bytes

## Code

~~```
function a(t){t=t.toUpperCase();t=t.replace(/AND|OR|BY|OF|\B.| |/g,"");return t}

```~~ ~~```
function a(t){return t.toUpperCase().replace(/AND|OR|BY|OF|\B.| |/g,"")}

```~~

I just read about arrow functions and realized I could shorten this up even more.

~~```
a=t=>t.toUpperCase().replace(/AND|OR|BY|OF|\B.| |/g,"")

```~~

According to this, you don't count the assignment in the length, so -2 bytes.

```
t=>t.toUpperCase().replace(/AND|OR|BY|OF|\B.| |/g,"")

```

This is my first golf, so it's not very good.
> 3 votes

# Answer
# 05AB1E, ~~33~~ ~~32~~ 28 bytes

Code:

```
‘€ƒ€—€‚€‹‘ð¡)Uuð¡)vXyQO>iy¬?

```

Uses **CP-1252** encoding.
> 2 votes

# Answer
# Haskell, ~~100~~ ~~99~~ ~~98~~ ~~82~~ 75 bytes

~~I am quite sure it can be shortened a lot more as I still suck at using `$`,`.` etc. so I keep using `()` insted=)~~

Thanks @nimi for your help magic!

```
import Data.Char
w=words
x=[h!!0|h<-w$toUpper<$>x,notElem h$w"OF BY OR AND"]

```

Example:

```
*Main> a "united states by america"
"USA"

```
> 2 votes

# Answer
# Python, 103 96 bytes

This is my first attempt at code golf, and this could probably be golfed a lot more. Thanks to DenkerAffe for saving seven characters.

```
lambda x:"".join([x[0]for y in x.split(" ") if y.lower() not in ['and','or','of','by']]).upper()

```

It takes the input, turns it into a list of words and takes their first letter if it's not one of the forbidden words, then turns everything to uppercase.
> 2 votes

# Answer
# PHP, ~~68~~ ~~61~~ 58 bytes

Uses ISO-8859-1 encoding.

```
for(;$w=$argv[++$x];)stripos(_AND_OR_BY_OF,$w)||print$w&ß;

```

Run like this (`-d` added for aesthetics only):

```
php -d error_reporting=30709 -r 'for(;$w=$argv[++$x];)stripos(_AND_OR_BY_OF,$w)||print$w&ß; echo"\n";' united states oF america

```

Ungolfed:

```
// Iterate over the CLI arguments (words).
for(;$w = $argv[++$x];)
    // Check if the word is one of the excluded words by substring index.
    // The check is case insensitive.
    stripos("_AND_OR_BY_OF", $w) ||
        // Print the word, converting to uppercase and getting only the
        // first char by using bitwise AND.
        print $w & "ß";

```
* Saved 7 bytes by using bitwise AND instead of using `ucwords`.
* Saved 3 bytes by using ISO-8859-1 encoding and using `ß` (binary `11011111`) for binary `AND` instead of a negated space (binary `00100000`).
> 2 votes

# Answer
# , ~~77~~ 75 bytes

```
cat(substr(w<-toupper(scan(,'')),1,1)[!grepl('^(AND|OR|OF|BY)$',w)],sep='')

```

Try it online!

-1 byte thanks to Dominic van Essen changing the indexing.

Reads from stdin. Takes the words, converts them to uppercase, removes those that are excluded from acronyms, extracts the first character from each, and prints them to the stdout.
> 2 votes

# Answer
# K (ngn/k), 34 bytes

```
{`c$-32+*'(" "\_x)^$`and`or`by`of}

```

Try it online!

* `_x` lowercase the input
* `(" "\...)` split input on spaces
* `(...)^$`and`or`by`of` remove and/or/by/of
* `*'` take the first character of each remaining word
* ``c$-32+` convert to uppercase
> 2 votes

# Answer
# Mathematica, ~~132~~ 117 bytes

```
ToUpperCase[First/@Characters@DeleteCases[StringDelete[StringSplit@#,"of"|"and"|"or"|"by",IgnoreCase->True],""]<>""]&

```

15 bytes saved thanks to @CatsAreFluffy.
> 1 votes

# Answer
# PowerShell, 81 Bytes

```
(-join($args[0].Split(" ")|?{$_-notmatch"^(and|or|by|of)$"}|%{$_[0]})).ToUpper()

```

---

Explanation

Split on the spaces creating an array. Drop the offending members. Pull the first character and join together. Use `ToUpper()` on the resulting string.
> 1 votes

# Answer
## Lua, 122 Bytes

I would have love to use a pattern to get rid of the banned words, but sadly, lua isn't made to match groups of characters... So I had to use a for loop instead, which is much more expensive.

```
s=arg[1]for k,v in next,{"of","and","by","or"}do
s=s:gsub(v,"")end
print(s:gsub("(%a)%a+",string.upper):gsub("%s","").."")

```

### Ungolfed

```
s=arg[1]                               -- initialise s with the argument
for k,v in next,{"of","and","by","or"} -- iterate over the array of banned words
do
    s=s:gsub(v,"")                     -- replace the occurences of v by
end                                    --   an empty string
print(s:gsub("(%a)%a+",                -- replace words (separated by spaces)
              string.upper)            -- by their first letter capitalised
         :gsub("%s","")                -- replace spaces with empty strings
                       .."")           -- concatenate to prevent the number of
                                       -- substitutions to be shown

```
> 1 votes

# Answer
# Factor, 175 bytes

I learned a lot by writing this.

```
USING: strings ascii sets splitting kernel sequences math.ranges ;
>lower " " split [ { "and" "or" "by" "of" } in? not ] filter [ first dup [a,b] >string ] map "" join >upper

```

As a word:

```
USING: strings ascii sets splitting kernel sequences math.ranges ;

: >initialism ( str -- str )
  >lower " " split                            ! string.lower.split(" ")
  [ { "and" "or" "by" "of" } in? not ] filter ! word in { } ?
  [ first dup [a,b] >string ]          map    ! word[0]
  "" join >upper ;                            ! "".join.upper

```

Unit tests:

```
USING: tools.test mk-initialism ;
IN: mk-initialism.tests

{ "LASER" } [ "Light Amplification by Stimulation of Emitted Radiation" >initialism ] unit-test
{ "USA"   } [ "United States OF Americaof" >initialism ]                              unit-test
{ "USA"   } [ "united states and america" >initialism ]                               unit-test
{ "JTW"   } [ "Jordan Of the World" >initialism ]                                     unit-test

```

Pass!
> 1 votes

# Answer
# Lua, ~~113~~ ~~112~~ 93 bytes

```
arg[1]:upper():gsub("%w+",function(w)io.write(("AND OR BY OF"):find(w)and""or w:sub(0,1))end)

```
> 1 votes

# Answer
# C#, 134 bytes

Golfed

```
class P{static void Main(string[] a){foreach (var s in a){if(!"AND OR BY OF".Contains(s.ToUpper())){Console.Write(s.ToUpper()[0]);}}}}

```

Readable

```
class P
{
    static void Main(string[] a)
    {
        foreach (var s in a)
        {
            if (!"AND OR BY OF".Contains(s.ToUpper()))
            {
                Console.Write(s.ToUpper()[0]);
            }
        }
    }
}

```

Execute from command line

75448.exe Light Amplification by Stimulation of Emitted Radiation

> LASER

75448.exe united states of america

> USA
> 1 votes

# Answer
# Husk, ~~19~~ 18 bytes

```
m←¤-w¨BYΘRΘF⁴ND¨ma

```

Try it online!

-1 byte from Dominic Van Essen.
> 1 votes

# Answer
# Zsh, ~~46~~ ~~45~~ 44 bytes

```
for i;printf ${${${i:u}:#(AND|OR|BY|OF)}[1]}

```

Try it online!

*-1 thanks to @roblogic*

Explanation:

```
for i;printf ${${${i:u}:#(AND|OR|BY|OF)}[1]}
for i;                                         # for each word in the input
                 ${i  }                        # take that word
                    :u                         # capitalised
                         (AND|OR|BY|OF)        # if it matches one of these words
               ${      :#              }       # replace it with an empty string
             ${                         [1]}   # take the first character
      printf                                   # and print with no newline

```
> 1 votes

# Answer
# Stax, ~~16~~ 12 bytes

```
î♣}ïû┴N=a,╥Ç

```

Run and debug it
> 1 votes

# Answer
# C (gcc), 149 bytes

```
#define x*strcmp(c,
F(char*s){char*d,*c=s;while(*s)*s++|=32;for(s=c;c;c=!d?*s=0:d+1)d=index(c,32),d?*d=0:0,1 x"and")x"or")x"by")x"of")?*s++=*c^32:0;}

```

Try it online!

Very naive approach. Will try to optimize it further. My first priority was to create a working example in C as there was no C submission yet.

Edit: optimized it by replacing initial conversion to upper case with conversion to lower case (easier as space is no longer an exception). I replaced strcmp with a define and replaced a while loop with a for. I did some further small optimizations and am now out of ideas.

Thanks to ceiling cat for bringing it down even more!
> 1 votes

# Answer
# Vyxal `sr`, ~~20~~ 16 bytes

-4 thanks to @Underslash.

```
⇧⌈«X⟩qḊ8ɖ⇩«⇧⌈Fvh

```

Try it Online!

```
⇧⌈«X⟩qḊ8ɖ⇩«⇧⌈Fvh    # Full program
⇧                   # Convert (implicit) input converted to uppercase...
 ⌈                  # Split on spaces
  «X⟩qḊ8ɖ⇩«⇧⌈       # Create the list ['OR', 'BY', 'OF', 'AND']
             F      # and remove those from the input.
              vh    # Replace each word with its first letter
                    # `s` flag: Concatenate the letters and print

```
> 1 votes

# Answer
# IPOS \- non competing, 27 bytes

```
uS`"AND|OR|BY|OF"ER`%S!h%S-

```

This works in the current version (v0.2) of the interpreter.

**Example run**

```
python IPOS.py -i "United States of America" uS`\"AND|OR|BY|OF\"ER`%S!h%S-
USA

```

*The backslashes there are only for escaping of the quotes and are not needed for the program.*

## Explanation

```
u                  # Make the input uppercase
S                  # Push a space to the stack
`"AND|OR|BY|OF"ER` # Push a command to the stack, that replaces matches of the regex
                   # with an empty string
%                  # Split the uppercased input string on spaces, apply the command and
                   # join back on spaces. This removes the required words from the input.
S                  # Push a space to the stack
!h                 # Push a command that only selects the first character of a string
%                  # Split on spaces, apply the command and join back on spaces
S-                 # Remove the remaining spaces (forgot to make this usuable
                   # with regexes, would have saved me some bytes here :( )

```
> 0 votes

# Answer
# bash / GNU coreutils, 60 bytes

`sed -e's/\b'{and,o[rf],by}'\W*//Ig' -re's/(\w)\S* ?/\u\1/g'`
> 0 votes

# Answer
# Pylongolf2, 14 bytes (UTF-8)

```
c| l1╨3♀~

```

Pylongolf2 has many non-ASCII characters that count as 2 bytes.

```
c| l1╨3♀~
c         read input
 |        split by space (note the space after |)
   l1     substring(0, 1)
     ╨3   convert to uppercase
       ♀~ pop the array into the stack and print it.

```
> 0 votes

# Answer
# 05AB1E, 19 bytes

```
lð¡“€ƒ€—€‹€‚“#K€нJu

```

Try it online!

A 21 byte version:

```
lð¡“€ƒ€—€‹€‚“#Kvy0èuJ

```

Try it online!
> 0 votes

# Answer
# Pip, 43 bytes

```
a:UCq^sFi,#a{`(OR|OF|AND|BY)`~=a@i?xOa@i@0}

```

definitely golfable, but I'm still learning regex

explanation:

```
a:UCq^s                                     input toUpper, split on " "
       Fi,#a{                             } iterate over a
             `(OR|OF|AND|BY)`~=a@i?xOa@i@0  if not exact match, output first char of this word

```

Try it online!
> 0 votes

# Answer
# C# .NET, 144 bytes

```
class P{static void Main(string[]a){foreach(var c in a[0].ToUpper().Split(' '))if(c!="OR"&c!="AND"&c!="BY"&c!="OF")System.Console.Write(c[0]);}}

```

Try Online
> 0 votes

# Answer
# 05AB1E, 18 bytes

```
lð¡“€ƒ€—€‹€‚“#K€нu

```

Try it online!

```
lð¡“€ƒ€—€‹€‚“#K€нu  # full program
                 u  # convert...
                н   # first character of...
               €    # each element of...
                    # implicit input...
l                   # in lowercase...
  ¡                 # split by...
 ð                  # spaces...
              K     # without any of the elements of...
   “€ƒ€—€‹€‚“       # "and or by of"...
             #      # split by spaces...
                 u  # to uppercase
                    # implicit output

```
> 0 votes

# Answer
# Scala, 68 bytes

```
_.toUpperCase.replaceAll("\\b(AND|OR|BY|OF) ?|(?<=\\b\\w)\\w+ ?","")

```

Try it online!

Not the most creative answer ever.

### Without regex, 75 bytes

```
_.toUpperCase split " "filterNot Set("AND","OR","OF","BY")map(_(0))mkString

```

Scastie
> 0 votes

# Answer
# Factor, 47 bytes

```
[ >upper R/ AND|OF|OR|BY|\B.| |/ ""re-replace ]

```

Try it online!
> 0 votes

# Answer
# Thunno 2, 16 bytes

```
RO“œẆḶuıdƓ“ROṗ€h

```

Try it online!

#### Explanation

```
RO“œẆḶuıdƓ“ROṗ€h  # Implicit input
RO                # Uppercase and split on spaces
  “œẆḶuıdƓ“       # Compressed string "and or by of"
           RO     # Uppercase and split on spaces
             ṗ    # Remove these words
              €h  # First character of each
                  # Implicit output

```
> 0 votes

# Answer
# Pip, 26 bytes

```
@_M_N"OROFBYAND"CH4FNUCa^s

```

Takes the string as a command-line argument. Attempt This Online!

A version that takes each word as a separate command-line argument would be **24 bytes** (replace `a^s` at the end with `g`). This *might* meet the spec, since the invocation would look something like:

```
pip.py acronym.pip United states of America

```

Try It Online!

### Explanation

```
@_M_N"OROFBYAND"CH4FNUCa^s
                       a   ; Command-line argument
                     UC    ; Uppercase
                        ^s ; Split on spaces
                   FN      ; Filter, keeping elements for which this function is falsey:
     "OROFBYAND"           ;   Take that string
                CH4        ;   Chop it into 4 pieces: ["OR";"OF";"BY";"AND"]
   _N                      ;   Is the argument in that list?
  M                        ; Map this function to each remaining string:
@_                         ;   Get the first character
                           ; Join and autoprint (implicit)

```
> 0 votes

---
Tags: code-golf, string
---