text:
Parse my Esperanto!
The famous constructed language Esperanto uses the Latin alphabet (mostly, see the linked wikipedia page for details). However, there are some characters with accents: ĉ, ĝ, ĥ, ĵ, ŝ, and ŭ. (C-circumflex, g-circumflex, h-circumflex, j-circumflex, s-circumflex, and u-breve.) Naturally, these characters are very hard to type. Even for this question, I had to search in the Unicode selector for the characters. Due to this, a convention using the letter "x" has been developed for electronic use. For example, "cxu" is used for "ĉu". (Note: the letter "x" is not used normally in the Esperanto alphabet."
However, I am a language purist! This *air quote* x nonsense is killing me! I need a program to fix this, preferably as short as possible so I can type it into my terminal as fast as possible!
Challenge
Your mission is to take a string of Esperanto using x-convention and convert it to real Esperanto.
In effect, you have to map:
cx: ĉ
gx: ĝ
hx: ĥ
jx: ĵ
sx: ŝ
ux: ŭ
Cx: Ĉ
Gx: Ĝ
Hx: Ĥ
Jx: Ĵ
Sx: Ŝ
Ux: Ŭ

All other printable ASCII characters should be accepted and not changed. Unicode would be nice, but not necessary.
Input and output can be in any format reasonable to your language. Good luck!
Testcases
"input" : "output"
_____________
"gxi estas varma" : "ĝi estas varma"
"Cxu sxi sxatas katojn aux hundojn?" : "Ĉu ŝi ŝatas katojn aŭ hundojn?"
"Uxcxsxabcd(hxSx)efg{};" : "Ŭĉŝabcd(ĥŜ)efg{};"
"qwertyuiop" : "qwertyuiop"
" " : " "
"" : ""
"x" : "x"
"xc" : "xc"
"xcx" : "xĉ"
"cxx" : "ĉx"

Scoring
This is code-golf. Answers are scored by smallest bytecount in the language's default encoding.
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
# Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
# Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:
# [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=149292,OVERRIDE_USER=47670;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="
"+e.body.replace(OVERRIDE_REG,"")+"
")});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;/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}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Good luck, have fun, and feel free to suggest improvements!
Clarifications:

You only need to worry about printable ASCII characters.

You only need to output a character that looks like the correct output. Yes, this means you can tack the accent onto the standard character.

ASCII here means 20-7E printable characters, 00-7F, or what?

All the printable ones.

Note: I added a clarification that you can use the letter and the modifier accent.

Combining circumflex is at 0302 ̂, and combining breve is at 0306 ̆.

^  Each one take 2 bytes in UTF8 as TIO count.

@user202729 A language purist would most probably hate combining chars, but those are actually easy to type with compose key.

@EriktheOutgolfer what do you mean “compose key”?

I have to point out that your second test sentence, altough grammatically correct, should more likely end with an "n" ("hundojn")

My bad, thanks. Mi pardonpetas.

Try feeding it the input "Linux"

@EriktheOutgolfer Why would a language purist care for different representations of the same grapheme?

QuadR, 65 bytes
.x
3::⍵M⋄'ĉĝĥĵŝŭĈĜĤĴŜŬ'['cghjsuCGHJSU'⍳⊃⍵M]

Try it online!
.x replace any char followed by "x" with
3::⍵M upon indexing error, return the match unmodified
⋄ now try:
 'ĉĝĥĵŝŭĈĜĤĴŜŬ'[…] index into this string with
  ⍵M the match's
  ⊃ first letter's
  ⍳ index
  'cghjsuCGHJSU' in this string
This is equivalent to the Dyalog APL tacit function:
'.x'⎕R{3::⍵.Match⋄'ĉĝĥĵŝŭĈĜĤĴŜŬ'['cghjsuCGHJSU'⍳⊃⍵.Match]}

Nice answer! +1

I'm not sure how bytes are counted here. Isn't the straightforward use of ⎕R shorter? ('cghjsuCGHJSU',¨'x')⎕r(,¨'ĉĝĥĵŝŭĈĜĤĴŜŬ')

@ngn It is, but my battery ran out before I had a chance to post that.

Retina, 27 bytes
iT`x`̂`[cghjs]x
iT`x`̆`ux

Try it online!
This program is composed by two transliterations. Due to having combining characters in the code this doesn't render too well, the first line should actually look similar to iT`x`^`[cghjs]x, where ^ stands for the circumflex accent combining character. What this is saying is that it should Transliterate (ignoring case) all the xs in the input into a ^, whenever they are following any letter in [cghjs].

Note: TIO incorrectly measures this code as 25 bytes. Actually, this Retina program uses UTF-8 encoding (other programs can use UTF-32 or ISO 8859-1) and the two combining characters present cost 2 bytes each.

C,  173  154 bytes
Thanks to @Colera Su for saving 17 bytes!
p,c,i;f(char*s){for(char*l="cghjsuCGHJSU";p=*s;~c&&putchar(p))for(c=*++s,i=0;c=='x'&&l[i];++i)l[i]-p||write(1,"ĉĝĥĵŝŭĈĜĤĴŜŬ"+i*2,2,c=-1,++s);}

Try it online!
Explanation:
p,c,i;
f(char*s)
{
    // The outer loop and an array of characters that are modified by a trailing 'x'.
    // The array/string is used for getting the index for the accented character later.
    for (char*l="cghjsuCGHJSU";

                                // Store the current character of the input string in 'p'.
                                // If it is '\0', the loop terminates.
                                p=*s;

                                      // The last statement in the loop.
                                      // If 'c==-1', it outputs the char stored in 'p'.
                                      ~c&&putchar(p))

        // Store the character following 'p' in 'c' and increment the string pointer.
        for(c=*++s, i=0;

                        // If 'c' is not the letter 'x', the inner loop terminates
                        // immediately. Otherwise it loops through the characters of
                        // string 'l'.
                        c=='x'&&l[i]; ++i)

            // If the character stored in 'p' is found inside the string 'l'...
            l[i]-p ||

                      // ...then print the accented character corresponding to 'p'.
                      // 'i' is the index of 'p' in 'l', and, because the characters
                      // with accents are two bytes each, the index is multiplied by 2.
                      write(1,"ĉĝĥĵŝŭĈĜĤĴŜŬ"+i*2,2,

                      // Finally set 'c' to -1 so that the non-accented character doesn't
                      // get printed too, and increment the string pointer so that the
                      // letter 'x' doesn't get printed either.
                                                    c=-1, ++s);
}

Nice! Can I have an explanation please?

Probably you can use literal null byte instead of \0?

(but that unfortunately doesn't work on TIO)

You can use write(1,"..."+i*2,2) to save 17 bytes. Try it online!

Python 3, 81 bytes
lambda s,T="cĉgĝhĥjĵsŝuŭ":eval("s"+".replace('%sx',%r)"*12%(*T+T.upper(),))

Try it online!
Generates and evaluates the string:
s.replace('cx','ĉ').replace('gx','ĝ').replace('hx','ĥ').replace('jx','ĵ').replace('sx','ŝ').replace('ux','ŭ').replace('Cx','Ĉ').replace('Gx','Ĝ').replace('Hx','Ĥ').replace('Jx','Ĵ').replace('Sx','Ŝ').replace('Ux','Ŭ')

Erik the Outgolfer saved a byte.

///, 75 bytes
/,/\/\///>/x\,/c>ĉ,g>ĝ,h>ĥ,j>ĵ,s>ŝ,u>ŭ,C>Ĉ,G>Ĝ,H>Ĥ,J>Ĵ,S>Ŝ,U>Ŭ/

Note: Because the OP request all printable characters must be processed, my "special characters" chosen must not be printable. So I chosen tab and newline instead of , which does not change my bytecount or code functionality. The code would look like:
/
/\/\/// /x\
/c  ĉ
g   ĝ
h   ĥ
j   ĵ
s   ŝ
u   ŭ
C   Ĉ
G   Ĝ
H   Ĥ
J   Ĵ
S   Ŝ
U   Ŭ/

However that requires the input must not contains tab or newlines.
Try it online!
Because /// can't take input, you should put the input after the code.
Pretty straightforward. I guess it can't be shorter because /// need special handling of each character.
Explanation:
/,/\/\//       Replace all `,` in the code by `//`
               (two slashes are represented as two backslash-ed slashes)
/>/x\,         (in original code) becomes
/>/x\//        (because `,` is replaced by `//`) - replace all occurence of
               `>` by `x/`.
/cx/ĉ//gx/ĝ//hx/ĥ//jx/ĵ//sx/ŝ//ux/ŭ//Cx/Ĉ//Gx/Ĝ//Hx/Ĥ//Jx/Ĵ//Sx/Ŝ//Ux/Ŭ/
               ^ The remaining part of the code should look like this.
               Straightforward replacement.

Python 3, 95 bytes
f=lambda x,v="cĉgĝhĥjĵsŝuŭCĈGĜHĤJĴSŜUŬ":v and f(x.replace(v[0]+"x",v[1]),v[2:])or x

Try it online!
-10 bytes thanks to WhatToDo
-1 byte thanks to Colera Su

96 bytes Try it online!

@user507295 oh smart idea. thanks!

Use and-or trick to save one byte: Try it online!

@ColeraSu oh cool, thanks. not sure why that trick vanished D:

@HyperNeutrino Because I didn't know about that trick. Sorry!

@WhatToDo Ah okay I see :P Don't worry about it! I do that all the time even when I do know the trick :P

Retina, 55 bytes
iT`CG\HJSUcg\hjsux`ĈĜĤĴŜŬĉĝĥĵŝŭ_`[cghjsux]x

Try it online! Non-combining approach. Bytes could be saved if not for the standalone x test cases.

Perl 5, 101 + 1 (-p) = 102 bytes
%k=qw/c ĉ g ĝ h ĥ j ĵ s ŝ u ŭ C Ĉ G Ĝ H Ĥ J Ĵ S Ŝ U Ŭ/;$"=join"|",keys%k;s/($")x/$k{$1}/g

Try it online!

JavaScript (ES6), 92 bytes
s=>[..."cghjsuCGHJSU"].reduce((a,v,i)=>a.split(v+"x").join("ĉĝĥĵŝŭĈĜĤĴŜŬ"[i]),s)

Try it online!
Used split-join method recommended in here to reduce byte counts because the new RegExp(/*blah*/) constructor took up too many bytes.
Comparison:
Original: a.replace(new RegExp(v+"x", "g"), "ĉĝĥĵŝŭĈĜĤĴŜŬ"[i])
New     : a.split(v+"x").join("ĉĝĥĵŝŭĈĜĤĴŜŬ"[i])

Shorter, combining accent approach (63 bytes), but with some artifacts visible.
s=>s.replace(/([cghjs])x/gi," ̂$1").replace(/(u)x/gi," ̌$1");

Footnote: I'm claiming my answer 92 bytes because the 63-byte solution has artifacts that may affect the output.

C, 145 144 bytes
Another C approach. Return by overwriting the input, using the fact that circumflex / breve are 2 bytes.
-1 bytes thanks to Steadybox.
i,t;f(char*s){for(t=1;*s;s++)if(*s^'x')for(i=12,t=1;i--;)t="cghjsuCGHJSU"[i]-*s?t:i*2;else t^1&&memcpy(s-1,"ĉĝĥĵŝŭĈĜĤĴŜŬ"+t,2),t=1;}

Try it online!

Using t^1&&memcpy(s-1,"ĉĝĥĵŝŭĈĜĤĴŜŬ"+t,2),t=1; instead of t^1?memcpy(s-1,"ĉĝĥĵŝŭĈĜĤĴŜŬ"+t,2),t=1:0; saves one byte. Try it online!

QuadR, 25 bytes
Combining diacritics edition.
ux
([cghjs])x
 ̆&
 ̂\1

i flag
Try it online!
Replace…
(u)x         u followed by x and
([cghjs])x   any of these letters followed by x …
 ̆\1          by a breve followed by the first group (the u) and
 ̂\1          a circumflex followed by the first group (the letter)

case insensitively
Equivalent to the following Dyalog APL code:
'(u)x' '([cghjs])x'⎕R' ̆\1' ' ̂\1'

Why is this 28 and not 24 bytes?

@EriktheOutgolfer TIO's SBCS counter confused me. Fixed. Thanks. Wait, does that mean I win?

Huh, now it looks like it's 27 bytes (copied from TIO), but 24 bytes when copied from here. What is QuadR's encoding, and which is correct?

@EriktheOutgolfer Both links report 24 on my FFQ/Win10. QuadR uses Dyalog Classic or any Unicode.

So it's 24 bytes or what?

APL (Dyalog Unicode), 57 bytes
Anonymous tacit function. Usages:

Prefix function to string. This transliterates the string.
Prefix function to list of strings. This transliterates the strings.
Infix function with input file tie number as right argument and output file tie number as left argument. This populates the output file with the transliterated content of the input file.

('cghjsuCGHJSU',¨'x')⎕R(,¨'ĉĝĥĵŝŭĈĜĤĴŜŬ')

(…)⎕R(…) PCRE Replace
'cghjsuCGHJSU' these letters
,¨'x' each followed by an x
 … with…
,¨'ĉĝĥĵŝŭĈĜĤĴŜŬ' each of these letters as strings
Try it online!

Perl 5, 49 + 2 (-p -C) = 61 51 bytes
s/[CGHJScghjs]\Kx/\x{0302}/g;s/[Uu]\Kx/\x{0306}/g

Try it online!
Saved 10 bytes thanks to Nahuel Fouilleul

could save 7 bytes: s/[CGHJScghjs]\Kx/\x{0302}/g;s/[Uu]\Kx/\x{0306}/g

seems it works also just with -C and without -C with warning (Wide character in print)

from perlrun -C on its own (not followed by any number or option list), or the empty string "" for the PERL_UNICODE environment variable, has the same effect as -CSDL.

J, 64 63 bytes
rplc((_2]\'ĉĝĥĵŝŭĈĜĤĴŜŬ');~"1'cghjsuCGHJSU',.'x')"0

How it works:
With _2]\ I rearrange the string 'ĉĝĥĵŝŭĈĜĤĴŜŬ' into a 12-row column in order to fit the shape of the other string.
,. adds 'x' to each character of the 'cghjsuCGHJSU' string and makes a 12 row by 2 columns array
;~"1' makes a list of boxed pairs of the above, "1 - rank 1 - apply to each row.
┌──┬──┐
│cx│ĉ │
├──┼──┤
│gx│ĝ │
├──┼──┤
│hx│ĥ │
├──┼──┤
│jx│ĵ │
├──┼──┤
│sx│ŝ │
├──┼──┤
│ux│ŭ │
├──┼──┤
│Cx│Ĉ │
├──┼──┤
│Gx│Ĝ │
├──┼──┤
│Hx│Ĥ │
├──┼──┤
│Jx│Ĵ │
├──┼──┤
│Sx│Ŝ │
├──┼──┤
│Ux│Ŭ │
└──┴──┘

rplc uses these boxed items to replace each occurrence of the left boxed item from a pair with the right one.
Try it online!

R, 75 70 bytes
function(s)gsub('([cghjs])x','\\1\U302',gsub('(u)x','\\1\U306',s,T),T)

Try it online!
-5 bytes thanks to Giuseppe
Explanation

gsub('(u)x','\\1\U306',s,T): replace in s every occurrence of an uppercase or lowercase "u" (by using ignore.case=TRUE via the fourth argument T) followed by an "x" the "u" followed by the unicode for a breve
gsub('([cghjs])x','\\1\U302',gsub('(u)x','\\1\U306',s,T),T): take the result of that and replace every occurrence of an uppercase or lowercase (by using ignore.case=TRUE via the fourth argument T) "c", "g", "h", "j", or "s" followed by an "x" with the letter followed by the unicode for a circumflex

using argument order rather than naming saves 3 bytes, and another two getting rid of the leading zero in \U0302 and \U0306: Try it online!

@Giuseppe -- great idea, thanks!

Befunge, 2x48 +1 = 99 bytes
>~:1+!#@_:"x"-v>$ 11p0"cghjsuCGHJSU"1\ >\31p11g-v
^ # #, : ++$\ _^#1"x"0*4!-"u"g11*"ʊ"!\_^#!:\*g13<

Try It Out (TIO is super weird about Befunge and I couldn't get any of my solutions to work on it)
How it works
>~:1+!@_

Gets input and checks if it's the end. End program if it is.
          "x"-v>
^ # #, : ++$\ _^

Checks if the character is an "x". If not, keep a copy of the character and print it.
               >$ 11p0"cghjsuCGHJSU"1\

Store the last character at (1,1). Puts all the characters to check into the stack.
                                       >\31p11g-v
                                      _^#!:\*g13<

Compare the last character against all the values in the stack.
                 1"x"0*4!-"u"g11*"ʊ"!\

Multiply the check (0 or 1) by ʊ (unicode value 650). Check whether the character was a u (for the breve) and adds 4 to the stack if so. Finally, add the ascii value of x (100) as well. The total adds up to the correct accent if needed or just an "x" if not.
>~:1+!#@_
^ # #, : ++$\ _^#

Add all the values in the stack together, print it and keep a duplicate. Go back up for the next input.

Mathematica, 81 bytes or 57 bytes
StringReplace[RemoveDiacritics@#<>"x"->#&/@Characters@"ĉĝĥĵŝŭĈĜĤĴŜŬ"]
It applies a replacement rule where the letter without the hat together with an "x" is replaced by the letter.
Here is an alternative using the added accents character:
StringReplace[{"ux"->"ŭ","Ux"->"Ŭ",c_~~"x":>c<>"̂"}]

sed, 40 bytes (38 chars)
s/([cghjsCGHJS])x/\1̂/g
s/(u|U)x/\1̆/g

Try it online!
I believe this is different enough from iBug's answer.

Lexurgy, 60 48 bytes
a:
x=>̂/{c,g,h,j,s,C,G,H,J,S} _
x=>̆/{U,u} _

Replaces x with the correct combining diacritic based on the preceding character.

-12 bytes for removing the Class.

CJam, 51 bytes
q"ĉĝĥĵŝŭĈĜĤĴŜŬ""cghjsuCGHJSU".{'x+@\/*}

Try it online!
Explanation:
q                   Read input
"ĉĝĥĵŝŭĈĜĤĴŜŬ"      String literal
"cghjsuCGHJSU"      Another string literal
.{                  Iterate over the strings in parallel
  'x+                 Add an 'x to the normal character
  @                   Rotate to bring the input to the top of stack
  \                   Swap to bring the "cx" to the top
  /                   Split the input on instances of "cx"
  *                   Join the input on instances of the accented character
}

Is this really 39 bytes? I count 39 characters and I don't think CJam have a special encoding.

@user202729 Changed (TIO counted bytes as characters for some reason)

Because TIO believe that all golfing languages have special character codepage, and it doesn't bother check if all characters are in the correct codepage.

JavaScript (ES6), 91 bytes
(i,s='cĉgĝhĥjĵsŝuŭCĈGĜHĤJĴSŜUŬ')=>i.replace(/.x/g,m=>s[1+s.search(m[0])||s]||m)

Try it online!

Scala, 110 bytes
Boring regex solution:
def?(s:String)="(.)x".r.replaceAllIn(s,m=>m.group(0)(0)+(if(m.group(0)(0).toUpper=='U')"\u0306"else"\u0302"))

Old scala solution (116 bytes)
def?(s:String)=s.foldLeft("")((r,c)=>if(c=='x')r.init+r.last+(if(r.last.toUpper=='U')"\u0306"else"\u0302")else r+c)

Ungolfed
def?(s:String)=
  s.foldLeft("")((r,c)=>  // 'Fold' string with empty string as first result
    if(c=='x')            // If current character is x
      r.init+             // Take the every character from result but the last
        r.last+           // The last character from result and add
          (if(r.last.toUpper=='U')
            "\u0306"      // combining breve if 'u' or 'U'
          else"\u0302")   // combining circumflex in any other case
 else r+c                 // Otherwise return result + character
)

PowerShell, 58 bytes
It's 54 characters and saving it in PowerShell ISE makes it UTF-8 + BOM for 58 bytes. It doesn't render as nicely in a browser:
$args-replace'(?<=u)x','̆'-replace'(?<=[cghjs])x','̂'

regex replaces the x with the combining Unicode characters from @user202729's comment.
e.g.
PS C:\> .\eo.ps1 "Cxu vi sxatas la cxapelliterojn? Mi ankaux."
Ĉu vi ŝatas la ĉapelliterojn? Mi ankaŭ.

Clojure, 126 115 bytes
-11 bytes by changing the replacement map to a partition of a string.
#(reduce(fn[a[f r]](clojure.string/replace a(str f\x)(str r)))%(partition 2"cĉgĝhĥjĵsŝuŭCĈGĜHĤJĴSŜUŬ"))

A reduction over a map of replacements to look for, and what to replace them with.
Still working on a way to compress the replacement map.
(defn translate [^String esperanto]
  (reduce (fn [acc [f r]] (clojure.string/replace
                            acc ; Replace the translation so far by
                            (str f \x) ; adding a x after each character, search for it in the string,
                            (str r))) ; and replace it with a stringified accented char

          esperanto ; Before the reduction happens, the accumulator is the original string

          ; A list of [char-to-find what-to-replace-with] pairs
          (partition 2"cĉgĝhĥjĵsŝuŭCĈGĜHĤJĴSŜUŬ")))))

JavaScript, 35 chars, 36 bytes
s=>s.replace(/([cghjsu])x/gi,"$1̂")

I don't think that works because ux should convert to ŭ, not û.

Raku, 57 50 bytes
{S:g:i/(<[cghjsu]>)x/{$0~chr 770+4*("u"eq$0.lc)}/}

Try it online!

Zsh, 71 bytes
for 2 3 (`fold -1<<<${a=cĉgĝhĥjĵsŝuŭ}${a:u}`)1=${1//$2x/$3}
<<<$1

Try it online!

sed, 108 bytes
s/cx/ĉ/g
s/gx/ĝ/g
s/hx/ĥ/g
s/jx/ĵ/g
s/sx/ŝ/g
s/ux/ŭ/g
s/Cx/Ĉ/g
s/Gx/Ĝ/g
s/Hx/Ĥ/g
s/Jx/Ĵ/g
s/Sx/Ŝ/g
s/Ux/Ŭ/g

You should format the code as code by \...`or...` or 4 indents.

@user202729 I obviously knew that. I was submitting from my Android phone so I didn't format it correctly.

This looks like it's 119 bytes long.


text:
Odd'em out: letters
Objective
Write a program or function (or equivalent) that sorts out and returns the odd letter in the matrix of random size.
Details
You will be passed a matrix (as a string) as input of random dimensions such as this.

bbbbbbbbbb
bbbbbdbbbb
bbbbbbbbbb
bbbbbbbbbb
bbbbbbbbbb

Your job is to find the letter that doesn't match the rest (in this case, it is d, found at line 2, col 6) and to return that letter as output. The matrix will consist of letters A-Z, a-z, newlines (\n, only on ends of rows) and have dimensions ranging from 5x5 to 10x10 (25-100 letters).
Standard loopholes apply. This is a code golf challenge;  entry with code of least bytes wins.
Input
Input will be passed in through standard input as a string if it is a program or as an argument if a function (or similar).
Output
A single character that is the "odd" in the matrix or None, nil, NUL, or the string "None" if there is no "odd" character.
More Examples

AAAAAAA
AAAAAAA
AAAAAAA
AAAIAAA
AAAAAAA

Answer: I

vvqvvvvvvv
vvvvvvvvvv
vvvvvvvvvv
vvvvvvvvvv
vvvvvvvvvv

Answer: q

puuuuuuuu
uuuuuuuuu
uuuuuuuuu
uuuuuuuuu
uuuuuuuuu
uuuuuuuuu
uuuuuuuuu
uuuuuuuuu
uuuuuuuuu
uuuuuuuuu

Answer: p
Generator
Here is a random matrix generator written in Python that you can use to test your program. Note: There is a slight chance that it could make a mistake and not put in an odd letter.

Instructions

1. Copy this code into a file called `matrix_gen.py`.
2. Run it with `python matrix_gen.py`.

---

from random import randint

rows = randint(5,10)
cols = randint(5,10)

charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
neg = charset[randint(0,51)]
pos = charset[randint(0,51)]
p_used = 0

comp = 0
matrix = ""

while comp < rows:
  row = ""
  while len(row) < cols:
    if not p_used and not randint(0,10):
      p_used = 1
      row = row + pos
    else:
      row = row + neg
  row = row + "\n"
  matrix = matrix + row
  comp += 1

print matrix[:-1]

Here is a literal translation of your Python code into JS.

@juniorRubyist "removing the bonus" isn't the same as "making the bonus mandatory". By moving the part that was optional so far into the requirements of the challenge, you've invalidated a large part of the existing answers.

Just let people output whatever if there's no character.

Python 3, 27 bytes
lambda x:min(x,key=x.count)

Try it online!

J, 12 10 7 bytes
-.}./.~

Try it online!
    /.~        Group identical items together
  }.           Remove one item from each group
-.             Remove the rest from the input

10 byte version
-._1 1{\:~

hisss...
       \:~        Sort down
  _1 1{           Take the last character (which is a newline) and the second one.
-.                Remove those from the input

@ FrownyFrog This is a clever way to find the odd character

can’t decide what i like better: this lovely hook or your dragon joke...

Brachylog, 8 4 bytes
oḅ∋≠

Try it online!
Explanation
I haven't used Brachylog before, so this may not be optimal.
oḅ∋≠  Input is a string.
o     Sort the input.
 ḅ    Split it into blocks of equal elements.
  ∋   There is a block
   ≠  whose elements are all different.
      That block is the output.

That use of ∋≠ after ḅ to get the results of length 1 is very clever. You should definitely post it in the Brachylog tips question.

@Fatalize Thanks, I added the tip.

05AB1E,  4  2 bytes
Saved 2 bytes thanks to Adnan
.m

Try it online!
Explanation
.m   # push a list of the least frequent character(s) in input

Do you need to remove the newlines, seeing as we're guaranteed the input will be at least 5 lines long?

@Shaggy: No I don't. That was to handle 2x2 matrices. I missed the part about 5x5 and up. Thanks!

It has to return nil if it doesn't have an "odd one out" doesn't it?

@MagicOctopusUrn That part was optional when this answer was posted. I guess that change invalidates most answers now...

K (oK), 7 6 bytes
Solution
*<#:'=

Try it online!
Example:
*<#:'="vvqvvvvvvv\nvvvvvvvvvv\nvvvvvvvvvv\nvvvvvvvvvv\nvvvvvvvvvv"
"q"

Explanation:
Found a slightly shorter approach: Evaluated right-to-left:
*<#:'= / the solution
     = / group matching items together
  #:'  / count (#:) each (')
 <     / sort ascending
*      / take the first one

Notes:
Whilst I'm expecting the bonus aspect of this challenge to get dropped, this solution will return the newline character \n if there is no odd character:
*<#:'="vvvvvvvvvv\nvvvvvvvvvv\nvvvvvvvvvv\nvvvvvvvvvv\nvvvvvvvvvv"
"\n"

C (gcc), 93 92 90 66 62 Bytes
Much shorter as a function
t;f(char*p){for(t=*p;*p;)t^*p++?putchar(*p^*--p?*p:t),*p=0:0;}

Try it online!
test code
main()
{
    char s[99];
    for(;gets(s);)f(s);
}

old version is a program
C 86 Bytes
char*p;s[9];main(t){for(;p=gets(s);)for(t=*p;*p;)t^*p++?putchar(*p^*--p?*p:t),*p=0:0;}

Outputs the odd character, or nothing.  run like this;
C:\eng\golf>python matrix_gen.py | a.exe
X
C:\eng\golf>python matrix_gen.py | a.exe
G
C:\eng\golf>python matrix_gen.py | a.exe
x
C:\eng\golf>python matrix_gen.py | a.exe

C:\eng\golf>python matrix_gen.py | a.exe
J

I don't know that it is quite fair to put the gets() into the test driver as it is sanitizing the input by removing the \n chars for you.  That's doing some work so that your function is not working on the original input.

@MichaelDorgan It works with the piped input from the python script as well as input on TIO.  Others simply hard-coded the input which didn't seem with the spirit of the challenge.

Suggest *p=!putchar(*p^*--p?*p:t) instead of putchar(*p^*--p?*p:t),*p=0

Prolog (SWI), 46 bytes
p(L):-select(X,L,Y),\+member(X,Y),writef([X]).

Try it online!
Or if the standard true output from prolog queries is not okay:
Prolog (SWI), 48 bytes
Z*L:-select(X,L,Y),\+member(X,Y),char_code(Z,X).

Try it online!
Explanation
Find the first element X in the input
that when removed, results in output
that does not contain X

then depending on the version above either:
print X as a character
or
return X as an atom

C, 94 bytes
Return by pointer. If none, return \0.
This will cause memory leaks. Assuming int is 4 bytes.
*t;f(c,p,i)char*c,*p;{t=calloc(64,8);for(*p=-1;*c;c++)t[*c]--;for(i=0;++i<128;)!~t[i]?*p=i:0;}

Try it online!

Functions must be reusable.

@Shaggy Actually, I don't know how to interpret that rule, as I see some (other) users explicitly know about that rule but still post such answers like this one.

@user202729, just because others do it doesn't mean it's right ;) If you spot such solutions, best to point it out to them.

@Shaggy Well, I explicitly pointed the rule but that user said "the rule explicitly says that this one is valid". I don't know what to say. | In this case the function require the array t be zeroed before calling each time not the first time.

@Shaggy Thanks, fixed.

Mathematica, 27 bytes
Last@*Keys@*CharacterCounts

Try it online!
-1 byte from Martin Ender

Retina, 13 bytes
s(O`.
(.)\1+

Try it online!
Explanation
s(O`.

Sort all characters.
(.)\1+

Remove any characters that appear at least twice.

Bash, 15 20 bytes
fold -1|sort|uniq -u

Try it online!
Explanation: folds the input to 1 character per line, sorts it into groups of matching letters, then prints only lines that are unique.
Thanks @Nahuel Fouilleul for catching and helping fix a problem with this approach.

doesn't work if the odd character is the second or the penuitlimate

@NahuelFouilleul Good catch... I'm unsure of how to fix that at the moment, but I will fix or delete later unless you had a suggested fix.

it can be simply fix with |sort| but there may be a better solution

also found a solution with grep but it's longer grep -oP '^(.)((?=(?!\1).){2}|.*\K(?!\1).)'

@NahuelFouilleul I'm going with the sort fix, thanks. You could always post that grep answer as your own if you want to, though.

Husk, 2 bytes
◄=

Try it online!
This is a function taking a string as input and returning a character. It takes the minimum of the input string when comparing characters for equality (i.e. it returns the character that is equal to the least number of other characters).

JavaScript (ES6), 37 bytes
Returns null if there's no odd letter.
s=>s.match(`[^
${s.match(/(.)\1/)}]`)

Test cases

let f =

s=>s.match(`[^
${s.match(/(.)\1/)}]`)

console.log(f(
  'bbbbbbbbbb\n' +
  'bbbbbdbbbb\n' +
  'bbbbbbbbbb\n' +
  'bbbbbbbbbb\n' +
  'bbbbbbbbbb'
))

console.log(f(
  'AAAAAAA\n' +
  'AAAAAAA\n' +
  'AAAAAAA\n' +
  'AAAIAAA\n' +
  'AAAAAAA'
))

console.log(f(
  'vvqvvvvvvv\n' +
  'vvvvvvvvvv\n' +
  'vvvvvvvvvv\n' +
  'vvvvvvvvvv\n' +
  'vvvvvvvvvv'
))

console.log(f(
  'puuuuuuuu\n' +
  'uuuuuuuuu\n' +
  'uuuuuuuuu\n' +
  'uuuuuuuuu\n' +
  'uuuuuuuuu\n' +
  'uuuuuuuuu\n' +
  'uuuuuuuuu\n' +
  'uuuuuuuuu\n' +
  'uuuuuuuuu\n' +
  'uuuuuuuuu'
))

console.log(f(
  'AAAAA\n' +
  'AAAAA\n' +
  'AAAAA\n' +
  'AAAAA\n' +
  'AAAAA'
))

Jelly, 4 bytes
ċ@ÐṂ

Try it online!
Return \n (a single newline) in case there is no odd character. Obviously \n is not a printable character.
Coincidentally this is exactly the same algorithm as Mr.Xcoder Python answer. (I came up with it independently)
Explanation:
  ÐṂ    Ṃinimum value by...
ċ@      ċount. (the `@` switch the left and right arguments of `ċ`)

That works because in a m×n matrix:

If there exists odd character: There are m-1 newlines, 1 odd characters and m×n-1 normal character, and 1 < m-1 < m×n-1 because 5 ≤ m, n ≤ 10.
If there doesn't exist odd character: There are m-1 newlines and m×n normal character, and m-1 < m×n.

Pyth, 4 bytes
ho/Q

Try it here!

.m/Q is 4 bytes as well

@Dave That outputs as a list though, I chose this because it was more elegant ;-)

Japt -h, 6 4 bytes
ü l1

Try it
ü l1     :Implicit input of multiline string
ü        :Group & sort
  l1     :Filter elements of length 1
         :Implicit output of last element

C# (.NET Core), 54 bytes
i=>i.GroupBy(x=>x).FirstOrDefault(g=>g.Count()<2)?.Key

Try it online!

You are right, my answer was wrong. I have deleted it. But you are missing the 18 bytes from the using statement in the byte count.

Perl 5, 17 + 3 (-00p) -25% = 15 bytes
/(.)\1/;s/
|$1//g

try it online

Octave, 26 25 bytes
1 byte saved thanks to @Giuseppe
@(x)x(sum(x(:)==x(:)')<2)

Anonymous function that takes a 2D char array as input, and outputs either the odd letter or an empty string if it doesn't exist.
Try it online!

Haskell, 33 * 0.75 = 24.75 bytes
f s=[c|[c]<-(`filter`s).(==)<$>s]

Returns an empty list if there's no odd character.
Try it online!
For each char c in the matrix (given as a string s) make a string of all chars in s that are equal to c and keep those of length 1.

Common Lisp, 47 bytes
(lambda(s)(find-if(lambda(x)(=(count x s)1))s))

Try it online!
Returns the odd letter or NIL if it does not exist.

C (gcc), 91 86 82 79 71 bytes
f(char*s){for(;*++s==10?s+=2:0,*s;)if(*s^s[-1])return*s^s[1]?*s:s[-1];}

Try it online!

Thanks to Gastropner for the xor and ? tricks (-3 bytes)
Reworked the compare version to fix bugs and used Gastropner magic from comments.

Explanation:
Compare current and previous char while skipping newlines.  If different, compare to next char.  This tells us if we return current or previous char.  The function returns the "odd" char value if it exists or 0 if the array is not odd. We get away with the "next" char check because there is always a newline before the \0 char.  If there is no odd char, we intrinsically return the \0 from the for loop.

Older, sexier xor code Explanation:
Make a running xor mask of the next 3 string values.  If they are all the same, then the value will be equal to any of the three.  If they are different, then the 2 identical will cancel each other out leaving the unique.
Must factor /n before the xor or it gets messy.
Also have to check 2 chars for inequality in case s[0] is the odd value.  This costs the extra || check.
v;f(char*s){while(s[3]){s[2]==10?s+=3:0;v=*s^s[1]^s[2];if(v^*s++||v^*s)break;}}

79 with a few tweaks. The fall-through return does not agree with my compiler, so only tested on TIO: v;f(char*s){while(s[3]){s[2]==10?s+=3:0;v=*s^s[1]^s[2];if(v^*s++||v^*s)break;}}

For the crap I am writing, TIO is what I stick with.  Thanks!

Rearranging some expressions allows another -2 for 77: v;f(char*s){while(s[2]==10?s+=3:0,v=*s^s[1]^s[2],s[3])if(v^*s++||v^*s)break;}
However your winning horse is the other one, if you fiddle with it a bit, for 73: v;f(char*s){for(v=-1;*++s==10?s+=2,v--:0,*s;v=0)if(*s^s[-1])return s[v];}

Yeah, but the xor seems so sexy.  :)

Suggest s+=*++s-10?0:2 instead of *++s==10?s+=2:0

Matlab, 25 Bytes
a=input('');a(a~=mode(a))

The input "a" where "a" isn't the mode of "a".
Outputs empty array for no oddball.

Java 8, 85 bytes
This is a lambda from String to String (e.g. Function<String, String>). It's essentially a copy of Luca's solution, but I've pared down the string sorting a bit.
s->new String(s.chars().sorted().toArray(),0,s.length()).replaceAll("(.)\\1+|\\n","")

Try It Online

Stax, 2 bytes
|!

Run and debug it

Alice, 16 * 75% = 12 bytes
/-.nDo&
\i..*N@/

Try it online!
Outputs Jabberwocky if there is no duplicate character.
Explanation
/...@
\.../

This is a framework for linear programs that operate entirely in Ordinal (string processing mode). The actual code is executed in a zigzag manner and unfolds to:
i..DN&-o

i   Read all input.
..  Make two copies.
D   Deduplicate one copy, giving only the two letters and a linefeed.
N   Multiset difference. Removes one copy of each letter and one linefeed.
    Therefore it drops the unique letter.
&-  Fold substring removal over this new string. This essentially removes
    all copies of the repeated letter and all linefeeds from the input,
    leaving only the unique letter.
.   Duplicate.
n   Logical NOT. Turns empty strings into "Jabberwocky" and everything else
    into an empty string.
*   Concatenate to the previous result.
o   Print the unique letter or "Jabberwocky".

Instead of &-, we could also use ey (transliteration to an empty string). Alternatively, by spending one more character on stack manipulation, we could also deduplicate the input which lets us remove the unwanted characters with N, but it's still the same byte count:
i.D.QXN.n*o@

Alice, 13 bytes
/N.-D@
\i&.o/

Try it online!
This is the solution without the bonus, it's simply missing the .n*.

Retina, 22 bytes
!`(.)(?!.*\1)(?<!\1.+)

Try it online! Only requires height and width of at least 3, rather than 5.

Ruby, 33 bytes
->s{s.chars.min_by{|c|s.count c}}

Try it online!
Uses the same idea as Mr. Xcoder's great Python answer.

APL+WIN, 16 bytes
(1=+/a∘.=a)/a←,⎕

Prompts for screen input and either outputs odd letter or nothing if there is no odd letter

a/⍨1=+/a∘.=a←,⎕ for a byte

@Uriel Thanks but I am afraid the operator ⍨ is not available in my old APL+WIN version 5 :(

PowerShell, 39 bytes
([char[]]"$args"|group|sort c*)[0].Name

Try it online!
Takes input as a string with newlines (as specified in the challenge), converts it to a char-array. We then Group-Object the characters, so that characters are grouped together by their names, then sort based on the count. This ensures that the lonely character is first, so we take the [0] index and output its .Name.
If newline is acceptable for "nothing" then this qualifies for the bonus.

I was hoping sort c*)[0] could be shortened, but what I came up with was the same number of bytes, ? c* -eq 1).

can be shortened by removing the double quotes around $args. Also it is more accurate to do ([char[]]$args|group|? c* -eq 1).Name as it will accurately return null when there is no odd character (instead of new line). However in terms of bytes this still won't bring you below 37.

@cogumel0 Doesn't run without double quotes.

@root you're correct. However to pass one of the requirements (A single character that is the "odd" in the matrix or None, nil, NUL, or the string "None" if there is no "odd" character.) it should still be changed. Newline is not part of the acceptable answers.

@cogumel0 Ah, the challenge was changed since I posted my answer. The "None / nil / whatever" used to just be a bonus rather than mandatory. I'm going to keep my answer as-is.

@AdmBorkBork thx for the explanation, now it's clear why your solution was posted that way.

Perl 6,  27  24 -25% = 18 bytes
*.comb.Bag.min(*.value).key

Test it
{%(.comb.Bag.invert){1}}

Test it
This will return an undefined value when given an input that doesn't have an odd character out.
Expanded:
{  # bare block lambda with implicit parameter ｢$_｣

  %(        # coerce into a Hash

    .comb   # split the input into graphemes (implicit method call on ｢$_｣)
    .Bag    # turn into a weighted Set
    .invert # invert that (swap keys for values) returns a sequence

  ){ 1 }    # get the character that only occurs once
}

Java (OpenJDK 8), 93 98 108 bytes
a->{char[]r=a.toCharArray();java.util.Arrays.sort(r);return String.valueOf(r).replaceAll("(.)\\1+|\\n","");}

Try it online!
The input is converted to an array of characters, which is then sorted. We have to make a string again so we can replace all occurences matching the regex.
I first tried to simply do it with one "replaceAll" but I did not manage to create a regex that would delete the first a in "abaa" for example.

I think what you're looking for in the first two statements is char[] r = a.toCharArray(); Arrays.sort(r); a = new String(r);; the existing code doesn't actually do anything to a. This should fix your solution for cases like abaa.

@Jakob the code does something. It converts a string to a char array and sorts it, then it changes it back to a string and replaces everything appearing more than once. If I managed to create a regex matching cases like abaaI could leave out the part converting the string to an array etc.

Nope. The first statement sorts a copy of the string's character array and discards it, and the second statement passes a through String.valueOf(Object), which leaves it unchanged.

@Jakob I don't have any words for this... I am sure I tested it and it was working in my tests but I simply feel stupid now, of course it discards the copy... Thank you

@Jakob fixed, but it costs 5 bytes... I should stop trying to submit Java solutions, in part because I seem to be an idiot :D

No, by all means keep golfing! The more you practice, the better you'll get.

One more thing: lambda solutions can't use imports without including them in the byte count, so you'll have to either add in an import for Arrays or use the fully-qualified name in your lambda.

@Jakob oh man, didn't think about that... plus another 10 bytes ^^ but hey, at least it's valid now :P and thank you for encouraging

R, 61 bytes
cat(names(sort(table(unlist(strsplit(scan(,""),""))),T))[-1])

Try it online!
Takes input from stdin, outputs the letter (or the empty string) to stdout.
Explanation:
x=scan(,"")                     # read in input
x=unlist(strsplit(x,""))        # split into characters
x=table(x)                      # tabulate character counts
x=sort(x,T)                     # sort into decreasing order
x=names(x)                      # get the names (the characters)
x=x[-1]                         # remove the first element
cat(x)                          # print out the remaining letter (or nothing if none exist)

Brainfuck, 125 bytes
,[----------[>],]<[->+<]<<[[->->+<<]>[>[->-<<<+>>]>[,<<,>>]<<<[->+<]>[->+<]<]>[-<<+>>]>[-<+>]<<<<]>>>>[<]<++++++++++.

Try It Online
Prints the letter of the matrix if there is no odd one out

PHP, 74 bytes
normal program, 57 bytes:
<?=chr(array_search(min($a=count_chars($argv[1],1)),$a));

(prints a newline if the is no odd character)
modified program, 74 bytes:
<?=count($a=count_chars($argv[1],1))<4?None:chr(array_search(min($a),$a));

(assumes Windows linebreaks; replace 4 with 3 for input with Unix linebreaks)
Run with php <scriptname> '<matrix>' or try then online.

Arturo, 36 bytes
$[s][select s'c->one? match s~"|c|"]

Try it

J, 17 bytes
~.{~[:(i.<./)#/.~

Outputs the odd character or LF.
Attempt This Online!
~.{~[:(i.<./)#/.~
    [:             NB. [: f g forces f(g(y))
             #/.~  NB. character frequency
      (i.<./)      NB. monadic hook
         <./       NB. minimum
       i.          NB. index of minimum in frequency list
  {~               NB. index from
~.                 NB. unique characters

Thunno DD, \$ 10 \log_{256}(96) \approx \$ 8.23 bytes
dcZZz;AKAK

Attempt This Online!
Explanation
dcZZz;AKAK  # Implicit input
dc          # Count of each character
  ZZ        # Zip with input
    z;      # Reverse-sort this list
      AKAK  # Last item of last item
            # Implicit output

Thunno 2, 3 bytes
æcḅ

Try it online!
Explanation
æcḅ  # Implicit input
æ    # Filter by:
 c   #  Count in input
  ḅ  #  Equals one
     # Implicit output

10 chars with two flags in Thunno 1, 3 bytes flagless in Thunno 2. Lol

@noodleman ikr so much progress :p Enjoy your holiday btw

source: Stack Exchange

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

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

sort: votes


text:
cool untitled sequence thingy
Let's define fn(k) as the sum of the first k terms of the natural numbers [1, ∞) where each number is repeated n times.
k       | 0    1    2    3    4    5    6    7    8    9
--------+-------------------------------------------------
f_1(k)  | 0    1    3    6    10   15   21   28   36   45
deltas  |   +1   +2   +3   +4   +5   +6   +7   +8   +9
--------+-------------------------------------------------
f_2(k)  | 0    1    2    4    6    9    12   16   20   25
deltas  |   +1   +1   +2   +2   +3   +3   +4   +4   +5
--------+-------------------------------------------------
f_3(k)  | 0    1    2    3    5    7    9    12   15   18
deltas  |   +1   +1   +1   +2   +2   +2   +3   +3   +3
The anti-diagonals of this as a square array is similar to OEIS sequence A134546.
Challenge
Write a program/function that takes two non-negative integers n and k and outputs fn(k).
Specifications

Standard I/O rules apply.
Standard loopholes are forbidden.
Your solution can either be 0-indexed or 1-indexed for n and/or k but please specify which.
This challenge is not about finding the shortest approach in all languages, rather, it is about finding the shortest approach in each language.
Your code will be scored in bytes, usually in the encoding UTF-8, unless specified otherwise.
Built-in functions that compute this sequence are allowed but including a solution that doesn't rely on a built-in is encouraged.
Explanations, even for "practical" languages, are encouraged.

Test cases
In these test cases, n is 1-indexed and k is 0-indexed.
n   k      fn(k)

1   2      3
2   11     36
11  14     17
14  21     28
21  24     27
24  31     38
31  0      0
In a few better formats:
1 2
2 11
11 14
14 21
21 24
24 31
31 0

1, 2
2, 11
11, 14
14, 21
21, 24
24, 31
31, 0

Reference implementation
This is written in Haskell.
f n k = sum $ take k $ replicate n =<< [1..]

Try it online!
This challenge was sandboxed.

Do you think that my edit improves formatting, or is it just on my browser?

@user202729 Heh... it looks off on my browser but I doubt my formatting looked good on most browsers... I'll just keep it like that, it doesn't lose any meaning. Just looks weird. :P

Do we need to handle the case f_n(0) = 0 for k 0-indexed?

@Cinaski 0 must be the first term, yes.

"cool untitled sequence thingy" Lol, I'm not the only one having a hard time coming up with names for sequences I made up I see.. ;)

@KevinCruijssen I was thinking of something along the lines of "Element-wise repeated range sum", but then I realized I literally suck at naming and my current title is so much cooler. :P

Can we output the first k elements?

@dylnan Sorry, no. In my opinion, that makes comparing solutions harder.

Isn't this just a long-winded way to say "n times the sum of natural numbers up to k", which is equal to n*(k²+k)/2?

@Fabian No, you only sum the first k terms from the list of repeated natural numbers, not the first n*k terms.

Ah, ok. Still seems like it could be optimised, but that would probably not make the code shorter.

Ruby, 32 28 23 bytes
->n,k{k.step(0,-n).sum}

Try it online!
Explanation
Let's visualize the sum as the area of a triangle, for example with n=3 and k=10:
*
*
*
**
**
**
***
***
***
****

Then we sum by column instead of row: the first column is k, then k-n, k-2n and so on.

Husk, 4 bytes
Σ↑ṘN

Try it online!
Explanation
This just ends up being a direct translation of the reference implementation in the challenge:
   N  Start from the infinite sequence of all natural numbers.
  Ṙ   Replicate each element n times.
 ↑    Take the first k values.
Σ     Sum them.

Python 2, 34 28 bytes
lambda n,k:(k+k%n)*(k/n+1)/2

Try it online!
Thanks Martin Ender, Neil and Mr Xcoder for helping.

You don't actually need the k/n anyway - k-(k/n)*n is just k%n. See my Batch answer.

28 bytes

Thanks. I didn't think it could get so simple.

Mathematica, 40 bytes
Tr@Sort[Join@@Range@#2~Table~#][[;;#2]]&

Try it online!
Tr[Range@(s=⌊#2/#⌋)]#+#2~Mod~#(s+1)&

Try it online!
Mathematica, 18 bytes
by Martin Ender
Tr@Range[#2,0,-#]&

Try it online!
n~Sum~{n,#2,0,-#}&

Try it online!

Tr@Range[#2,0,-#]& or n~Sum~{n,#2,0,-#}& using the trick from G B's Ruby answer.

APL (Dyalog), 12 10 8 bytes
+/∘⌈÷⍨∘⍳

Try it online!
n on the left, k (0 indexed) on the right.

MATL, 12 11 bytes
:iY"Ys0h1G)

Try it online!
k is 0-indexed.
Takes input in reverse order.
Saved 1 byte thanks to @Giuseppe

Jelly, 5 bytes
Rxḣ³S

One more byte than @Mr.Xcoder's Jelly solution but this is my first ever submission in Jelly and I'm still confused about how the tacitness of Jelly chooses operands so I'm still satisfied. Note the order of the inputs are k then n.
Explanation
Rxḣ³S
R           Range: [1,2,...,k]
 x          Times: repeat each element n times: [1,1,1,2,2,2,...,n,n,n]
  ḣ³        Head: take the first k elements. ³ returns the first argument.
    S       Sum

Try it online!

Jelly, 4 bytes
1-indexed
Ḷ:‘S

Try it online! or see a test suite.

You can do 0 indexing so I think Ḷ:S also works

@dylnan Actually I don’t think that’s what 0-indexed means here. I rolled back, and we’ll see

@dylnan Division by zero is an error.

JavaScript (ES6),  24  21 bytes
Takes input in currying syntax (n)(k). Returns false instead of 0.
n=>g=k=>k>0&&k+g(k-n)

Test cases

let f =

n=>g=k=>k>0&&k+g(k-n)

console.log(f(1 )(2 )) // 3
console.log(f(2 )(11)) // 36
console.log(f(11)(14)) // 17
console.log(f(14)(21)) // 28
console.log(f(21)(24)) // 27
console.log(f(24)(31)) // 38

How?
n =>             // main unamed function taking n
  g = k =>       // g = recursive function taking k
    k > 0 &&     // if k is strictly positive:
      k +        //   add k to the final result
      g(k - n)   //   subtract n from k and do a recursive call

This is similar to @GB's Ruby answer.
The challenge describes how to build the 'staircase' from left to right, whereas this recursive function builds it from bottom to top. With n = 2 and k = 11:

C, 38 34 bytes
Recursive definition.
-4 bytes thanks to Steadybox.
f(n,k){return k--?1+f(n,k)+k/n:0;}

Try it online!

32 bytes by Mr. Xcoder, G B
f(n,k){return(k+k%n)*(k/n+1)/2;}

Try it online!

34 bytes in Python, 36 bytes in C

Using G B's approach, 32 bytes

https://tio.run/##RcpBCoMwEIXhtTnFEBBmOik2brqIHkZSUmLoVKxdiWeP01VXH7z3x@szxloTiiu0y4iFSyt0wdIJe@r6cNQsG7ymLEhmN016r4C/aYYRfFAGuCvMDpbv9kFriUzz77J2t6AM4HuVmWBZ9Ulo2wdYBwlnB5komKOe -> 28 bytes

34 bytes (the recursive version): f(n,k){return k--?1+f(n,k)+k/n:0;} Try it online!

Batch, 34 bytes
@cmd/cset/a(%2+%2%%%1)*(%2/%1+1)/2

A closed-form formula that I found. First argument n is 1-indexed, second argument k is 0-indexed.

Python 2, 29 bytes
lambda n,k:sum(range(k,0,-n))

Try it online!
Thanks to totallyhuman for -3 bytes!

Python 2, 30 bytes
f=lambda n,k:k>0and k+f(n,k-n)

Try it online!

Haskell, 28 bytes
n#k|m<-k`mod`n=sum[m,m+n..k]

Try it online!
An approach I found just by screwing around with some range parameters. Most definitely not the shortest but it's pretty cool how there's so many different approaches.

R, 37 33 31 bytes
-6 bytes thanks to Giuseppe
function(n,k)sum(rep(1:k,,k,n))

Try it online!
Nothing fancy. The [0:k] handles the case when k=0.

You can get rid of the braces here. If you use the in-order arguments for rep.default, you can get rid of [0:k] by using rep(1:k,,k,n) but then your answer is basically rturnbull's but with base R rather than R + pryr

You can still get rid of the braces! {}

the [0:k] substitution got me and I forgot about the braces :)

C++, 53 bytes
Just use the formula. n is 1-indexed and k is 0-indexed.
[](int n,int k){return k/n*(k/n+1)/2*n+k%n*(k/n+1);};

Try it online!

Save a couple of bytes by abusing the ~ operator. [](int n,int k){return-k/n*~(k/n)/2*n-k%n*~(k/n);};

Java (OpenJDK 8), 23 bytes
n->k->(k+k%n)*(k/n+1)/2

Try it online!
Port of G B's Python 2 answer.

J, 13 bytes
1#.]{.(#1+i.)

How it works:
The left argument is n, the right is k.
i.  generates a list 0..k-1
1+  adds one to each number of the list, yealding 1,2,...,k
#   forms a hook with the above, so n copies of each elements of the list are copied.
]{.  take the first n of them
1#. find their sum by base conversion.
Try it online!

I like the hook.

Retina, 29 26 bytes
\d+
$*
(?=.*?(1+)$)\1
$'
1

Try it online! Link includes test cases and header to reformat them to its preferred input (0-indexed k first, 1-indexed n second). I was inspired by @GB's Ruby answer. Explanation:
\d+
$*

Convert to unary.
(?=.*?(1+)$)\1
$'

Match every string of n within k, and replace the match with everything after the match. This is k-n, k-2n, k-3n, but n is also after the match, so you get k, k-n, k-2n etc. This also matches n, which is simply deleted (it's no longer needed).
1

Sum the results and convert back to decimal.

Pyth, 5 bytes
s%_ES

Try it here!
Port of G B's Ruby answer. A port of my Jelly one would be 6 bytes: +s/Rvz

Perl 6, 39 bytes
->\n,\k{(0,{|($_+1 xx n)}...*)[^k].sum}

Test it
n and k are both 1 based
Expanded:
-> \n, \k { # pointy block lambda with two parameters ｢n｣ and ｢k｣

  ( # generate the sequence

    0,         # seed the sequence (this is why ｢k｣ is 1-based)

    {          # bare block lambda with implicit parameter ｢$_｣
      |(       # slip this into outer sequence
        $_ + 1 # the next number
        xx n   # repeated ｢n｣ times (this is why ｢n｣ is 1-based)
      )
    }

    ...        # keep doing that until

    *          # never stop

  )[ ^k ]      # get the first ｢k｣ values from the sequence
  .sum         # sum them
}

Kotlin, 40 bytes
{n:Int,k:Int->Array(k,{i->i/n+1}).sum()}

Try it online!

05AB1E, 9 bytes
FL`}){I£O

Try it online!
Explanation
F           # n times do
 L`         # pop top of stack (initially k), push 1 ... topOfStack
   }        # end loop
    )       # wrap stack in a list
     {      # sort the list
      I£    # take the first k elements
        O   # sum

Python 2, 44 bytes
f=lambda n,k:sum(sorted(range(1,k+1)*n)[:k])

Try it online!

Python 2, 38 bytes
lambda n,k:sum(i/n+1for i in range(k))

Try it online!

Clojure, 54 bytes
#(nth(reductions +(for[i(rest(range))j(range %)]i))%2)

2nd argument k is 0-indexed, so (f 14 20) is 28.

APL+WIN, 13 bytes
+/⎕↑(⍳n)/⍳n←⎕

Prompts for screen input for n and then for k. Index origin = 1.

Japt, 7 6 bytes
Originally inspired by GB's solution and evolved to a port!
Takes k as the first input and n as the second.
õ1Vn)x

Try it

Explanation
Implicit input of integers U=k & V=n. Generate an array of integers (õ) from 1 to U with a step of V negated (n) and reduce it by addition (x).

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

Try it online!
I'm certain this can be done better, but it's a start.

R, 27 bytes
Anonymous function that takes k and n in that order. Creates a list of length k (third argument to rep) that is composed of 1 through k (first argument to rep), repeating each element n times (fourth argument to rep). Then takes the sum of that list.
n is 1-indexed and k is 0-indexed. Returns an error for n<1.

pryr::f(sum(rep(1:k,,k,n)))

Try it online!

Befunge, 27 Bytes
&::00p&:10p%+00g10g/1+*2/.@

Try It Online
Takes k then n as input. Uses G B's answer as its mathematical basis.

Jelly, 4 bytes
R÷ĊS

Try it online!
Takes input in order k, n. Creates an array of ints from 1 to k, divides each by n and then rounds up, and sums.

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


text:
Repeated Digit Primes
Another sequence, another challenge.*
Definition
A prime p is in this sequence, let's call it A, iff for every digit d in p's decimal expansion, you replace d with d copies of d and the resulting integer is still prime; zeros are not permitted.
For example, 11 is trivially in this sequence (it's the first number, incidentally). Next in the sequence is 31, because 3331 is also prime; then 53 because 55555333 is also prime, and so on.
Challenge
Given an input n, return A(n), i.e. the nth item in this sequence.
Examples
Here are the first 20 terms to get you started. This is A057628 on OEIS.
11, 31, 53, 131, 149, 223, 283, 311, 313, 331, 397, 463, 641, 691, 937, 941, 1439, 1511, 1741, 1871

This means A(0) = 11, A(1) = 31, etc., when using zero indexing.
Rules

You can choose zero- or one-based indexing; please specify in your answer which.
Instead of returning just the nth element, you can instead choose to return the first n terms.
You can assume that the input/output will not be larger than your language's native integer format; however, the repeated-digit prime may be larger than your language's native format, so that will need to be accounted for.
For example, 1871, the last number of the examples, has a corresponding prime of 18888888877777771, which is quite a bit larger than standard INT32.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Output can be to the console, returned from a function, displayed in an alert popup, etc.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

*To be fair, I had come up with the first few terms of the sequence just playing around with some numbers, and then went to OEIS to get the rest of the sequence.

I wonder if there exists a prime whose repeated digit result also is in this sequence, and whose repeated digit result also is in this sequence, and so on, ad infinitum. Seems highly unlikely.

@Steadybox 11 meets this condition, ad infinitum. But other than that it would be interesting to see how many times you could apply the digit repeating operation and keep getting primes.

Given that 1666666999999999 is prime, why isn't 169 in the sequence?

@PabloOliva Because 169 itself isn't prime, it's 13 * 13.

Husk, 15 bytes
!fo§&öεpd´ṘΠdİp

Try it online!
!                 Index into
             İp     the list of primes
 f                    for which:
            d            the digits of p
  o§&                      satisfy both:
     öεpd´Ṙ                  repeated "themselves" times, they form a prime.
           Π                 they are all nonzero.

Erik the Outgolfer saved a byte. Using ṗ instead of εp would save another byte, but that makes the program so slow it times our even for n = 2.

@H.PWiz I don't think we judge on speed here...

I really should speed up ṗ in the interpreter, it's crazy how it's slower than finding all prime factors...

05AB1E, 14 13 bytes
-1 byte thanks to Emigna!
µNSÐPŠ×JpNpPĀ½

Try it online!
Explanation
µNSÐPŠ×JpNpPĀ½
µ              # Do until the input is reached...
 N              # Push the iteration counter
  S             # Split it to its digits
   Ð            # And push two copies of it to the stack
    P           # Get the digital product of the counter
     Š          # And place it two places down the stack
      ×J        # Repeat each digit by itself and join it back to a number
        p       # Check for primality on that result
         Np     # And on the original counter as well
           PĀ   # Create the product and truthify the result
                # Implicit: If it is true increment the input number

Jelly, 18 14 bytes
ÆPaDxDḌÆPaDẠµ#

Try it online!
Mr. Xcoder: -1 Byte (logical all)
Erik the Outgolfer: -2 Bytes (one line instead of two)
HyperNeutrino: -1 Byte (return first n elements of sequence)
Explanation
ÆPaDxDḌÆPaDẠµ#     First Link
ÆP                Is prime?
  a               logical and
   D              convert number to list of digits
    xD            repeat each digit as many times as it's value
      Ḍ           convert to an integer
       ÆP         is prime?
         a        logical and
          D       list of digits
           Ạ      logical all
            µ     the following link as a monad
             #    Do this until n matches are found and return them all

Edit: originally submitted an answer that included numbers with 0 in it's decimal representation which is specifically not allowed.

I tried making a shorter and independent answer but I just got the same thing :( xD

Wolfram Language (Mathematica), 100 bytes
Nest[#+1//.i_/;!PrimeQ@FromDigits[##&@@#~Table~#&/@(l=IntegerDigits@i)]||Min@l<1:>NextPrime@i&,1,#]&

Try it online!
Jonathan Frech saved 3 bytes
and -7 bytes from JungHwan Min
-15 bytes from Martin Ender
also thanks to Jenny Mathy

Python 2, 130 bytes

Thanks to ArBo for this four byte shorter solution.

f=lambda n,c=9:n and f(n-(('0'in`c`)<p(c)*p(int("".join(d*int(d)for d in`c`)))),c+1)or~-c
p=lambda n:all(n%m for m in xrange(2,n))

Try it online!

Python 2, 195 179 167 140 138 136 135 134 bytes

Saved 27 bytes thanks to ovs; using xrange instead of range, thus circumventing a MemoryError and compacting the prime function; improving integer index counting.
Saved two bytes; using binary pipe or operations | to save bytes over or.
Saved two bytes; inverting the prime function and doing some further logic manipulation.
Saved a byte; using ~- instead of 0** to invert the existence of a zero in j, as & followed by a true boolean isolates this value's boolean property.
Saved a byte thanks to Lynn; golfing ~-A&B&C (equivalent to (not A) and B and C) with A, B, C being booleans to A<B==C.

def f(n,j=9,p=lambda n:all(n%j for j in xrange(2,n))):
 while n:j+=1;n-=("0"in`j`)<p(j)==p(int("".join(d*int(d)for d in`j`)))
 print j

Try it online! (1-indexed)
Explanation
Defines a main function  f which takes in an integer index, n, and a by default set value j, the current sequence canditate (intitiated to 9 to improve performance whilst keeping program size) and a prime checking function.
As long as n is non-zero, the n-th sequence entry is not yet found. Thus j is incremented and n is decremented by one iff j is a number which satisfies the required properties.
When the loop ends, j is the n-th sequence entry and thus printed.

I'm a bit late to the party, but you can shave off 4 more bytes

Alice, 72 70 66 62 56 bytes
Thanks to Leo for saving 5 bytes.
/.\&wh...tz~F0/*$\W.tzt$W?K/ o
\i/&.,a:.$K;d&\FR/K.!w.a%

Try it online!
Uses 1-based input.
Explanation
The neatest golfing trick here (even though it only saves a couple of bytes) is that I'm using a  primality test which gives 0 for composite n for n for non-composite n. That way, we don't have to use the result directly in a conditional, but we can pass it straight on to the next part that checks that the input doesn't contain any zeros.
/i\       Read all input in Ordinal mode (the usual way to read decimal input).
&w        Push the current IP position onto the return address stack (RAS)
          n times. This effectively begins our main loop. We will return
          here after each number we've checked, but whenever we come across
          a repeated digit prime (RDP), we will pop one copy of the address
          from the RAS, so that the loops ends once we've found n RDPs.

h.        Increment our main loop iterator X (initially an implicit zero on
          the empty stack) and duplicate it.
.         Make another copy.
.tz       Drop all factors less than X. This gives X for prime X and 1 for
          non-prime X.
~F        Check whether X divides this value. Of course, X divides X so this
          gives X for non-composite X. But X doesn't divide 1 (unless X is 1),
          so we get 0 for composite X. Call this Y.
0         Push a 0.
\         Switch to Ordinal mode.
F         Implicitly convert both to string and check whether Y contains 0.
$/K       If it does, return to the w. Either way, switch back to Cardinal mode.
          Note that the only numbers that get to this point are 1 and prime
          numbers which don't contain 0. It's fine that we let 1 through here,
          because we'll use a proper primality test for the digit-expanded
          version later on.
.!        Store a copy of X on the tape. Let's call the copy that remains on
          the stack Z, which we're now decomposing into digits while expanding
          them.
w         Push the current IP position to the RAS. This marks the beginning
          of an inner loop over the digits of Z.

  .a%       Duplicate Z and retrieve its last digit D by taking Z % 10.
  \./       Duplicate D (in Ordinal mode but that doesn't matter).
  &.        Duplicate D, D times. So we end up with D+1 copies of D.
  ,         Pop the top D and pull up the Dth stack element, which is Z.
  a:        Discard the last digit by taking Z / 10.
  .$K       If Z is zero now, skip the K and end the inner loop, otherwise
            repeat the inner loop.
;         Discard the 0 (what used to be Z).
          We now have D copies of each digit D on the stack, but the digits
          were processed in reverse order, so the last digit is at the bottom.
d&        Repeat the next command once for each stack element.
\*        Concatenate in Ordinal mode. This joins all the digits on the
          stack into a single string.
R         Reverse that string. This is the digit-expanded version of X.
/         Switch back to Cardinal mode.
W         Pop the inner loop's return address from the RAS. We could have done
          this right after the most recent K, but putting it here helps lining
          up the two Ordinal sections in the program layout.
.tzt      Is the digit-expanded number a prime?
$W        If so, we've found an RDP. Pop one copy of the main loop address
          from the RAS.
g         Recover the current value of X from the top left grid cell.
K         Jump back to the w if any copies of the return address are left
          on the RAS. Otherwise, we leave the main loop.
/o        Implicitly convert the result to a string and print it in
          Ordinal mode.
          The IP will then bounce off the top right corner and start
          travelling through the program in reverse. Whatever it does
          on the way back is utter nonsense, but it will eventually get
          back to the division (:). The top of the stack will be zero
          at that point and therefore the division terminates the program.

Pyth, 21 bytes
.f&.AKjZT&P_ss*VK`ZP_

Try it here!
Rather lengthy as Pyth doesn’t have a Decimal Expansion built-in.

Take the first N positive integers (.f), that:

Have all the digits truthy (.AKjZT), and (&)...
The vectorized multiplication of their string representation with their digits (*VK`Z), joined together and converted to an integer (ss) are prime (P_), and (&)...
That are primes themselves (P_).

You can remove e as per a new rule amendment.

@EriktheOutgolfer Done, thanks

J, 81 bytes
f=.[:1&p:(*@(*/)*x:@#~)&.(10&#.inv)
[:{.(4&p:@{.@]([,]+f@[){:@])^:([>{:@])^:_&2 0

This is one of those situations for which I haven't yet found a good J solution.
Nevertheless, I post this in hopes of learning something new.
f tells us if a given number is a "repeated digit prime". It breaks down as follows:
[:1&p:                               is the following a prime?
      (*@                            the signum of...
         (*/)                        the product of the digits
             *                       times...
              x:@                    force extended precision of...
                 #~)                 self-duplicated digits
                    &.               "Under": perform this, then perform its inverse at the end
                      (10&#.inv)     convert to a list of digits

And finally the main Do... While verb, with its pesky, seemingly unavoidable boilerplate, which arises from the fact that we need to use a list to store our progress, which requires both "current prime" and "found so far" registers, since our left argument is already taken to store the stopping condition, ie, n.  This means that we must use many precious bytes for the simple task of specifying args ([ and ]) and unpacking our 2 element list ({. and {:):
[:{.                                                take the first element of the final result, of the following Do... While:
    (4&p:@                                          the next prime after...
          {.@                                       the first element of...
             ]                                      the right arg
                       {:@])                        the last (2nd) elm of the arg...
              ([,]+f@[)                             those two now become the left and right args to this verb...
               [,                                   left arg appended to...
                 ]+                                 right arg plus...
                   f@[                              f of the left arg...
                             ^:(      )^:_          keep doing all that while...
                                [>                  the left is bigger than...
                                  {:@]              the last elm of the right arg
                                          &2 0      seed the process with 2 0, ie,
                                                    the first prime, and 0 rdps found so far.

Try it online!

Is it really fewer bytes to have a helper function? Can't you just replace f with the helper function wrapped in parentheses. Also, I tried my hand at golfing the helper function and came up with 1 p:('x',~"."0#])&.":, which unfortunately doesn't successfully exclude primes with '0' in them. Do you have any thoughts? It also has to have the 'x',~ part to get extra precision ...

@cole yes re: helper function adds a byte, but at this point we are polishing brass on the Titanic, so i figured why bother, just retain the clarity, and maybe miles or FrownyFrog will chime in with an idea that saves real bytes

i’ll check out your golfing of the helper function later

57 bytes so far (((0>.-)((*&(1&p:)0&e.|10#.#~),.&.":))([,(+*)~)])/^:_@,&2, use 10x to extend the range otherwise n = 15 will skip 937

@miles, you are a J god.  already found some nice new tricks in here.  going to look it over again tomorrow to make sure i understand the iteration / decrementing.  I don't know if you noticed the link to my SO question, but would you say this is a general technique that could answer solve the issue I raised there?

Perl 6, 51 bytes
{(grep {!/0/&is-prime $_&S:g/./{$/x$/}/},2..*)[$_]}

Try it online!

grep {...}, 2..* filters the infinite sequence of natural numbers starting from 2 using the predicate function between the braces.  (...)[$_] indexes into this filtered list using the function's argument $_.
!/0/ filters out numbers that contain a zero digit.
S:g/./{$/ x $/}/ replicates each digit in the test number's decimal expansion.
is-prime $_ & S:g/./{$/ x $/}/ calls the built-in is-prime function with an and-junction of $_, the test number, and the number resulting from replicating its digits.  The function will return true if both members of the and-junction are prime.

Vyxal, 88 bitsv2, 11 bytes
Þp'f:ẋfṅ⌊æ;~AẎ

Try it Online!
Bitstring:
0010101101000000100111110011100100110010100100011000111001011001000011111011010100010010


text:
Wir hassen Umlaute! (We hate umlauts!)
Introduction
As you all know, German has umlauts. They're these things: ¨
However, most keyboards don't have an umlaut key. That's fine, though, because you can write ö, ä, and ü as oe, ae, and ue.
Challenge

Your job is to to replace ö, ä, and ü with oe, ae, and ue (and likewise for their capital versions).
You have to deal with both the combining diacritical mark and single characters. (Thank you @ETHProductions for pointing this out.)
Capitalization of the base letter stays intact.
Capitalization of the e depends on the capitalization of the surrounding letters after replacement. You should write it as e unless it's adjacent to a capital letter on both sides, in which case write it as E. (End of line and space are not capital letters.)
Standard loopholes and I/O rules apply.
This is code-golf, so shortest code in UTF-8 bytes wins!

Example Input and Output
Test cases using precomposed characters
ü = ue
üb = ueb
üB = ueB
Ü = Ue
Üb = Ueb
ÜB = UEB

Test cases using combining diacritics
ö = oe
öb = oeb
öB = oeB
Ö = Oe
Öb = Oeb
ÖB = OEB

Inverse.

I feel like this is highly related. Seems to be kinda sorta the opposite challenge.

Related

That one reminded me of https://geekandpoke.typepad.com/geekandpoke/2011/08/coders-love-unicode.html ;-)

I don't understand if the challenge is about replacing a single word or entire text blocks, ie whether to deal with word separation.

Why is it necessary to replace both types? This is a really awkward input format.

Perl 5 (-pC -MUnicode::Normalize -Mutf8 -MList::Util=max), 63, 58, 53 bytes
$_=NFD$_;s/([oau])\K̈(?=(.?))/max($1,$2)lt a?E:e/gei

try it online

saved bytes using -Mutf8 and chaging \x{308} by unicode character

QuadR, 112 bytes
[öäüÖÄÜ].?
.̈.?
1(819⌶⍣(2=+/M≠819⌶M))(∊'oauOAU'M)['öäüÖÄÜ'⍳⊃M]'e',⍵p↓1↓M←⍵M

Try it online!
Replace…
 [öäüÖÄÜ].? any umlaut'ed character, optionally followed by a character
… or…
 .̈.? any character and a combining umlaut, optionally followed by a character
… with the result of the following function:
 ⍵M the Match
 M← store in M
 1↓ drop one character from the left
 ⍵p↓ drop one character if match had combing umlaut (⍵p is 0-indexed pattern number)
 …'e', prepend the following character and an e:
  (…)[…] index using:
   ⊃M the first character of the Match
   'öäüÖÄÜ'⍳ …'s index in the list of umlaut'ed characters
  … into:
   'oauOAU'M the two-element list of the de-umlaut'ed characters and the Match
   ∊ enlisted (flattened)
 1(…) apply the following derived function with 1 as left argument:
  819⌶⍣(…) casefold (to uppercase, because left argument would be 1) if:
   819⌶M the lowercased Match
   M≠ Boolean where the Match differs from that (i.e. is uppercase)
   +/ sum that
   2= 2 is equal to that
Equivalent to the tacit Dyalog APL function:
'[öäüÖÄÜ].?' '.̈.?'⎕R{1(819⌶⍣(2=+/M≠819⌶M))(∊'oauOAU'M)['öäüÖÄÜ'⍳⊃M]'e',⍵.PatternNum↓1↓M←⍵.Match}


text:
Circular Keyboard Spiral
This is a QWERTY keyboard.
Q W E R T Y U I O P
 A S D F G H J K L
  Z X C V B N M

We can "spiral out" on this keyboard, starting from G. The spiral will start at G, go to H, then to Y, then to T, then F, then V, then B, then N, then J, then U, then R, then D, then C,... etc. Your challenge is to, given a number 1 ≤ N ≤ 26, output the first N characters in this spiral. (If you are confused, refer to the pictures at the end of the post.)
The catch? Your program's score is proportional to the indices of characters found inside the spiral!
Scoring

For every letter (case-insensitive) in your code, add the index of that character in the spiral to your score (starting from 1).
For every character not in the spiral, add 10 to your score.
The lowest score wins.

For example, the program print("Hello, World!") has a score of 300.
For your convenience, I have written an automatic program grader.

var SPIRAL = "GHYTFVBNJURDCMKIESXLOWAZPQ";
function grade(program) {
    var score = 0;
    for(var i = 0; i < program.length; i++) {
        if(/^[A-Za-z]$/.test(program[i])) {
            score += SPIRAL.indexOf(program[i].toUpperCase()) + 1;
        }
        else {
            score += 10;
        }
    }
    return score;
}

input.oninput = function() {
    output.value = "Your program's score is: " + grade(input.value);
}
textarea { width: 500px; height: 6em; font-style: monospace; }
<textarea id="input"></textarea>
<textarea disabled id="output"></textarea>

Other rules

Your submission may be a program or function.
You may take N starting at 0 or 1 and ending at 25 or 26, respectively, but the outputs should still begin with "G" and end with "GHYTFVBNJURDCMKIESXLOWAZPQ".
You must output the characters in the spiral in order.
If a function, you may return a list of characters instead of a string.
You may have one trailing newline following the output.
You may use lowercase letters instead of uppercase letters, or a combination of both.

Test cases
number -> output
1 -> G
2 -> GH
5 -> GHYTF
12 -> GHYTFVBNJURD
15 -> GHYTFVBNJURDCMK
24 -> GHYTFVBNJURDCMKIESXLOWAZ
26 -> GHYTFVBNJURDCMKIESXLOWAZPQ

Pictures

The spiral superimposed:

Someone has watched Sphere recently...

@Pureferret Could you enlighten me? I'm not sure what you refer to.

@ConorO'Brien In Sphere (both the novel and movie), an alien communicates with humans using a two-digit numeric code where each number corresponds to a letter on the keyboard in a very similar pattern.

Japt, 304 264 162 points
Saved 40 points thanks to @ConorO'Brien
;î"历锋㫿鮹㿬崴ꨜꎋΞ"csG

Test it online!
In order to save as many points as possible, the entire string is condensed into 9 Unicode chars by interpreting each run of 3 letters as a base-36 number, then converting to a code point. The program itself takes this compressed string (which costs 110 points, including the quotes) and maps each charcode by converting it to a string in base-36 (G after the ; at the beginning). î takes the first {input} chars of this, which is implicitly printed.

C, score: 544
g(g){write(1,"GHYTFVBNJURDCMKIESXLOWAZPQ",g);}

Try it online!

...why are you naming the function the same thing as the argument?

@QPaysTaxes Because g is the cheapest letter per the scoring used in the challenge.

Ah, I missed the custom scoring.

Spiral, score:  61921   5127   4715   4655  4191
4.X~>v+^#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v
   X *   X X X X X X X X X X X X X X X X X X X X X X X X X
   ! >   h y t f V b n j u [ ( 1 3 2 ) ] U J N B F T Y H G
0;vgv*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*vvv****v+^v+^v+^v+^*v++4
    X X X X X X X X X X X X X X X X X X X X X X X X X X
    v v v v v v v v v v v v v v v v v v v v v v v v v v
    Y y J F V u t U [ G H B n 3 N 2 j ) h g f ] ( 1 b T

An interpreter can be found here.
Explanation:
P.X~ZZ*v+^#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v
   X       X X X X X X X X X X X X X X X X X X X X X X X X X
   !       h y t f V b n j u r d c m k i e s x l o w a z p q
0;vgv*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*v*****************************************************************vP
    X X X X X X X X X X X X X X X X X X X X X X X X X X
    v v v v v v v v v v v v v v v v v v v v v v v v v v
    z y x w V u t s r q p o n m l k j i h g f e d c b a

The program begins at the 0 character on the fourth line. The first piece of code to run is 0;vg. ; takes a number
as input and places it in the stack. v places what is in the register (a zero) into the stack. It will
be used as the counter. g is a label, when it is reached, the control jumps to the other occurence of
the letter g in the code.
So this is where the control is now:
X
v
g

Since there is whitespace in all other directions, the instruction pointer starts moving upwards.
v places a zero into the stack, and X pops it from the stack immediately. Because the popped value
is zero, the instruction pointer moves to X (otherwise it would treat it as whitespace).
By default, the control flow is in turn-right mode, so now when it reaches the junction, the instruction
pointer turns to the right. v yet again pushes a zero into the stack, * increments the register by one.
v*v*v
  X
  v
  g

The next v places what is in the register (number 1) into the stack, the instruction pointer attempts to turn
to the right, hitting the next X. The value just added to the stack is popped and placed in the register.
Because it is non-zero, X is not entered, and the IP proceeds to the next * on the right instead, again
incrementing the value in the register.
v*v*v*v*v
X X X X X
v v v v v
i h g f e

This happens again and again until we reach the end of this part and the line of *s begins. By now the value
in the register is 6, which is ASCII letter g minus ASCII letter a. Thus with a line of 97 *s we increment
the value in the register to 103, which matches the letter g we want to print. v pushes it into the stack,
and P is another label upon hitting which we jump to the other P on the first line of the code.
Here . pops the value from the stack and prints it as a character. After that X pops the extraneous zero
from the stack, then ~ compares the two remaining values in the stack (the values being the counter and the
input value). If the values are the same, the operator places zero in the stack (otherwise -1 or 1). Again,
the control attempts to turn right. X pops the value of the comparison from the stack, if it is zero, X, and
after it ! is entered, terminating the program.
P.X~ZZ*v+^
   X
   !

Otherwise the IP continues to the Z, which is a label which in this case jumps only one step to the right.
The reason for doing this is that jumping sets the value in the register back to zero. * increments the
register and v places the resulting 1 into the stack. + pops the two top elements of the stack (the
1 and the counter), adds them, and places the result in the stack (in effect this increments the counter by
one). ^ copies the result from the stack to the register without removing it from the stack.
# decrements the value in the register by one, v pushes the decremented value to the stack, the IP attempts
to turn to the right, and the X pops the value from the stack. If the value is non-zero the IP keeps moving
to the east, decrementing the value in the register, until it hits zero, and the IP enters an X branch.
#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v
 X X X X X X X X X X X X X X X X X X X X X X X X X
 h y t f V b n j u r d c m k i e s x l o w a z p q

The branch leads to a label corresponding to the value of the counter. Upon hitting the label, the control jumps
to the other occurence of the label in the section where we started with the label g, starting another iteration.
As with the g, the value in the register gets incremented up to the ASCII value of the letter we need to print.
Then the character is printed and the counter incremented, another label is selected. This happens until after the last iteration
the counter equals the input, and the program terminates.
Edit:
P.X~Zv+^
   X *
   ! Z

Achieves the same thing as
P.X~ZZ*v+^
   X
   !

but with less whitespace.
Edit 2:
vv****v+^v+^v+^v+^*v++P

Can be used instead of:
*****************************************************************vP

Ironic that a languaje called "Spiral" has such a high score in a spiral output problem.

Haskell,  471
(`take`"GHYTFVBNJURDCMKIESXLOWAZPQ")

Try it online!
This is a bit of a benchmark, I feel like there must be a better way, but its the best I've found so far.
Explanation
I suppose I should explain this for those not familiar with Haskell too well.  The function take takes the first n elements of the list.  It is called like this:
take n list

We want to take the first n elements of the sting "GHYTFVBNJURDCMKIESXLOWAZPQ", so we want something like
f n=take n"GHYTFVBNJURDCMKIESXLOWAZPQ"

We can do better though, we can infix take using backticks
f n=n`take`"GHYTFVBNJURDCMKIESXLOWAZPQ"

And now this can be made pointfree
(`take`"GHYTFVBNJURDCMKIESXLOWAZPQ")

It's a shame partial application requires using partial in Clojure. This is what I was going for, but partial was too expensive.

Isn't your score 470? That's what the snippet in the question is giving me anyway...

Jelly, 211 score
19 bytes
“eȷÞ('¢ạẓkȮV’œ?ØAðḣ

Try it online!
saved a bunch of score thanks to Emigna's suggestion to use œ? :D

TI-Basic (TI-84 Plus CE), 454 432 points
sub("GHYTFVBNJURDCMKIESXLOWAZPQ",1,Ans

-22 points from Conor O'Brien
Run with 5:prgmNAME.
Returns/prints the substring from 1 to Ans (the number input).
TI-Basic is a tokenized langauge, so I'm scoring this by the byte values of the tokens.
sub( is 0xbb 0x0c, so 20
" is 0x2a, so *, so 10*2=20
Uppercase letters don't change, so the string is 351
, is 0x2b, so +, so 10*2=20
1 is 0x31, so 1, so 10
Ans is 0x72, which is r, so 11
20 + 20 + 351 + 20 + 10 + 11 = 432

With this interpretation of the scoring rules, you can save 31 more bytes by looking for the letters in creative places. Replace the S, A, Z, P by the stat variables s, a, z, p (in the STAT + 5 menu), which score 17 points each: they're 2-byte tokens whose first byte corresponds to b. Replace the O, W, Q by the ordinary lowercase letters, which score 20 points each: they're 2-byte tokens 0xBBBF, 0xBBC7, 0xBBC1.

Befunge, Score: 531
QPZAWOLXSEIKMCDRUJNBVFTYHG"&\>,# 1#\-# :# _@

I feel this challenge would have been more interesting if the output had to be in a spiral as well.

Vim, 461 418
CGHYTFVBNJURDCMKIESXLOWAZPQg^[G@" D

Thanks @pacholik for -43 score!
Try it online!

Make it 418 with CGHYTFVBNJURDCMKIESXLOWAZPQg©G@" D (© is escape)

Python 3, score = 762 753
1-based input. This is worse than the trivial approach, since it uses 37 non-letters. It is somewhat interesting, though.
-9 thanks to Leo.
h=lambda g:g and h(g-1)+chr(65+int('GYGGYHGYYGYTGTYHGYGGHGGTGHGYGYGFGHGGYGGHHGGHHYYGHGHGGYFGGYHGGTHGHTGGGGGFGGVHGT'[g*3-3:g*3],35)%26)or''

Try it online!

I like this approach :) By the way [:g*3][-3:] can become [g*3-3:g*3] lowering the total score by 9 points

05AB1E, score: 204
.•3ŽγY
₁ùÐÁo0ª ’ö:•£

Try it online!

I wondered why it was cached hah!

APL (Dyalog), score: 391
↑∘'GHYTFVBNJURDCMKIESXLOWAZPQ'

Try it online!
The only use for Latin letters in Dyalog is in variable names and some system functions. Apart from that, only glyphs and some Greek letters are used.

Brainf**k, score = 2690
Input a single byte ranging from 0x1 to 0x1a.
>>++++>+++>>>>++++++++++[<+<-<+>>>-]<<--<+++>>>++>->+++++++++++>++++++>-------->---->-->>---------->--------->+++++>++++++++>--->+>----------->+++++++++>------->+++++++>++++++++++++>----->------>+>>+++++++[<+++++++++++[<[[+<]+<]>->[[>]>]<<<-]>-]<<[-]>,[[<]<.[-]>+[>]<-]

Try it online!

C#, score 546
g=>"GHYTFVBNJURDCMKIESXLOWAZPQ".Substring(0,g);

Rust, score 443
It is not often that Rust is good at code golf but here it beats many languages
|g|&"GHYTFVBNJURDCMKIESXLOWAZPQ"[..g]

Golang, score 861
func g(g int){io.WriteString(os.Stdout,"GHYTFVBNJURDCMKIESXLOWAZPQ"[0:g])}

Play it online !

Javascript ES6, 527 points
g=>`GHYTFVBNJURDCMKIESXLOWAZPQ`.slice(0,g)

Try it !

f=g=>`GHYTFVBNJURDCMKIESXLOWAZPQ`.slice(0,g)

input.oninput = function() {
    output.value = f(input.value);
}
textarea { width: 500px; height: 6em; font-style: monospace; }
<textarea id="input"></textarea>
<textarea disabled id="output"></textarea>

PHP, 590 points
<?=substr(GHYTFVBNJURDCMKIESXLOWAZPQ,0,$argv[1]);

Try it online!

Python 3, 522
lambda g:"GHYTFVBNJURDCMKIESXLOWAZPQ"[:g]

Try it online!
An anonymous lambda utilizing Python's slicing of strings ("asdf"[:i] gets the first i characters of "asdf")

Clojure, 484 474 points
-10 points because apparently a % can exist after a number without a space separating them!? I might have to go back over and improve some submissions.
#(subs"ghytfvbnjurdcmkiesxlowazpq"0%)

An anonymous function. Basically a Clojure port of what's already been posted. Scores nicely! I think this is the first Clojure program I've ever written that doesn't contain a single space.
(defn spiral [n]
  ; Substring the hardcoded list, going from index 0 to n
  (subs "ghytfvbnjurdcmkiesxlowazpq" 0 n))

Ly, 521 points
"QPZAWOLXSEIKMCDRUJNBVFTYHG"ns[,spol];

Try it online!
I don't feel as though this is optimizable.

Bash, score: 465
cut -b-$1<<<GHYTFVBNJURDCMKIESXLOWAZPQ

Try it online!

Husk, 293 bytes
↑¨ghytfvb⌋ȷÜdcmkÏexl⁰Λzpq

This is the shortest one I could find, next closer ¨gHYtfvB⌋ȷÜdCmkÏex←ẆAzpq¨ for a score of 293..
Try it online!
Explanation
Brute-force search, turns out all lower-case gave the best score. It's basically the same as @Wheat Wizard's solution, take (↑) on a compressed string (¨).

Common Lisp, score: 580
(subseq"GHYTFVBNJURDCMKIESXLOWAZPQ"0(read))

Try it online!

Excel, 490 points
=LEFT("GHYTFVBNJURDCMKIESXLOWAZPQ",A1)

Convention for Excel ansers is to take input from A1.  Changing this to G1 cuts 22 points (468).
=LEFT("GHYTFVBNJURDCMKIESXLOWAZPQ",G1)

PHP, score 584
fiddled a bit with the dictionary; the fact that xoring the string cuts it off rendered substr obsolete.
<?=">1 -?/;73,+=:420<*!56.8#)("^str_repeat(y,$argv[1]);

Try it online.

Pyth, score: 371
<"GHYTFVBNJURDCMKIESXLOWAZPQ

Try it here.
How?
<"GHYTFVBNJURDCMKIESXLOWAZPQ"Q   implicit string end, implicit input
<                            Q   first Q(=input) elements ...
 "GHYTFVBNJURDCMKIESXLOWAZPQ"    ... of this string

Ruby, 453 points
->g{'GHYTFVBNJURDCMKIESXLOWAZPQ'[0,g]}

Try it online!

><>, 558+16= 574 points
<;v? : <{"GHYTFVBNJURDCMKIESXLOWAZPQ"
  >$o1-^

Uses the -v flag to push input onto the stack.
Pushes the spiral onto the stack in reverse order, then rotates the input to the top. Then, while the top of the stack is non-zero, prints the next letter and decrements the top of the stack.
Try it online!

Pyth, 261 points
<."AZJ{Û§zoÆæÏýú

Try it here!
This outputs uppercase letter. For lowercase, you can try the alternative 261 byter.

Perl, score 568 517
Thanks to Nahuel Fouilleul for saving 51 points.
($_)=GHYTFVBNJURDCMKIESXLOWAZPQ=~/.{$_}/g

Try it online!

GHYTFVBNJURDCMKIESXLOWAZPQ=~/.{$_}/;$_=$& + -p = 501+25

Yes that'll work. Do you know how to set up the inputs on TIO? I struggled a lot yesterday

yes below > input for standrad input instead of > arguments (for command line parameters)

($_)=GHYTFVBNJURDCMKIESXLOWAZPQ=~/.{$_}/g better = 492 +25

Mathematica, 528
"GHYTFVBNJURDCMKIESXLOWAZPQ"~StringTake~#&

Try it online!

Julia 0.6, score 433
g->"GHYTFVBNJURDCMKIESXLOWAZPQ"[1:g]

Try it online!


text:
Do I have permission?
The Challenge
Given a string indicating the symbolic notation of UNIX permission of a file and its ownership (user ID and group ID), decide whether a given user A has permission to read / write / execute it.
Related.
Permissions in UNIX system
In UNIX, every file has three classes of permissions (user, group and others) and ownership, including which user and which group it belongs to.
The symbolic notation consists of ten characters. The first character is not important in this challenge. The remaining nine characters are in three sets of three characters, representing permissions of user, group and others class. Characters in each set indicates whether reading / writing / executing is permitted. If permitted, it will be r, w or x. Otherwise, it will be -.
Note that setuid, setgid and sticky bit may change the third character of each set to s, S, t or T. Here's a simple rule: if the character is lowercase letter, then the permission is set; otherwise, it is not.
(For the details of symbolic notation of permissions, please refer to here.)
Every user has its user ID, and every group has its group ID. All IDs will be non-negative integers. A user will belong to at least one group. If a user A want to get access to a file, the system will check their permissions as follows:

If the file belongs to user A, check the permissions of user class.
If the file doesn't belong to A, but A belongs to the group which the file belongs to, check the permissions of group class.
Otherwise, check the permissions of others class.

However, there is one exception: if the user ID is 0 (superuser), they have permission to do anything!
Specifications

Your program / function should take these as input in any reasonable format:

Permissions in symbolic notation.
User ID and group ID which the file belongs to.
The user ID of A, and a list of group IDs which A belongs to.
Type of access. You can use any three different one-digit or one-character values for read, write and execute.

Return / output a truthy value if A has permission to access the file, or a falsy value if not.
You can assume that the first character of the notation will always be - (regular file).
This is code-golf, so the shortest in bytes wins!

Test Cases
The format here is [permissions, user ID of file, group ID of file, user ID of A, group IDs of A, type(r/w/x)].
[-rwx------, 13, 15, 13, [15, 24], r]: True   # user
[-rwxr-xr-x, 13, 24, 24, [15, 24], w]: False  # group
[-rwxr-Sr-T, 13, 15, 24, [15, 35], x]: False  # group
[-rwsr-xr-t, 13, 15, 24, [24, 35], x]: True   # others
[----------, 13, 15, 0, [0, 1, 2], r]: True   # superuser
[----------, 13, 15, 1, [0, 1, 2], r]: False  # others
[----rwxrwx, 13, 15, 13, [15, 24], r]: False  # user

JavaScript (ES6), 61 51 50 bytes
Takes 6 distinct parameters as input, in the order described in the challenge. Expects the last parameter to be 1 for read, 2 for write or 3 for execute. Returns 0 or 1.
(p,u,g,a,G,P)=>!a|p[u-a?6-3*G.includes(g)+P:P]>'Z'

Test cases

let f =

(p,u,g,a,G,P)=>!a|p[u-a?6-3*G.includes(g)+P:P]>'Z'

//            p             u   g   a   G          P
console.log(f('-rwx------', 13, 15, 13, [15, 24],  1)) // True  (user)
console.log(f('-rwxr-xr-x', 13, 24, 24, [15, 24],  2)) // False (group)
console.log(f('-rwxr-Sr-T', 13, 15, 24, [15, 35],  3)) // False (group)
console.log(f('-rwsr-xr-t', 13, 15, 24, [24, 35],  3)) // True  (others)
console.log(f('----------', 13, 15,  0, [0, 1, 2], 1)) // True  (superuser)
console.log(f('----------', 13, 15,  1, [0, 1, 2], 1)) // False (others)
console.log(f('----rwxrwx', 13, 15, 13, [15, 24],  1)) // False (user)

Python 2, 76 70 67 63 59 58 56 55 52 49 48 bytes
lambda p,u,g,A,G,t:A*'_'<p[~(u==A)*3*(g in G)-t]

Try it online!
Takes type as 3 for read, 2 for write ,and 1 for execute

68 bytes

It is not necessary to be superuser to have group ID 0. I added it to the test cases.

@ColeraSu Ah i misread, can the user id be negative?

Both UID and GID will be non-negative.

Java (OpenJDK 8), 60 bytes
(p,u,g,U,G,t)->U<1|p.charAt(t+(u==U?0:G.contains(g)?3:6))>90

Try it online!
The mapping for the type is the following: 1 means r, 2 means w and 3 means x.

Pyth, 22 21 bytes
|!Q}@@c3tw*nEQ-2}EEEG

Try it online. Test suite.
Takes input as six lines:
user id
permissions
file user id
file group
user groups
permission (0 = read, 1 = write, 2 = execute)

Explanation
|!Q}@@c3tw*nEQ-2}EEEG     Implicit: read user id to Q
 !Q                       True if user id is 0, false otherwise
|                         If true, just return it
         w                Read permission string
        -                 Omit first -
      c3                  Split in 3 parts
            E             Read file user id
           n Q            See if it doesn't equal Q
                          -> False (0) if user matches, true (1) otherwise
                 E        Read file group
                  E       Read user groups
                }         -> True (1) if group matches, false (0) otherwise
              -2          Subtract from 2
                          -> 1 if group matches, 2 otherwise
          *               Multiply the two numbers
                          -> 0 if user matches, 1 if group matches, 2 otherwise
     @                    Take correct part of permission string
    @                     Take correct character of that part
   }                G     See if it is in lowercase alphabet

Go, 284 bytes
import(."unicode";."golang.org/x/exp/slices")
func X(P string,f,g,u,a int,s[]int)int{P=P[1:]
p,i:=0,0
for;i<3;i++{for j:= 0;j<3;j++{e:=0
if IsLower(rune(P[3*i+j])){e++}
p|=e<<(3*i+j)}}
if u==0{return 1}
p>>=a
if f==u{return p&1}else if Contains(s,g){return p>>3&1}else{return p>>6&1}}

Attempt This Online!
rwx is 012.
Explanation
import(."unicode";."golang.org/x/exp/slices")
func X(P string,f,g,u,a int,s[]int)int{
// load the perms
P=P[1:] // strip the leading char
p,i:=0,0
// for all chars in the string...
for;i<3;i++{for j:= 0;j<3;j++{
// if it's lowercase, bit-or it with its respective location in the perms variable
e:=0
if IsLower(rune(P[3*i+j])){e++}
p|=e<<(3*i+j)}}
// the perm variable is stored as
// 876543210
// xwrxwrxwr
// -o-|g|-u-
// other, group, user, with the lowest bit on the right.
if u==0{return 1} // superuser
p>>=a // constant offset based on the access type
if f==u{
// user's file
return p&1
}else if Contains(s,g){
// user's group's file
return p>>3&1
}else{
// other
return p>>6&1
}}

Directly accessing the string, 145 bytes
import."golang.org/x/exp/slices"
func X(P string,f,g,u,a int,s[]int)bool{k:=0
if f==u{}else if Contains(s,g){k=3}else{k=6}
return u<1||P[a+k]>90}

Attempt This Online!
Based on @Olivier Grégoire's answer, and rwx is also 123 here.

C (GCC), 117 bytes
f(p,u,g,U,G,t,o)char*p;int*G;{t=t-'r'?t-117:1;if(o=u-U?6:0)for(;*G;++G)if(g==*G)o=3;return U==0|p[t+=o]>96&p[t]<123;}

Attempt This Online!

106 bytes