text:
When I grow up I want to be ASCII
Task
Your task is to take a character in:
AÁÀÃÂBCÇDEÉÊFGHIÍJKLMNOÕÓÔPQRSTUÚVWXYZaáàãâbcçdeéêfghiíjklmnoõóôpqrstuúvwxyz
and turn it into a characters in:
AAAAABCCDEEEFGHIIJKLMNOOOOPQRSTUUVWXYZaaaaabccdeeefghiijklmnoooopqrstuuvwxyz
by the obvious operation: dropping the accents in the letters.
Input
A character in any sensible format, including but not limited to:

A string with only one character;
A unicode codepoint.

Output
The transformed char in any sensible format, which includes:

A string with only one char;
A unicode codepoint.

Test cases
'A' -> 'A'
'Á' -> 'A'
'À' -> 'A'
'Ã' -> 'A'
'Â' -> 'A'
'B' -> 'B'
'C' -> 'C'
'Ç' -> 'C'
'D' -> 'D'
'E' -> 'E'
'É' -> 'E'
'Ê' -> 'E'
'F' -> 'F'
'G' -> 'G'
'H' -> 'H'
'I' -> 'I'
'Í' -> 'I'
'J' -> 'J'
'K' -> 'K'
'L' -> 'L'
'M' -> 'M'
'N' -> 'N'
'O' -> 'O'
'Õ' -> 'O'
'Ó' -> 'O'
'Ô' -> 'O'
'P' -> 'P'
'Q' -> 'Q'
'R' -> 'R'
'S' -> 'S'
'T' -> 'T'
'U' -> 'U'
'Ú' -> 'U'
'V' -> 'V'
'W' -> 'W'
'X' -> 'X'
'Y' -> 'Y'
'Z' -> 'Z'
'a' -> 'a'
'á' -> 'a'
'à' -> 'a'
'ã' -> 'a'
'â' -> 'a'
'b' -> 'b'
'c' -> 'c'
'ç' -> 'c'
'd' -> 'd'
'e' -> 'e'
'é' -> 'e'
'ê' -> 'e'
'f' -> 'f'
'g' -> 'g'
'h' -> 'h'
'i' -> 'i'
'í' -> 'i'
'j' -> 'j'
'k' -> 'k'
'l' -> 'l'
'm' -> 'm'
'n' -> 'n'
'o' -> 'o'
'õ' -> 'o'
'ó' -> 'o'
'ô' -> 'o'
'p' -> 'p'
'q' -> 'q'
'r' -> 'r'
's' -> 's'
't' -> 't'
'u' -> 'u'
'ú' -> 'u'
'v' -> 'v'
'w' -> 'w'
'x' -> 'x'
'y' -> 'y'
'z' -> 'z'

You can check here for a Python reference implementation without regexes.

This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it... And happy golfing!

@a'_' ç isn't a vowel, so it boils down to accented vowels and ç

@a'_'  I think the input section is clear enough. "A character in any sensible format"

Āåčşğ and such omitted intentionally?

@WGroleau we don't use those in Portuguese, that is why those were omitted.

So it's basically a Z̵̡̛̘͈̠̼̭̮̝̳͖̲̝͔̟̏̾́̄̈̒͆͛̆̑ä̶̮̠̖̟̮̭̀l̴͇̹̺̬̎͆g̷̨̧̗͍̲̤͔͊̈́̈́͋̉͗͐̈́̄̅̌͠͝͝͝ơ̸̡̲̳͓͙̗̰͇̦̂͐̒̈́̈̇͒ cleaner?

@DarrelHoffman yes

Is doing web requests allowed? I already know a website that does this: https://lingojam.com/GlitchTextGenerator ;) Edit: It doesn't actually work for this challenge, just for the "Zalgo" above. But it wasn't really meant seriously anyway.

@FabianRöling historically, no, unless the problem specifically asks you to interact with an external resource your answer should work on its own (with reasonable things included like stdlib obviously)

JavaScript (Node.js), 39 bytes
A port of my CP-1610 answer.
I/O format: a Unicode code point.
n=>n>>7?Buffer("ACEIOOU")[n/4&7]^n&32:n

Try it online!

JavaScript (Node.js), 44 bytes
I/O format: a string with only one character.
c=>'oeaUICuic?OEA'[Buffer(c)[1]*13%59%13]||c

Try it online!
How?
When passed into Buffer(), the accented letters used in the challenge are turned into two bytes \$(b_0,b_1)\$, corresponding to their UTF-8 encoding. The non-accented letters are turned into a single byte \$b_0\$ corresponding to their regular ASCII code (or 1-byte UTF-8 encoding).
Examples:
Buffer('À') // --> <Buffer c3 80>
Buffer('B') // --> <Buffer 42>

Try it online!
We use the following formula to convert the 2nd byte of accented letters to an index \$n\$ into a 13-character lookup string of non-accented letters:
$$n=((b_1\times13)\bmod 59)\bmod 13$$
This results in NaN for non-accented letters, which are simply left unchanged.
  c  |   UTF-8    | 2nd byte | * 13 | mod 59 | mod 13 | output
-----+------------+----------+------+--------+--------+--------
 'À' | 0xC3, 0x80 |    128   | 1664 |   12   |   12   |  'A'
 'Á' | 0xC3, 0x81 |    129   | 1677 |   25   |   12   |  'A'
 'Â' | 0xC3, 0x82 |    130   | 1690 |   38   |   12   |  'A'
 'Ã' | 0xC3, 0x83 |    131   | 1703 |   51   |   12   |  'A'
 'Ç' | 0xC3, 0x87 |    135   | 1755 |   44   |    5   |  'C'
 'É' | 0xC3, 0x89 |    137   | 1781 |   11   |   11   |  'E'
 'Ê' | 0xC3, 0x8A |    138   | 1794 |   24   |   11   |  'E'
 'Í' | 0xC3, 0x8D |    141   | 1833 |    4   |    4   |  'I'
 'Ó' | 0xC3, 0x93 |    147   | 1911 |   23   |   10   |  'O'
 'Ô' | 0xC3, 0x94 |    148   | 1924 |   36   |   10   |  'O'
 'Õ' | 0xC3, 0x95 |    149   | 1937 |   49   |   10   |  'O'
 'Ú' | 0xC3, 0x9A |    154   | 2002 |   55   |    3   |  'U'
 'à' | 0xC3, 0xA0 |    160   | 2080 |   15   |    2   |  'a'
 'á' | 0xC3, 0xA1 |    161   | 2093 |   28   |    2   |  'a'
 'â' | 0xC3, 0xA2 |    162   | 2106 |   41   |    2   |  'a'
 'ã' | 0xC3, 0xA3 |    163   | 2119 |   54   |    2   |  'a'
 'ç' | 0xC3, 0xA7 |    167   | 2171 |   47   |    8   |  'c'
 'é' | 0xC3, 0xA9 |    169   | 2197 |   14   |    1   |  'e'
 'ê' | 0xC3, 0xAA |    170   | 2210 |   27   |    1   |  'e'
 'í' | 0xC3, 0xAD |    173   | 2249 |    7   |    7   |  'i'
 'ó' | 0xC3, 0xB3 |    179   | 2327 |   26   |    0   |  'o'
 'ô' | 0xC3, 0xB4 |    180   | 2340 |   39   |    0   |  'o'
 'õ' | 0xC3, 0xB5 |    181   | 2353 |   52   |    0   |  'o'
 'ú' | 0xC3, 0xBA |    186   | 2418 |   58   |    6   |  'u'

PHP, 42 39 34 bytes
<?=iconv('','us//TRANSLIT',$argn);

-3 Bytes thanks to @Neil
Try it online!

Welcome to Code Golf! This is a nice first answer.

JavaScript (Node.js), 22 bytes
s=>s.normalize`NFD`[0]

Try it online!
save 2 bytes, thanks Arnauld.

T-SQL, 35 33 bytes
SELECT v COLLATE Greek_BIN FROM t

Input is taken from a pre-existing table t with CHAR(1) column v, per our IO standards.
This code simply displays the input after converting it to a different SQL collation.
SQL collations define sorting rules as well as case and accent sensitivity properties for SQL text data. They can even define the valid code page, which is how this particular trick works. Code page 1253 ("Greek - ANSI") doesn't include any of the accented characters in the question, so the collation conversion maps each to its non-accented version.
I based my version on this StackOverflow answer, which uses a more standard collation with a much longer name: SQL_Latin1_General_CP1253_CI_AI.
EDIT: Saved 2 bytes by replacing Greek_CS_AI with Greek_BIN. Both use code page 1253, which is really the part that matters, not the "accent insensitive" property.
SQL supports nearly 4000 collations, run this on your SQL server to return all collations that use code page 1253, ordered by the shortest name:
SELECT name, bytes=len(name), description, codepage=COLLATIONPROPERTY(name, 'CodePage')
FROM fn_helpcollations()
WHERE COLLATIONPROPERTY(name, 'CodePage') = 1253
ORDER BY len(name)

It is possible to replace characters individually, but that is much longer (79 Bytes):
SELECT TRANSLATE(v,'ÁÀÃÂÇÉÊÍÕÓÔÚáàãâçéêíõóôú','AAAACEEIOOOUaaaaceeiooou')FROM t

iconv, 21 20 bytes
iconv -tus//TRANSLIT

Try it online! Link includes test suite. Edit: Thanks to @NahuelFouilleul for a 1 byte saving. Port of @Oxgeba's PHP answer, but I used us as a synonym for ASCII to save a further 3 bytes.

Just posted this as a bash answer only to see you've done it already and better! +1 :-)

could save one byte removing the space after -t

05AB1E (legacy), 24 23 22 bytes
žy›i•M¦>á•₂вI28&èI96&+

-2 bytes thanks to @Grimmy.
I/O as unicode codepoint.
Try it online.
Explanation:
žy›i             # If the (implicit) input-codepoint is larger than 128:
    •M¦>á•       #  Push compressed integer 3755486693
          ₂в     #  Convert it to base-26 as list: [1,5,15,21,3,9,15]
    I28&         #  Push the input-codepoint, and bitwise-AND it with 28
        è        #  Index it into the list (0-based and with wraparound)
         I96&    #  Push the input-codepoint, and bitwise-AND it with 96
             +   #  And add it to the indexed value
                 #  (after which it is output implicitly as result)
                 # (implicit else:)
                 #  (take the implicit input-codepoint as implicit output)

See this 05AB1E tip of mine (sections How to compress large integers? and How to compress integer lists?) to understand why •M¦>á• is 3755486693 and •M¦>á•₂в is [1,5,15,21,3,9,15].

Python 3, 61 56 bytes
lambda s:s[s>'z':]or'EIOOUaaceioou_AAC'[ord(s)*17%67%17]

Try it online!

Python 3.8 (pre-release), 76 74 bytes
lambda s:(n:=name(s)*2)[21::-2].title()['SM'in n]
from unicodedata import*

Try it online!
Examples
s                               'À'
name(s)                         'LATIN CAPITAL LETTER A WITH GRAVE'
name(s)*2                       'LATIN CAPITAL LETTER A WITH GRAVELATIN CAPITAL LETTER A WITH GRAVE'
                                  ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
(name(s)*2)[21::-2]             'ARTE AIA IA'
(name(s)*2)[21::-2].title()     'Arte Aia Ia'
'SM' in name(s)*2 ==            False == 0
(name(s)*2)[21::-2].title()[0]  'A'

s                               'À'
name(s)                         'LATIN SMALL LETTER C WITH CEDILLA'
name(s)*2                       'LATIN SMALL LETTER C WITH CEDILLALATIN SMALL LETTER C WITH CEDILLA'
                                  ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
(name(s)*2)[21::-2]             'WCRTE LM IA'
(name(s)*2)[21::-2].title()     'Wcrte Lm Ia'
'SM' in name(s)*2               True == 1
(name(s)*2)[21::-2].title()[1]  'c'

Python 3, 55 bytes
Basically the same as tsh's JavaScript answer.
lambda s:normalize('NFD',s)[0]
from unicodedata import*

Try it online!

CP-1610 machine code,  27 26 22  21 DECLEs1 ≈ 27 bytes
As per the exception described in this meta answer, the exact score is 26.25 bytes (210 bits)
A routine taking a Unicode code point in R0 and returning another code point in the same register.
081             |         MOVR    R0,     R1
045             |         SWAP    R1,     2
203 009         |         BPL     @@rtn
065             |         SLR     R1,     2
3B9 007         |         ANDI    #7,     R1
0F9             |         ADDR    R7,     R1
2F9 006         |         ADDI    #6,     R1
3B8 020         |         ANDI    #32,    R0
3C8             |         XOR@    R1,     R0
0AF             | @@rtn   JR      R5
041 043 045 049 |         STRING  "ACEIOOU"
04F 04F 055     |

