text:
How lit is this room?  pt. 1
Related to this question.
A room is defined to be a (not necessarily convex) non-intersecting polygon, expressed as an ordered list of 2-dimensional coordinates. A sufficiently bright lightbulb is placed at a specific point inside the room, and emits light in every direction. Your task is to find the total illuminated area of the room. You may take in input in any reasonable format. The points on the polygon/room as well as the coordinates of the light source are rational numbers. They can be taken in clockwise or counterclockwise, either format is fine. The test case in the problem is given counterclockwise.
The following picture shows two example rooms, where the purplish dot represents the light source, and the shaded region represents the illuminated area.
Test case:
(1/2, 18)
(1,3)
(5,1/2)
(7,5)
(12,7)
(16,3)
(15,11)
(8,19)
(3,7)
Light source located at (5,8)
Answer: 815523/6710 ≈ 121.538

Here is a graphical depiction of the solution to that test case. The two points that define the solution that are not on the original polygon are (55/61, 363/61) and (856/55, 357/55).
This formula may be helpful in calculating the area.
Since this is code-golf, the shortest code in bytes wins.

For those curious, part 2 might take a while to post because it'll take me forever to draw the pictures, and I also don't know how to solve it.

The points on the polygon/room as well as the coordinates of the light source are rational numbers.

Is there an upper bound on the number of vertices or should your program theoretically be able to handle an unlimited number? Also, your code-golf tag is broken. it's [tag:code-golf]

Your program or at least your algorithm should theoretically be able to handle an unlimited number, I can't think of a reason to arbitrarily limit the number of vertices (but I'm open to changing this if you have a specific reason why)

Ah, the good old shoelace formula!  By the way, we actually have MathJax so you needn't embed the formula as an image.

it's stolen from wikipedia, do you have a link that shows how to use MathJax?

Meta post on finally getting MathJax back!!

Here's a mathjax version of your image (right click > show math as > TeX commands): $$\begin{align*}
\mathbf{A}&=\frac{1}{2}\left|\sum_{i=1}^{n-1}x_{i}y_{i+1}+x_{n}y_{1}-\sum_{i=1}^{n-1}x_{i+1}y_{i}-x_{1}y_{n}\right|\
&=\frac{1}{2}\left|x_{1}y_{2}+x_{2}y_{3}+\cdots+x_{n-1}y_{n}-x_{2}y_{1}-x_{3}y_{2}-\cdots-x_{n}y_{n-1}-x_{1}y_{n}\right|
\end{align*}$$
You can use https://www.codecogs.com/latex/eqneditor.php as an editor and a way to get used to mathjax, and there's this tutorial which can help

Are the points guaranteed to be ordered clockwise?

Yes, they are ordered (an unordered set of points don't form a unique nonconvex polygon)

But they could also be ordered counterclockwise. A list of points still defines the same polygon following rotation or reversal of the list.

Yes, they can be guaranteed to be ordered clockwise, then. The test case is ordered counterclockwise, but I think this falls under “any reasonable format.”

OK, I had wondered this about the first Monte Carlo answer, but now that we have a second one: should these even be considered as valid answers? It seems they are solving a slightly different challenge than the one described.

I also wondered this, but I thought it wasn't my place to comment on that because I don't know very much about what this community considers acceptable.

@bushdid911 I think you can decide; it's your challenge. For example, you could require a minimum accuracy in a given time limit. (Maybe not for this challenge, but for part 2.)

Python 3, 388 398 408 409 415 417 493 bytes

To make it more accurate, increase n
from random import*
u=uniform
c=lambda A,B,C:(C[1]-A[1])*(B[0]-A[0])>(B[1]-A[1])*(C[0]-A[0])
I=lambda A,B,C,D:c(A,C,D)!=c(B,C,D)and c(A,B,C)!=c(A,B,D)
def a(l,v,n=9**6,s=0):
 g=lambda i:(min(x[i]for x in v),max(x[i]for x in v))
 for _ in'x'*n:
  h=((u(*g(0)),u(*g(1))),l);s+=any([I(*f,*h)for f in list(zip(v,v[1:]+[v[0]]))])^1
 return(abs(g(0)[0]-g(0)[1])*abs(g(1)[0]-g(1)[1]))*float(s/n)

Basic Monte-Carlo approach.  Steps listed below.

Find x and y ranges that the shape occupies.
Create a list of edges created by the vertices
Iterate a large number of times (the more the better)
Create a random point (j,k) inside the x,y range.
Check if any of the edges intercept with the line-segment created by the light and the random point. If any of the edges intercept, increment the variable s
Divide s by the total numbers, then multiply by the total range area.

Ungolfed version:
import random

def ccw(A,B,C):
    return (C[1]-A[1])*(B[0]-A[0]) > (B[1]-A[1])*(C[0]-A[0])

def intersect(A,B,C,D):
    return ccw(A,C,D) != ccw(B,C,D) and ccw(A,B,C) != ccw(A,B,D)

def lit_area(light, vertices):
    # points: list of points
    # i     : x => i=0
    #       : y => i=1
    get_range = lambda i: (min(x[i] for x in vertices), max(x[i] for x in vertices))
    xr = abs(get_range(0)[0] - get_range(0)[1])
    yr = abs(get_range(1)[0] - get_range(1)[1])

    edges = list(zip(vertices, vertices[1:] + [vertices[0]]))

    num_sims = 1000000

    num_successes = 0
    for _ in range(num_sims):
        guess_x = random.uniform(*get_range(0))
        guess_y = random.uniform(*get_range(1))

        light_guess_line = ((guess_x, guess_y), light)

        if not any([intersect(*e, *light_guess_line) for e in edges]):
            num_successes += 1
    return float(num_successes / num_sims) * (xr * yr)

if __name__ == "__main__":
    points = [
    (1/2, 18),
    (1,3),
    (5,1/2),
    (7,5),
    (12,7),
    (16,3),
    (15,11),
    (8,19),
    (3,7)
    ]
    light_source = (5,8)
    print("Area lit by light: %f"% lit_area(light_source, points))

Try it online!
Credit for line intersection algorithm
Also, credit to all the helpful commenters on how to golf this even further.

The first line can become from random import* (line break) u=uniform for -2 bytes

you can shave some more bytes by replacing each of the 4 spaces in the function with a single space, and remove the space after g=lambda i:

Does n have to be a power of 10? Otherwise you can save a byte by using a power of 9.

No, powers of 10 are not required. I’ll put in all of your suggestions tomorrow!  Until then, happy Valentine’s Day everyone!

As @ConorO'Brien mentioned, you can remove loads of leading whitespaces. And in addition to the space at i:(min, the space at x[i]for can be removed as well. Also, return float(s/n)*(r*t) can be return(r*t)*float(s/n). And I'm not entirely sure, but can't the variables r and e be removed and used directly, since you only use them once? It somehow does give a slightly different result even though g isn't modified, so that part confuses me a bit (I'm not too familiar with Python to understand why the result is slightly different).

Actually, it's different due to the random, duh.. So the e and r variables can be removed, and the abs(g(0)[0]-g(0)[1]) and list(zip(v,v[1:]+[v[0]])) can be used directly.

@KevinCruijssen The result will change with each run regardless of changes to the code. This is due to the use of the random number generator.

@JPeroutek Yeah, I realized that shortly after my first comment, hence the second comment. :)

@KevinCruijssen Sorry, Stack app doesn’t automatically reload comments :) thanks for the feedback

Putting it all together, it's 419 bytes

Would it be legal to pull my variable n into the parameters, and have it specified when the function is called?  Or does that go against the rules?

409 bytes by combining variable declarations

@JPeroutek you can pull your definitions in the parameters and assign default values. With this you get Stephen's suggestion to 408 bytes:

TIO

if not any([I(*f,*h)for f in list(zip(v,v[1:]+[v[0]]))]):s+=1 can become s+=any([I(*f,*h)for f in list(zip(v,v[1:]+[v[0]]))])^1 to save 7 bytes.

for _ in range(n): can become for _ in'x'*n: to save 4 bytes.

j=u(*g(0));k=u(*g(1));h=((j,k),l) can become h=(u(*g(0)),u(*g(1))),l to save 10 bytes.

Haskell, 559 618 632 bytes
r(a:b)=b++[a]
s=zip<*>r
(?)a=sum.zipWith(*)a
o(a,b)=r a?b-a?r b
(a,b)!(c,d)=(c-a,d-b)
(a,b)#(c,d)=a*d-b*c
x i a@(e,f)b j c d|let k@(g,h)=a!b;l=c!d;m=c!a;n=l#k;o=m#l/n;p=m#k/n;q|i>0=o<0||o>1|let=o<=0||o>=1;r|n==0||q||p<0||p*j>1=[]|let=[(e+o*g,f+o*h)]=r
(a&b)(c:e@(d:_))|let(f,g)=span(/=d)b;h=zip f$r$f++[d]=concat[[k,l]|(i,j)<-h,[[k],[l]]<-[x 1 i j 0 a<$>[c,d]],and[x 0 m n 1 a o==[]|o<-[k,l],(m,n)<-h,(m,n)/=(i,j)]]++(a&g)e
(_&_)_=[]
z a b=sum[o$unzip[c,a,d]|e@(f:_)<-[[c|c<-b,and[all(==c)$x 1 d e 1 a c|(d,e)<-s b]]],(c,d)<-s$a&until((f==).head)r b$e++[f]]/2