How?
All the special characters we're interested in are located in the 0xC0-0xFF Unicode range.
full range        relevant letters  replacement

   | 0123 4567       | 0123 4567       | 0123 4567
---+----------    ---+----------    ---+----------
C0 | ÀÁÂÃ ÄÅÆÇ    C0 | ÀÁÂÃ ---Ç    C0 | AAAA ---C
C8 | ÈÉÊË ÌÍÎÏ    C8 | -ÉÊ- -Í--    C8 | -EE- -I--
D0 | ÐÑÒÓ ÔÕÖ×    D0 | ---Ó ÔÕ--    D0 | ---O OO--
D8 | ØÙÚÛ ÜÝÞß    D8 | --Ú- ----    D8 | --U- ----
E0 | àáâã äåæç    E0 | àáâã ---ç    E0 | aaaa ---c
E8 | èéêë ìíîï    E8 | -éê- -í--    E8 | -ee- -i--
F0 | ðñòó ôõö÷    F0 | ---ó ôõ--    F0 | ---o oo--
F8 | øùúû üýþÿ    F8 | --ú- ----    F8 | --u- ----

As shown in the tables above, each group of \$4\$ accented letters is mapped to a single non-accented letter. So, given a code point \$n\$, we compute the index:
$$i=\left\lfloor\frac{n}{4}\right\rfloor\bmod 8$$
We pick the corresponding letter from the lookup string "ACEIOOU" and then apply the correct case.
Full commented test code
        ROMW    10                ; use 10-bit ROM width
        ORG     $4800             ; map this program at $4800

        ;; ------------------------------------------------------------- ;;
        ;;  main code                                                    ;;
        ;; ------------------------------------------------------------- ;;
main    PROC

        SDBD                      ; set up an interrupt service routine
        MVII    #isr,   R0        ; to do some minimal STIC initialization
        MVO     R0,     $100
        SWAP    R0
        MVO     R0,     $101

        EIS                       ; enable interrupts

        SDBD                      ; R4 = pointer into the test case table
        MVII    #tc,    R4
        MVII    #$200,  R3        ; R3 = backtab pointer
        MVII    #76,    R2        ; R2 = number of test cases

@@loop  MVI@    R4,     R0        ; R0 = character code point
        CALL    conv              ; invoke our routine

        SUBI    #32,    R0        ; turn the result into an Intellivision card
        SLL     R0,     2
        SLL     R0
        MVO@    R0,     R3        ; draw it
        INCR    R3                ; increment the backtab pointer

        DECR    R2                ; next test case
        BNEQ    @@loop

        DECR    R7                ; done: loop forever

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  test cases                                                   ;;
        ;; ------------------------------------------------------------- ;;
tc      PROC

        DECLE   65   ; A
        DECLE   193  ; Á
        DECLE   192  ; À
        DECLE   195  ; Ã
        DECLE   194  ; Â
        DECLE   66   ; B
        DECLE   67   ; C
        DECLE   199  ; Ç
        DECLE   68   ; D
        DECLE   69   ; E
        DECLE   201  ; É
        DECLE   202  ; Ê
        DECLE   70   ; F
        DECLE   71   ; G
        DECLE   72   ; H
        DECLE   73   ; I
        DECLE   205  ; Í
        DECLE   74   ; J
        DECLE   75   ; K
        DECLE   76   ; L
        DECLE   77   ; M
        DECLE   78   ; N
        DECLE   79   ; O
        DECLE   213  ; Õ
        DECLE   211  ; Ó
        DECLE   212  ; Ô
        DECLE   80   ; P
        DECLE   81   ; Q
        DECLE   82   ; R
        DECLE   83   ; S
        DECLE   84   ; T
        DECLE   85   ; U
        DECLE   218  ; Ú
        DECLE   86   ; V
        DECLE   87   ; W
        DECLE   88   ; X
        DECLE   89   ; Y
        DECLE   90   ; Z
        DECLE   97   ; a
        DECLE   225  ; á
        DECLE   224  ; à
        DECLE   227  ; ã
        DECLE   226  ; â
        DECLE   98   ; b
        DECLE   99   ; c
        DECLE   231  ; ç
        DECLE   100  ; d
        DECLE   101  ; e
        DECLE   233  ; é
        DECLE   234  ; ê
        DECLE   102  ; f
        DECLE   103  ; g
        DECLE   104  ; h
        DECLE   105  ; i
        DECLE   237  ; í
        DECLE   106  ; j
        DECLE   107  ; k
        DECLE   108  ; l
        DECLE   109  ; m
        DECLE   110  ; n
        DECLE   111  ; o
        DECLE   245  ; õ
        DECLE   243  ; ó
        DECLE   244  ; ô
        DECLE   112  ; p
        DECLE   113  ; q
        DECLE   114  ; r
        DECLE   115  ; s
        DECLE   116  ; t
        DECLE   117  ; u
        DECLE   250  ; ú
        DECLE   118  ; v
        DECLE   119  ; w
        DECLE   120  ; x
        DECLE   121  ; y
        DECLE   122  ; z

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  ISR                                                          ;;
        ;; ------------------------------------------------------------- ;;
isr     PROC

        MVO     R0,     $0020     ; enable display

        CLRR    R0
        MVO     R0,     $0030     ; no horizontal delay
        MVO     R0,     $0031     ; no vertical delay
        MVO     R0,     $0032     ; no border extension
        MVII    #$D,    R0
        MVO     R0,     $0028     ; light-blue background
        MVO     R0,     $002C     ; light-blue border

        JR      R5                ; return from ISR

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  our routine                                                  ;;
        ;; ------------------------------------------------------------- ;;
conv    PROC

        MOVR    R0,     R1        ; copy R0 to R1
        SWAP    R1,     2         ; copy the lower byte of R1 to its upper byte,
                                  ; resulting in a negative word for an accented letter
        BPL     @@rtn             ; return right away if it's a regular ASCII character

        SLR     R1,     2         ; right-shift by 2 positions
        ANDI    #7,     R1        ; isolate the 3 least significant bits
        ADDR    R7,     R1        ; add the address of our lookup string,
        ADDI    #6,     R1        ; computed as PC + 6
        ANDI    #32,    R0        ; isolate the case bit of the original character
        XOR@    R1,     R0        ; XOR it with the non-accented letter

@@rtn   JR      R5                ; return

        STRING  "ACEIOOU"         ; lookup string

        ENDP

Output

screenshot from jzIntv

1. A CP-1610 opcode is encoded with a 10-bit value (0x000 to 0x3FF), known as a 'DECLE'.

C (gcc), 37 bytes
A port of my CP-1610 answer.
I/O format: a Unicode code point.
f(n){n=n>>7?"ACEIOOU"[n/4&7]^n&32:n;}

Try it online!

C (gcc), 45 bytes
I/O format: a Unicode code point.
f(n){n=n>>7?"ooieca?UOOIECAu"[n*15%61%15]:n;}

Try it online!

Ruby, 41 bytes
->c{c<?~?c:"ACEIOOUxaceioou"[c.ord/4%16]}

Try it online!

PHP 5.4+, 32 bytes
This uses the htmlentities() function to return the HTML entity for the character.
<?=htmlentities($argn.$argn)[1];

For the "AÁÀÃÂ" (Ä is missing from the list), it returns "AÁÀÃÂ".
Do you see a problem? The character I want is on position 0 or 1.
So, I just duplicate the input. Problem solved!
You can try this on http://sandbox.onlinephpfunctions.com/code/690dbfcff4c6dec4170954333c62b9b472eaaa93

Can you consider adding a TIO link or a screenshot if such a link doesn't work? :D

@RGS I've added a link to where you can try it. Just make sure you pick PHP 5.4 or higher.

thanks a lot! At first the code wasn't working, but then I realized it was because of the arrow you wrote in front of the command argument. Thanks for the link and for the interesting submission.

I've updated the link. And thank you.

Java 8, 85 70 47 39 bytes
c->c>122?"ACEIOOU".charAt(c/4&7)^c&32:c

-46 bytes by creating a port of @Arnauld's C answer, so make sure to upvote him!
Try it online.
Original answer (85 bytes):
import java.text.*;c->(char)Normalizer.normalize(c,Normalizer.Form.NFD).getBytes()[0]

Try it online.
Explanation:
c->                         // Method with character as both parameter and return-type
  c>122?                    //  If the character isn't a regular letter:
   "ACEIOOU".charAt(        //   Get the character in String "ACEIOOU" at index:
     c/4&7)                 //    c integer-divided by 4 and then bitwise-ANDed by 7
    ^c&32                   //   And convert it to lowercase if the input was lowercase
  :                         //  Else (it is a regular letter):
   c                        //   Simply return the input as is

import java.text.*;         // Required import for both Normalizer
c->                         // Method with String as parameter and character as return-type
 (char)                     //  Convert the following byte to a character:
   Normalizer.normalize(c,  //   Normalize the input-String,
     Normalizer.Form.NFD)   //   using canonical decomposition
   .getBytes())             //   Convert that to a byte-array (UTF-8 encoding by default)
     [0]                    //   And only leave the first byte

Turing Machine Code, 796 286 bytes
0 * * r 0
0 Á A r 0
0 À A r 0
0 Ã A r 0
0 Â A r 0
0 Ç C r 0
0 É E r 0
0 Ê E r 0
0 Í I r 0
0 Õ O r 0
0 Ó O r 0
0 Ô O r 0
0 Ú U r 0
0 á a r 0
0 à a r 0
0 ã a r 0
0 â a r 0
0 ç c r 0
0 é e r 0
0 ê e r 0
0 í i r 0
0 õ o r 0
0 ó o r 0
0 ô o r 0
0 ú u r 0
0 _ _ * halt

Try it online!
Saved an incredible 510 bytes thanks to @ovs! That might be some kind of record here on Code Golf.

You can remove all the lines doing no changes and add 0 * * r 0.

@ovs, Oustanding spot. Just give me a moment....

Perl 6 Raku, 15 14 bytes
*.samemark(~0)

Try it online!
Returns the string with the same marks/accents as the number 0, i.e. remove all marks.

I see Perl has some interesting functions

Wolfram Language (Mathematica), 16 bytes
Mathematics is not the only field Mathematica has built-ins for...
RemoveDiacritics

Try it online! (all the characters are in a single string in the link, but it obviously works character-by-character)
Sledgehammer, 4 bytes
⣕⠬⣠⢹

Corresponds to the code RemoveDiacritics@Input[].

R, 34 32 bytes
-2 thanks to Giuseppe
iconv(scan(,''),,"us//TRANSLIT")

Try it online!

05AB1E, 53 bytes
-1 thanks to Kevin Cruijssen
"áéíõúÁÉÍÕÚàêióuÀÊIÓUãeiôuÃEIÔUâeiouÂEIOUÇç"žÀ4×„Cc«‡

Try it online!
Explanation
"áéíõúÁÉÍÕÚàêióuÀÊIÓUãeiôuÃEIÔUâeiouÂEIOUÇç" A huge lookup table of the unicode characters

žÀ        Push "aeiouAEIOU"
  4×      Repeat it 4 times
    „Cc«  Concatenate "Cc" to the string
        ‡ Transliterate input
```

иJ to × for -1

Python 2, 141 bytes
o='';i=input()
for x in'AÁÀÃÂ CÇ EÉÊ IÍ OÕÓÔ UÚ aáàãâ cç eéê ií oõóô uú'.split():
 if i in x:o=x[0]
print(o,i)[o=='']

Try it online!
Just a simple lookup without any imports. If it finds a "special" character it prints the first character in the string where it is found otherwise just prints the input.

C (gcc), 61 59 bytes
g(char*w){w=*w+61?*w:"oeaUICuic OEA"[(256+w[1])*13%59%13];}

Try it online!
Uses Arnauld's formula from his JavaScript answer.

Perl 6, 30 bytes
{{S/W.+//}(.uniname).uniparse}

Try it online!

Some quick rearranging for 27 bytes

Bash + Core utilities, 40 32 bytes
iconv -f utf8 -t ascii//TRANSLIT

Try it online!

Perl 5 -pC -MUnicode::Normalize=NFD, 17 bytes
$_=NFD$_;s/\pM//g

Try it online!

Japt, 23 bytes
A port of Arnauld's JS solution. I/O as codepoints.
Á7?H&U^`aÅ8`u cU/4&7:U

Try it

C# (Visual C# Interactive Compiler), 39 bytes
x=>x.Normalize((NormalizationForm)2)[0]

Try it online!

I don't think the [0] is necessary.

Retina 0.8.2, 72 bytes (53 characters)
T`À-ÃÇÉÊÍÓ-ÕÚà-ãçéêíúó-õ`AAAAC\E\EI\O\O\OUaaaaceeiu\o

Try it online! Link includes test cases. Explanation: The Transliterate command has some special characters E, O and o, so these need to be quoted. To avoid repetition, the os are processed last as the last character in the replacement string is automatically repeated. The remaining repetition is one byte less than the overhead of the T command; compare this 72-byte 58-character alternative (which also corrupts eth and n with tilde):
T`ÚÀ-Ã`UA
T`Ç-Ê`C\E
T`Í-Õ`I\O
T`úà-ã`ua
T`ç-ê`ce
T`í-õ`i\o

perl -MText::Unidecode -pC -e, 14 bytes
$_=unidecode$_

Can you please include a TIO link for your solution? Thanks!!!

Nim, 45 bytes
import unidecode
echo stdin.readAll.unidecode

Try it online!

PowerShell Core, 17 bytes
($args|% N* 2)[0]

Try it online!
Inspired by the C# answer, thanks Gymhgy!
Takes the input as a string.
Could be shorten down to 14 bytes using a filter, but I don't think it is allowed?

Vyxal, 82 bytes / 53 chars
`áéíõúÁÉÍÕÚàêióuÀÊIÓUãeiôuÃEIÔUâeiouÂEIOUÇç`k∨4*‛Cc+Ŀ

Try it Online!
The bad version, I can't figure out how to port any of the good ones.

Many of these characters are not in the Vyxal codepage, which means this cannot be encoded using the codepage. You'll have to use UTF-8, where the program takes 82 bytes.

Vyxal, 18 bytes
»æ₁s≥»₄τ?28⋏i?96⋏+

Try it Online!

Jelly, 24 bytes
:4ị“CEIOOU A‘^&32$µ>Ø⁷$¡

Try it online!
Another port of Arnauld's technique, using codepoint I/O.
Jelly, 24 bytes
&28ị“¦Ðß¤µÐ¢‘+&96$µ>Ø⁷$¡

Try it online!
Porting Kevin Cruijssen's 05AB1E solution seems to come out to the same length, but it doesn't feel ungolfable.
Using unicodedata comes out considerably longer, if anyone was wondering:
Jelly, 37 bytes
“¦DSƥ4ṖĿẹṁɦ~73°Ñƙ€YḄuḃRṙæṪB\æ“œþ»jŒVḢ

Try it online!


text:
Generate A298757
Miller-Rabin test
Given a base \$b\$ and an odd number \$n\$:
Write \$n\$ as \$2^{s}\times d + 1\$ where \$d\$ is odd
\$n\$ is a strong probable prime if either:

\$b^d\equiv 1 \pmod n\$
\$b^{d\cdot2^r}\equiv -1 \pmod n\$

for any non-negative \$r\$ strictly less than \$s\$.
A  strong probable prime which is composite is a pseudoprime.
See en.wikipedia.org/wiki/Strong_pseudoprime for more information.
Challenge
Make a script that generates very good bases (bases, \$b\$, for which the first pseudoprime is larger than with any smaller base).
Additional rules

Your script should be as fast as possible.
Your script should not use a lookup table (for the output, lookup table for primes is fine).
You may use external libraries as long as that library is written in the same language.
Speed will be measured in terms of how many terms it can generate in 1 min.

Python implementation of the Miller-Rabin test
def miller(n, b):
    if n % 2 == 0:
        return n == 2
    d = n - 1
    s = 0
    while d % 2 == 0:
        d >>= 1
        s += 1
    if pow(b, d, n) == 1:
        return True
    elif any(pow(b, d * 2 ** r, n) == n - 1 for r in range(s)):
        return True
    return False

An entry is valid if it will never stop producing better bases and it won't produce a base worse than it has generated before.
Example of a valid python entry:
from sympy import isprime
base = 2
record = 2
while True:
    number = 9
    while True:
        while isprime(number):
            number += 2
        if miller(number, base):
            if number > record:
                record = number
                print(base)
            break
        number += 2
    base += 1

Little over 20 sec to generate:
2
1320
4712
5628
7252
7852
14787
17340
61380
78750

My code generates the above in ca. 20 sec on my laptop, and generates one more term in 72 sec. so the score is 10 terms.
Arnauld pointed out that the challenge is just to generate A298757.
Sympy's isprime is not the problem as it runs in less than .5 sec for 700 digit numbers.
Edit:
I didn't mean to give advantage to specific languages like C, so I will convert them to python.

not accepting answers is a consequence of a question being closed, not a reason explaining why it was closed. Once a question is clarified and re-opened, users are allowed to answer it again.

The appropriate action when your question is closed is not to delete it and repost it. You should have edited your previous post and waited for it to be reopened. After doing some tests I came to the same conclusion that the prime test was not the most significant factor for small inputs, though I'd still be worried it would dominate for larger values. Regardless, please spend some time reading the help centre so you are more aware of what the purpose of this site is. Also consider using our sandbox.

@FryAmTheEggman Thank you for explaining, English is not my native language and I may have misinterpreted the reason. Btw, sympy uses a baillie PSW test so even for 700 digit numbers it takes less than 0.2 sec, so it won't dominate for values that my implementation above will ever deal with.

"Edit: I didn't mean to give advantage to specific languages like C, so I will convert them to python.", no, that's terrible. C and C++ should be allowed to use processor-specific features. If someone writes a solution in some esoteric language, I'm sure as hell that you won't be able to convert it into Python, and most likely they won't be able to either.

Voting to close as unclear per @S.S.Anne's comment

Rust, \$n = 15\$
use std::collections::VecDeque;

fn miller(n: u64, mut b: u64) -> bool {
    let s = (n - 1).trailing_zeros();
    let mut t = n - 1 >> s;
    b %= n;
    let mut a = b;
    while t != 1 {
        b = b * b % n;
        t >>= 1;
        if t & 1 != 0 {
            a = a * b % n;
        }
    }
    if a == 1 || a == n - 1 {
        return true;
    }
    for _ in 1..s {
        a = a * a % n;
        if a == n - 1 {
            return true;
        }
        if a == 1 {
            return false;
        }
    }
    return false;
}

fn main() {
    let mut record = 2;
    let mut factor = VecDeque::new();

    for base in 2.. {
        factor.clear();
        let mut q = 3;
        let mut qq = q * q;
        for n in (9..).step_by(2) {
            let mut p = factor.pop_front().unwrap_or(0);

            if n == qq {
                if p == 0 {
                    p = q;
                }
                q += 2;
                qq = q * q;
            } else if p == 0 {
                continue;
            }

            if miller(n as u64, base) {
                if n > record {
                    println!("{}", base);
                    record = n;
                }
                break;
            }

            let mut m = p - 1;
            while *factor.get(m).unwrap_or(&0) != 0 {
                m += p;
            }
            if factor.len() < m + 1 {
                factor.resize(m + 1, 0);
            }
            factor[m] = p;
        }
    }
}

Try it online!

It seems like Rust is good at these fastest-code challenges.

Either Rust or Anders Kaseorg...or both :)

JavaScript (Node.js), \$n=15\$
This is essentially just a port of the example implementation, with an optimized modular exponentiation and a cache for odd composite numbers.
Further optimized by merging powMod() and miller(), as Anders Kaseorg first did.
function miller(n, b) {
  let s = 31 - Math.clz32(n - 1 & 1 - n);
  let t = n - 1 >> s;
  let k = b %= n;

  while(t != 1) {
    b = (b * b) % n;

    if((t >>= 1) & 1) {
      k = (k * b) % n;
    }
  }
  if(k == 1 || k == n - 1) {
    return true;
  }
  while(k != 1 && --s) {
    if((k = (k * k) % n) == n - 1) {
      return true;
    }
  }
  return false;
}

function isPrime(n) {
  let m = n ** 0.5;

  for(let d = 3; d <= m; d += 2) {
    if(!(n % d)) {
      return false;
    }
  }
  return true;
}

function nthOddComposite(n) {
  if(n < oddComposite.length) {
    return oddComposite[n];
  }

  let k;

  for(k = oddComposite[oddComposite.length - 1]; isPrime(k += 2);) {}
  oddComposite.push(k);

  return k;
}

let oddComposite = [ 9 ];
let ts = +new Date();

for(let i = 0, record = base = 2;; base++) {
  for(let j = 0;; j++) {
    number = nthOddComposite(j);

    if(miller(number, base)) {
      if(number > record) {
        record = number;
        console.log(
          ++i + '\tbase = ' + base + '\ttime = ' + ((new Date() - ts) / 1000).toFixed(2)
        );
      }
      break;
    }
  }
}

Try it online! (this TIO link has \$n\le15\$ as a hard-coded limit)
Output
1       base = 2        time = 0.00
2       base = 1320     time = 0.02
3       base = 4712     time = 0.03
4       base = 5628     time = 0.04
5       base = 7252     time = 0.04
6       base = 7852     time = 0.05
7       base = 14787    time = 0.07
8       base = 17340    time = 0.07
9       base = 61380    time = 0.18
10      base = 78750    time = 0.22
11      base = 254923   time = 0.62
12      base = 486605   time = 1.14
13      base = 1804842  time = 4.05
14      base = 4095086  time = 9.13
15      base = 12772344 time = 28.41
--------------------------------------> time limit
16      base = 42162995 time = 94.23

C++ (clang), \$n=14\$
#include <iostream>
#include <cmath>
#include <chrono>
#include <iomanip>

template <typename I>
bool isPrime(I n)
{
    if (n < 2) {
        return false;
    }
    if (n == 2 || n == 3) {
        return true;
    }
    if (n % 2 == 0 || n % 3 == 0) {
        return false;
    }
    I srt = std::sqrt(n);
    int inc = 4;
    for (I i = static_cast<I>(5); i <= srt; i += inc)
    {
        if (n % i == 0) {
            return false;
        }
        inc = 6 - inc;
    }
    return true;
}

template <typename I>
I pow(I base, I exp, I mod)
{
    I result = 1;
    for (;;)
    {
        if (exp & 1) {
            result = (result * base) % mod;
        }
        exp >>= 1;
        if (!exp) {
            break;
        }
        base = (base * base) % mod;
    }
    return result;
}

template <typename I>
bool miller(I n, I b)
{
    if (n % 2 == 0) return n == 2;
    I d = n - 1;
    I s = 0;
    while (d % 2 == 0)
    {
        d >>= 1;
        s += 1;
    }
    if (pow<I>(b, d, n) == 1)
    {
        return true;
    }
    else
    {
        for (int r = 0; r < s; ++r) {
            if (pow<I>(b, d * (1 << r), n) == n - 1) {
                return true;
            }
        }
    }
    return false;
}

template <typename I>
void genBase()
{
    auto start = std::chrono::steady_clock::now();
    I base = 2;
    I record = 2;
    int count = 0;
    while (true)
    {
        I number = 9;
        while (true)
        {
            while (isPrime(number))
            {
                number += 2;
            }
            if (miller(number, base))
            {
                if (number > record)
                {
                    record = number;
                    auto now = std::chrono::steady_clock::now();
                    auto diff = now - start;
                    std::cout << std::setw(3) << ++count << ". " << std::setw(10) << base <<
                        " @ " << std::setprecision(4) << std::chrono::duration<double, std::milli>(diff).count()/1000 << " s\n";
                }
                break;
            }
            number += 2;
        }
        base++;
    }
}

int main(){
    genBase<unsigned long long>();
    return 0;
}

Try it online!
Basically a port of the OP's Python solution.
Output:
 1.          2 @ 0.001043 s
 2.       1320 @ 0.0234 s
 3.       4712 @ 0.06999 s
 4.       5628 @ 0.08394 s
 5.       7252 @ 0.1051 s
 6.       7852 @ 0.117 s
 7.      14787 @ 0.2111 s
 8.      17340 @ 0.244 s
 9.      61380 @ 0.8129 s
10.      78750 @ 1.022 s
11.     254923 @ 3.133 s
12.     486605 @ 5.843 s
13.    1804842 @ 21.69 s
14.    4095086 @ 48.38 s

source: Stack Exchange

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

sort: votes


text:
Bad factorial joke
Sometimes I make bad jokes... And a bad joke I like to make involves interpreting exclamation marks in sentences as the factorial sign.
Task
Your task is to write a program that receives a sentence and applies the factorial joke to the sentence.
The "factorial joke" consists of looking for exclamation marks "!" and doing the factorial of whatever is to the left of it. If the thing to the left is an integer, then the usual factorial is used. If the thing to the left is a word (a sequence of characters in [a-zA-Z], delimited by spaces), then we want to concatenate all of the subsequent prefixes of the word.
E.g. if the word was abcd then abcd! = abcdabcaba.
However, there is an exception, which is when the sentence contains a "1!" or "2!", because 1! = 1 and 2! = 2 and the joke doesn't really work. In these cases, your program can do whatever it wants EXCEPT applying the factorial joke or returning the same sentence.
Input
A sentence with characters in the range [a-zA-Z0-9 !] with the restriction that only one exclamation mark "!" is present and to the right of an integer or a "word". This means you don't have to worry with things as "abc4!" as a word here is defined as a sequence of alphabetical characters delimited by spaces.
Output
The same sentence, but with the factorial joke applied to the word or integer on the left of the exclamation mark.
Test cases
You can find a Python reference implementation here
We lost the match 3 to 0! -> We lost the match 3 to 1
ora bolas! -> ora bolasbolabolbob
give me 4! -> give me 24
I wanted 2! give me 2 -> undefined
Let us build a snowman! -> Let us build a snowmansnowmasnowmsnowsnosns
We are late because it is past 17! -> We are late because it is past 355687428096000
I only have one! -> I only have oneono
I only have 1! -> undefined
Incredible! I have never seen anything like it -> IncredibleIncrediblIncredibIncrediIncredIncreIncrIncInI I have never seen anything like it
What an amazing code golf challenge this is! -> What an amazing code golf challenge this isi
So many test cases! -> So many test casescasecascac
These are actually just 11! -> These are actually just 39916800
No wait! there are 13 -> No waitwaiwaw there are 13

This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it... And happy golfing!

05AB1E, 23 22 26 25 20 bytes
ð¡εD'!åi¨ÐaiηRJë2Lså+!]ðý

+4 bytes for two bug-fixes (+1 in case the input is without spaces; +3 for 0!)
-5 bytes thanks to @Grimmy.
Outputs 2/3 for 1!/2! respectively.
Try it online or verify all test cases.
Explanation:
ð¡                  # Split the (implicit) input-string on spaces
                    # (NOTE: `#` cannot be used here if the input doesn't contain spaces)
  ε                 # Map each part to:
   D                #  Duplicate it
    '!åi           '#  If it contains a "!":
        ¨           #   Remove the last character (the "!")
         D          #   Duplicate it
          !         #   Take the factorial of it (strings remain the same)
           s        #   Swap to get the duplicate value again
            >       #   Increase it by 1 (strings remain the same)
             η      #   Get the prefixes of this string/integer
              R     #   Reverse it
               J    #   And join them together to a single string
                M   #   And then push the largest value on the stack
                    #   (which is either the factorial-integer;
                    #    or the integer+1 if it was 0, 1, or 2;
                    #    otherwise it's the longest string, which is the joined prefixes)
  ]                 # Close both the map and if-statement
   ðý               # And join everything with space delimiter again
                    # (after which the result is output implicitly)