Exact solution (barring bugs). Haskell has built-in exact rational arithmetic. Try it online!
Note that this gives 815523/6710, not 814643/6710, for the example room, and the first wall intersection is calculated as (55/61, 363/61). I'm fairly sure this is correct because the Monte Carlo entry (slowly) converges to the same result.
Legend:
z light roomPoints
    -- Main function, returns lit area.
    -- Compute list of visible corners in the room, then calls (&).
(&) light roomPoints' visibleCorners
    -- Compute visibility polygon. visibleCorners is the subset of points
    -- that are visible from the light. The first point of roomPoints'
    -- must coincide with the first visibleCorner.
x pEndpoints p1 p2 qSegment q1 q2
    -- Intersect line segments (p1, p2) and (q1, q2).
    -- If pEndpoints, exclude endpoints p1, p2.
    -- If not qSegment, allow intersection to extend past q2 (i.e. raycast).
r   -- Rotate list by one, used to construct closed loops etc.
s   -- Construct closed loop
(!) -- Vector between two points
(?) -- Dot product
(#) -- Cross product
o   -- Polygon area

Bonus: Gloss GUI for testing. Click next to points to move them.
import qualified Graphics.Gloss as G
import qualified Graphics.Gloss.Interface.IO.Interact as GI

solnPoly a b|let c@(d:_)=[c|c<-b,and[all(==c)$x 1 d e 1 a c|(d,e)<-s b]]=a&until((d==).head)r b$c++[d]
solnArea = z

main =
  let fromRatP (x, y) = (fromRational x, fromRational y)
      displayScale = 10
      scalePoints = G.scale (fromInteger displayScale) (fromInteger displayScale)
      displayMode = G.InWindow "" (512, 512) (0, 0)
      drawBasePoly pointSz ps =
          mconcat $ G.lineLoop ps :
                    [G.translate x y (G.circleSolid pointSz) | (x, y) <- ps]
      drawVisPolyOf light ps =
          G.color G.blue $ drawBasePoly 0.2 $ map fromRatP $ solnPoly light ps
      drawLight (x, y) =
          G.translate x y $
          G.color G.yellow (G.circleSolid 0.5) <> G.circle 0.5
      draw (light, ps) =
          mconcat [
              scalePoints $ drawLight (fromRatP light),
              scalePoints $ drawBasePoly 0.4 (map fromRatP ps),
              scalePoints $ drawVisPolyOf light ps,
              G.translate (-200) (-50) $ G.scale 0.2 0.2 $
                G.color G.blue $ G.text $ "Lit area: " ++ show (solnArea light ps)
          ]
      event (GI.EventKey (GI.MouseButton GI.LeftButton) GI.Down _ (curx_, cury_)) (light, ps) =
          let dist (x,y) (x',y') = (x'-x)^2 + (y'-y)^2
              curx = curx_ / fromInteger displayScale
              cury = cury_ / fromInteger displayScale
              cursorR = (fromInteger$round curx, fromInteger$round cury)
              maxDist = 3
              snapAmount = 1
              (d, i) = minimum [(dist p cursorR, i) | (p, i) <- zip (light : ps) [0..]]
              snapTo n a = fromInteger$n*round(a/fromInteger n)
              snapCursor = (snapTo snapAmount curx, snapTo snapAmount cury)
              light' | i == 0 && d < maxDist^2 = snapCursor
                     | otherwise = light
              ps' | i > 0 && d < maxDist^2 = take (i-1) ps ++ [snapCursor] ++ drop i ps
                  | otherwise = ps
          in (light', ps')
      event _ state = state
      state0 =
        ((2, 2), [(0, 0), (10, 0), (10, 5), (20, 0), (20, 20), (15, 5),
                  (10, 10), (6, 10), (10, 12), (0, 12), (4, 10), (0, 10)])
  in G.play displayMode G.white 60
            state0
            draw
            event
            (\_ -> id)

Actually, you’re right. I must have made a typo lol. Will update those numbers slightly

APL+WIN
This is an ungolfed version of this interesting challenge which I offer to demonstrate my logic. My ancient version of APL+WIN is not well suited to golfing nested control structures. More modern APLs could well do better - challenge?
If readers validate the logic I will have a go at golfing this solution. If the logic is wrong I will simply delete.
r←b Room v

⍝Separate x and y coordinates of vertices
x←v[;1] ⋄ y←v[;2]

⍝Intercept and slope of each line segment and ray through each vertex
s←(y,¨1⌽y)⌹¨(1E¯9+1,[1.1]¨x,¨1⌽1E¯9+x)
l←(y,¨b[2])⌹¨(1E¯9+1,[1.1]¨x,¨b[1]+1E¯9)

⍝Coordinates of vertices
x←x,¨1⌽x ⋄ y←y,¨1⌽y

⍝Initialise intersection matrix
r←((⍴s),0)⍴0

⍝Evaluate intersection matrix
:for i :in ⍳⍴l
    t←0⍴0
    :for j :in ⍳⍴s
        t←t,⍎1⍕∊((↑∊l[i])-↑∊s[j])÷((1↓∊s[j])-1↓∊l[i])
    :endfor
    z←r←r,t
:endfor

⍝Identify x coordinates of valid intersections in the direction of the ray
:for i :in ⍳⍴l
    t←(r[i;i])
    :for j :in ⍳⍴s
        :if t<b[1]
            r[j;i]←r[j;i]×(r[j;i]<t)^r[j;i]>⌊/∊x[i]
        :else
            r[j;i]←r[j;i]×(r[j;i]>t)^r[j;i]<⌈/∊x[i]
        :endif
    :endfor
 :endfor

⍝Identify the edges intersected
e←(+/r≠0)/⍳⍴l

⍝Intersection x coordinates
cx←(+/r)[e]

⍝Intersection y coordinates
cy←⍎1⍕+/¨(s[e])× 1,¨(+/r)[e]

⍝Replace original coordinates that are in shadow
x[e]←(1↓¨x[e]),¨cx
y[e]←(1↓¨y[e]),¨cy

⍝Calculate lit area
r←+/.5×(|-/¨x)×|-/¨y

R, 296 255 bytes
function(s,l,u=cbind(s,s[,1]),d=t(diff(t(u))),q=l-u,r=apply(s,1,range),g=c(diff(r)))mean(replicate(1e6,!any((q[i<-1:ncol(s)*2]*(p=runif(2)*g+r[1,]-u)[j<-i-1]>p[i]*q[j])!=(q[i+2]*p[i+1]>q[i+1]*p[i+2])&(p[i]*d[j]>p[j]*d[i])!=(q[i]*d[j]>q[j]*d[i]))))*prod(g)

Try it online!
This is a further reduced version of the Python answer. The core Monte Carlo method is the same, but I rearranged some of the functions to make them shorter. In my first iteration, I'd been over-aggressive in rearrangement, and I then realised I could optimise both length and speed by returning to a version of the intersection algorithm closer to the python.
Here's an ungolfed version that also plots the results:
find_lit_ungolf <- function(shape, light, plot = TRUE) {
  lines <- cbind(shape ,shape[,1])
  diffs <- t(diff(t(lines)))
  light_minus_lines <- light - lines
  shape_range <- apply(s,1,range)
  shape_range_diff <- c(diff(shape_range))
  successes <- t(replicate(
    n = 1e5,
    {
      random_point <- runif(2) * shape_range_diff + shape_range[1, ]
      random_minus_lines <- random_point - lines
      q <- light_minus_lines
      p <- random_minus_lines
      d <- diffs
      i <- 1:ncol(s)*2
      success <-
        !any((q[i]*p[i-1]>p[i]*q[i-1])!=(q[i+2]*p[i+1]>q[i+1]*p[i+2])&(p[i]*d[i-1]>p[i-1]*d[i])!=(q[i]*d[i-1]>q[i-1]*d[i]))
      c(random_point, success)
    }))
  colnames(successes) <- c("x", "y", "success")
  if (plot) {
    shape <- t(shape)
    colnames(shape) <- c("x", "y")
    print(ggplot(as_tibble(successes), aes(x, y)) +
      geom_point(aes(colour = factor(success)), alpha = 0.3) +
      geom_polygon(data = as_tibble(shape), alpha = 0.2) +
      annotate("point", light[1], light[2], col = "yellow"))
  }
  mean(successes[, 3]) * prod(shape_range_diff)
}
find_lit_ungolf(s, l)


text:
The Highest Dice
Challenge:
Here we have the first 100 items of a sequence:
6,5,4,3,2,1,66,65,64,63,62,61,56,55,54,53,52,51,46,45,44,43,42,41,36,35,34,33,32,31,26,25,24,23,22,21,16,15,14,13,12,11,666,665,664,663,662,661,656,655,654,653,652,651,646,645,644,643,642,641,636,635,634,633,632,631,626,625,624,623,622,621,616,615,614,613,612,611,566,565,564,563,562,561,556,555,554,553,552,551,546,545,544,543,542,541,536,535,534,533,...

How is this sequence formed? We first have the number in the range [6, 1] (all possible values of a single die from highest to lowest). We then have the numbers [66..61, 56..51, 46..41, 36..31, 26..21, 16..11] (all possible concatted values of two dice from highest to lowest). Etc.
This is related to the OEIS sequence A057436: Contains digits 1 through 6 only, but with all the numbers with equal amount of digits sorted backwards in the sequence.
The challenge is to choose one of these three options for your function/program with the sequence above:

Take an input \$n\$ and output the \$n\$'th value of this sequence, where it can be either 0-indexed or 1-indexed.
Take an input \$n\$ and output the first \$n\$ or \$n+1\$ values of this sequence.
Output the values from the sequence indefinitely.

Of course, any reasonable output format can be used. Could be as strings/integers/decimals/etc.; could be as an (infinite) list/array/stream/etc.; could be output with space/comma/newline/other delimiter to STDOUT; etc. etc. Please state what I/O and option you're using in your answer!
General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code (i.e. TIO).
Also, adding an explanation for your answer is highly recommended.

Here some larger test cases if you choose option 1:
n         0-indexed output    1-indexed output

500       5624                5625
750       4526                4531
1000      3432                3433
9329      11111               11112
9330      666666              11111
9331      666665              666666
10000     663632              663633
100000    6131232             6131233

Per the suggested edit, kolmogorov complexity tag does not apply to sequences, only to a constant, finite, fixed output. A sequence goes on forever.

In addition to what @mbomb007 said, I also allow outputting the n'th value or first n/n+1 values based on an input, whereas KC challenges will never have inputs.

Jelly, 5 bytes
ḃ6ạ7V

Try it online!
1-indexed nth value.

Perl 6, 24 23 bytes
-1 byte thanks to nwellnhof
{.put;.[]X~(6...1)}...*

Try it online!
Outputs the sequence infinitely separated by spaces/newlines. Or, for a few more bytes we can have a lazy infinite list we can index into instead.
Perl 6, 27 bytes
{flat {@=.[]X~(6...1)}...*}

Try it online!
Explanation:
{                         }    # Anonymous code block
 flat                          # Return the flattened
                      ...*       # Infinite sequence
      {              }             # Defined as
         .[]                       # The previous element arrayified
            X~                     # Each concatenated with
              (6...1)              # All of 6 to 1
       @=                          # Arrayified

Python 2, 39 38 34 bytes
f=lambda n:n and-n%6+1+f(~-n/6)*10

Try it online!
Outputs 1-indexed number

Bash, 31 bytes
f()(x+={6..1};eval echo $x;f);f

TIO
update from comments, the n'th value 1-indexed, +GNU tools + perl, 64 bytes, 7 bytes saved thanks to @manatwork
dc<<<6o$1p|perl -pe 's/(.)0/($1-1).6/e?redo:s/0//'|tr 1-6 654321

64 bytes

Doesn't help much, but the in the 2nd solution is shorter to escape the semicolon than double quoting the entire expression: bc<<<obase=6\;$1. But if you switch to dc, there is nothing to escape: dc<<<6o$1p.

thanks indeed it saves 7bytes but because of bijective numeration it still not working a mix bash perl (66bytes) dc<<<6o$1p|perl -pe '1while s/(.)0/($1-1).6/e;s/0//'|tr 1-6 654321

R, 43 bytes
p='';repeat cat(p<-sapply(p,paste0,6:1),'')

Try it online!
Prints the sequence indefinitely

-9 thanks to @Kirill L.

@tk3: without the second parameter it will concatenate the last value of the sub-sequence of n-digits elements, with the first value of the sub-sequence of n+1 digits elements. e.g. 6 5 4 3 2 166 65 64...

MATL, 11 bytes
`6:P!V@Z^DT

Outputs the values indefinitely.
Try it online!
Explanation
`      % Do...while
  6:   %   Push [1 2 3 4 5 6]
  P    %   Flip: gives [6 5 4 3 2 1]
  !    %   Transpose: turns the row vector into a column vector
  V    %   Convert the number in each row to the corresponding char
  @    %   Push current iteration index, starting from 1
  Z^   %   Cartesian power. Gives a matrix where each row is a Cartesian tuple
  D    %   Display immediately
  T    %   Push true. This is used as loop condition, to give an infinite loop
       % End (implicit)

JavaScript (ES6), 26 bytes
Returns the \$n\$th term, 1-indexed.
f=n=>n--&&[f(n/6|0)]+6-n%6

Try it online!

Haskell, 38 34 bytes
An infinite list of numbers:
d=[6,5..1]
l=d++[10*m+n|m<-l,n<-d]

Try it online!
Two earlier solutions that give infinite lists of strings, each using 38 bytes:
[1..]>>=sequence.(`replicate`"654321")

Try it online!
do n<-[1..];mapM id$[1..n]>>["654321"]

Try it online!

A 36; byte version, based on your replicate one.

Haskell, 28 bytes
l=(+).(10*)<$>0:l<*>[6,5..1]

Try it online!
Produces an infinite list of numbers l. Using <$> and <*> cuts a byte off:
29 bytes
l=[10*n+d|n<-0:l,d<-[6,5..1]]

Try it online!
The approach is similar to the Haskell Output All String answer fixed input string "654321", and skipping the empty string output by changing where it's prepended.
30 bytes
l=[n++[d]|n<-"":l,d<-"654321"]

Try it online!

That's great! I saw it's shorter to start off from 0 (or ""), but didn't find a cheap way to not have it in the result...

05AB1E, 10 bytes
Outputs the sequence indefinitely.
¸[6LRâJD»,

Try it online!
Explanation
¸           # initialize the stack with a list containing the empty string
 [          # loop
  6L        # push [1 ... 6]
    R       # reverse
     â      # cartesian product
      J     # join each inner list
       D    # duplicate (saving a copy for next iteration)
        »,  # join on newline and print

Never knew ¸ at the start creates a list containing an empty string. And 2 bytes shorter than the solution I used to generate the test cases, so of course a +1 from me. :)

Perl 5, 40 37 bytes
-3bytes thanks to @Xcali
map{say}<"$_">while s//{6,5,4,3,2,1}/

37 bytes
40 bytes

37 bytes

Brilliant use of glob. +1

Java (JDK), 48 bytes
String f(int n){return n-->0?f(n/6)+(6-n%6):"";}

Try it online!
This returns the 1-indexed nth element.
Recursion seems to beat the iterative lambda.

Iterative version, 49 bytes
n->{var r="";for(;n-->0;n/=6)r=6-n%6+r;return r;}

Try it online!

C# (.NET Core), 38 bytes
int f(int n)=>n-->0?f(n/6)*10+6-n%6:0;

Try it online!
Outputs the n-th value (1-based).

Which one is this solving?

@Stackstuck - I've now specified this in my answer.

Oh good!  We're not overlapping.  I just wrote the infinite printer.

Brachylog, 13 11 bytes
Thanks to Fatalize for 2 bytes
6~d{⟧₁∋}ᵐẉ⊥

Outputs indefinitely. Try it online!
Here's a 14-byte version that outputs the first \$n\$ values: Try it online!
Explanation
6~d           Start with a number, all of whose digits are 6's
              Brachylog considers these in the order 6, 66, 666, 6666...
   {   }ᵐ     Map this predicate to each of those digits:
    ⟧₁         1-based reverse range: [6,5,4,3,2,1]
      ∋        The output digit must be a number in that range
              Brachylog considers possible outputs in this order: 6, 5, 4, 3, 2, 1, 66, 65...
         ẉ    Write a possible output with newline
          ⊥   Force the predicate to fail and backtrack to the next possibility

You are on a Brachylog roll!

You can save 2 bytes by using a failure-driven loop, as they are called in Prolog: 6~d{⟧₁∋}ᵐẉ⊥. You basically end your program with "false" which will force it to print all solutions.

Ooh, nice. Yes, I've been enjoying it a lot!

Japt, 14 bytes
There's gotta be a shorter solution using function methods and/or Cartesian product but (for now?) the best I can manage is a port of Arnauld's JS solution so be sure to upvote him too.
©ß´Uz6)s+6-Uu6

Try it or test terms 0-1000

Wolfram Language (Mathematica), 88 78 bytes
(l=d=c=7-Range@6;While[Length@c<#,d=Flatten[(10#+l)&/@d];c=c~Join~d;];c[[#]])&

Try it online!
saved 4 + 6 bytes thanks to @IanMiller
List is 1 indexed, outputs the n'th number.

You can replace Range[6,1,-1] with 7-Range@6 to save 4 characters

For codegolf rules you can also write it as an anonymous function: (l=d=c=7-Range@6;While[Length@c<#,d=Flatten[(10#+l)&/@d];c=c~Join~d;];c[[#]])&

@IanMiller thanks! I wasn't sure what the rules were about the format.

Mathematica, 56 bytes
Flatten[FromDigits/@Tuples[7-Range@6,#]&/@Range@#][[#]]&

Requires excessive amounts of memory to actually run as it creates all numbers in the sequence which have length equal to or less than the input (i.e. it creates \$\frac{6}{5}(6^n-1)\$ terms) then takes the required value from the list. For practice use replace the second last # with a specific value for the length you want to use it on.

+1, that is monstrous overkill but works perfectly for brevity!

@JonathanFrech Thanks for fixing my mathjax. I wasn't sure how to activate it here as its slightly different that math.se

Please note that the original edit was by this user.

Oops my bad. Thanks to @geza-kerecsenyi too.

Pip -l, 16 bytes
x:YP6-,6W1PxCP:y

Outputs the sequence indefinitely. Try it online!
Explanation
The -l flag means that lists are printed with each item on its own line; if an item is itself a list, its elements are concatenated with no separator. E.g. the list [1 [2 3] [4 [5 6]]] would be printed as
1
23
456

With that cleared up:
x:YP6-,6W1PxCP:y
      ,6          Range(6): [0 1 2 3 4 5]
    6-            Subtract each element from 6: [6 5 4 3 2 1]
  YP              Yank that value into the y variable, and also print it
x:                Assign that value also to x
        W1        While 1 (infinite loop):
           xCP:    Assign to x the cartesian product of x with
               y   the list [6 5 4 3 2 1]
          P        Print it

After the first loop iteration, x looks like [[6;6];[6;5];[6;4];...;[1;1]]; after the second iteration, [[[6;6];6];[[6;6];5];[[6;6];4];...;[[1;1];1]]; and so on. We don't need to worry about flattening the sublists, because -l effectively does it for us.

Charcoal, 18 bytes
ＮθＷθ«←Ｉ⊕﹪±θ⁶≔÷⊖θ⁶θ

Try it online! Link is to verbose version of code. 1-indexed. Explanation:
Ｎθ

Input n
Ｗθ«

Repeat until n is zero.
←Ｉ⊕﹪±θ⁶

Reduce -n modulo 6, then increment the result and output from right to left.
≔÷⊖θ⁶θ

Decrement n and integer divide it by 6.

Retina 0.8.2, 36 bytes
.+
$*_
+`(_*)\1{5}(_+)
$1$.2
T`7-1`d

Try it online! Link includes test cases. 1-indexed. Explanation:
.+
$*_

Convert to unary. (Retina 1 would save 2 bytes here.)
+`(_*)\1{5}(_+)
$1$.2

Convert to bijective base 6 by repeated divmod. Note that the use of + means that the extracted digit is always a number from 1 to 6 instead of 0 to 5 for regular base 6 conversion. ((_{6})* is faster but costs bytes extracting the quotient.)
T`7-1`d

Transpose the digits so that the 6s come first and the 1s last. (There are no 7s or 0s but this allows me to use the d shortcut.

C# (.NET Core), infinite printing, 181 180 88 bytes.

string[] s=new string[]{" "},t;int i,j,k,l=1;while(true){j=l;t=new string[l=6*j];for(i=6;i>0;i--)for(k=(6-i)*j;k<l;)t[k]=i+s[k++%j];
for(k=0;k<l;)System.Console.Write(t[k++]);s=t;}

Sadly it freezes repl.it instead of outputting properly in the infinite version as written (I believe it to be an error in repl.it, as it does not output as the program loops like it should), so anyone hoping to test needs a computer.  If you add a read at the front of the loop it works in repl.it as well.
Outputs to the console, obviously.
On any finite system the code will most likely eventually crash with an out of memory error.
Reworked the code to use @dana 's lambda.
int f(int n)=>n-->0?f(n/6)*10+6-n%6:0;for(int i=0;++i>0;)System.Console.Write(f(i)+" ");

Try it online!

I have no idea if I've golfed this well or not.

Saved one byte by removing unnecessary k++.

(also, I greatly welcome golfing assistance, I'm very new to this.)

Welcome :) If you are interested in golfing in C#, you may want to check out this post for some tips: https://codegolf.stackexchange.com/q/173/8340

Cubix, 22 bytes
This will output the sequence indefinitely.  The general idea is that it has a base number which 6 - 1 is added to.  For each add the result is output multiplied by 10, which is pushed to the bottom of the stack to be used later in the sequence.  The base is then popped and the next base started.
..w.06+ONo*w;|uW!(pq;;

Try it online!
    . .
    w .
0 6 + O N o * w
; | u W ! ( p q
    ; ;
    . .

Watch It Run

Forth (gforth), 63 bytes
: f recursive dup 6 < if 6 - abs 1 .r else 6 /mod 1- f f then ;

Try it online!
0-indexed outputs nth value
Explanation
If N is less than 6, output the absolute value of N - 6. Otherwise, get the quotient and remainder of dividing N by 6. Call the function recursively on the quotient, then call it on the remainder.
Code Explanation
: f                 \ start a new word definition
  recursive         \ declare that this word is recursive so we can call it from itself
  dup 6 <           \ check if n is less than 6
  if                \ if it is:
    6 - abs 1 .r    \ subtract 6, get the absolute value, then print with no appended space
  else              \ else if it's greater than 6:
    6 /mod          \ get the quotient and remainder of dividing n by 6
    1-              \ subtract 1 from the quotient (because we're 0-indexed)
    f               \ call f on the result
    f               \ call f on the remainder (shortcut to format and print, it's always < 6)
  then              \ end the if/else
;                   \ end the word definition

APL(NARS), 27 chars, 54 bytes
{0>⍵-←1:0⋄(6-6∣⍵)+10×∇⌊⍵÷6}

traslate the solution by dana https://codegolf.stackexchange.com/a/179980 in APL...
test:
  f←{0>⍵-←1:0⋄(6-6∣⍵)+10×∇⌊⍵÷6}
  f 500
5625
  f¨750 1000 9329 9331 10000 100000
4531 3433 11112 666666 663633 6131233
  f¨⍳9
6 5 4 3 2 1 66 65 64

C#, print from start to n, ??? bytes
Credit to @dana for the lambda expression.
int f(int n)=>n-->0?f(n/6)*10+6-n%6:0;for(int i=0;i<int.Parse(a[0]);)System.Console.Write(f(++i)+" ");

Operation: Run with command line 0th argument equal to the integer you want to count to.  (It should be noted that a[0] is a reference to the otherwise unmentioned command line args array, and I don't know how to count it.)

Since part of the code is a snipper instead of a full program or function, I assume you're using the Visual C# Interactive Compiler? Could you perhaps add a Try it online link with test code? PS: Your current byte-count is 102

source: Stack Exchange

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

sort: votes


text:
The Great Pyramid of Quine
The task is a rather simple quine challenge with a twist, you must output your source code in the shape of a pyramid. The shape of a pyramid is defined below:
       1
      234
     56789
    ABCDEFG
   HIJKLMNOP
  QRSTUVWXYZa
 bcdefghijklmn
......etc......

The main limitation of this challenge is that your quine must contain exactly enough bytes as to not obstruct the pattern of the pyramid. For instance, the following program lengths would work:
1-byter: 1st layer of the pyramid (not allowed by definition of a quine).
4-byter: 1st and 2nd layers of the pyramid.
9-byter: 1st, 2nd and 3rd layers of the pyramid.
etc...

So, if your program was:
QWERTY

It would not be valid, because it would arrange like:
  Q
 WER
TY

However, if your program was QWERTYUIO, it would be fine:
  Q
 WER
TYUIO

Rules

Standard loopholes are obviously disallowed, no reading your own source.
The pyramid must be centered, trailing characters are allowed, but not required.

Also, any character may be used to center the pyramid, doesn't have to be (char)32.

Your quine must be able to be shaped into a pyramid.

It must retain the original ordering of your sourcecode.
Your source-code may NOT contain the character being used to format the pyramid.
E.G. if your sourcecode contains a space, you'll need another char for the format.

You may use comments in your quine to "pad" to the correct size.

Obviously, these must be output as part of the quine.

If the program contains newlines/tabs, they aren't part of the quine and should be omitted in the output.
The shape is counted in characters, not bytes; if the shape is malformed you're not doing it right.

The lowest possible score here should be 4.

Does the original quine need to be in the shape of a pyramid, or does just the output need to be?

@KrystosTheOverlord the output, the original doesn't matter. If the original has tabs or newlines you should omit these in the output as well in order to retain the shape of the output.

Is it valid if the output has a bunch of trailing spaces/newlines?

@Emigna should it be? I don't see a problem with it unless others do at this point. Also, define "a bunch of", isn't the consensus usually "a single trailing newline is acceptable"?

@MagicOctopusUrn: Yeah, the usual consensus is that a trailing newline is okay. For ascii-art output, whitespace that doesn't affect the format of the output are often okay. For a quine challenge that feels kinda iffy though, which is why I asked.

You should make a challenge where you need to have the quine in the format of a pyramid :).

Are 1 character solutions allowed?

@VFDan that's not a quine by definition.

@MagicOctopusUrn I mean a program that is one character that prints that same character. It prints its source code, so it is a quine.

@VFDan it's not though. Read the definition of a quine as told by the meta. 1 is a quine poly-got in over 50 languages (by your definition) which is why that's not the case.

05AB1E, 36 bytes
"34çs«DJā·<£õK.cJ?"34çs«DJā·<£õK.cJ?

Try it online!
If trailing characters are allowed also means at the end of the output, 0"D34çýā·<£.c"D34çýā·<£.c is a layer shorter at 25 bytes.

34ç is the basis of all 05AB1E quines, isn't it haha? Also, not sure how I feel about the random amount of trailing newlines... I'd prefer someone else to make that call (what's the norm, 1 trailing/preceeding is allowed?) that seems super on-the-edge.

@MagicOctopusUrn:  Yeah, it's kinda questionable. I assume my shorter version isn't OK, which is why I didn't use it as the primary program, but I felt I should ask since it would save me a whole layer.

Dang, you beat me to it. And instead of ā·< I used 9ÅÉ (in the 25 byter, didn't thought about the trailing newline..)

@MagicOctopusUrn Btw, all other answers have a trailing newline, so all would be invalid except for this 36-byter..

Java 11, 324 256 227 bytes
v->{var s="v->{vars=%c%s%1$c;for(inti=0;;)System.out.printf(%1$c%%%1$c+(15+i)+%1$cs%%n%1$c,s.format(s,34,s).substring(i*i,++i*i));}///";for(int i=0;;)System.out.printf("%"+(15+i)+"s%n",s.format(s,34,s).substring(i*i,++i*i));}//

-29 bytes thanks to @JoKing.
Outputs with leading spaces to make the triangle. (Note that the whitespace between var    s and int i are tabs, not spaces.)
Try it online.
Explanation:
quine-part:

var s contains the unformatted source code String
%s is used to put this String into itself with s.format(...)
%c, %1$c and 34 are used to format the double-quotes (")
%% is used to format the %
s.format(s,34,s) puts it all together

Challenge part:
for(int i=0;;)         // Loop `i` indefinitely upwards from 0
  System.out.printf(   //  Print with format:
    "%"+(15+i)+"s      //   Add leading spaces to make the line length size 15+`i`
                 %n",  //   And include a trailing newline
    s.format(s,34,s).substring(
                       //   And append a substring of the source code-String
       i*i,            //    From index `i` squared
       ++i*i));}       //    To index `i+1` squared

Which stops with an java.lang.StringIndexOutOfBoundsException: begin 225, end 256, length 226 error for the String#substring(int,int) method, the iteration after it has printed the result (which is fine according to the meta).

it doesn't save you any anything really, but you don't need to s=s.format part when you can have the format in the loop instead

@JoKing Ah of course. Thanks. Unfortunately I have to decrease the base program without comments to at least 196 (142) to save bytes (or only golf it to 225 (152) and find a workaround to have an odd number of bytes somehow). It's currently 228 without the comments.

Tried a different approach and ended up only two bytes off and only because of it being an odd number... The workaround for odd lengths is a %% in the string and only one % in the actual code, but this means the comments are mandatory

@JoKing Nice approach with the spaces replaced with tabs so we can have leading spaces (and omit the tabs from the output due to the challenge rules). I've been able to rework your code with /// in the string so the string is long enough for it to go to the expected iteration to print everything, before stopping with the StringIndexOutOfBoundsException for the .substring. And with only two trailing // at the end of the actual program, since it only prints two trailing // as well. :)

Oh wow, I didn't expect a Java answer! Nice one!!!

Python 2, 81 bytes
s='n=0;\nprint(8-n)*chr(32)+("s=%r;exec(s*9)"%s)[n*n:][:n-~n];n+=1;#JK';exec(s*9)

Try it online!
An eval quine that uses spaces as the filler character.

without error?

and with spaces as padding

or... well... clearly with that much padding you could put a signature (i.e. a more interesting string thatn aaaaaaaaa) in it :P

@ASCII-only Good point, see updated answer ;)

Python 2, 169 bytes
Uses 0 for formatting the pyramid.
s='s=%r;k=s%%s;print"\\n".join(`1-1`*(12-n)+k[n*n:][:n-~n]for n in range(13))#######################';k=s%s;print"\n".join(`1-1`*(12-n)+k[n*n:][:n-~n]for n in range(13))

Try it online!

Python 2, 147 bytes
This uses the rule If the program contains newlines/tabs, they aren't part of the quine and should be omitted in the output.
s='s=%r;k=s%%s;print"\\n".join(`1-1`*(12-n)+k[n*n:][:n-~n]forninrange(13))##';k=s%s;print"\n".join(`1-1`*(12-n)+k[n*n:][:n-~n]for	n	in	range(13))##

Try it online!

Perl 6, 67 bytes
<say("<$_>~~.EVAL".substr($!++²,$!*2-1).indent(8-$!))xx⁸>~~.EVAL

Try it online!
I used a couple of unicode characters in order to squeeze out that extra layer. Outputs using spaces:
       <
      say
     ("<$_
    >~~.EVA
   L".substr
  ($!++²,$!*2
 -1).indent(8-
$!))xx⁸>~~.EVAL

Explanation:
<say("<$_>~~.EVAL"                                  )   >~~.EVAL   # Normal quine
                  .substr($!++²,$!*2-1)              xx⁸  # Split into layered substrings
                                       .indent(8-$!)      # And indent each one

Gol><>, 36 bytes
":P}r6&56F:M}F0ss|&:P&Roao{|;Nooooo!

Try it online!
an even younger version, 36 bytes
":P}r6&56F:M}R` &:P&Fo|ao{|;Noooooo!

I feel so close to getting it one line shorter, grrrr....
Try it online!
even younger version, 36 bytes
"r2ss6&56F:M}R` &:P&Fo|ao{|;what????

This one's code is smaller, but it still comes out to the same amount sadly, the comment takes up the remainder of the space.
Try it online!
slightly younger version, 36 bytes
"r2ss156F:M}F` o|:PP}Fo|ao{{|;Wowza!

Wowza! Heh, I just used that to fill some space, but the program works, to golf down, I used a few prepushed values rather than using variables!
Try it online!
Older version, 42 bytes
"r2ss0V_~6:&F&:M&F` o|_PPV_Fo|ao|;empty...

This has a trailing newline, and has more chars than i would like...
I'm going to be golfing this severely...
Try it online!

25 bytes

R, 169 144 bytes
s='`!`=intToUtf8;cat(sprintf("%*s",11+(i=1:12),substring(paste0("s=",q<-!39,s,q,";eval(parse(t=s))"),(i-1)^2+1,i^2)),sep=!010)';eval(parse(t=s))

Try it online!
           s
          ='`
         !`=in
        tToUtf8
       ;cat(spri
      ntf("%*s",1
     1+(i=1:12),su
    bstring(paste0(
   "s=",q<-!39,s,q,"
  ;eval(parse(t=s))")
 ,(i-1)^2+1,i^2)),sep=
!010)';eval(parse(t=s))

Managed to shorten it by moving to a string that’s parsed rather than an expression that’s departed. Had to use a redefinition of a unary operator to get it under the 144 though.

Clean, 256 bytes
module QQ;import StdEnv,Text;q=dec'#';$n#k=(s<+q<+s<+q)%(n^2,n^2+n*2)=lpad k(16+n)(dec q);Start=join{toChar 10}(map$[0..15]);s="module QQ;import StdEnv,Text;q=dec'#';$n#k=(s<+q<+s<+q)%(n^2,n^2+n*2)=lpad k(16+n)(dec q);Start=join{toChar 10}(map$[0..15]);s="

Try it online!
Pretty much the standard quine, conveniently also a template quine, with the formatting function added.

Even though it's code-golf, I love these longer answers. Holy cow that's impressive.

C# (Visual C# Interactive Compiler), 225 bytes
var s="var s={0}{1}{0};for(int i=0;;)WriteLine(string.Format(s,(char)34,s).Substring(i*i++,2*i-1).PadLeft(i+14,(char)2));//";for(int i=0;;)WriteLine(string.Format(s,(char)34,s).Substring(i*i++,2*i-1).PadLeft(i+14,(char)2));//

Uses a STX char as padding. Did not realize Kevin Cruijssen already submitted an exact copy in java before posting until I was done, but I decided to post this anyways.
Try it online!

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


text:
Cell phone Charge
Challenge Taken with permission from my University Code Challenge Contest

The dependence we have on mobile phones makes us charge them every night up to the maximum level of the battery, so we do not run the risk of running out of power by the middle of the next day. There are even people who, when they see a free outlet during the day, put it to charge for what may happen.
I am one of them.
Over the years, I have refined my technique to not charge the battery to the maximum every night. With my perfectly known repetitive routines, I am clear on what times of the day I will be able to do those partial recharges (and how many units the level will increase) and what lowers the battery level between each charge. With these data, every night I calculate the minimum battery level I have to leave the house the next day with so that it never falls below my self-imposed threshold of two units.
What I have not yet managed to master is that same calculation when I leave the established routine and I have several alternatives to do things. It happens, for example, on the days when I'm en route to another city to which I can arrive in different ways.
In my first approach to the problem, I am assuming that I want to move around a "chessboard", from the upper-left corner to the lower-right corner. In each "cell" I can either charge the mobile a specific amount, or I cannot and its load level goes down.
Challenge
Given a FxC matrix of integers, output the minimal battery level amount I need to go from the top-left corner to the bottom-right without the load level ever falling below 2 units.
In the matrix, a positive number indicates how much I can charge my mobile phone before I have to resume following my path, while a negative number indicates that there are no outlets and that the mobile's battery drops its charge level by that amount. It is guaranteed that the quantities in the source and destination cells (top-left and bottom-right corner) are always 0 and that the rest of the values (absolute value) do not exceed 100.
Example
Given:
$$ \begin{bmatrix} &-1&1&-1 \\ -1&-1&-1&-1 \\ -1&1&-1&-1 \\ 1&1&-1&0 \end{bmatrix}$$
The path I need less battery is:
$$ \begin{bmatrix} &-1&1&-1 \\ \color{blue}{-1}&-1&-1&-1 \\ \color{blue}{-1}&1&-1&-1 \\ \color{blue}{1}&\color{blue}{1}&\color{blue}{-1}&0 \end{bmatrix}$$
And the minimal battery level amount I need is 4
Notes

The Start is always going to be the top-left corner
The End is always going to be the bottom-right corner
You cannot go to a cell you've already passed. Example: Once in position (0,1), you cannot go to the initial point (0,0)
Your battery level cannot (for any reason) go under 2
You can assume there will always be a beginning and an end
You can take the 1-dimensional arrays as multidimensional if you need to [1,2,3] == [[1,2,3]]
There can be multiple correct (minimal needed charge) paths
Your goal is to only output the lowest initial battery level needed, not the route
You can only go vertically and horizontally (not diagonally)

Test Cases
[0, 0] => 2
[0, 1, 0] => 2
[0, -1, 0] => 3
[0, 15, -20, 5, 0] => 7
[[0, -3],[-5, 0]] => 5
[[0, -5, -9, 5], [-3, 5, 2, -2], [2, -4, -4, 0]] => 5
[[0, -1, 1, -1], [-1, -1, -1, -1], [-1, 1, -1, -1], [1, 1, -1, 0]] => 4

I forgot the day of the challenge. Sandbox post

To anybody remembering: The challenge "The Hungry Moose" never made it out of the sandbox, so this is no dupe.

@BlackOwlKai I think both challenges are different

Will the optimal path ever require moving left or up? For example [[0,1,-1],[-9,-9,1],[-9,1,-1],[-9,-1,-9],[-9,1,0]]

@KamilDrakari Yes

Are there any other squares equal to 0 besides start and end? None of the examples do, but there doesn't look to be a rule that excludes this.

@dana no, there are only 2 0s placed one at the top-left corner and the other one at the bottom-right

Python 2, 208 202 bytes
lambda s:2-f(s)
def f(s,x=0,y=0):
 if x>-1<y<s[y:]>[]<s[y][x:]!="">s[y][x]:k=s[y][x];s[y][x]="";return k+min(0,max([len(s[y+1:]+s[y][x+1:])and f(eval(`s`),x+a/3-1,y+a%3-1)for a in 7,1,5,3]))
 return-9e9

Try it online!

Python 2, 217 211 bytes
i=input()
X,Y=len(i[0]),len(i)
s=[[0]*4+[i]];r=[]
for m,l,x,y,g in s:
 if X>x>-1<y<Y<"">g[y][x]:r+=[m]*(Y-y<2>X-x);l+=g[y][x];g[y][x]="";s+=[[min(m,l),l,x+a/3-1,y+a%3-1,eval(`g`)]for a in 7,1,5,3]
print 2-max(r)

Try it online!

JavaScript (ES7),  162 156  154 bytes
m=>(M=g=(x,y,n,k)=>m.map((r,Y)=>[r[x+1]]+[m[y+1]]?r.map((v,X)=>r[1/v&&(x-X)**2+(y-Y)**2==1&&g(X,Y,u=v+n,k<u?k:u,r[X]=g),X]=v):M=M>k?M:k))(0,0,0)|M<0?2-M:2

Try it online!
Commented
m => (                          // m[] = input matrix
  M =                           // initialize M to a non-numeric value
  g = (x, y, n, k) =>           // g = recursive depth-first search function
    m.map((r, Y) =>             // for each row r[] at position Y in m[]:
      [r[x + 1]] +              //   if either r[x + 1]
      [m[y + 1]] ?              //   or m[y + 1] is defined:
        r.map((v, X) =>         //     for each value v at position X in r[]:
          r[                    //
            1 / v &&            //       if v is numeric
            (x - X) ** 2 +      //       and the squared Euclidean distance
            (y - Y) ** 2 == 1   //       between (x, y) and (X, Y) is 1:
            &&                  //
              g(                //         do a recursive call:
                X, Y,           //           with (X, Y)
                u = v + n,      //           with n = n + v
                k < u ? k : u,  //           with k = min(k, n + v)
                r[X] = g        //           set r[X] to a non-numeric value
              ),                //         end of recursive call
            X                   //       then restore r[X]
          ] = v                 //       to its initial value
        )                       //     end of inner map()
      :                         //   else (we've reached the bottom right corner):
        M = M > k ? M : k       //     update M to max(M, k)
    )                           // end of outer map()
)(0, 0, 0) |                    // initial call to g with x = y = n = 0 and k undefined
M < 0 ? 2 - M : 2               // return 2 - M if M is negative, or 2 otherwise

R, 224 220 217 213 210 bytes
f=function(x,m=rbind(0,cbind(0,x,0),0),i=2,j=2,p=F,k=c(1:-1,0,0,-1:1),b=Inf,`^`=min){m[i,j]=0
for(h in 1:4)b=b^'if'(all(c(R<-i+k[h],C<-j+k[h+4])>dim(x)),max(2,2-cumsum(p)^0),if(v<-m[R,C])b^f(x,m,R,C,c(p,v)))
b}

Try it online!

C# (Visual C# Interactive Compiler), 242 bytes
a=>{int m=1<<31,n=~m;void g(int w,int x,int y,int z){for(int i=4,t,c,d,e;i-->0;)try{t=a[c=i<1?w-1:i<2?w+1:w,d=i>2?x-1:i>1?x+1:x];n=t==0&z<n?z:n;a[c,d]=m;e=y+t<2?2-y-t:0;if(t!=m)g(c,d,y+t+e,z+e);a[c,d]=t;}catch{}}a[0,0]=m;g(0,0,2,2);return n;}

Try it online!
//a: input matrix
a=>{
  // m: marker for used cells
  // n: result, initialized to a huge value
  int m=1<<31,n=~m;
  // recursive function
  // w: 1st dim coordinate
  // x: 2nd dim coordinate
  // y: current charge level
  // z: initial charge for current path
  void g(int w,int x,int y,int z){
    // i: loop variable
    // t: temp holds overwritten value
    // c: adjacent 1st dim coordinate
    // d: adjacent 2nd dim coordinate
    // e: delta charge needed
    for(int i=4,t,c,d,e;i-->0;)
      // avoid index out of range errors
      // by using try/catch
      try{
        // determine neighbor
        // coordinates and save value
        t=a[c=i<1?w-1:i<2?w+1:w,
            d=i>2?x-1:i>1?x+1:x];
        // if we have found a 0, check if
        // initial charge is lower than the
        // lowest so far. save it if it is.
        n=t==0&z<n?z:n;
        // mark current cell used
        a[c,d]=m;
        // determine if we need to
        // increase the initial charge
        e=y+t<2?2-y-t:0;
        // make recursive call if current
        // cell was not previously in use
        if(t!=m)g(c,d,y+t+e,z+e);
        // restore current cell value
        a[c,d]=t;
      }catch{}
  }
  // mark starting cell used
  a[0,0]=m;
  // start the recursive function
  g(0,0,2,2);
  // return the result to the caller
  return n;
}


text:
Return Spiral Indexes!
Spirals are cool , so are numbers, and number spirals are even cooler. But what if I want a specific number, in a specific place using xy coordinates...
Challenge
Using an infinite spiral moving down first, curling in a counterclockwise manner
ex:
 6  5  4
 7  0  3
 8  1  2
 9 10 11

Take negative and positive inputs(integers) in the form of (x, y)
When given those coordinates return the number at that position in the spiral
The integer inputs must be the maximum that your language can use

ex:
 6  5  4
 7  0  3
 8  1  2
 9 10 11

input : (0,0)
output : 0

input : (1,1)
output : 4

input : (-1,-1)
output : 8

input : (5,5)
output : 100

input : (-5, -6)
output : 121

input : (2, -5)
output : 87

input : (-9, 2)
output : 349

input : (-7, 8)
output : 271

input : (-5, -7)
output : 170

Scores
This is a codegolf, so smallest code wins!!!

This challenge has created the spiral tag. If we want to really use it (I'm not sure how useful it is), other questions about spirals should be tagged as well

related, related, related

This is (almost) the reverse of this challenge.

except the other is strating to the right 1 is (1,1) and this downward 1 is (0,-1)

I would call that a duplicate. There's barely anything changing when using a spiral starting downwards or rightwards.

@OlivierGrégoire The other one requires that you output the position, this challenge is the reverse, you need to output the number at the coordinates given

This is in need of a couple more test cases using higher indices.

May I answer with a 1-indexed spiral?

@attinat what do you mean by with a one indexed spiral?

I would assume that @attinat means can (1,1) be the centre of the spiral, rather than (0,0)

the number at (0,0) would be 1.

JavaScript (ES7), 50 bytes
This is using a slightly modified version of the formula that I've used and explained in this post.
x=>y=>(i=4*(x*x>y*y?x:y)**2)-(x<y||-1)*(i**.5-x-y)

Try it online!
or Try a version that displays the spiral.

Just checked the higher indices, this answer definitely works.

05AB1E, 18 15 bytes
·nàDtIO-I`›·<*-

Port of @Arnauld's JavaScript (ES7) answer.
And -3 bytes thanks to @Arnauld as well.
My answer uses the formula:
$$T=\max((2*x)^2, (2*y)^2)$$
$$P=\begin{cases}
1&\text{if }y>x\\
-1&\text{if }y\le x
\end{cases}$$
$$T - (\sqrt{T} - (x+y)) * P$$
Which saves bytes with some of 05AB1E's convenient builtins, in comparison to the similar but slightly different formula @Arnauld uses in his answer.
Try it online or verify all test cases.
Explanation:
·                # Double both values in the (implicit) input-list
 n               # Then square both values
  à              # Take the maximum of the two
   Dt            # Duplicate it, and take its square-root
     IO-         # Subtract the sum of the input-list
        I`›      # Check if y is larger than x (1 if truthy; 0 if falsey)
           ·<    # Double it, and decrease it by 1 (1 if 1; -1 if 0)
             *   # Multiply both
              -  # Subtract them from each other (and output the result implicitly)

Good explanation you got there, and good job at completing the challenge! :)

Perl 5, 55 bytes
From @Arnauld's formula
/ /;$_=($i=2*max abs$`,abs$')**2-($`<$'||-1)*($i-$`-$')

TIO

Jelly, 15 bytes
Ḥ²Ṁ©½_S×>/Ḥ’Ɗ®_

Try it online!
Port of @KevinCruijssen’s version of @Arnauld’s formula so be sure to upvote them.

Nice golfing there, you are tied for the least bytes in this challenge with KevinCruijssen's

Wolfram Language (Mathematica), 45 bytes
(For[i=j=0,ReIm@i!=#,i+=I^⌈2√++j⌉I];j)&

Try it online!
Generates the spiral up to the desired point


text:
How fast can I say your program?
I recently decided to download some dictation software, in order to help with my writing. However, it doesn't work very well when I'm coding, since I have to change from saying words to symbols and back again. It's even worse when I'm coding in an esoteric language which is all symbols.
In order to make my use of the dictation program more consistent, I decided to switch it over to character mode, where I just say the name of each character instead. Problem solved! Though this does delay my novel's release date a little bit...
So, assuming that the longer the name of a character, the longer it takes to say, how long will it take me to spell out some of my programs/sentences?
Specifications
Given a string consisting of only printable ASCII, return the sum of each character's unicode name. For example, / is called SOLIDUS with 7 characters, and A is LATIN CAPITAL LETTER A with 22 characters.
But remember, I have to say your programs out loud to execute them, so their score will be based on how long it takes me to say them, i.e. as the sum of the lengths of each character's unicode name.
Test Cases:
In format input => output with no trailing/leading spaces in input.
A      => 22
/      => 7
Once upon a time...           => 304
slurp.uninames>>.comb.sum.say => 530
JoKing => 124
!" #$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~        =>  1591
Double-check your \s on the last test case ;)   => 755
<say "<$_>~~.EVAL">~~.EVAL     => 388
,[.,]  => 58
19     => 19

Rules:

Input to your program will only consist of printable ASCII characters, that is, the codepoints 32 (space) to 126 (tilde).

For convenience sake, here is the list of lengths of the characters you have to handle: [5,16,14,11,11,12,9,10,16,17,8,9,5,12,9,7,10,9,9,11,10,10,9,11,11,10,5,9,14,11,17,13,13,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,19,15,20,17,8,12,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,18,13,19,5]

Here is a reference program you can use to score your program.

Peter Taylor has pointed out that the reference program normalises some unicode characters. It should still work for most solutions, but feel free to correct it if you need

Since you're saying what the characters actually look like, your solution will be scored by the characters that are displayed, not the bytes involved. This is directed at languages with custom encodings.

You can assume that I've memorised the entire Unicode library and can say whatever strange characters you use.

Sorry Rogem, but answers have to be composed of displayable characters. Unprintables are fine, I just have to be able to read the characters out loud.
Whatever you do, do not use ﯹ in your program.

ARABIC LIGATURE UIGHUR KIRGHIZ YEH WITH HAMZA ABOVE WITH ALEF MAKSURA ISOLATED FORM this will be the full name of my child

This program scores 6 in word mode: Try it online!

The reference program is buggy. Consider [this test] (https://tio.run/##dY5PC4JAEMXvfYphYcNsWcrSi@Ahrx3rlB223FTSXdk/oUR9daP1YoceDMPj92Z4LVd1NAya9YDSkikAOIpKsIbDVHsuClNCKq0wcJAGxTN3AqiD7eqNsu4UrIPojOhVNhe6YwXVUhnPp3feL5KEzp@tqoS5AcId4CDUgDc54NBNJhABqXLPpQl8F7VjDQLLqXX/CX2w2vLfoCP@SOJ/4EW1bYbhAw) where \x[2126] is counted as \x[3a9].

Java 8, score 846 838 822 816
ௐ->ௐ.map(ˇ->Character.getName(ˇ).length()).sum()

-8 score thanks to @tsh replacing the _1 with ꀊ.
-22 score thanks to @ASCII-only replacing the ꀊ with ˇ and $ with ௐ.
Try it online.
Explanation:
The ௐ and ˇ are used instead of the s and c I would normally use, because lowercase letters are all 20 (i.e. LATIN SMALL LETTER S), but ௐ (TAMIL OM) is 8 and ˇ (CARON) is 5.
ௐ->                         // Method with IntStream parameter and integer return-type
  ௐ.map(ˇ->                 //  Map each character to:
      Character.getName(ˇ)  //   Get the name of the character
               .length())   //   Get the length of that name
   .sum()                   //  And after the map: sum all lengths together,
                            //  and return it as result

I like how this Java stuff beats the 05AB1E answer both in terms of bytes and it terms of score...

@EriktheOutgolfer Ikr. Builtins ftw I guess. ;)

@KevinCruijssen It does save a couple bytes that you don't have to push compressed integer 87235805968599116032550323044578484972930006625267106917841 :P

Use ꀊ instead of _1 would save some points.

@tsh Thanks! Completely forgot other 'weird' characters besides regular letters and _$ are possible as well for variables.

Remember _ is shorter >_> also the ohm sign Peter Taylor used if that's valid in Java

@ASCII-only Just _ isn't allowed in Java, why do you think I had _1 in the first place.. But your tip on Peter Taylor's answer regarding ˇ (CARON) does work, so thanks! If you know another one shorter than 11 to replace the $, let me know. :)

@KevinCruijssen Peter Taylor's Ω (OHM SIGN) is 8 characters long. Also haha I wasn't aware it was not valid, just assumed since it's valid in C# and Peter used _1 too (program to find short variable names, the box character can't  be used)

@ASCII-only Thanks. I've decided to use the ௐ (TAMIL OM) since it's also 8 bytes.

Perl 6, score 337
+*.uninames.&[~].ords

Try it online!

That .&[~] instead of .join is a neat trick. I can never remember what reduction operators can be applied through that method

Japt v2.0a1 -x, Score 926 908 875 865 829 791 789
Takes input as an array of characters.
®cg`061742//0.450./..//.2/5117385`c+51 r\A_p26}  n#

Try it or run all test cases on TIO
(APOSTROPHE is omitted from the 6th test case on TIO as Japt can't handle both single and double quotes in the same input string)

Explanation
®cg`...`c+51 r\A_p26}  n#      :Implicit input of character array
®                              :Map
 c                             :  Character code
  g                            :  Index into (0-based, with wrapping)
   `...`                       :    The string described below
        c+51                   :    Increment the codepoint of each by 51 (="8cKidj55gebbc9agh895c97a99baa9bba59ebhddMjfkh")
                               :    (Space closes the above method)
             r                 :    Replace
              \A               :      RegEx /[A-Z]/g
                _              :      Pass each match through a function
                 p26           :        Repeat 26 times
                    }          :      End function
                               :    (Space closes the replace method)
                               :  (Space closes the indexing method)
                       n       :  Convert to integer
                        #      :    From base 32 (note the trailing space)
                               :Implicitly reduce by addition and output

Building The String
(Scores include the steps and extra characters needed to reverse each modification)

The array gave a baseline score of 2161.
Converting each to a single character in a base >=23 and joining to a string scored 1832.
Replacing both runs of m and k with a single, uppercase character scored 963.
There were still too many expensive letters so next I tried to get rid of them by reducing the codepoints of all characters. 5 was the character with the lowest codepoint (53) so I started with 52, which scored 756
After trying all numbers that would leave no letters in the string, 51 gave the best score of 738
Finally, replacing the quotation marks with slightly cheaper backticks gave a score of 734. Backticks in Japt are usually used to enclose and decompress a compressed string but, luckily, none of the characters in this string are contained in Shoco's library

The final string, so, contains the characters at the following codepoints:
[5,48,24,54,49,55,2,2,52,50,47,47,48,6,46,52,53,5,6,2,48,6,4,46,6,6,47,46,46,6,47,47,46,2,6,50,47,53,49,49,26,55,51,56,53]

05AB1E, score 963
Îv•Fδà‚<0?9½mΣ@×ƶC₁vc-™uΔ_ε'•21вεD3‹i22α₂и}}˜yÇ32-è+

Try it online or verify all test cases.
Explanation:
Î               # Push 0 and the input-string
 v              # Loop `y` over the characters of this input-string:
  •Fδà‚<0?9½mΣ@×ƶC₁vc-™uΔ_ε'•
               '#  Push compressed integer 87235805968599116032550323044578484972930006625267106917841
   21в          #  Converted to Base-21 as list: [5,16,14,11,11,12,9,10,16,17,8,9,5,12,9,7,10,9,9,11,10,10,9,11,11,10,5,9,14,11,17,13,13,0,19,15,20,17,8,12,2,18,13,19,5]
    ε           #  Map over this list:
     D3‹i       #   If the value is smaller than 3:
         22α    #    Take the absolute difference of this value with 22
            ₂и  #    Repeat it 26 times as list
    }}          #  Close the if-statement and map
      ˜         #  Flatten the list
       yÇ       #  Get the unicode value of the current character
         32-    #  Subtract 32
            è   #  Index it into the list of integers
             +  #  And add it to the sum
                # (and output the sum implicitly as result after the loop)

See this 05AB1E tip of mine (sections How to compress large integers? and How to compress integer lists?) to understand why •Fδà‚<0?9½mΣ@×ƶC₁vc-™uΔ_ε'•21в is [5,16,14,11,11,12,9,10,16,17,8,9,5,12,9,7,10,9,9,11,10,10,9,11,11,10,5,9,14,11,17,13,13,0,19,15,20,17,8,12,2,18,13,19,5].

R; Score: 3330 1586 1443
Also challenging in R due to lack of built-ins.
Well the code is now mostly @Giuseppe's but that's alright. I was able to make a small edit to golf further by replacing the * with the ~, and the s with the dot.
Thanks to @Nick Kennedy for getting this down to 1443 by using arcane magic "a UTF8 encoded version of the number sequence"
function(.)sum((c(+",752230178/0,30.1002110221,052844",61~26,+":6;8/3",59~26,+"94:,")-39)[+.-31]);`+`=utf8ToInt;`~`=rep

Try it online

1769 points -- makes a minimal attempt to compress the values...

also, utf8ToInt is a super helpful command for golfing :-) I haven't been on PPCG for a month or so, so it's nice to see new people golfing in R!

Ah, I had a way to compress it, but was not aware of utf8ToInt. I'll have to work on this later tonight/tomorrow.

1617 -- I'm just making random edits instead of doing my actual work :-(

Well I appreciate it. What does the footer do over at TIO?

It's just more lines of code under the program/snippet that doesn't affect bytecount - useful to do some tests in

Also see the C# solution, I'm sure you can do something similar, just gotta do asc first, the lookup table logic should be mostly the same?

if packages are allowed function(.)sum(nchar(u_char_name(as.u_char(utf8ToInt(.)))));library(Unicode) is 1388.

Down to 1443: https://tio.run/##xc09DoIwFADgu3ShTR/w3usPBeQA7m7GpAmxCYPFIKxcvQ4ewvGbvq2kS13Sked9WbNs1Od4STlLLaBzzAapCy2CwYYQmQiZCdBxsFaAp5M9aDH4MbRGgOt/7u0AQtWmV3fd1IYeaow6Tseewm295n2MZ5y257skWf2prlT5Ag Using a UTF8 encoded version of the number sequence.

C# (Visual C# Interactive Compiler) (score 1627 1116 1096 1037 1019 902)
Ω=>Ω.Sum(ˇ=>(31&-ˇ)>5&ˇ>62?22-ˇ/91*2:"♁♌♊♇♇♈♅♆♌♍♄♅♁♈♅♃♆♅♅♇♆♆♅♇♇♆♁♅♊♇♍♉♉♏♋♐♍♄♈♎♉♏♁"[ˇ-6-ˇ/33*26]-9788)

This uses no built-in database: just some special-casing for letters and a lookup table.
Online test suite.
It can't score itself, because most of the characters are not in range, including the variables CARON and OHM SIGN and the zodiac symbols used to encode the lookup table.
Thanks to ASCII-only for many suggestions.

What scoring program did you use

tio.run/##NZDrdpNAFIX/z1OMY0wgwhCg0NAEanpT22jVaquGiAQnYbgMhIHWGJO36gv0xSJrBf@cdS57r72@E3A54HR3UbFgyMuCsoVEWenM7d3To@08PeKbKhU82xG2suDJdgd2xLauikPNbLc9R9eONU32FFPtakeI5CyOExrly5CShC4iSuMoonEcEcriZZryrFyGSZFygiZebdP1rmZOZcsUdwMwzwriB6Fw7xfQh5RBRh4m0zVAIyRBRYGaBpCybw8BumYBgVWesVpb0pRgjPc3vXcAEE@qIscVo8xPCXccHGTpDPMqxdxf7XWG3gPoMruqifcLVauNz1wEn7detDuC2H0pyVjpqZp@YJiHfetoMLSd41ejk9Oz84vXb95eXo3fvb/@8PHTzecvt3dfv32fuO70h/fTnwW/yHwR0ihOUpbly4KX1f3D79Wf9d/NtskyLBWgs6yaJUQOQhLEcJVVBXRdDmukMiQw8XkJS1KXwOcEDsQG3TAAGtYU0EXDludst/j8djR20f@u@UK/D5A0wdK0oa1H1WrCLbARwV1BSzKmjAgttPYly9hAaDsQrueCL26QONj9Aw

This should be 1590 whereas yours seems to score 1735 on the reference implementation

tio.run/##NZDrdpNAFIX/z1OMY0wgwsDMAIEkUNOb2karVls1RCQ4abBhiAy0xpi8VV@gLxZZK/HPWeey99rrO4nUE5luTyuR9GVZpOJGS0UZTP3t44MfPD7gyypTIj9QNroS6X4LttQmI2qfOs1mFDB6QKkeGQ5p0y7SOjalzCQd1zA1ZmJimpQQk1KimTZ1Lavr9FyDeVZXQ6OotjHWps5YZ5667YFpXvA4mSl3cQFjmAoo@P1ovAJogDRoGJBSgIxd2wHoQiQcVotc1NoyzTjGeHdjpgWQnFfFAlciFXHGZRDgJM8mWFYZlvFyp7OZCdBZfl4T7xaE1sYnIYJPG8@aLUVtP9d0bJiEMst2Oq7X7fX94ODF4PDo@OT05avXZ@fDN28v3r3/cPnx09X15y9fR2E4/hZ9jyfJDz69maU/b@eZyBe/CllWd/e/l39Wf9ebfZbtEYCO82oy53oy48ktXOZVAcNQwhqpnHE4j2UJS16XJJYc9tQ9um0D1K8pYIj6jSjYbPDJ1WAYov/d/guuC5A2wtp4T1uPxNuHe2CtgusiLfkwFVxpoFWsefYaQj@AcDVVYnWN1N72Hw

Should score 1120?

@ASCII-only, I used the Python answer below; the Java answer also gives 1627. The problem seems to be that the reference solution is buggy: Ω is U+2126, OHM SIGN, not GREEK CAPITAL LETTER OMEGA.

What's the micro one then? (Also replaced micro sign with ohm sign, 1116 now)

Aargh, I missed a subtraction of 32 to fix the index in my program to find the best offset for the lookup table. µ is MICRO SIGN.

https://tio.run/##NZDbdpNAGIXv5ynGMUaIMDDDIRAONT2pbbRqtVVDRIKTBhuGyEBrjMmVz@KD@SKRtYI3e/2nvfb6/lSoqch2pzVPfVGVGb9RMl6Fs2D39/efIGwEX9a5FAehtFXjrkFkn9rdbhza5IBSNdZcu0cHSOlblBo66Tuarhg6JrpOCdEpJYpuUcc0B7bnaIZrDhQ0jlW7MRpGj9oT1XDlnQdmRcmSdC7dJSVMYMYhZ/fjyRqgIVKgpkFKAdL2ZR@gC54yWC8L3txWWc4wxvudoZsAiUVdLnHNM57kTIQhTot8ikWdY5Gs9neWoQN0Vpw3uPsBoY3xQYTgw86j7mNJ7j1RVKzphBqmZfcdd@D5QXjwdHh4dHxy@uz5i7Pz0ctXF6/fvL189/7q@sPHT@MomnyOvyTT9Cub3cyzb7eLnBfL76Wo6rv7H6uf61@bbZtluQSg46KeLpiazll6C1dFXcIoErBBquYMLhJRwYo1kiaCQU9u0S0LIL@hgBHyO3G43eKTq@EoQv@r9guOA5AyxsqkpW1a4rbhLtjI4LrMKjbKOJM6aJ0orrWBMAghXM@kRN4g2dv9Aw

Score 1055 I think?

@ASCII-only, I've made further savings by using & instead of && and by reworking the comparison against 26 into a comparison against 5.

Let us continue this discussion in chat.

Score 5 name: ˇ, no other names shorter than 8 that C# accepts, also not verified with Java program

Why do you use Ω?.. It's name is GREEK CAPITAL LETTER OMEGA, which is even longer than just a letter.. The challenge description has a Perl 6 program to get your score.

@Kevin, as per my earlier comment the reference implementation is buggy. I think it's applying normalisation to turn the source character OHM SIGN into GREEK CAPITAL LETTER OMEGA.

@PeterTaylor Ah ok. I also just noticed the same thing with the KELVIN SIGN which it changes to LATIN CAPITAL LETTER K.. Nice score for a overall pretty verbose language without builtins for the challenge nor compression btw, +1 from me!

I'm honestly surprised how close this comes to the builtin-based Java answer (and even the Perl answer). Granted, letters are very, very expensive using this scoring method which explains the closeness. Also @PeterTaylor >64 -> >62 for -1 score should work?

@ASCII-only, now beating Python...

Haha, of course there's a better offset. I thought about it but doubted there would be a contiguous block of characters with names that short, I guess I just forgot you don't need a very wide range since the range of values being encoded is pretty small

Python 3, Score of 993
lambda _:len(''.join(map(__import__('unicodedata').name,_)))

Try it online!
Below 1000 now, any tips still appreciated.
-16 thanks to Kirill L.

993

You can replace _ by ˇ for 987.

Attache, 1934
Sum@{ToBase[FromBase[Ords@"!ZByru=#9fBYb$a3Si0^pU,ZP#3$cd'(c-_lhu]h(]5;!W|?M4:<_^sU;N&XFN`t:u"-32,95],23][Ords@_-32]}

Try it online!
Simple compression and indexing.

:P looks like using a smarter lookup (see C# answer) would help with score. Or even just using a charset that doesn't contain letters to compress

Perl 5 -pl, score 723
s,\N{OX}*.,_charnames'viacode ord$&,ge,$_=y,,,c

Try it online!
Explanation
s,        ,                        ,ge  # Replace globally
  \N{OX}*   # zero or more OX characters , loads the
            # _charnames module as side effect,
         .  # any character
           _charnames'viacode ord$&  # with its Unicode character name
                                     # (using old package delimiter).
                                      ,$_=y,,,c  # Set $_ to its length

C# (Visual C# Interactive Compiler), Score: 4007 3988 3759 3551 2551
ˇ=>ˇ.Sum(_=>new[]{5,16,14,11,11,12,9,10,16,17,8,9,5,12,9,7,10,9,9,11,10,10,9,11,11,10,5,9,14,11,17,13,13,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,19,15,20,17,8,12,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,18,13,19,5}[_-32])

I feel crushed by Peter Taylor's solution up above. Thanks to Peter Taylor for pointing out a simple lookup table was better than my previous dictionary solution.
Try it online!

This is considerably worse than a direct lookup table: _1=>_1.Select(_2=>new int[]{5,16,14,11,11,12,9,10,16,17,8,9,5,12,9,7,10,9,9,11,10,10,9,11,11,10,5,9,14,11,17,13,13,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,19,15,20,17,8,12,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,18,13,19,5}[_2-32]).Sum() scores 2786.