You can unify the alphabetic case with the 1 or 2 case by testing for y! = y. 22.

Alternative 22, featuring 200% more loops.

20 (alternative: ð¡εD'!åi¨D!s>ηRJM]ðý).

@Grimmy Nice approach with the > to cover the edge case 0!! I was trying to just use ! and alike on the strings to get rid of the if-statement, since I knew they're be unaffected, but couldn't really figure it out. PS: I've used your alternative 20-byter, since it was closer to my initial solution.

Python 3.8, 222 \$\cdots\$ 178 176 bytes
Saved 2 bytes thanks to Kevin Cruijssen!!!
Added 2 3 bytes to fix bugs.
Saved 5 bytes thanks to ovs!!!
lambda j:(g:=re.match(r"(.*)\b(\w+)!(.*)",j).group)(1)+(str(math.perm(int(f)))*-~(f in'1 2')if(f:=g(2))[0]<':'else''.join(f[:i]for i in range(len(f),0,-1)))+g(3)
import math,re

Try it online!
Replaces 1! with 11 and 2! with 22.
Ungolfed:
import math,re
def f(j):
 m=re.match(r"(.*)\b(\w+)!(.*)" ,j)
 f=m.group(2)
 if f in ('1','2'):f=''
 if re.match(r"\d+",f):
     f=str(math.factorial(int(f)))
 else:
     f=''.join(f[:i] for i in range(len(f),0,-1))
 return m.group(1)+f+m.group(3)

Why are the imports in your golfed version behind the lambda while in front of the code in the ungolfed version?

@Mast To golf away the header which assigns a name to the lambda. This is standard practice since you save 2 bytes (f=) and you don't need the imports until the function is actually called (in the test code, for instance). The header is f=\  so the function can be called.

JavaScript (ES6),  86 85  80 bytes
Replaces 1! and 2! with 0 ... ¯\_(ツ)_/¯
s=>s.replace(/\w+!/,g=s=>(s=s.slice(0,-1))?1/s?'1006'[s]||s*g(s-1+'#'):s+g(s):s)

Try it online!
How?
Because the callback function of replace() is recursive, it's better to feed it with a single variable \$s\$ to keep the recursive calls short. That's why the ! is captured along with the word preceding it.
The same slice(0,-1) is used to remove the ! on the first iteration and to build the prefixes in case of a string. In order to make the factorial computation compatible with that method, we just have to pad the recursive argument with a random character which is immediately removed by the next iteration.
To deal with the weird edge cases \$1!\$ and \$2!\$, we use the small lookup string '1006' to stop the recursion whenever the value is less than or equal to \$3\$. This way, we have \$0!=1\$, \$3!=6\$ and \$n! = 6\cdot\prod_{k=4}^{n}k\$ for \$n>3\$, but \$1!=2!=0\$ (sic).
Commented
NB: alternate slash symbols used in the regular expression to prevent the syntax highlighting from being broken
s =>                        // s = input string
  s.replace(                // find in s
    ⁄\w+!⁄,                 // a word followed by a '!'
    g = s =>                // g is a recursive function computing the replacement
      (s = s.slice(0, -1))  //   remove the last character from s
                            //   (for the 1st iteration, it removes the '!')
      ?                     //   if the resulting string is not empty:
        1 / s ?             //     if this is a numeric value:
          '1006'[s]         //       0 -> 1, 1 -> 0, 2 -> 0, 3 -> 6
          || s *            //       for all other values, multiply s by
             g(s - 1 + '#') //       the result of a recursive call with s - 1,
                            //       padded with a '#' for the next slice()
        :                   //     else (s is a string):
          s +               //       append s
          g(s)              //       append the result of a recursive call
      :                     //   else (s is empty):
        s                   //     stop recursion
  )                         // end of replace()

How about 9 instead of -~s?

@user41805 -~s also turns $0$ into $1$.

Python 3, 157 155 bytes
Thanks to Noodle9 for -2 bytes.
(*s,w),b=map(str.split,input().split('!'))
w*=1+(w in'1 2')
if'A'>w:
 i=int(w);w=1
 while i:w*=i;i-=1
else:
 d=w[:-1]
 while d:w+=d;d=d[:-1]
print(*s,w,*b)

Try it online!

-3 bytes by removing the w*=1+(w in'1 2') and changing the i=int(w) to i=int(w*-~(w in'1 2')) and an additional -5 bytes by changing the d=w[:-1] and while d:w+=d;d=d[:-1] to d=w and while d:d=d[:-1];w+=d: 147 bytes.

Actually, i=int(w)+(w in'1 2') is an additional -2: 145 bytes

Wolfram Language (Mathematica), 173 bytes
StringRiffle[""<>If[Last@#=="!",If[NumberQ[n=ToExpression[""<>#]],If[n>0&&n<3&&First@#!="0","",ToString@n],Rest@NestList[Most,#,Length@#-1]],#]&/@Characters/@StringSplit@#]&

Try it online!
-2 bytes from @Kevin Cruijssen

Can you change the n==1||n==2 to n>0&&n<3 for -2 bytes, or would there be a possible edge case I'm overlooking preventing this?

Your solution doesn't work for 0!

@RGS fixed . . .

Perl 5 -p -MList::Util=product, 93 bytes
s/(\d+)!/$1?$1>2?product 1..$1:'':1/e;s%(\w+)!%join'',map{substr$1,0,$_}reverse 1..length$1%e

Try it online!

This is based on your answer, but just 87 bytes: sub f{pop=~s/(\d+)!/$1?$1>2?product 1..$1:'':1/er=~s/(\S*)(.)!/$1?$1.$2.f("$1!"):$2/er} but it doesn't work in all perl versions. It works in 5.22 and 5.26, but not 5.28 and 5.30. Don't know why.

Jelly, 22 21 bytes
;”ḟV$¹ƤṖṚƊfØD$?ċ¡€”!K

Try it online!
A full program taking a list of words and printing a string. For the 1 and 2 cases the 1 and 2 are dropped from the output. Saved a byte now that a list of words is permitted input.
Explanation
Ḳ                      | Split at spaces
                ċ¡€”!  | For each word, if it contains a ! then do the following:
           fØD$?       | - If any characters are left after restricting to digits:
     $                 | - Then:
 ;”ḟ                   |   - Append ḟ (which will filter out 1 and 2 at the next step because x! == x)
    V                  |   - Evaluate (i.e. calculate the factorial and then filter out the input number)
          Ɗ            | - Else:
      ¹Ƥ               |   - Prefixes
        Ṗ              |   - Remove last
         Ṛ             |   - Reverse
                     K | Finally, join with spaces

Ruby, 88 85 83 bytes
->s{s.sub(/\S+!/){|z|z<?1?1:z>?9?z.chars.map{z=z.chop}*'':eval([6,*4..z.to_i]*?*)}}

Try it online!

Retina, 70 bytes
' %/!$/&/^[012]!$/(`..
$.(*__
/\D./(^`.
$`
.+
*
_
$.>`$*
~`^
^.$*¶$$.(

Try it online! Link includes test cases. Explanation:
' %

Split the input into words.
/!$/&

Only process words that end in !.
/^[012]!$/(`

If this is 0!, 1! or 2!...
..
$.(*__

... then return the incremented digit. (Approach shamelessly stolen from @Arnauld.)
/\D./(

If the word contains a non-digit (excluding the trailing !)...
^`.
$`

... then replace it with all of its prefixes in reverse order. (Note that these are exclusive prefixes so that the empty prefix is included but the string including the ! is excluded.)
.+
*
_
$.>`$*
~`^
^.$*$n$$.(

Otherwise compute the factorial.

This seems to fail for inputs containing 1! or 2! due to the rule "In these cases, your program can do whatever it wants EXCEPT applying the factorial joke or returning the same sentence."

@KevinCruijssen Ah, I overlooked that part of the rule. Let me think about how I can apply that rule in the fewest amount of bytes.

@KevinCruijssen Well, that cost me 11 bytes, but I was able to remove the 0! special case for 3 bytes and I found another byte I'd forgotten to golf off, so it could have been worse...

Red, 242 225 204 bytes
func[s][c: charset[#"0"-#"z"]parse s[any[change[copy t any c"!"](
case[find"12"t[0]t <"A"[t: to 1 t p: 1 while[t > 1][p: p * t
t: t - 1]p]t >":"[p: copy t until[take/last p append t p p =""]t]])| skip]]s]

Try it online!

SNOBOL4 (CSNOBOL4), 206 bytes
	D =84 ** 9
	INPUT ARB . L SPAN(&UCASE &LCASE D) . W '!' REM . R
	W SPAN(D) 	:F(S)
	N =W + 1	LT(W,3)	:S(O)
	N =W
F	W =W - 1	GT(W,1)	:F(O)
	N =N * W	:(F)
S	N =N W
	W ARB . W RPOS(1)	:S(S)
O	OUTPUT =L N R
END

Try it online!
84 ** 9 = 208215748530929664 which has all the digits from 0-9.
	D =84 ** 9						;* D contains every decimal digit.
	INPUT ARB . L SPAN(&UCASE &LCASE D) . W '!' REM . R
	;* split the input into an ARBitrary Left part, the Word followed by a '!' and the REMainder to the Right part.
	W SPAN(D) 	:F(S)					;* if W has digits, goto S
	N =W + 1	LT(W,3)	:S(O)				;* if W < 3, then N = W + 1 and goto O
	N =W							;* set N = W
F	W =W - 1	GT(W,1)	:F(O)				;* decrement W, and goto O if W == 0
	N =N * W	:(F)					;* N = N * W, goto F
S	N =N W							;* W is a string, so set N = N W
	W ARB . W RPOS(1)	:S(S)				;* set W to W excluding its final character and if W had any characters, goto S
O	OUTPUT =L N R						;* output Left, the New middle, and the Right string.
END

R, 205 201 194 189 bytes
s=scan(,'');l=grepl('\\w!',s);w=s[l];n=nchar;k=function(m,x)substr(x,1,n(x)-m);w=k(1,w);b=as.numeric(w);o=`if`(is.na(b),Reduce(paste0,sapply(0:n(w)-1,k,w)),gamma(b+1));s[l]=o;if(o!=w)cat(s)

Try it online!

Jelly, 26 bytes
ḲṖVN!Ƒ¡!ƲṖƤṚ$<”AẠ$?¹ċ?€”!K

A full program accepting a string which prints the result.
Try it online!
Kind of a tough one for Jelly.
How?
ḲṖVN!Ƒ¡!ƲṖƤṚ$<”AẠ$?¹ċ?€”!K - Link: list of characters, s
Ḳ                          - split at space characters -> words
                       ”!  - literal '!' character
                      €    - for each word:
                     ?     -   if...
                    ċ      -   ...condition: count (i.e. contains?)
                  ?        -   ...then: if...
                 $         -            ...condition: last two links as a monad:
             <             -              less than:
              ”A           -                literal 'A' character
                Ạ          -              all?
        Ʋ                  -            ...then: last four links as a monad:
 Ṗ                         -              pop (remove the '!')
  V                        -              evaluate as Jelly code (get an integer)
      ¡                    -              repeat...
     Ƒ                     -              ...number of times: is invariant under?:
    !                      -                factorial
   N                       -              ...action: negate (i.e. 1;2;X -> -1;-2;X)
       !                   -              factorial (-1! = -2! = inf)
            $              -            ...else: last two links as a monad:
          Ƥ                -              for prefixes:
         Ṗ                 -                pop (remove the `!` from each prefix)
           Ṛ               -              reverse
                   ¹       -   ...else: no-op
                         K - join with spaces
                           - implicit, smashing print

Husk, 23 bytes
wm??öΣ↔ḣhȯs§Y→ΠiV√I€'!w

Try it online!
Maps 1 to 2 and 2 to 3.
On my phone, so writing an explanation is not too easy, but I'll try.
Code with parentheses for "clarity":
wm(?(?(Σ↔ḣh)(s§Y→Πi)(V√))(I)(€'!))w

The main part of the code is built by conditionals, they may be a bit easier to read once you know that in Husk ?abc means if c then a else b. Also, most of the time fg is the composition of functions f and g, so we are actually applying g before f (to oversimplify it, you should read the code backwards)
A pseudocode for this could be:
Split input into words, map the following function to each word and then join them again.
  If word contains '!':
    if any character of the word is a letter:
      get the head of the word (drop final '!')
      get the list of prefixes (heads)
      reverse it
      join prefixes in a single word
    else:
      convert word to integer
      get the maximum between:
        successor
        factorial
      convert it back to string
  else apply Identity function (do nothing)

Charcoal, 57 bytes
≔⌕θ!η≔⊟⌕Ａ⁺ …θη ζ…θζ≔✂θζη¹ε≡ε2¹1¹0¦1¿ΣεＩΠ…·¹Ｉε⭆ε…ε⁻Ｌεκ✂θ⊕η

Try it online! Link is to verbose version of code. Explanation:
≔⌕θ!η

Find the position of the !.
≔⊟⌕Ａ⁺ …θη ζ

Find the position of the start of the word ending in !.
…θζ

Print the prefix of the input before the word.
≔✂θζη¹ε≡ε

Extract the word and switch on it.
2¹1¹0¦1

If it's 2 or 1 then output a -, otherwise if it's a 0 then outputs 1, otherwise...
¿ΣεＩΠ…·¹Ｉε

... if it's an integer then output its factorial, otherwise...
⭆ε…ε⁻Ｌεκ

... output its prefixes in reverse order. (These are inclusive prefixes, so they include the word itself but not the empty string.)
✂θ⊕η

Print the suffix of the input after the !.

@RGS What part of "If it's 2 or 1 then output a -" computes the factorial of 1?

I was sure I had tested your code with 0! and 1! and it gave 1 in both cases... But now I tested it again and it does output - for 1!, so something weird happened!

Japt, 27 bytes
Well, this is just god-awful but I've spent far too long on it to not post it. Kids, let this be a warning against trying to golf without your full faculties about you!
r"(%w+)!"Ï<3?°Y:Yn ÊªYå+ Ôq

Try it

05AB1E, 26 22 26 bytes
ð¡εD'!¢i¨D.ïiÐ!Ês!*ëηRJ]ðý

Try it online!

Nice alternative, but umm.. it's pretty ironic you've asked me about 0! even though your own approach doesn't work for it either. ;)

@KevinCruijssen Yes it does? 0! is 1

0! is 0?.. There are also a few other problems btw: # doesn't work for inputs without spaces (i.e. test results in t e s  right now - also missing a trailing t :S); and the trailing 2 gets removed in test case I wanted 2! give me 2

Will fix just got 4 bytes back :)

Based on the Á it seems you're currently assuming the ! is always at the end? That's probably where most of the issues I mentioned come from. Oh, and # to ð¡ fixes the issue of input without spaces. :) Had that initially wrong as well in my answer.

Yeah I noticed that @KevinCruijssen got some meetings now so will have to work out how to remove that assumption soon

C# (Visual C# Interactive Compiler), 227 bytes
s=>{var w=s.Split("!")[0].Split(" ").Last();if(!int.TryParse(w,out int n))for(;(w=w.Substring(1)).Length!=0;)s=s.Replace("!",w+"!");else{for(int i=n;--i>0;n=n*i);s=s.Replace(w+"!",""+(n<1?1:n>4?n:0));}return s.Replace("!","");}

Try it online!

Suggest n*=i istead of n=n*i

C (GCC), 236 bytes
i,j;char*a,*b,*c,*d;f(char*s){a=strchr(s,33);for(b=a;b>s&!isspace(b[-1]);--b);for(d=s;d-b;)putchar(*d++);*a=0;if(*b&64)for(c=a;*b;*--c=0)printf("%s",b);else{for(i=j=1;j-atoi(b);)i*=++j;printf("%d",i);}printf("%s",a+1);j>0&j<3&&puts(b);}

Try It Online!
Explanation:
i,j;
char*a,*b,*c,*d;

f(char*s)
{
    // a is the first '!' in s
    a=strchr(s,33);
    // b is the first character after the first whitespace before a, or s if there is no whitespace there
    for(b=a;b>s&!isspace(b[-1]);--b);
    // Print each character from s to b
    for(d=s;d-b;)putchar(*d++);
    // Null-terminate s at a
    *a=0;
    // If b is alphabetic
    if(*b&64)
        // While there's anything left of b, print b and shorten it by adding an earlier null terminator
        for(c=a;*b;*--c=0)
            printf("%s",b);
    else {
        // If b is not alphabetic, it's assumed to be a number.
        // i is the product of all j-s between 1, and b as a number
        for(i=j=1;j-atoi(b);)i*=++j;
        printf("%d",i);
    }
    // Print everything after the exclamation mark
    printf("%s",a+1);
    // Print the number twice if it's 1 or 2
    j>0&j<3&&puts(b);
}

ceilingcat's 226 byte version:
i,j;char*a,*b,*c,*d;f(char*s){for(b=a=index(s,33);b>s&!isspace(b[-1]);--b);for(d=s;*a=d-b;)putchar(*d++);if(*b&64)for(c=a;*b;*--c=0)printf(b);else{for(i=j=1;j-atoi(b);)i*=++j;printf("%d",i);}printf("%s",a+1);j>0&j<3&&puts(b);}

Try It Online

I didn't know about the index function ... Thanks!

208 bytes

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


text:
(RGS 4/5) Inverting matrices modulo m
Task
Given an integer matrix M and a modulus m, find an inverse of M modulo m. If the matrix M is not invertible modulo m, the behaviour is left unspecified.
Matrix inverse
If M is a square matrix, its inverse exists if and only if its determinant is not 0. Similarly, when we are talking about matrices modulo m, the inverse of M will exist if and only of the determinant of M is invertible modulo m, which happens when the determinant is coprime with m.
The inverse of M is a square matrix inv(M) such that M*inv(M) = inv(M)*M = I, where
$$I = \begin{bmatrix}
1 & 0 & 0 & \cdots & 0 \\
0 & 1 & 0 & \cdots & 0 \\
\vdots & \ddots & \ddots & \ddots & \vdots \\
0 & 0 & \cdots & 0 & 1
\end{bmatrix}$$
has the same shape of M and is called the identity matrix. As an example, consider the first test case, where [[22, 43], [29, 37]] is the inverse of [[26, 16], [38, 41]] mod 45:
$$\begin{bmatrix}
26&16\\38&41
\end{bmatrix} \cdot \begin{bmatrix}
22&43\\29&37
\end{bmatrix} = \begin{bmatrix}
1036&1710\\2025&3151
\end{bmatrix} \equiv \begin{bmatrix}
1 & 0 \\ 0&1
\end{bmatrix} \mod 45$$
Input
A square matrix M with integer values between 0 and m-1, inclusive, and a positive integer m > 1. The matrix may be given in any sensible format, including

a list of lists, where the inner lists encode the rows, like M = [[1, 2], [3, 4]], or a flattened version, like M = [1, 2, 3, 4]
a list of lists, where the inner lists encode the columns, like M = [[1, 3], [2, 4]], or a flattened version, like M = [1, 3, 2, 4]

where these encode the matrix
\$\$\begin{bmatrix}
1 & 2 \\ 3 & 4
\end{bmatrix}\$\$
The integer m giving the modulus.
You may also accept the size of the matrix as input.
The inputs can be given in any order.
Output
A matrix representing the inverse of M modulo m. You may assume such an inverse exists. Preferable format is for each matrix entry \$a_{i,j}\$ to satisfy \$0 \leq a_{i,j} < m\$ but this is just to make it easier to compare with the test cases.
Test cases
45, [[26, 16], [38, 41]] -> [[22, 43], [29, 37]]

39, [[29, 50], [29, 1]] -> [[16, 19], [4, 35]]

35, [[24, 14], [48, 45]] -> [[5, 7], [4, 33]]

53, [[43, 20], [15, 8]] -> [[5, 14], [37, 7]]

49, [[15, 11, 30], [20, 12, 40], [33, 25, 2]] -> [[33, 28, 23], [25, 18, 0], [25, 48, 13]]

37, [[8, 9, 22, 17], [24, 30, 30, 19], [39, 8, 45, 23], [5, 30, 22, 33]] -> [[18, 17, 26, 20], [29, 36, 23, 1], [19, 0, 9, 3], [30, 23, 14, 21]]

This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it... And happy golfing!

This is the fourth challenge of the RGS Golfing Showdown. If you want to participate in the competition, you have 96 hours to submit your eligible answers. Remember there is still 300 reputation in prizes! (See 6 of the rules)
Also, as per section 4 of the rules in the linked meta post, the "restricted languages" for this third challenge are only Jelly, V (vim) and 05AB1E so submissions in these languages are not eligible for the final prize. But they can still be posted!!
Otherwise, this is still a regular code-golf challenge, so enjoy!

I don't think it's quite true that a matrix is invertible if it has a nonzero determinant, when working modulo m where m is composite. For example, [[2, 0], [0, 1]] has determinant 2 but isn't invertible modulo 6.

@xnor fixed, what I really wanted was "coprime with m".

May we take the size of the matrix as input?

@RobinRyder sure, I don't mind that. Edited it into the input section

@ngn you have to explain it in a different way because I did not understand

@LuisMendo you can assume the solution exists and you can have a random runtime. A solution already does what you described.

Thanks. The input test cases all have non-negative entries. You shoud probably state that in the challenge rules, or include a test case with negative entries

@LuisMendo everything here is modulo m, so what do you mean? Do you think it makes a difference?

In the description, you say A square matrix M with integer values between 0 and m-1, inclusive. However, in the last test case, one of the elements of the matrix is 39, greater than m, which is 37

Can you please provide a reference program?

@S.S.Anne I haven't had the time for that, sorry. You might Google on how to invert matrices. All the general algorithms work, provided you change them to use modular arithmetic, like modular inverses, instead of using floating-point divisions

Is the inverse guaranteed to exist?

@S.S.Anne yes, you may assume it exists

Hmm... This is similar to (~l+1)%l but not quite.

It might be nice to have a test case where at least the top left element is not relatively prime to the modulus - to force failure in a naive Gaussian elimination.  In fact, it would be nice to have a test case where all elements of the original matrix are not relatively prime to the modulus - for example, modulus 6, matrix [[2, 3], [3, 2]]

R, 68 bytes
function(M,m,n,A=M){while(any(A%*%M%%m!=diag(n)))A[]=rpois(n^2,9)
A}

Try it online!
Strikingly slow. Will most likely time out for all test cases on TIO, but is guaranteed to give an answer eventually.
Works by rejection sampling: generates random matrices A, with each value taken from a \$Poisson(9)\$ distribution, until a solution is found.
Note that to get A of the correct dimensions, it is 6 bytes shorter to initialize it as A=M and then replace all the values with A[]=rpois(n^2,9) than to create it directly with A=matrix(rpois(n^2,9),n).

small typo, this should return A rather than I, right? Assuming it ever returns, haha.

@Giuseppe Of course, it should return A. Thanks!

J, 18 16 bytes
(]%1+.]^5 p:[)%.

Try it online!
Resolves p/q mod n element-wise (instead of using det(M) to resolve the modular inverse globally).
Abuses GCD of rational numbers to extract 1/q from p/q.
How it works
(]%1+.]^5 p:[)%.    NB. left arg = modulo, right arg = matrix
(            )%.    NB. bind inv(matrix) as new right arg
        5 p:[       NB. phi(modulo)
      ]^            NB. inv(matrix)^phi(modulo) element-wise
   1+.              NB. GCD with 1; GCD(1, p/q) = 1/q
 ]%                 NB. Divide inv(matrix) by the above element-wise

J, 18 bytes
%.@]*-/ .*@]^5 p:[

Try it online!
A dyadic tacit function that takes modulo (left arg) and the matrix (right arg), and gives possibly very large-valued modular inverse of the matrix. To reduce the range, prepend [| at the start of the function.
How it works: the math
A simple mathematical way to calculate the modular inverse of a matrix is the following:
$$
\begin{align}
M^{-1} \text{ mod }n &= \text{cofactor}(M) \times \bigl((\det M)^{-1} \text{ mod }n \bigr) \\
&= M^{-1} \times \det M \times \bigl((\det M)^{-1} \text{ mod }n \bigr)
\end{align}
$$
If the matrix \$M\$ is invertible modulo \$n\$, we know that \$(\det M)^{-1} \text{ mod }n\$ exists, and it can be found using Euler's theorem:
$$
(\det M)^{-1} \equiv (\det M)^{\varphi(n)-1} \text{ mod }n
$$
Then we can simplify the original equation to
$$
\begin{align}
M^{-1} \text{ mod }n &= M^{-1} \times \det M \times \bigl((\det M)^{\varphi(n)-1} \text{ mod }n \bigr) \\
&\equiv M^{-1} \times (\det M)^{\varphi(n)} \mod{n}
\end{align}
$$
And now the fun fact: J has built-ins for matrix inverse, matrix determinant, and Euler's totient function. And it uses built-in rational numbers when calculating the matrix inverse!
How it works: the code
%.@]*-/ .*@]^5 p:[    NB. left arg = modulo, right arg = matrix
             5 p:[    NB. totient(modulo)
     -/ .*@]          NB. det(matrix)
            ^         NB. det(matrix) ^ totient(modulo)
%.@]                  NB. inv(matrix)
    *                 NB. inv(matrix) * det(matrix) ^ totient(modulo)

Nice, I knew there had to be some way to get modular matrix inversion from regular matrix inversion.

I'm wondering if there's a way to do this without computing the matrix determinant. If I understand what's going on, the matrix inverse gives rational entries like p/q, and we need to re-interpret each of them as p/q done modulo n producing integer values. It would suffice to multiply everything by any large value that clears all the denominators and thereby produces integers, and equals 1 modulo n. One such value is indeed det(M)^phi(n). But maybe there's a shorter one.

@xnor Your understanding is correct. Without det(M), the only other way would be to compute p/q mod n element-wise (or entirely fall back to Gaussian elimination).

Wolfram Language (Mathematica), 23 bytes
¯\_(ツ)_/¯   the answer was in the documentation of Modulus
Inverse[#2,Modulus->#]&

Try it online!

JavaScript (ES6),  209  206 bytes
Takes input as (modulo)(matrix).
This transposes the matrix of cofactors (resulting in the adjugate) and multiply it by the inverse of the determinant of \$M\$ modulo \$m\$.
m=>M=>M.map((r,y)=>r.map((_,x)=>((g=k=>(++k*D(M)%m+m)%m-1?g(k):x+y&1?-k:k)``*D(h(M,x).map(r=>h(r,y)))%m+m)%m),h=(a,n)=>a.filter(_=>n--),D=M=>+M||M.reduce((s,[v],i)=>s+(i&1?-v:v)*D(h(M,i).map(r=>h(r,0))),0))

Try it online!
Commented
Helper function \$h\$
The function \$h\$ removes the \$n\$-th entry from the array \$a[\:]\$.
h = (a, n) =>                // a[] = array, n = index
  a.filter(_ => n--)         // keep all but the n-th entry

Helper function \$D\$
The function \$D\$ computes the determinant of the matrix \$M\$.
D = M =>                     // M[] = input matrix
  +M ||                      // if M[] is 1x1, stop recursion and return its unique value
  M.reduce((s, [v], i) =>    // otherwise, for each value v at (0, i):
    s +                      //   add to the sum
    (i & 1 ? - v : v) *      //   either v or -v depending on the parity of i
    D(                       //   multiplied by the result of a recursive call with:
      h(M, i)                //     M[] without the i-th row
      .map(r => h(r, 0))     //     and without the first column
    ),                       //   end of recursive call
    0                        //   start with s = 0
  )                          // end of reduce()

Main function
m => M =>                    // m = modulo, M[] = matrix
  M.map((r, y) =>            // for each position y:
    r.map((_, x) =>          //   for each position x:
      (                      //
        ( g = k =>           //     g is a recursive function taking a counter k
            ( ++k *          //       increment k and multiply it
              D(M)           //       by the determinant of M
              % m + m        //
            ) % m - 1 ?      //       if it's not congruent to 1 modulo m:
              g(k)           //         try again until it is
            :                //       else:
              x + y & 1 ? -k //         return either k or -k
                        : k  //         depending on the parity of x+y
        )`` *                //     initial call to g with a zero'ish value
        D(                   //     multiply by the determinant of:
          h(M, x)            //       M[] without the x-th row
          .map(r => h(r, y)) //       and without the y-th column
        ) % m + m            //     return the result modulo m
      ) % m                  //
    )                        //   end of inner map()
  )                          // end of outer map()

SageMath, 48 33 bytes
Saved 15 bytes thanks to ovs!!!
lambda m,M:~Matrix(Integers(m),M)

Nothing on TIO for SageMath unfortunately.
Modular inverse of a matrix M (input as a Python list of lists) mod m.

@ovs So sorry, is that correct? On my phone so can't check.

Yes this works. This is the same operator as you use in expressions like -~n.

@ovs Makes sense - thanks! :-)

Is this a library for Python or another language?

@S.S.Anne If you follow the above link you'll get to the dev page. It's basically a whole system built on top of Python w numpy/scipy that does symbolic math!!

Jelly, 25 bytes
ÆḊ×Ɱ⁹%ỊTḢ×ZÆḊ-Ƥ$-ƤNÐe⁺€Zʋ

Try it online!
A dyadic link taking the matrix as its left argument and the modulus as its right. Returns a matrix. Append a % to get it within the range 0, m

MATL, (25?)  31 29  26 bytes
My first MATL answer
-5 bytes & a bug-fix (+2) thanks to Luis Mendo!
The trailing . may be unnecessary - it is if there is only ever a single inverse of M with elements modulo m.
:inZ^!"&G@[]eY*w\tZyXy=?@.

A full program which prints the elements in row major order separated by newlines.
Try it online! - Too slow for any of the given test cases.
Quite possibly not the best approach for MATL.
How?
:inZ^!"&G@[]eY*w\tZyXy=?@. - expects inputs m and M
:                          - range (m) -> [1,2,...,m]
 i                         - push input (M)
  n                        - number of elements
   Z^                      - ([1,2,...,m]) Cartesian power (#elements(M))
     !                     - transpose
      "                    - for each column, C:
       &G                  -   push both inputs
         @                 -   push C
          []               -   push an empty array (to make e work as below)
            e              -   reshape (C) to square matrix of side ceil(#elements(C)^0.5)
             Y*            -   (reshaped C) matrix multiplication (copy of M)
               w           -   swap top two stack entries
                \          -   (multiplication result) modulo (copy of m)
                 t         -   duplicate top of stack
                  Zy       -   size
                    Xy     -   (size by size) identity matrix
                      =    -   equal -> logical matrix
                       ?   -   if all are truthy:
                        @  -     push C
                         . -     break
                           - implicit print of stack (the valid C)

@LuisMendo - I'm almost certain you'll beat this using another method, but any tips for this one would be welcome!

...also why is w "necessary" where I have it / is there something more normal that should go there?

Thanks! Yes the 2 was somehow lost and should have been the column size. You're also correct about q being unnecessary since we don't have to give an answer modulo m.

Sledgehammer, 6 bytes
⠑⡿⡆⠱⣁⣭

Decompresses into this Wolfram Language function:
Inverse[#2, Modulus -> #1]

Try it online!

Charcoal, 41 bytes
ＦＥＸθ×ηη⪪Ｅ×ηη÷ιＸθλη¿⬤ι⬤ζ⁼⁼λν﹪ΣＥμ×ξ§§ιπλθＩι

Try it online! Link is to verbose version of code. Takes input as \$ m, n, M \$ where \$ n \$ is the size of \$ M \$, and does not reduce its output modulo \$ m \$ (can be done at a cost of 2 bytes). Stupidly slow, so don't try this with realistic values. Explanation:
ＦＥＸθ×ηη⪪Ｅ×ηη÷ιＸθλη

There are \$ m^{n^2} \$ possible square matrices of size \$ n \$ with coefficients between \$ 0 \$ and \$ m \$. Looping over this value, compute each matrix, but don't bother reducing the terms modulo \$ m \$. Then, loop over the list of matrixes.
¿⬤ι⬤ζ⁼⁼λν﹪ΣＥμ×ξ§§ιπλθ

Perform the steps of matrix multiplication of this matrix by the input matrix, reduce it modulo \$ m \$, and compare the each result to the appropriate value of the identity matrix.
Ｉι

If this was the inverse then print the matrix.

By stupidly slow, I mean it can only cope with 4x4 with a modulus of 2 or 3x3 with a modulus of 2 or 3 or 2x2 with a modulus of up to 21 (23 at a cost of 2 bytes) on TIO.

R, 128 bytes
function(x,m,n)t(round(which((1:m*det(x))%%m<1.5)[1]*outer(1:n,1:n,Vectorize(function(a,b)det(x[-a,-b,drop=F])*(-1)^(a+b))))%%m)

Try it online!
A function taking three arguments, x = the matrix, m = the modulus and n the number of rows of x. Returns a matrix. Uses the same method as my Jelly answer.

Jelly, (21?) 22 bytes
The trailing Ṫ may be unnecessary - it is if there is only ever a single inverse of M with elements modulo m.
Ḷṗ⁹L²¤ṁ€⁹æ×%³L⁼þ`$ƑɗƇṪ

A full program printing the result.
Try it online! - Too slow for any of the given test cases (the 35 case took ~20 minutes locally).

11 bytes (but floating point output):
Using Bubler's observation (go upvote!) that raising the determinant to Euler's totient is enough to remove the determinant's denominators:
æ*-×ÆḊ*ÆṪ}ɗ

However, unlike in J, the inversion of \$M\$ in Jelly gives floats so we no longer get an integer matrix as output.
Try it online!

@RGS - I guess the 11 would only be acceptable if an integer output was given, even though this is not explicitly stated in the question?

WIN+APL, 114 bytes
Prompts for matrix followed by modulus.
m←r←⎕⋄z←r[1;1]⋄⍎∊(¯1+1↑⍴r)⍴⊂'z←z×1 1↑r←(1 1↓r)-((1↓r[;1])∘.×1↓r[1;])÷r[1;1]⋄'⋄⌊.5+n|((1=n|z×⍳n)/⍳n←⎕)×(z←⌊.5+z)×⌹m

Try it online! Courtesy of Dyalog Classic

Magma, 34 bytes
func<m,M|Matrix(Integers(m),M)^-1>

No TIO for magma, though you can try it on http://magma.maths.usyd.edu.au/calc/

Java 8, 270 261 bytes
M->m->{int l=M.length,R[][]=new int[l][l],T[][]=new int[l][l],d=0,s=l,r,c,k;for(;d!=1|s!=0;){for(r=l*l;r-->0;R[r/l][r%l]=d*=Math.random())d=m;for(d=1,s=r=l;r-->0;d*=T[r][r]%m)for(c=l;c-->0;s-=T[r][c]%m)for(T[r][c]=k=0;k<l;)T[r][c]+=M[r][k]*R[k++][c];}return R;}

-9 bytes thanks to @ceilingcat.
Keeps trying random matrices (including duplicates) until it find the correct one, so times out for most test cases. I tried adding a cache so it tries random matrices without duplicates, but then it still times out for the same test cases.
Try it online (only contains the test cases m=35; M=[[24,14],[48,45]] and m=5; M=[[15,13],[21,13]]).
Explanation:
M->m->{                    // Method with int-matrix & int parameters and int-matrix return
  int l=M.length,          //  Dimension of the input-matrix
      R[][]=new int[l][l], //  Result-matrix of that same size
      T[][]=new int[l][l], //  Temp-matrix of that same size
      d=0,                 //  Flag for the diagonal
      s=l,                 //  Flag for the decreasing sum
      r,c,k;               //  Index integers
  for(;d!=1                //  Continue looping as long as the diagonal flag isn't 1 yet
       |s!=0;){            //  nor the decreasing sum flag isn't 0 yet:
    for(r=l*l;r-->0;       //   Loop over all cells:
      R[r/l][r%l]=         //     Set the current cell in matrix `R`:
        d*=Math.random())d=m;
                           //      To a random value in the range [0,m)
    for(d=1,               //   Reset the diagonal flag to 1
        s=r=l;             //   Reset the decreasing sum flag to `l`
        r-->0              //   Loop over the rows:
        ;                  //     After every iteration:
         d*=               //      Multiply the diagonal flag by:
            T[r][r]        //       The value in the `r,r`'th cell of matrix `T`
                   %m)     //       Modulo the input `m`
      for(c=l;c-->0        //    Inner loop over the columns:
          ;                //      After every iteration:
           s-=             //       Decrease the decreasing sum flag by:
              T[r][c]      //        The value in the `r,c`'th cell of matrix `T`
                     %m)   //        Modulo the input `m`
        for(T[r][c]=k=0;   //     Reset the `r,c`'th cell of matrix `T` to 0
            k<l;)          //     Inner loop `k` in the range [0, length):
          T[r][c]+=        //      Increase the `r,c`'th cell of matrix `T` by:
            M[r][k]        //       The `r,k`'th cell of matrix `M`
            *R[k++][c];}   //       Multiplied by the `k,c`'th cell of matrix `R`
  return R;}               //  And if the loops are done: return matrix `R` as result

R, 97 83 bytes
function(M,m,d){while(any(M%*%(x=matrix(T%/%m^(1:d^2-1),d))%%m-diag(d)))T=T+1;x%%m}

Try it online!
Pretty slow. Takes the dimension of the matrix as input. The previous version using a for loop is a bit faster.
Thanks to Robin Ryder for -14 bytes.
Explanation:
We iterate over every number between \$1\$ and \$m^{d^2}\$, converting each to its base-\$m\$ digits (with leading zeros), reshaping those digits into a matrix of the appropriate size, and testing to see if it's the inverse of \$M\$ modulo \$m\$.
I wanted to attempt the whole series in SNOBOL but I'm not sure I will be able to implement matrix multiplication in SNOBOL in time for it to be a valid submission...

83 bytes with a while loop.

Python 3 + SymPy, 33 bytes
from sympy import*
Matrix.inv_mod

Try it online!
SymPy's Matrix class has a method for modular inverse.


text:
Summing intertwined terms of an array
I'm recieving 2-dimensional positions of two objects as a string with this format: x1,y1,x2,y2. The string is recieved from a readline call (replaced in the snippet with a prompt).
In order to get the horizontal and vertical position differentials, I'm writing the following code:

[x1,y1,x2,y2]=prompt("Please enter the positions separated by commas").split`,`
dx=+x2-x1
dy=+y2-y1
console.log(dx,dy)

Is there a way to get dx and dy using less characters since I don't really need the positions? I suppose the main problem could be in the variable assignment which can probably be done in one step. I can use ECMAScript 6.
I don't really know if I have to precise it but removing the text in the prompt or giving variables 1-char names doesn't count, I have written them on purpose to clarify my question. The console.log is not part of the code golf either since the variables are supposed to be used after in the program.

Welcome to Code Golf! Despite the close vote, I think you've already included the appropriate tags for such a question and this is indeed on-topic.

I would appreciate if the people voting to close this could leave a comment.  There is no way this user can improve the question without the necessary feedback.

Are you asking how to golf the middle two lines, specifically? Or the whole thing?

@Shaggy I would like to code golf the whole program, except for the two voluntary mistakes mentioned. I think the main problem could be in the variable assignment which can probably be done in one step

Could you state in the question what requirements you have on the input  and precisely? Also, it may not matter much here, but please state what version(s) you are limited to using.

Are the + in +x2-x1 and +y2-y1 necessary?

So we recently adopted some new requirements for questions about golfing specific code, and your post already does a good job covering most of these. One remaining point is, what's the source or context for the challenge? Note also FryAmTheEggman's question on I/O. Also, I think it would help to edit your comment to Shaggy about your goal into the question itself.

I guess the console.log is also not part of what to golf, since otherwise I think you can just substitute in the expression for dx and dy. Is the goal of the snippet to have these values be saved to variables so that they can be used multiple times in code that follows?

@mypronounismonicareinstate No, they're not. The subtraction operator is unconditionally doing ToNumber(lval) and ToNumber(rval), whereas the addition operator includes a test on the type.

@xnor I'd argue 5 upvotes on a post that is less than two weeks old is not really a sign of consensus yet, especially when you are both the question asker and the answerer there.

I'm not sure exactly what you're looking for, but perhaps something like this?
[x1,y1,dx,dy]=prompt("Please enter the positions separated by commas").split`,`
dx-=x1
dy-=y1
console.log(dx,dy)

Reusing x2 and y2 as dx and dy, respectively, lets you use the -= operator to shorten it a bit.


text:
Mad Libs number sequences
My robot for generating Mad Libs-style sequence challenges has gone rogue! To defeat it, I need you to write code that can solve all the challenges it can crank out.
Your input is three selections for the blanks A, B, C, each from (1,2,3), specifying the sequence challenge to solve, and the number \$n\$ that's the input to the challenge.
Challenges
Given a positive integer \$n\$, output (A) ________

A:
    (1) the \$n\$'th
    (2) whether \$n\$ is a
    (3) the smallest number above \$n\$ that's a

positive (B) _______

B:
  (1) Fibonacci number
  (2) triangular number
  (3) multiple of 3

whose base-10 representation (C) _______

C:
  (1) starts and ends with the same digit.
  (2) is in sorted order.
  (3) doesn't have any 1's.

Example
Given selections (A, B, C) = (3, 1, 1) and n=13, the challenge is "Given a positive integer \$n\$, output (A3) the smallest number above \$n\$ that's a positive (B1) Fibonacci number whose base-10 representation (C1) starts and ends with the same digit." With input n=13, the Fibonacci numbers bigger than \$13\$ start out as \$21, 34, 55, 89, ...\$, and the first one starting and ending with the same digit is is 55. So you should output 55.
Details

You may take the fill-in-the-blank selections one-indexed (1, 2, 3) or zero-indexed (0, 1, 2).
Note that we're restricting the sequences to positive values, so none of them contain zero. They start as

Fibonacci: \$1, 1, 2, 3, ...\$
Triangular: \$1, 3, 6, 10, ...\$
Multiple of 3: \$3, 6, 9, 12, ...\$

For choice A1, outputting the \$n\$'th element, \$n\$ is one-indexed. So, the n=1 Fibonacci number is 1, the n=2 Fibonacci number is also 1, n=3 gives 2, and so on.
For deciding whether n is in the sequence (A2), you may use any two consistent outputs decision-problem-style.
You may assume that each sequence has an infinite number of terms meeting each condition C, and not worry about what happens with machine overflows and the like.
For C2, digits in sorted order can have "ties", such as 377.

Test cases
Here are all outputs for every combination with n=10, as (A,B,C), n: result. For these, we use one-indexed selections, and for A2 we use 1/0 for True/False
(1, 1, 1), 10: 165580141
(1, 1, 2), 10: 89
(1, 1, 3), 10: 987
(1, 2, 1), 10: 1431
(1, 2, 2), 10: 78
(1, 2, 3), 10: 276
(1, 3, 1), 10: 222
(1, 3, 2), 10: 36
(1, 3, 3), 10: 42
(2, 1, 1), 10: 0
(2, 1, 2), 10: 0
(2, 1, 3), 10: 0
(2, 2, 1), 10: 0
(2, 2, 2), 10: 0
(2, 2, 3), 10: 0
(2, 3, 1), 10: 0
(2, 3, 2), 10: 0
(2, 3, 3), 10: 0
(3, 1, 1), 10: 55
(3, 1, 2), 10: 13
(3, 1, 3), 10: 34
(3, 2, 1), 10: 55
(3, 2, 2), 10: 15
(3, 2, 3), 10: 28
(3, 3, 1), 10: 33
(3, 3, 2), 10: 12
(3, 3, 3), 10: 24

The first 10 outputs, n=1 to n=10, for each challenge combination are:
(1, 1, 1): 1, 1, 2, 3, 5, 8, 55, 17711, 63245986, 165580141,
(1, 1, 2): 1, 1, 2, 3, 5, 8, 13, 34, 55, 89,
(1, 1, 3): 2, 3, 5, 8, 34, 55, 89, 233, 377, 987,
(1, 2, 1): 1, 3, 6, 55, 66, 171, 595, 666, 1081, 1431,
(1, 2, 2): 1, 3, 6, 15, 28, 36, 45, 55, 66, 78,
(1, 2, 3): 3, 6, 28, 36, 45, 55, 66, 78, 253, 276,
(1, 3, 1): 3, 6, 9, 33, 66, 99, 111, 141, 171, 222,
(1, 3, 2): 3, 6, 9, 12, 15, 18, 24, 27, 33, 36,
(1, 3, 3): 3, 6, 9, 24, 27, 30, 33, 36, 39, 42,
(2, 1, 1): 1, 1, 1, 0, 1, 0, 0, 1, 0, 0,
(2, 1, 2): 1, 1, 1, 0, 1, 0, 0, 1, 0, 0,
(2, 1, 3): 0, 1, 1, 0, 1, 0, 0, 1, 0, 0,
(2, 2, 1): 1, 0, 1, 0, 0, 1, 0, 0, 0, 0,
(2, 2, 2): 1, 0, 1, 0, 0, 1, 0, 0, 0, 0,
(2, 2, 3): 0, 0, 1, 0, 0, 1, 0, 0, 0, 0,
(2, 3, 1): 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
(2, 3, 2): 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
(2, 3, 3): 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
(3, 1, 1): 2, 3, 5, 5, 8, 8, 8, 55, 55, 55,
(3, 1, 2): 2, 3, 5, 5, 8, 8, 8, 13, 13, 13,
(3, 1, 3): 2, 3, 5, 5, 8, 8, 8, 34, 34, 34,
(3, 2, 1): 3, 3, 6, 6, 6, 55, 55, 55, 55, 55,
(3, 2, 2): 3, 3, 6, 6, 6, 15, 15, 15, 15, 15,
(3, 2, 3): 3, 3, 6, 6, 6, 28, 28, 28, 28, 28,
(3, 3, 1): 3, 3, 6, 6, 6, 9, 9, 9, 33, 33,
(3, 3, 2): 3, 3, 6, 6, 6, 9, 9, 9, 12, 12,
(3, 3, 3): 3, 3, 6, 6, 6, 9, 9, 9, 24, 24,

In condition A2, must the two outputs be the same for all 9 values of (B, C)? Or is it OK if we output (say) 0 and 1 for Fibonacci sequences, but 2 and 4 for triangular numbers?

@RobinRyder I'll say they can be different for each one, since conceptually each set of conditions makes for its own challenge.

JavaScript (ES6),  158 ... 145  144 bytes
Takes input as (a,b,c,n), with \$a\$, \$b\$ and \$c\$ 0-indexed.
(a,b,c,n)=>(g=x=>[(d=[...x+''],i+=C=![d[0]-x%10,d+''>d.sort(),/1/.test(x)][c])>n,x>=n,x>n&C][a]?a-1?x:C&x==n:g([y,x+y,x+3][b],y+=b||x))(i=0,y=1)

Try it online!
Commented
(a, b, c, n) => (              // given the challenge parameters ...
  g = x =>                     // g is a recursive function taking the current value x
    [                          // this is the array for A
      (                        //   a = 0:
        d = [...x + ''],       //     d[] = array of digits in x
        i += C =               //     increment i if C is true
          ![                   //     set C if the condition is false:
            d[0] - x % 10,     //       c = 0: the 1st and the last digits are not equal
            d + '' > d.sort(), //       c = 1: the digits are not in sorted order
            /1/.test(x)        //       c = 2: there's a '1' in x
          ][c]                 //     pick the relevant condition for C
      ) > n,                   //     exit if i is greater than n
      x >= n,                  //   a = 1: exit if x is greater than or equal to n
      x > n & C                //   a = 2: exit if x is greater than n and C is true
    ][a]                       // pick the relevant condition for A
    ?                          // if we're done:
      a - 1 ? x                //   if a is not equal to 1, return x
            : C & x == n       //   otherwise, test whether C is true and x is equal to n
    :                          // else:
      g(                       //   do a recursive call:
        [                      //     update x:
          y,                   //       b = 0: x = y (Fibonacci)
          x + y,               //       b = 1: x += y (triangular numbers)
          x + 3                //       b = 2: x += 3 (multiples of 3)
        ][b],                  //     pick the relevant update for B
        y += b || x            //     if b = 0, add x to y (for Fibonacci)
                               //     otherwise, add b to y (we actually just need to
                               //     add 1 for triangular numbers; for multiples of 3,
                               //     y is ignored anyway)
      )                        //   end of recursive call
)(i = 0, y = 1)                // initial call to g with x = i = 0 and y = 1

Python 3, 426 \$\cdots\$ 204 181 bytes
Saved 9 bytes thanks to RGS!!!
def f(a,b,c,n):
 j=i=l=x=0;y=1
 while(i<n,l<n,l<=n)[a]:
  j+=1;x,y=y,x+y;p=(x,j*-~j//2,3*j)[b];s=str(p)
  if(s[0]==s[-1],[*s]==sorted(s),not'1'in s)[c]:l=p;i+=1
 return(l,l==n)[a%2]

Try it online!
\$(a,b,c)\$ are zero-indexed and ...whether \$n\$ is a... returns True/False.

You can save some bytes by doing the middle test on your if like I'm doing

@RGS Much better comparing two lists, thanks! :-) See you've taken the sequence gen to the next level, nice one! :D

Wolfram Language (Mathematica), 245 bytes
Input {a,b,c,n}
True/False for A(2)
(d=#4;a=#;c=#3;n={#&@@(i=IntegerDigits)@#==#~Mod~10&,OrderedQ@i@#&,i@#~FreeQ~1&};{t=v=1;While[v<=d,While[!n[[c]][#@t++]];v++];#[t-1],!FreeQ[#[w=Range[3d]],d]&&n[[c]]@d,#&@@Select[Select[#@w,#>d&],n[[c]]]}[[a]]&[{Fibonacci,#(#+1)/2&,3#&}[[#2]]])&

Try it online!
Here are all test cases for n=1 to 10

R, 199 bytes
f=function(A,B,C,n){u=c(sum(1:B),1+2*(B>2))
while(sum(v<-grepl(c("^(.)(.*\\1)?$","^1*2*3*4*5*6*7*8*9*$","^[^1]*$")[C],u))<n+2)u=c(u[1]+c(u[2],sum(u^0)+1,3)[B],u)
w=u[v]
c(w[3],n%in%w,min(w[w>n]))[A]}

Try it online!
Conditions C1-C3 are checked via regex.
In all cases, it computes the first n+2 terms verifying the condition; this is always enough. They are stored in reverse in w. Then:

for A1, take w[3]
for A2, check whether n appears in w
for A3, take the min of the elements of w which are greater than n.

Details of the regexes:

C1: ^(.)(.*\\1)?$: get first digit with ^(.), then find either the end of the number (correspond to a 1-digit number) or any sequence followed by the same digit again
C2: ^1*2*3*4*5*6*7*8*9*$: any number of 1s, then any number of 2s, then... then any number of 9s
C3: ^[^1]*$ only digits which are not 1

w is built as the elements of sequence u verifying the regex, where u is the Fibonacci/Triangular/multiples of 3 sequence, built iteratively by adding the appropriate increment at each step.

Jelly, 58 bytes
ị"“ÆḞ“+1c2“×3”,“.ịEƊ“ṢƑ“ċ1¬$”,“ṖṪ“e@“>Ƈ”ż“¶1ÇD“Ɗ⁸+1¤#Ç”FvḢ

Try it online!
A dyadic link taking the choices in the order B, C, A as the left argument and n as the right argument. Builds a program from component parts and then executes it. The presence of two ones at the start of the Fibonacci sequence added an extra four characters!
Explanation
ị"          | Index into the following list of strings, zipped with the first argument (so the first choice picks from the first list of strings, the second from the second and the third from the third):

First set of choices
“ÆḞ         | - Fibonacci sequence
“+1c2       | - Triangular numbers
“×3”,       | - Multiply by 3

Second set of choices
“.ịEƊ       | - Extract last and first terms and check if equal
“ṢƑ         | - Check whether invariant when sorted
“ċ1¬$”,     | - Count 1s and then logical not

Third set of choices
“ṖṪ         | - Remove last then take last remaining
“e@         | - Exists (with arguments reversed)
“>Ƈ”        | - Keep those greater than

Fixed bits of generated program
ż           | Zip with strings representing the following
“¶1ÇD       | - Newline, then 1 followed by call of previous link followed by D convert to decimal digits
“Ɗ⁸+1¤#Ç”   | - Last three as a monad called to find n+1 matching terms

Code to execute the generated program
F           | Flatten
 v          | Call as Jelly code using n as argument
  Ḣ         | Head (needed when A is 3)

Example generated code for [1,1,1]:
ÆḞ
1ÇD.ịEƊƊ⁸+1¤#ÇṖṪ

Python 3, 182 173 bytes
def f(a,b,c,n):
 u=i=l=0;v=b&2|1
 while(i<n,l<n,l<=n)[a]:
  u,v=v,[u+v,2*v-u+1,v+3][b];s=str(u)
  if(s[0]==s[-1],[*s]==sorted(s),not'1'in s)[c]:l=u;i+=1
 return(l,l==n)[a%2]

Try it online!
The skeleton was borrowed from Noodle9's Python answer, but I'm building the sequence of values in a different way.
Thanks to @xnor for saving me 9 bytes.

I like how you're building the sequences iteratively. A golf: the initial variable assignments can be u=i=l=0;v=b&2|1.

Python 2, 162 bytes
Inputs A, B, C are 0-indexed.
a,b,c,n=input();
i=0;x=k=1
while[n,i<n,i<=n][a]|1-x:i,k=[k,k+i,i+3][b],k+(b or i);s=`i`;x=[s[0]==s[-1],sorted(s)==list(s),not'1'in s][c];n-=x>a
print[i,i==n][a%2]

Try it online!

05AB1E, 49 44 bytes
∞3*∞Åf∞ηO)³èʒ1å≠y¬Å¿yD{Q)Iè}D¹²i<èë²<i.ië›Ïн

Input is 1-based in the order \$n,A,B,C\$, and for A2 it'll output \$0\$/\$1\$ for truthy/falsey respectively.
-5 bytes thanks to @Grimmy.
Try it online or verify all test cases.
Explanation:
∞           # Push an infinite list of positive integers: [1,2,3,...]
 3*         # Multiply each by 3
∞           # Push an infinite list of positive integers again
 Åf         # Get the (0-based) n'th Fibonacci of each
∞           # Push an infinite list of positive integers again
 η          # Get all prefixes
  O         # And sum each prefix
   )        # Wrap all infinite lists into a list
    ³è      # And index the third input (B) into it (0-based and with wraparound)
ʒ           # Filter this list by:
 1å         #  Check if the current value contains a 1
   ≠        #  And invert the boolean
 y          #  Push the current value again
  ¬         #  Push its head (without popping)
   Å¿       #  And check if the value ends with this head
 y          #  Push the current value again
  D{        #  Create a copy, and sort its digits
    Q       #  Check if both are equal
     )      #  Wrap all three checks into a list
      Iè    #  And index the next fourth input (C) into it (0-based and with wraparound)
}D          # After the filter: duplicate the resulting filtered infinite list
  ¹         # Push the first input (n)
   ²i       # If the second input (A) is exactly 1:
     <      #  Decrease `n` by 1 to make it 0-based
      è     #  And use it to index into the filtered infinite list
    ë²<i    # Else-if the second input (A) is 2:
        .i  #  Check if input `n` is in the filtered infinite list
    ë       # Else (second input (A) is 3):
     ›      #  Check for each value whether `n` is larger than it
      Ï     #  Only keep the values at the truthy indices
            #  (hence the duplicate after the filter)
       н    #  And only keep its first value
            # (after which the result is output implicitly)

Oh, you beat me to it (: Here's what I had (order n, A, B, C). Those are remarkably different, there's likely something to gain by merging the two.

@Grimmy I had infinite lists at first as well, but the å screwed that over, hence the use of žm now. I also use 0-based lists, with 1-based input, so it'll ignore the leading 0s. But I think we can indeed save some bytes by using parts from both our programs. :)

Whoops, you're right, I need to use .i instead of å. Still comes out as 44 by stealing your ¬Å¿: TIO.

@Grimmy Oh, didn't knew about .i! That's pretty cool. Was actually working on a test suite with all test cases, which is failing a bit, so will combine our programs first instead.

@Grimmy Your λ+} failed due to the implicit input, so I use ∞Åf instead. I've also kept the 1-based indexing, since it didn't matter for the byte-count anyway. Thanks for -5 though. :)

Bash + GNU utilities, 277 bytes
b=(d*5*d4+dvd*-r4-dvd*-* 8*1+dvd*- d3/3*-)
c=('^(.)(.*\1)?$' ^`seq -s* 9`*$ -v\ 1)
f()(egrep -q ${c[$3]}<<<$5&&dc<<<"$5 ${b[$2]}d/p"||echo 1)
case $1 in
0)for((n=1;k<$4;n++,k+=!`f $* $n`+($n$2$3<102))){ :;};$[--n];;1)n=`f $* $4`;;2)for((n=$4+1;`f $* $n`;n++)){ :;}
esac
echo $n

Try it online!
Input is passed in the arguments, in the order A B C n.  The values A, B, and C are 0-based.
Output is on stdout.  For A=1, the output is 0 for truthy and 1 for falsey.
There is lots of spurious output on stderr, which is allowed under standard golfing rules, but if you want to try it out yourself, I recommend a command like:
madlibs 0 2 1 5  2>/dev/null
so that your output doesn't have stderr output included in it.

The TIO link shows all 27 combinations of A, B, and C, and all values of n from 1 to 6.  (TIO times out if I use larger values for n, but I've tested more on my own computer.)
By the way, this script requires GNU utilities.  In particular, it won't work on OS X (and probably other BSD systems), because seq is different there.

Some comments on the code:
b is an array of three dc scripts for testing whether a number is a Fibonacci number, a triangular number, or a multiple of 3, respectively.  (Each dc script outputs 0 for true and 1 for false.)
c is an array of three regexes which match an input which starts and ends with the same digit, or is in sorted order, or doesn't have any 1s, respectively.  The regex for being in sorted order is computed using seq, not given explicitly, because the code is shorter that way.
f is a function that tests to see if input $5 satisfies the requirements with B=$2 and C=$3.  It prints 0 for true, and 1 for false.  (This works by calling the appropriate dc script from b and matching against the appropriate regex from c.)
The case statement computes the desired answer by calling f as needed to test whether the appropriate numbers have the required properties.