text:
VEVO User Account Checker
We often see music videos on Youtube. Many Youtube channels that host music videos are "powered by VEVO". Those can be easily identified by both embedding VEVO at their video thumbnails and appending VEVO to their channel name.
Now write some code to test whether a string given by user is a VEVO user account or not.
Requirements for valid VEVO user account strings:

Must only contain uppercase, lowercase, and digit characters. (no whitespace or punctuation)
Must not exceed 80 characters length.
Must have "VEVO" substring at the end of string

Test cases:
Valid inputs:
AdeleVEVO
ConnieTalbotVEVO
SHMVEVO
justimberlakeVEVO
DJMartinJensenVEVO
test123VEVO

Invalid inputs:
syam kapuk
jypentertainment
Noche de Brujas
testVEVO123

Of course, because this is code-golf, I'm looking for the shortest code using any programming language.

Nice first question! +1

test-cases: VEVO and ūņīčōdēVEVO

other suggested test cases: test123VeVo and one with more than 80 characters

You should wait a lot longer before accepting a best answer; the question has only been up for an hour and there are plenty more languages that people might answer in!

What's considered acceptable output here? Would 0 for valid and another/any other number for invalid be allowed?

Another suggested test case: test123 VEVO (ends with VEVO but contains whitespace)

Alternatively, it is even better if you don't accept an answer at all, so that it is more a competition between answers in each language, rather than between languages.

"uppercase, lowercase, and digit characters" requires defining (I would assume (as, I believe, all have done already) that you mean A-Za-z0-9; but it could mean anything that may be uppercased or lowercased, for example ạ and Ạ and digits in other alphabets, for example 九 (9).

If you're going to accept any answer, please accept the shortest (the winner), rather than an arbitrary answer.

Can I invert the the valid/invalid and return True for an invalid string and false for a valid one?

Downside of accepting the Fish answer after only an hour: its the second longest answer that's currently available and most definitely not the winner...

Python 2, 45 bytes
-3 bytes thanks to Rod. -2 bytes thanks to ovs.
lambda s:len(s)<81*s.isalnum()<'VEVO'==s[-4:]

Try it online!
A regex solution turns out to be longer.
lambda s:re.match('^[^\W_]{0,76}VEVO$',s)
import re

Japt v2.0a0, 20 16 bytes
Returns 1 for valid or 0 for invalid. [\l\d] would also work in place of [^\W_] for the same byte count.
è/^\w{0,76}VEVO$

Try it | Check all test cases
Explanation: è counts the number of matches of the RegEx in the input. In Japt, the \w RegEx class doesn't include underscore.

Nice one. Best I could do without regex is ;¥oB+mc)¯80 ©"VEVO"¥Ut4n

@ETHproductions, nice trick with B+mc :) By the way, if Japt2 had a character class for [A-Za-z0-9], we could beat Retina here! Might even be worth overriding \w & \W.

Heh, I think I was actually planning to do that originally... I should get back to work on Japt in general :P

JavaScript (ES6), 27 36 34 31 bytes
Saved 2 bytes thanks to @Neil and 3 bytes thanks to @Shaggy
s=>/^[^\W_]{0,76}VEVO$/.test(s)

Test cases

let f =

s=>/^[^\W_]{0,76}VEVO$/.test(s)

console.log(f('syam kapuk')) // (INVALID)
console.log(f('jypentertainment')) // (INVALID)
console.log(f('Noche de Brujas')) // (INVALID)
console.log(f('testVEVO123')) // (INVALID)
console.log(f('AdeleVEVO')) // (VALID)
console.log(f('ConnieTalbotVEVO')) // (VALID)
console.log(f('SHMVEVO')) // (VALID)
console.log(f('justimberlakeVEVO')) // (VALID)
console.log(f('DJMartinJensenVEVO')) // (VALID)

Doesn't \w match _s as well?

I think ((?!_)\w) saves 2 bytes.

Would [^\W_] work for a 3 byte saving?

@Shaggy Heck. For some reason, I was thinking such characters classes were not working within character sets. Thanks!

Doesn't JS have any way of skipping the lambda? Like /^[^\W_]{0,76}VEVO$/.test or something?

@totallyhuman Indeed, this is a function that is equivalent to the function in this answer, but 6 bytes shorter…

@Xufox I'm not sure what the consensus is. We could do (new RegExp).test.bind(/^[^\W_]{0,76}VEVO$/), which indeed gives a function that can be called in a standard way. But how would you use (and re-use) /^[^\W_]{0,76}VEVO$/.test?

@Arnauld Well, /^[^\W_]{0,76}VEVO$/.test is an expression that evaluates to a function which you can directly use like this: /^[^\W_]{0,76}VEVO$/.test("TestVEVO") or (/^[^\W_]{0,76}VEVO$/.test)("TestVEVO"). You can save it in a variable f=/^[^\W_]{0,76}VEVO$/.test; and use f("TestVEVO"), but as far as I know, this assignment is optional in terms of code golf, so you can just skip it.

@Xufox No, we can't save it in a variable, because test would lose its this context (hence the need to bind). This is why it's quite special and not equivalent to the function in this answer.

PHP, 51 bytes
-10 bytes thanks to @Ismael Miguel for using <?= instead of <?php echo! and removing the closing tag
<?=preg_match("/^[^\W_]{0,76}VEVO$/",fgets(STDIN));

Try it online!
Thanks for the other answers so I didn't have to write the regex!

Instead of <?php echo, you can do <?=preg_match("/^[^\W_]{0,76}VEVO$/",fgets(STDIN));.

You're welcome. You can leave out the closing PHP tag. Quoting the documentation: "If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file." (http://php.net/manual/en/language.basic-syntax.phptags.php). This should save you 2 more bytes. Also, instead of [^\W_], just use \w, which is the same as [a-zA-Z_].

Thanks as well, I have a few answers to update now!

You're welcome. One advice: reading the documentation and getting familiar with it will help a lot.

Dyalog APL, 47 bytes
{0::0⋄(∧/(1(819⌶)t)∊⎕A,⎕D)∧77>≢t←,∘'VEVO'⍣¯1⊢⍵}

Try it online!
A pure regex solution is 32 bytes, but also is much more boring than this approach.
{0::0⋄(∧/(1(819⌶)t)∊⎕A,⎕D)∧77>≢t←,∘'VEVO'⍣¯1⊢⍵} a dfn with right arg '⍵'
 0::0⋄                                          on error, return 0
                                 ,∘'VEVO'       a train that appends VEVO
                                         ⍣¯1    apply it -1 times
                                             ⍵  on '⍵'
                                                and error if impossible (which returns 0)
                               t←               save on variable 't'
                              ≢                 get the length of that
                           77>                  if that's smaller than 77
                          ∧                     and
         (1(819I)t)                              [for each of] 't' uppercased
                   ∊⎕A,⎕D                        is it in the uppercase alphabet concatenated with the digits
       ∧/                                        reduced by and

Instead of using ⍣¯1 to check for VEVO and needing the dfn guard, you can do 'VEVO'≡¯4↑⍵. Moving things around a bit gets me {('VEVO'≡¯4↑⍵)∧∧/⍵∊⎕D,⎕A,(819⌶)⎕A}

@Cowsquack yeah, I might have forgotten about ↑.. There are other better ways to do this challenge though (i.e. Eriks answer) and I like this idea :p

C# (.NET Core), 87 + 18 = 105 bytes
Try it online!
a=>a.Where(x=>char.IsLetterOrDigit(x)).Count()==a.Length&a.Length<81&a.EndsWith("VEVO")

Wouldn't this fail if the input contains any non-alphanumeric characters?

@Shaggy You are right, will fix a bit later.

I have checked with TIO and found that input "ConnieTalbotVEVO" (which should be valid input) was falsely declared as invalid input.

@BagasSanjaya It is because I put tabs after it in the test case, take the tabs out and it will be the same as the test case above and will work.

73+18: a=>a.All(x=>char.IsLetterOrDigit(x)&x<123)&a.Length<81&a.EndsWith("VEVO") only ASCII letters or 67+18: a=>a.All(x=>char.IsLetterOrDigit(x))&a.Length<81&a.EndsWith("VEVO") with unicode support

APL (Dyalog), 25 bytes
≢'^[^_\W]{0,76}VEVO$'⎕S 3

Try it online!

C (gcc), 83 bytes
c,i;f(char*s){for(c=i=0;s[i];c+=!isalnum(s[i++]));c=i<81*!c*!strcmp("VEVO",s+i-4);}

Try it online!

I don't see any return statement, how does this return c? Undefined behavior?

@MDXF This is indeed undefined behavior and an abuse of how gcc uses the same registers for variable assignment and return values (see tips for golfing in C ). This is not portable and does not necessarily work with other compilers (for instance it doesn't work with clang)

that's very impressive. How did you find that out?

sometimes f("VO" also be true, when before is "VI" stored; or maybe fault

Grime, 13 bytes
e`n{-76"VEVO"

Try it online!
Nothing fancy here.
Match the entire input against the pattern: at most 76 alphanumeric characters, followed by the string VEVO.
Prints 1 for match and 0 for no match.
I remembered that the last quote could be removed at end of line, but apparently it just causes a parse error.

><>, 147 125 bytes
!\i:0(?^1[::::::"/9@Z`z"!
;>{(?;{(?v{(?;{(?v{(?;{(?v
 ~l1-?!v >       > !|!: !<
;v    ]/~l99*-0(?!;4["OVEV"{-?;{-?;{-?;{-?;1n

Try it online!
><>, 147 bytes
Try it online!
This prints 1 if the input string is valid and nothing for an invalid input.
Edit 1: Changed the Alphanumeric checks to use ranges rather than comparing against every character. (saving 22 bytes)

I don't have the time right now to golf this, but I'm pretty sure you can lose bytes by doing comparisons to character codes. The gist of it would be to reject things less than '0' and greater than 'z' and then reject things between '9' and 'A' as well as between 'Z' and 'a'.

@cole :- I wasn't at my PC to change this yesterday after the post but you are right, comparisons do cut a bit off. I'm sure if you scan across the code you may be able to drop some extra bytes off.

Bash, 53 26 30 bytes
[[ $1 =~ ^[^\W_]{0,76}VEVO$ ]]

Exit code 0 for VALID results and 1 for INVALID results.
Still working on 80 characters or less.
-27 bytes from removing output, thanks to @KeyWeeUsr
+4 bytes, fixed regex (same as everyone else)
Try it online!

You can just echo 1 for true, or just go without any echo. There's no need to echo anything as you still end up with an exit code that you actually check with && and ||

Okay, wasn't sure what sort of output (if any) was required. The question didn't really say.

The idea of 'truthy' is explained here https://codegolf.meta.stackexchange.com/q/2190/16658 and is generally implied universally unless specified as otherwise

This doesn't output anything on TIO. Also, your RegEx allows underscores, which it shouldn't. And you're not checking for length. We require solutions to be fully functional here, works in progress shouldn't be posted. I'd recommend deleting it until you can fix the problems. (On a related note, why do people upvote solutions that clearly don't work?)

@Shaggy The output is via exit code.

><>, 101 89 83 81 94 bytes
Edit: Switched to checking for non-alphanumeric characters rather than for alphanumeric. Switched back cause I forget to check between Z and a. Thanks @Emigna. Rip those lost bytes though
Edit 2: Also, I can totally just get rid of those }}}}. Thanks Teal pelican for that and finding the problem with TIO
Edit 3: replaced a ~~~ with a p
!\i::0(?v:::"/")$":"(*$:"`")$"{"(*+$:"@")$"["(*+?
0/?("S"l/
l/"VEVO"[4pn?$0(6
!\{-?vl?
1/;n0/n

I don't know why this won't work on TIO, but it works fine here. The problem was that the {} commands in TIO don't work for an empty list. Try It Here
How It Works
!\i::0(?v:::"/")$":"(*$:"`")$"{"(*+$:"@")$"["(*+?
0/....../
......... Checks each input is alphanumeric
...       If any isn't, print 0 and exit with an error
...

...
0/?("S"l/ Checks if there are more than 80 characters
...       If so, print 0 and exit with an error
...
...

...
...
l/"VEVO"[4pn?$0(6 Check if the input is less than 4 characters
...               If so, print 0 and exit with an error
...

...
...
./"VEVO"[4pn?$0(6 Take the last 4 characters of the input into a new stack (first time I've actually used [)
...               Add "VEVO" to the stack to compare
...

...
0/....../n
........V
!\{-?vl?  Check if the last 4 characters are VEVO
1/;n0/n   Print 1 and exit with an error if so, else print 0 and exit

For consistency, replacing the ; in the last line with an invalid instruction makes every output an error.

I believe your TIO error might be how it works with ordering on the ending stack split. TIO LINK HERE Having a mess around in TIO you can change it to this.

Thanks @Tealpelican. Fixed that and killed a few more bytes

You are missing the check for characters between "Z" and "a".

@Emigna Oops, thanks! Fixed!

C++, 129 105 102 bytes
Thanks to other answers that showed me that i can count the number of characters
 -2 bytes thanks to Zacharý
#include<regex>
int v(std::string s){return std::regex_match(s, std::regex("[a-zA-Z0-9]{0,76}VEVO"));}

TIO LINK

Where's TIO link at your answer? I'd like to test your code...

Forgive me if this is a lack of knowledge of C++. Can you move remove the variable r, and just have the regex inside the call to std::regex_match?

There is an unneeded space after the comma

You can remove the comma the space after the comma.

Stacked, 21 bytes
['^\i{0,76}VEVO'-''=]

Try it online!

05AB1E, 21 bytes
žKÃQsg81‹IR4£"OVEV"QP

Try it online!

Retina, 18 bytes
A`\W|_|.{81}
VEVO$

Try it online!
or
^[^\W_]{0,76}VEVO$

Try it online!

Haskell, 75 bytes
-2 bytes thanks to user28667.
import Data.Char
f s|l<-length s=all isAlphaNum s&&l<81&&drop(l-4)s=="VEVO"

Try it online!

-2 bytes if you use drop(length s-4) and extract length s

Java (OpenJDK 8), 37 36 bytes
Pretty simple answer using some lovely regex.
Quite possibly the shortest Java answer I've ever done.
-1 bytes thanks to Neil on the Javascript answer
w->w.matches("((?!_)\\w){0,76}VEVO")

Try it online!

Deorst, 22 bytes
'^[^\W_]{0,76}VEVO$'gm

Try it online!
Just uses the regex found by Shaggy

V, 17 bytes
ø^¨áüä©û,76}VEVO$

Try it online!
Hexdump:
00000000: f85e a8e1 fce4 a9fb 2c37 367d 5645 564f  .^......,76}VEVO
00000010: 24                                       $

Compressed regexes for the win!
ø                   " Count the number of matches of
 ^                  "   The beginning of the line
  ¨áüä©             "   A letter or number...
       û,76}        "   From 0 to 76 times...
            VEVO    "   Followed by "VEVO"
                $   "   At the end of the line

Perl 5, 35 29+1(-a) = 30 bytes
-6 bytes thanks to ETHproductions
Added 4 bytes. Didn't see that underscore wasn't allowed.
This is my first golf, so here's hoping I did it right.
Returns 1 if valid, 0 if not.

print/^[^\W_]{0,76}VEVO$/?1:0

Try it online!

Welcome to PPCG! You can remove extraneous whitespace to get down to  25 (+1) bytes: print/^\w{1,76}VEVO$/?1:0

+0 converts match bool into number, rather than ?1:0, saves 2 bytes. Calling with -ple prints $_ for you. So: perl -ple '$_=/^[^\W_]{0,76}VEVO$/+0'. 25 bytes. If you are happy to get  blanks on non-matching lines, $_=/^[^\W_]{0,76}VEVO$/ is 23 bytes.

Ruby -n, 22+1 = 23 bytes
p~/^[^\W_]{0,76}VEVO$/

Output 0 if true, nil if false
Try it online!
Using the same boring regex as everybody else.

Swift 4, 113 bytes
import Foundation;var f={(s:String)->Bool in s.range(of:"^[^\\W_]{0,76}VEVO$",options:.regularExpression) != nil}

Try it online!

AWK, 23 bytes
$0~/^[^\W_]{0,76}VEVO$/

Try it online!
Outputs the account name if valid, and outputs nothing if it isn't valid

Clean, 61 bytes
import StdEnv
?['VEVO']=True
?[_:l]=length l<80&& ?l
?_=False

Try it online!

Google Sheets, 33 Bytes
Anonymous worksheet function that takes input from range A1 and outputs to the calling cell
=RegexMatch(A1,"^[^\W_]{0,76}VEVO

Where's the closing bracket?

@BagasSanjaya that's one of the wonderful things about Google Sheets, it autocompletes unclosed strings and groups. So when this is pasted into a cell and you either click off the cell or press enter GS converts this to =RegexMatch(A1,"^[^\W_]{0,76}VEVO") without any feedback to the user and executes

Clojure, 146 bytes
(fn[u](let[c count](and(<(c u)81)(=(c(filter #(let[i(int %)](or(< 47 i 58)(< 64 i 91)(< 96 i 123)))u))(c u))(clojure.string/ends-with? u"VEVO"))))

Try it online!
This would be much shorter using a regex, but I figured doing it manually would be more interesting.
(defn vevo? [username]
  (and (< (count username) 81)

       ; Filter out the illegal characters, then check if the length is the same as the original string
       (= (count (filter #(let [i (int %)]
                            ; Make sure the char code is in the valid ranges
                            (or (< 47 i 58) (< 64 i 91) (< 96 i 123)))
                         username))
          (count username))

       (clojure.string/ends-with? username "VEVO")))

Any TIO link for testing?

@BagasSanjaya I can add one in a bit. It seems like adding TIO links are standard now. They were optional last time I used the site frequently, but now everyone's adding them.

@BagasSanjaya I added a link. Unfortunately TIO seems broken. It can't find the ends-with? function, even though that's part of the standard library.


text:
Rational Polynomial Interpolation
Explanation
In this task you'll be given a set of N points (x1,y1),…,(xN,yN) with distinct xi values and your task is to interpolate a polynomial through these points. If you know what Lagrange interpolation is you can skip this section.
The goal of a polynomial interpolation is to construct the (unique) polynomial p(x) with degree N-1 (for higher degrees there are infinite solutions) for which p(xi) = yi for all i = 1…N. One way to do so is to construct N Lagrange basis polynomials and form a linear combination. Such a basis polynomial is defined as follows:

As you can see if you evaluate li at the points x1,…,xi-1
,xi+1,…
,xN it is 0 by construction and 1 for xi, multiplying by yi will only change the value at xi and set it to yi. Now having N such polynomials that are 0 in every point except one we can simply add them up and get the desired result. So the final solution would be:

Challenge

the input will consist of N data points in any reasonable format (list of tuples, Points, a set etc.)
the coordinates will all be of integer value
the output will be a polynomial in any reasonable format: list of coefficients, Polynomial object etc.
the output has to be exact - meaning that some solutions will have rational coefficients
formatting doesn't matter (2/2 instead of 1 or 1 % 2 for 1/2 etc.) as long as it's reasonable
you won't have to handle invalid inputs (for example empty inputs or input where x coordinates are repeated)

Testcases
These examples list the coefficients in decreasing order (for example [1,0,0] corresponds to the polynomial x2):
[(0,42)] -> [42]
[(0,3),(-18,9),(0,17)] -> undefined (you don't have to handle such cases)
[(-1,1),(0,0),(1,1)] -> [1,0,0]
[(101,-42),(0,12),(-84,3),(1,12)] -> [-4911/222351500, -10116/3269875, 692799/222351500, 12]

Relevant, relevant and relevant

Pari/GP, 14 bytes
polinterpolate

Takes two lists [x1, ..., xn] and [y1, ..., yn] as input. Outputs a polynomial.
Try it online!

Pari/GP, 35 bytes, without built-in
f(x,y)=y/matrix(#x,,i,j,x[j]^(i-1))

Takes two lists [x1, ..., xn] and [y1, ..., yn] as input. Outputs a list of coefficients.
Try it online!

Enlist, 25 bytes
Ḣ‡ḟ¹‡,€-÷_Ḣ¥€§æc/§₱W€$↙·Ṫ

Try it online!

Monadic link takes an array of length 2 (e.g., [[101,0,-84,1],[-42,12,3,12]]) as input. The first element of the array is list of x value, the second is list of y value. Output as list of coefficient in increasing degree.
Because @HyperNeutrino forgot to wrap numbers in rational wrapper if it is evaluated in list, (Try it online!) the argument must be hardcoded in the code.
The ↙ is necessary because HyperNeutrino make some mistake in implementing · I don't know (or is this a feature? Not sure)
Equivalent Mathematica code:
Expand[ Table[
 Times @@ ((z - #)/(xi - #) & /@ DeleteCases[x, xi])
 , {xi, x}] . y]

Try it online!
where x and y are list of coordinates. This prints the polynomial.

What Enlist have for this challenge:

Built in rational number support
Convolution æc (my feature request)

If you need a rational number version of Jelly, M might be worth a shot

Python, with numpy, 301 bytes
See this notebook for how it works.

Golfed version. 301 bytes, it can be golfed much more. Attempt this online!
import numpy as np
from itertools import combinations as C
from numpy.polynomial import Polynomial as P
def l(k,x):return P([sum([np.prod(x) for x in C(np.delete(x,k),i)])*(-1)**(i+1)/np.prod(np.delete(x,k)-x[k]) for i in range(len(x))][::-1])
def f(x,y):return sum(l(k,x)*y[k] for k in range(len(y)))

Ungolfed version. Attempt this online!
import numpy as np
from itertools import combinations
from numpy.polynomial import Polynomial

# get the Lagrange basis function
def l(k, x):
    n = len(x)
    assert (k < len(x))

    x_k = x[k]
    x_copy = np.delete(x, k)

    denominator = np.prod(x_copy - x_k)

    coeff = []

    for i in range(n):
        coeff.append(sum([np.prod(x) for x in combinations(x_copy, i)]) * (-1)**(i+1) / denominator)

    coeff.reverse()

    return Polynomial(coeff)

def f(x,y):return sum(l(k,x)*y[k] for k in range(len(y)))

x=[101,0,-84,1]
y=[-42,12,3,12]
print(f"{l(0,x)=}\n")
print(f"{l(1,x)=}\n")
print(f"{l(2,x)=}\n")
print(f"{l(3,x)=}\n")
print("y[0]*l(0,x)+y[1]*l(1,x)+y[2]*l(2,x)+y[3]*l(3,x)== f(x):")
print(f(x,y))

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:
lexicographically sorted list of index
Given a drawing of the letter shoot system, where an existing piece of pipe is marked with a *, and an empty spot is marked with a ., your task is to compile a lexicographically sorted list of index tuples [entry row, entry column, exit row, exit column], where each index is 0-based. Entry and exit points are always on the border of the map. Mail can travel horizontally, vertically and diagonally and will usually maintain its direction, unless it is forced by the pipes to turn into a curve. Only 45 degree turns are possible -- the system is built in such a way that mail capsules will never get stuck.
It is guaranteed that pipes at the entry points have exactly one neighboring pipe, and that that neighbor is not on the same border as the entry point. It is also guaranteed that mail will eventually reach an exit point.
Example
For
pipesPlan =
[[".",".","."],
 ["*","*","*"],
 [".",".","."]]

the output should be

airMail(pipesPlan) = [[1,0,1,2], [1,2,1,0]].

For
pipesPlan =
[[".", ".", "*", ".", "."],
 [".", ".", "*", ".", "."],
 ["*", "*", "*", "*", "*"],
 [".", ".", "*", ".", "."],
 [".", ".", ".", "*", "."]]

the output should be

airMail(pipesPlan) = [[0,2,4,3], [2,0,2,4], [2,4,2,0], [4,3,2,0]].

[input] array.char pipesPlan
    The rectangular plan of pipes, where an * marks a piece of pipe and a.
marks an empty spot.

[output] array.integer
    A lexicographically sorted list of tuples [entry row, entry column,
exit row, exit column] that specify where a letter shot from entry row,
entry column would end up according to the pipesPlan. Indices are 0-based.

Hi, and welcome to Programming Puzzles & Code Golf, nice first question, all that is required is a win condition, I would suggest shortest code in bytes for each language wins, adding the code-golf tag would be sufficient too.

Please do not immediately cv badly rephrased tasks that can be improved within a short time, it takes them forever to get reopened.

@Uriel So what are close votes used for? Prevent answers to unclear challenges. About "it takes them forever to get reopened" - it's OP's fault for writing unclear challenge, and in my opinion it takes quite a short time if it's really clear. Ask on chat is also a good idea.

@user202729, This is also a new user, I feel like we should cut him some slack and just maybe help him rephrase until we are happy. This question is literally just adding a tag away from being fine.

Welcome to PPCG! This is an interesting challenge, but it doesn't quite fit our expectations, as others have mentioned. I would suggest using The Sandbox to get feedback on future challenges. I'm looking forward to answering this and future challenges!

@Mat What would be the output for such cases like this? Where would the mail go to?

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


text:
52 Week Challenge
The 52 week challenge is a way to save money. For example, Week 1, you save $1.00. Week 2 you save $2.00, and it continues through the year, adding one more dollar to each week’s savings goal. By Week 52, you’ll set aside $52.00, which will bring the year’s total savings to $1,378! Of course, you can decide how much money you start saving and how many weeks.
Given an amount for Week 1 and the number of weeks the challenge should run for, return the total amount saved  at the end of the challenge.
Week 2 will have as twice the amount of Week 1, Week 3 will have thrice the amount of Week 1, etc.
Examples
1 and 52 weeks: 1378
5 and 6 weeks: 105
.25 and 100 weeks: 1262.5
10 and 1 week: 10
7 and 0 weeks: 0
0 and 30 weeks: 0
0 and 0 weeks: 0

This challenge is very poorly specified; the task is unclear and it lacks any winning or validity criterion. Please respecify it so the exact task is clear and it is easy to determine if a submission is valid and which submissions win.

Hi, Welcome to PPCG! We generally host programming competitions, and  the challenges here should have a clear specification in order to indisputably decide whether an answer is valid and a winning criterion to determine which submission wins. For guidance, you can visit this meta thread: How does this site work? It might be worth reading through this too. For future challenges, we can help you improve them with the Sandbox. :-)

I've edited your post to conform to our standards while following a possible interpretation of your original text. If it doesn't suit you, feel free to roll the edit back.

I think this challenge has one thing preventing it being reopened: How does setting aside $52 bring the year's total to $1378? What mapping is being done?

@cairdcoinheringaahing That's $1+$2+$3+…+$52=$1378.

I've voted to close this as a duplicate of sum all integers from 1 to n, because it requires simply computing that result and multiplying it by another input.

Japt, 5 bytes
Takes weeks as the first input and starting amount as the second.
õ x*V

Try it

Alternatively, õ*V X

J, 6 bytes
*2!1+]

Takes the amount as the left argument and the weeks as the right argument.
Try it online!
Explanation
* 2 ! 1 + ]
      1 + ]  Add 1 to the weeks.
  2 !        (Weeks + 1 choose 2)
*            Multiply by the starting amount.

This takes advantage of the fact that the nth triangle number is (n+1 choose 2). Perhaps unsurprisingly, this is almost the exact same answer as the one I have for the sum of digits from 1 to n challenge. Just substitute >: for 1+] and tack on the *.

Wolfram Language (Mathematica), 13 bytes
#*(#+1)*#2/2&

Try it online!

R, 23 bytes
function(a,w)sum(0:w*a)

Try it online!
Takes input as amount, weeks.

Python 3, 20 bytes
lambda a,w:a*w*-~w/2

Try it online!

Jelly, 3 bytes
R×S

Try it online!


text:
Is it a Rubik's Cube?
A venerated pass time of pedants is to point out that pictures of "Rubik's Cubes" (on t-shirts, posters etc.) are not actually solvable.
The first thing that should be checked is that the cube is made up of the right pieces.  To be solvable a cube needs six colors each with nine squares.  The cube also needs each edge and corner unit (these are the smaller cubes that make up the cube) to be unique.  Not only must they be unique but if two center pieces are opposite each other no edge or corner piece can contain both of those colors.
Once you have a cube that is made up of all the right pieces you still need to verify it can be solvable.  There are a couple of rules here, so I'll defer to an expert to explain them, the spoiler below explains how we can do this.  If you are interested in solving the problem on your own you don't need to visit the site to understand or participate in this challenge.

 Linked explanation

Your task is to take a pattern as input and determine if it is in fact a solvable Rubik's cube.  To be solvable there must be a way to perform valid moves on a cube so that the cube has only one color on each face (and the different faces have different colors).  Most Rubik's cubes have a standard coloring (White is opposite Yellow, etc.) you may not assume that the solve state follows this particular coloring.
A valid move is either the clockwise or anti-clockwise rotation of a single face of the cube.  With the rotation of the face of the cube any squares bordering the face are rotated as well, staying connected to the face they were previously touching.
IO
You may take the cube in any reasonable manner.  If your language has some builtin "cube-face" type, good for you, that is fine as input, other wise you can take a 2D array of the net, of the cube, 1 3 by 3 lists for each face.  Just be reasonable.  If you want to know if a specific format is acceptable comment or ping me in chat and I will add to the challenge to state its validity.
Your input format need only support up to 9 possible colors.
For output this is a decision problem so you should output one constant value for "Yes, this is a valid Rubik's cube" and one different constant value for "No, this is not a valid Rubiks cube".

This is code-golf so answers will be scored in bytes with less bytes being better.
Test Cases
Here are test cases.  They are formatted as the net of a cube with each square as a single letter.  Different letters represent different colors.
Any more testcases can be added upon request.
Solvable
   RRR
   RRR
   RRR
GGGWWWBBBOOO
GGGWWWBBBOOO
GGGWWWBBBOOO
   YYY
   YYY
   YYY

   GRR
   GRR
   ORW
WWRBWYBOOGGY
GGRBWGYBBOOO
OOGRWGYWWRBB
   WYO
   YYB
   YYB

Unsolvable
   RRR
   RRR
   RRR
GGGWWWBBBOOO
GGGWWWBBBOOO
GGGWYWBBBOOO
   YWY
   YYY
   YYY

   RRR
   RRR
   RRR
GGGWWWBBBOOO
GGGWWWBBBOOO
GGGWWWBBBOOO
   YWY
   YYY
   YYY

   RRR
   RRR
   GGG
GGYWYWRBBOBO
GGYWWWROBOOO
GGYWWWRBBOOO
   BBB
   YWY
   YYY

   RRW
   RRW
   GGG
GGYWWYEOBROO
GGYWWYEBBROO
GGOWWYWBBROO
   BBB
   YYW
   YYO

I feel obligated to point out that the Rubik's cube in your avatar is not solvable. It only has 4 squares on the side facing us, whereas a normal Rubik's cube should have 9. Not to mention the weird symbols on top of the squares.

@DJMcMayhem My children have Rubik's cubes with only four "sub-cubes".

Can we assume a standard colouring? e.g (W opposite Y ...)

@H.PWiz No, you can't.  That was implicit in my definitions but I will make it explicit in the question.

@DJMcMayhem By "normal", you mean 3×3. :P That could be a 2×2 cube. The symbols are definitely unlike a Rubik's cube, though.

Can we take input like this (with 0 representing R, 1 representing G, etc)?

@MDXF Yes sure.

@WheatWizard Thanks (not sure if it will actually help but might make it easier for Cubically)

Your specification does not include a complete description of the three parity laws of the cube. 1. It is impossible to have only 1 edge flipped 180 degrees (mentioned) 2. It is impossible to have only 1 corner twisted 120 degrees (not mentioned) 3. It is impossible to have an odd permutation of the cubies (not mentioned.). I'm casting a close vote until this is resolved. See https://www.ryanheise.com/cube/cube_laws.html for an explanation.

@LevelRiverSt I added the link to the site you linked.  I will also point out that my original explanation did hit point 2.

@DJMcMayhem You're referring to this, right? Just keeping it in case OP changes their avatar.

@Adám This is 3D, so a 2×2×2 has 8 sub cubes. Unless you're talking about a 2×2×1... Anyway - how is this unclear?

@LevelRiverSt Note that the Rubik's cube is self-contained, anyone can derive at the mathematical formulation and parity laws independently.

@user202729 My comment was an answer to DJMcMayhem's.

@user202729 While it's possible to derive the parity laws independently, they're not obvious and it's likely some might miss them. Further, the original post pointed out edge flip parity but not swap parity, which might lead one to think swap parity could be ignored. Meta question  https://codegolf.meta.stackexchange.com/q/14383/15599 is precisely about these occasions when the spec does not match reality, whether the OP did it intentionally to simplify the challenge or unintentionally as they had an incorrect understanding. Hence the need for disambiguation. I've now withdrawn my close vote.

@WheatWizard Thanks your intent is clearer now. Your original spec discussed swapping 2 stickers on the same cubie. This has the same effect as flipping an edge. But when 2 stickers are swapped on a corner it transforms into its mirror image, making the cube unsolvable for geometric (not parity) reasons even if dismantled. This is quite different from rotating a single corner 120 degrees. In that case the cube can be solved without peeling if dismantled, but cannot be solved by normal moves for parity reasons. The latter is harder to detect and I don't think it is covered in your original spec

@trichoplax Thanks, fixed now.

@WheatWizard can input be a 3x2 matrix of 3x3 matrices, arranged as row0: front back, row1: left right, row2: up down?

@ngn of course it can. As long as you are not trying to use the input to encode extra information you are fine.

@EriktheOutgolfer Thanks for keeping the image for posterity. OP's avatar is now a frog. A frog is most certainly not a solvable cube.

Cubically, 1664 1631 1089 bytes
⇒FD2F'R'D2RUR'D2RFD2F'U'
⇒Ff1F'
⇒LFf1F'L'
⇒F'f1F
⇒F2f1F2
⇒L'F2f1F2L
⇒D'F'f1FD
⇒LR'FLR'DLR'B2L'RDL'RFL'RU2
⇒LFf8F'L'
⇒R'F'f8FR
⇒Ff8F'
⇒F'f8F
⇒ULU'f8UL'U'
⇒U'R'Uf8U'RU
⇒F2f8F2
⇒Df15D'
⇒D'f15D
⇒D2f15D2
⇒UF2UF2D'L2B2U'B2DL2F2D2B2D2F2
⇒U'DL2UD'B2
⇒UF2UF2D'L2B2D'R2UR2F2D2B2U2B2
⇒BL'BU2D2F'RF'U2D2
⇒LD'F2U'B2U'RU2R'F2R2F2D'R2DF2D
⇒B2URB2D2B2RB2U'D'L2D'B2
⇒B2LF'U'B2UFL'R2B2U'D2L2D'B2U
⇒B2RB2D2B2RB2U'L2UD'F2U'F2B2
⇒D2R'FUB2U'F'RU2B2D'F2R2UF2UF2
⇒B2R2U'L'D2B2U2R'U2R2F2L2R2UR2
⇒D2L'B2U2F2RUL2U'F2R2U'R2U2F2DL2D'
⇒UB2U'L2DL2B2DB2D'B2
⇒BR'BL2B'RBL2B2
⇒UF2B2U'F2B2U'F2L2R2B2R2
⇒R2U'F2DR2UF2D'R2DF2R2D'F2
⇒U'F2DF2UL2F2DL2DF2L2D2F2
⇒U2D'L2U'F2L2U'B2L2R2U'L2B2
⇒F2D'R2U2L2B2UF2L2U2F2L2UF2R2
⇒[f1]3
⇒[f2f37]3
⇒[f3f38]3
⇒[f4f39]3
⇒[f5f40]3
⇒[f6f41]3
⇒[f7f42]3
⇒[f8f43]2
⇒[f9f44]2
⇒[f10f45]2
⇒[f11f46]2
⇒[f12f47]2
⇒[f13f48]2
⇒[f14f49]2
⇒[f15f50]2
⇒[f16f51]2
⇒[f17f52]2
⇒[f18f53]2
⇒[f19f54]2
⇒[f20f55]3
⇒[f21f56]4
⇒[f22f57]5
⇒[f23f58]6
⇒[f24f59]7
⇒[f25f60]8
⇒[f26f61]9
⇒[f27f62]9[f27f62]2
⇒[f28f63]9[f28f63]3
⇒[f29f64]9[f29f64]4
⇒[f30f65]2
⇒[f31f66]3
⇒[f32f67]4
⇒[f33f68]5
⇒[f34f69]6
⇒[f35f70]7
rs[f36f71]8

Output if solvable: Solved!
Output if unsolvable: (empty, no output)
Input should be formatted as a Cubically cube-dump (see the Debug section). This was explicitly allowed by the OP.
Explanation
This program takes the approach of using a Devil's Algorithm to iterate over every possible state of the cube in the same group as the solved cube. If the cube is solvable, it will be solved at some point before the algorithm has finished (assuming the algorithm I used works properly).
Every line beginning with ⇒ (0x84 in Cubically's codepage) is a function definition; these functions build off of each other to make up the actual Devil's Algorithm. The first line to be executed is the last one:
rs[f36f71]8

r reads a cube from stdin and sets the memory cube to it. s puts the interpreter into "solvemode", which means that it exits and prints Solved! if the cube becomes solved (after being unsolved) at any point. The rest of the commands (which simply repeat f36f71 8 times) correspond to the final algorithm at the bottom of the linked page:
(D) = (CP) = (CPT8) = [(CPC8)(CPT7)]8 (3,847,762,288,469,010,006,992 moves)

(D) is the Devil's Algorithm. If you apply it to the cube, it will be solved at some point before you have done the algorithm once. As you can see, it is terribly long, nearly a thousand times more moves than there are possible positions.

How can I run it?
You can try it online, but that link doesn't work. TIO will almost definitely time out before this algorithm finishes (the maximum runtime for an interpreter is 60 seconds). If the cube is not solvable, this algorithm will take up to 11 million years for Cubically to finish (at ~15.2 million moves per second, which is what my Cloud9 IDE gets).
Additionally, you need a lot of memory to perform 3 sextillion moves. Cubically can perform about 4 million moves per second, but the process will most likely be killed due to overcommitted memory. It dies after 15 seconds on my VM with 512MB of memory. Why should performing moves on an already-allocated flat array cost memory? Found a memory leak (or twenty) and fixed it.
Here is a much more readable version that behaves the same way.
But I really want to see that it works!
The first actual move that is executed in this devil's algorithm is F2, so the quickest cube to solve would be one scrambled with F2:
   000
   000
   555
113222133444
113222133444
113222133444
   000
   555
   555

This indeed executes in 0.007 seconds on TIO.
How can this be improved?
There are certainly more devil's algorithms; I've found one that uses less than a thirtieth of the moves this one does. However, that would come at the cost of several thousand bytes (around 100MB more) and several dozen hours of converting a complex Hamiltonian circuit to Cubically code.
It's also possible to remove some of the functions and put them straight in the loop at the bottom. However, I'm going to sacrifice some bytes for some readability.
Additionally, I'm considering a modification of Cubically's looping behavior so that I can more easily repeat algorithms 7 or 8 times (instead of just hard-coding them with the function calls repeated 7 or 8 times in the source). Or I'll work some magic out with the notepad, and golf this using more loops.
Note that I will continue to optimize anything possible in the interpreter, so this may work on an average PC sometime in the future!

Cubically, 2 bytes
r▦

I like the above answer better so I'm adding this as an alternate solution. This runs in under a second, as opposed to a few million years.
r    read cube from standard in
 ▦   and solve it

Output if the cube is solvable: (nothing)
Output if the cube is unsolvable: Error: The cube has reached an unsolvable state.

Does this work if we swap sides?  For example 2 is opposite 4 in the cube dump, does it work if 2 is opposite 5 and 4 is opposite 0?

@WheatWizard Yes it does, solvemode checks if each face has a unique integer, and if that integer is the only one on the face.

Ok as it ought.  I was not familiar with Cubically enough to know if this was the case or not from your description.

@WheatWizard Just making sure I understand you correctly - this is (along the lines of) what you were referring to, is that right?

Yes.  And it should be solvable.

APL (Dyalog Classic), 190 174 bytes
{∧/~∊(×1 2 3|+.-⌿↑⊃∘⍋¨¨¨a)({2|≢∪{⍵⌊⍵[⍵]}⍣≡⍵,0}¨⍳⌿↑⌽b)((∪≢∩)¨/b←(⊃∘⍋⌽⊢)¨¨¨a),6≢≢∪⊃⊃a←{c←4⍴⊂⍬⋄c[+/1≠i],←(≠/×i←↑⍳3⍴3){⊂⌽⍣⍺⊢⍵~' '}¨,⌿(3|∘.+⍨⍳3)⍉⍤¯1↑1 0 1\⍵⋄1↓c}¨⍵(3 3∘⍴¨1 1∘⌷¨⍵)}

Try it online!
The argument is a 3x2 matrix (row0: front back, row1: left right, row2: up down) of 3x3 character matrices. Returns 1 for a solvable Rubik's cube, 0 otherwise.
In the TIO link, function t, which is not included in the character count, reads 9 lines of input, converts them from the default input format (a net) to the required 3x2 x 3x3 matrix, calls the solution and prints OK if the result is as expected.
The algorithm splits the given cube into 26 cubies - strings of length 3 (corners), 2 (edges), and 1 (centres). It also generates the 26 cubies of a solved cube with the same 6 central cubies. All of the following criteria must be met:

there are no duplicates among the 6 centres
the sets of given/solved cubies match, up to rotation - e.g. consider 'WBR' and 'BRW' the same cubie, but not 'BWR'
the parities of both the corner permutation and the edge permutation are even
the modulo-3 sum of corner rotation indices (e.g. taking the "smallest" letter B as a reference point we have: 'BRW'→0, 'WBR'→1, 'RWB'→2) match between the given and solved cubes; same for the corners modulo 2


text:
Program an Uncircularness Score
Your task is to program a mathematical function \$s\$, that takes a nonempty finite set \$A\$ of points in the 2D plane, and outputs an uncircularity score \$s(A)\$ that satisfies following properties:

Positive Definiteness: If there is a circle or a straight line that contains all points of \$A\$, then \$s(A) = 0\$. Otherwise \$s(A) > 0\$

Surjectivity: It is surjective to the nonnegative real numbers, that means for every nonnegative real number \$r\$ there is a finite subset \$A\$ of the plane such that \$s(A) = r\$.

Translation Invariance: \$s\$ is translation invariant if \$s(A) = s(A + v)\$ for every vector \$v\$ and for all \$A\$.

Scale Invariance: \$s\$ is scale invariant, if \$s(A) = s(tA)\$ for every \$t≠0\$ and for all \$A\$.

Continuity. \$s\$ is said to be continuous if the function \$f(p) := s(A ∪ \{p\})\$ (mapping the a point p to a real number) is continuous using the standard absolute value on the real numbers, and the standard euclidean norm on the points of the plane.

Intuitively speaking this uncircularness score can be thought of as something similar to the correlation coefficient in linear regression.
Details
Your function in theory has to work in the reals, but for the purpose of this challenge you can use floating point numbers as substitute. Please provide an explanation of your submission and an argument why those five properties hold. You can take two lists of coordinates or a list of tuples or similar formats as input. You can assume that no point in the input is repeated i.e. all points are unique.

What does it mean for a circle to contain all points of A?

@H.PWiz Consider a circle as a subset of the 2d plane, the a point is contained in the circle if it is an element of this subset.

Can our program error out in theorically zero probability? (the actual probability is nonzero because floating point number is discrete) / Do you allow floating point imprecision to be ignored? Relevant meta.

@flawr Sorry, just to be clear, the points must be on the circumference of the circle?

@H.PWiz Yes. Circle here means the boundary of the circle.

@user202729 Floating pont issues are handled as usual.

@H.PWiz Sorry I misunderstood your question. Yes a circle is a set of points of a fixed distance to their common center.

@flawr Because some people call a disc a circle.

Python 2 with numpy, 116 bytes
from numpy import*
def f(x,y):a=linalg.lstsq(hstack((x,y,ones_like(x))),(x*x+y*y)/2);return a[1]/sum((x-a[0][0])**4)

Takes x and y as 2d column vectors and returns an array containing the answer.  Note that this will give an empty array for a perfectly straight line or with 3 or fewer points.  I think lstsq gives no residuals if there's a perfect fit.
Explanation
Essentially, this finds the circle of best fit and gets the squared residuals.
We want to minimize (x - x_center)^2 + (y - y_center)^2 - R^2.  It looks nasty and nonlinear, but we can rewrite that as x_center(-2x) + y_center(-2y) + stuff = x^2 + y^2, where the stuff is still nasty and nonlinear in terms of x_center, y_center, and R, but we don't need to care about it.  So we can just solve [-2x -2y 1][x_center, y_center, stuff]^T = [x^2 + y^2].
We could then back out R if we really wanted, but that doesn't help us much here.  Thankfully, the lstsq function can give us the residuals, which satisfies most of the conditions.  Subtracting the center and scaling by (R^2)^2 = R^4 ~ x^4 gives us translational and scale invariance.

This is positive definite because the squared residuals are nonnegative, and we're dividing by a square.  It tends toward 0 for circles and lines because we're fitting a circle.
I'm fairly sure it's not surjective, but I can't get a good bound. If there is an upper bound, we can map [0, bound) to the nonnegative reals (for example, with 1 / (bound - answer) - 1 / bound) for a few more bytes.
We subtract out the center, so it's translationally invariant.
We divide by x**4, which removes the scale dependence.
It's composed of continuous functions, so it's continuous.

Can you elaborate what your submision is actually computing?

@flawr Edited that in.

I tried to test this on {(1, 0), (2, 0), (3, 0), (4, t)} for t → 0, but f(array([[1.0],[2.0],[3.0],[4.0]]),array([[0.0],[0.0],[0.0],[t]])) seems to give me array([ 0.00925926]) for all nonzero t. (I know you said this breaks for t = 0, but the result should at least approach 0 for t → 0.) Am I calling it wrong?

Python, 124 bytes
lambda A:sum(r.imag**2/2**abs(r)for a in A for b in A for c in A for d in A if a!=d!=b!=c for r in[(a-c)*(b-d)/(a-d)/(b-c)])

Takes A as a sequence of complex numbers (x + 1j*y), and sums Im(r)2/2|r| for all complex cross-ratios r of four points in A.
Properties

Positive Definiteness. All terms are nonnegative, and they’re all zero exactly when all the cross-ratios are real, which happens when the points are collinear or concyclic.
Surjectivity. Since the sum can be made arbitrarily large by adding many points, surjectivity will follow from continuity.
Translation Invariance. The cross-ratio is translation-invariant.
Scale Invariance. The cross-ratio is scale-invariant. (In fact, it’s invariant under all Möbius transformations.)
Continuity. The cross-ratio is a continuous map to the extended complex plane, and r ↦ Im(r)2/2|r| (with ∞ ↦ 0) is a continuous map from the extended complex plane to the reals.

(Note: A theoretically prettier map with the same properties is r ↦ (Im(r)/(C + |r|2))2, whose contour lines w.r.t. all four points of the cross-ratio are circular.  If you actually need an uncircularness measure, you probably want that one.)

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


text:
How lit is this mountain?
A mountain is defined to be a set of line segments whose first point has coordinates (0,a) where a > 0, and whose last point has coordinates (b,0), where b > 0. All intermediate points have a y-coordinate (ordinate) strictly greater than 0. You are given the points on the mountain sorted in ascending order of x-coordinate (abscissa). Note that two points can have the same x-coordinate, producing a vertical segment of the mountain. If you are given two points with the same x-coordinate, they should be connected in the order they are given. In addition, there can be horizontal segments of the mountain These horizontal segments are not lit, no matter what. All coordinates are nonnegative integers.
The question: what is the total length of the mountain that would be lit, assuming the sun is an infinite vertical plane of light located to the right of the mountain? This number does not need to be rounded, but if it is rounded, include at least four decimal places. I have included a picture:

Here, the lines that are bolded represent the segments that are lit. Note that in the input, P appears before Q (PQ is a vertical line segment) so the previous point is connected to P and not Q.
You may take input in any reasonable format, like a list of lists, a single list, a string, etc.
Test case:
(0,3000)
(500, 3500)
(2500, 1000)
(5000,5000)
(9000,2000)
(9000,3500)
(10200,0)

Output: 6200.0000

There are two lit-up segments here, as shown in this image:
The first one has length 5000/2 = 2500 and the second one has length 3700.
This is code-golf, so the shortest answer in bytes wins.

Hint: When finding the length of a segment, there are three points you need to consider: the two endpoints, and the point that is "blocking" it (in the 2nd picture, that would be (9000,3500) which determines the length of the 3-4-5 segment. Let the two points on the main segment be (x1, y1) and (x2,y2). The point which is "blocking" it is (x3, y3). Assume y2 < y3 <= y1. Then the length of the segment is ((y1 - y3)/(y1 - y2))*sqrt((x1 - x2)^2 + (y1 - y2)^2). This is essentially the distance formula, multiplied by the fraction of the segment which is actually used.

May the mountain be horizontal?

Yes, there can be horizontal segments on the mountain. However it will go to 0 at some point.

But should they be lit?

They are not lit. The light, being perfectly horizontal, can only run parallel to them and never strike them. I edited the problem to clarify this.

May we take input as two lists, one with x coordinates and one with y coordinates?

Test case: (0, 100) (10, 25) (20, 50) (30, 25) (40, 75) (50, 0) (shadow cast by a peak that's not a direct neighbour).

Yes, a shadow can be cast by a peak that is not a neighbor. I guess I can add another test case to cover that.

@mrxcoder I would classify that as a reasonable input format, yes.

@imallett All I’m saying is, a problem “find the total length of the mountain” wouldn’t bee all that interesting.

Some notes: 1. Generally we leave challenges in the sandbox for at least 24 hours, because not everyone is in the same timezone as you are. 2 hours is too short in my opinion. 2 Also, you should shorten the sandbox post, because it's still visible to moderators and users with ≥ 2000 reputation. 3 [tag:code-golf] need a pair of square brackets: [tag:code-golf].

Yeah I will collapse the sandbox post edit: i see you did it, thanks

Good idea about scanning in a hand-drawn picture for a challenge.

Python 2,  134 131 128 124 120 117 109  107 bytes
p=input();s=0
for X,Y in p[1:]:x,y=p.pop(0);n=y-max(zip(*p)[1]);s+=n*(1+((X-x)/(y-Y))**2)**.5*(n>0)
print s

Try it online!
Takes input as a list of tuples / two-element lists of floating-point numbers.
Explanation
We basically iterate through the pairs of points in the graph, and if
\$y_1 > y_2\$, then we calculate how much of the line is exposed to light. The pairwise iteration is performed with a for loop to get the next point, \$(x_2, y_2)\$, popping the first element in the list each time to retrieve the current point, \$(x_1, y_1)\$.
Maths – What part of the line segment is exposed to light?

Let \$(x_1, y_1)\$ be the coordinates of the current point. Let \$y_{max}\$ be the maximum height of a point after the current one (local maxima after the current point)  and \$(x_2, y_2)\$ be the coordinates of the next point. In order to calculate the length exposed to the sun, \$L\$, we ought to find \$x_3\$, as shown in the diagram. Naturally, if \$y_1 \le y_{max}\$, the  segment is not exposed to light at all.
In the triangle formed, the line segment of length \$x_3\$ is parallel to the base, of length \$x_2 - x_1\$, so all three angles are congruent. Therefore, from the Fundamental Theorem of Similarity (case Angle-Angle), we can deduce that \$\frac{x_3}{x_2 - x_1} = \frac{y_1-y_{max}}{y_1}\$. Hence, \$x_3 = \frac{(y_1-y_{max})(x_2 - x_1)}{y_1}\$. Then, we can apply the Pythagorean Theorem to find that:
$$L = \sqrt{(y_1-y_{max})^2+x_3^2}$$
By joining the two formulas, we arrive at the following expression, which is the core of this approach:
$$L = \sqrt{(y_1-y_{max})^2+\left(\frac{(y_1-y_{max})(x_2 - x_1)}{y_1}\right)^2}$$
$$L = \sqrt{(y_1-y_{max})^2\left(1+\frac{(x_2 - x_1)^2}{y_1^2}\right)}$$
Code – How does it work?
p=input();s=0                             # Assign p and s to the input and 0 respectively.
for X,Y in p[1:]:                         # For each point (X, Y) in p with the first
                                          # element removed, do:
    x,y=p.pop(0)                          # Assign (x, y) to the first element of p and
                                          # remove them from the list. This basically
                                          # gets the coordinates of the previous point.
    n=y-max(zip(*p)[1])                   # Assign n to the maximum height after the
                                          # current one, subtracted from y.
    s+=n*(1+((X-x)/(y-Y))**2)**.5         # Add the result of the formula above to s.
                                 *(n>0)   # But make it null if n < 0 (if y is not the
                                          # local maxima of this part of the graph).
print s                                   # Output the result, s.

Changelog

Gradually optimised the formula for golfing purposes.
Saved 1 byte thanks to FlipTack.
Saved 2 bytes by removing the unnecessary condition that y>Y, since if the local maxima of the Y-coordinate after the current point subtracted from y is positive, then that condition is redundant. This unfortunately invalidates FlipTack’s golf, though.
Saved 3 bytes by changing the algorithm a bit: instead of having a counter variable, incrementing it and tailing the list, we remove the first element at each iteration.
Saved 8 bytes thanks to ovs; changing (x,y),(X,Y) in the loop condition with a list.pop() technique.
Saved 2 bytes thanks to Ørjan Johansen (optimised the formula a little bit).

JavaScript, 97 bytes
a=>a.reduceRight(([p,q,l=0,t=0],[x,y])=>[x,y,y>t?(y-t)/(s=y-q)*Math.hypot(x-p,s)+l:l,y>t?y:t])[2]

f=a=>a.reduceRight(([p,q,l=0,t=0],[x,y])=>[x,y,y>t?(y-t)/(s=y-q)*Math.hypot(x-p,s)+l:l,y>t?y:t])[2];
t=[[0, 3000], [500, 3500], [2500, 1000], [5000, 5000], [9000, 2000], [9000, 3500], [10200, 0]];
console.log(f(t));

( 5 bytes may be saved, if taking reversed version of input is considered valid. )

Never seen reduceRight in code golf befor elol

@emanresuA I would strongly recommend ES rename reduceRight to foldr.

APL+WIN, 48 bytes
+/((h*2)+(((h←-2-/⌈\m)÷-2-/m←⌽⎕)×(⌽-2-/⎕))*2)*.5

Prompts for a list of x coordinates followed by a list of y coordinates
Explanation
h←-2-/⌈\m difference between successive vertical maxima viewed from the right (1)

-2-/m←⌽⎕ vertical difference between points (2)

⌽-2-/⎕ horizontal difference between points (3)

The lit vertical distances = h and the lit horizontal distances are (3)*(1)/(2). The rest is Pythagoras.

Would +/.5*⍨(h*2)+×⍨((h←-2-/⌈\m)÷-2-/m←⌽⎕)×⌽-2-/⎕ work?

Unfortunately my old APL+WIN version does not have the ⍨ operator so I cannot say

@Cows quack Managed to try it in an old version of Dyalog Unicode (v13) and your suggestion does work

Swift, 190 bytes
import Foundation
func f(a:[(Double,Double)]){var t=0.0,h=t,l=(t,t)
a.reversed().map{n in if l.0>=n.0&&n.1>l.1{t+=max((n.1-h)/(n.1-l.1)*hypot(n.0-l.0,n.1-l.1),0)
h=max(n.1,h)}
l=n}
print(t)}

Try it online!
Explanation
import Foundation                  // Import hypot() function
func f(a:[(Double,Double)]){       // Main function
  var t=0.0,h=0.0,l=(0.0,0.0)      // Initialize variables
  a.reversed().map{n in            // For every vertex in the list (from right to left):
    if l.0>=n.0&&n.1>l.1{          //   If the line from the last vertex goes uphill:
      t+=max((n.1-h)/(n.1-l.1)     //     Add the fraction of the line that's above the
        *hypot(n.0-l.0,n.1-l.1),0) //     highest seen point times the length of the line
                                   //     to the total
      h=max(n.1,h)}                //     Update the highest seen point
    l=n}                           //   Update the last seen point
  print(t)}                        // Print the total

Python 2, 122 120 bytes
k=input()[::-1]
m=r=0
for(a,b),(c,d)in zip(k,k[1:]):
 if d>m:r+=(b>=m or(m-b)/(d-b))*((a-c)**2+(b-d)**2)**.5;m=d
print r

Try it online!

Since we are allowed to take a list of x values and a list of y values as two inputs I'm pretty sure we could take a list of co-ordinates in reverse, removing the need for [::-1].

Python 2, 89 bytes
M=t=0
for x,y in input()[::-1]:
 if y>M:t+=(y-M)*abs((x-X)/(y-Y)+1j);M=y
 X,Y=x,y
print t

Try it online!
Takes in a list of pairs of floats. Based off ovs's solution.

Think we can take a reverse list (we are allowed to take x and y as separate lists), so you can drop the [::-1].

Jelly,  23  21 bytes
-2 thanks to caird coinheringaahing
ṀÐƤḊ_⁸«©0×I}÷I{,®²S½S

A dyadic link taking a list of y values on the left and a list of the respective x values on the right (as explicitly allowed by the OP in comments)
Try it online!
How?
The fraction of a (sloping) section that is lit is the same fraction that would be lit if it were a vertical drop. Note that since squaring occurs to evaluate slope lengths the calculated heights along the way may be negative (also in the below the run-lengths of the lit slopes are calculated as negative divided by negative).
ṀÐƤḊ_⁸«©0×I}÷I{,®²S½S - Link:list, yValues; list, xValues
 ÐƤ                   - for suffixes of the yValues:       e.g. [ 3000, 3500, 1000, 5000, 2000, 3500,    0]
Ṁ                     -   maximum                               [ 5000, 5000, 5000, 5000, 3500, 3500,    0]
   Ḋ                  - dequeue                                 [ 5000, 5000, 5000, 3500, 3500,    0]
     ⁸                - chain's left argument, yValues          [ 3000, 3500, 1000, 5000, 2000, 3500,    0]
    _                 - subtract                                [ 2000, 1500, 4000,-1500, 1500,-3500,    0]
        0             - literal zero                            0
      «               - minimum (vectorises)                    [    0,    0,    0,-1500,    0,-3500,    0]
       ©              - copy to the register for later
           }          - apply to right:                     e.g [    0,  500, 2500, 5000, 9000, 9000, 10200]
          I           -   incremental differences               [  500, 2000, 2500, 4000,    0, 1200]
         ×            - multiply (vectorises)                   [    0,    0,    0,-6000000, 0,-4200000, 0]
               {      - apply to left:                     e.g. [ 3000, 3500, 1000, 5000, 2000, 3500,    0]
              I       -   incremental differences               [  500,-2500, 4000,-3000, 1500,-3500]
             ÷        - divide (vectorises)                     [    0,    0,    0, 2000,    0, 1200,    0]
                ®     - recall from the register                [    0,    0,    0,-1500,    0,-3500,    0]
               ,      - pair (i.e. lit slope [runs, rises])     [[0, 0, 0,    2000, 0,    1200, 0], [0, 0, 0,   -1500, 0,    -3500, 0]]
                 ²    - square (vectorises)                     [[0, 0, 0, 4000000, 0, 1440000, 0], [0, 0, 0, 2250000, 0, 12250000, 0]]
                  S   - sum (vectorises)                        [  0,   0,   0, 6250000,   0, 13690000,   0]
                   ½  - square root (vectorises)                [0.0, 0.0, 0.0,  2500.0, 0.0,   3700.0, 0.0]
                    S - sum                                     6200.0

25 byte monadic version taking a list of [x,y] co-ordinates:
ṀÐƤḊ_«0
Z©Ṫµ®FI×Ç÷I,Ç²S½S

Try this one.

The input can be two lists of values. I have asked the OP a while ago and they said it's fine.

I feel like there are too many ⁸s and ⁹s.

21 bytes

@cairdcoinheringaahing thanks, I didn't know what { and } did back then.

APL (Dyalog Unicode), 31 bytesSBCS
Uses Graham's formula.
Anonymous prefix function taking 2×n matrix of data as right argument. The first row contains x-values from right to left, and the second row the corresponding y-values.
{+/.5*⍨(×⍨2-/⌈\2⌷⍵)×1+×⍨÷⌿2-/⍵}

Try it online!
{…} anonymous lambda where ⍵ is the argument:
 2-/⍵ deltas (lit. pairwise minus-reductions)
 ÷⌿ Δx⁄Δy (lit. vertical division reduction)
 ×⍨ square (lit. multiplication selfie)
 1+ one added to that
 (…)× multiply the following with that:
  2⌷⍵ second row of the argument (the y values)
  ⌈\ running maximum (highest height met until now, going from right)
  2-/ deltas of (lit. pairwise minus-reduction)
  ×⍨ square (lit. multiplication selfie)
 .5*⍨square-root (lit. raise that to the power of a half)
 +/ sum

J, 46 bytes
1#.((2([:%:@+&*:/-)/\,.)*>./\@]%&(2-~/\])])&|.

Try it online!
Takes x coord list as left arg, y coord list as right arg.
Could save 5 bytes if reversed lists were allowed.
Though solved independently, the approach I landed on is almost identical to Adam's APL approach.

Kotlin, 178 bytes
fun L(h:List<List<Double>>)=with(h.zip(h.drop(1))){mapIndexed{i,(a,b)->val t=a[1]-drop(i).map{(_,y)->y[1]}.max()!!;if(t>0)t*Math.hypot(1.0,(a[0]-b[0])/(a[1]-b[1]))else .0}.sum()}

Try it online!
The testing part is very much not golfed :)


text:
Output the Goodstein sequence
(This might be quite classic but this is my first post here, so I'm not ready for the fancy stuff yet)
The Goodstein sequence is defined for an input number as follows:
Pick a starting number n, let b=2 and repeat:

write n in heriditary base b notation
substitute all the (b)s to (b+1)s in n and substract 1
output the new decimal evaluation of n
increment b

Hereditary Base notation is a decomposition of a number where the basis is the bigger number to appear. Examples:

83 in HB3: 3^(3+1)+2
226 in HB2: 2^(2^(2+1))+2^(2+1)+2

Goodstein sequences always end up at 0, but they tend to first get quite big quite fast so it is not asked to output the complete sequence.

Task:
Given an input number in any reasonable format, your job is to output the Goodstein sequence for this number at least until it reaches 10^25 or 0
Examples:
Input: 3
Output: 3, 3, 3, 2, 1, 0
Input: 13
Output: 13, 108, 1279, 16092, 280711, 5765998, 134219479, 3486786855, 100000003325, 3138428381103, 106993205384715, 3937376385706415, 155568095557821073, 6568408355712901455, 295147905179352838943, 14063084452067725006646, 708235345355337676376131, 37589973457545958193377292
Input: 38
Output: 38, 22876792454990

Details:

Input number can be an array, a string, an integer, as long as it is in decimal base
Output follows the same rule
Separation of the terms in the output can be spaces, new-lines, or any reasonable separation
As soon as the sequence becomes larger than 10^25, your program may exit normally, throw an error/exception, or continue (no restriction)
This is code-golf, so the shortest answer (in bytes) wins
Of course, standard loopholes are forbidden
Python ungolfed working example here

Could you add an step-by-step of one test case?

≥ 10²⁵ or > 10²⁵? Should that term be printed?

@Rod feel free to uncomment some lines in the linked TIO ;) tell me if that's enough or if you need more detail. Besides, I believe the YouTube Channel PBS Infinite Series has an excellent video on the topic

@user202729 you have to print all terms until the sequence reaches 10^25, so if one of the sequences were to contain that exact number, your program should print it too.

Welcome to PPCG! Nice first challenge!

@tfbninja Thanks for the warm welcome

Related. Related.

In the 13 test case, I'm getting 295147905179352838943 instead of 295147905179352838671, and different results from then on. Looking at your numbers in the relevant bases, they then make less and less sense, so I think you have some kind of precision/overflow issue in the generating program.

@ØrjanJohansen Yeah, the bug is that int(q/base.b), q%base.b needs to be q//base.b, q%base.b (or simply divmod(q, base.b)) to avoid floating-point errors.

@ØrjanJohansen & AndersKaseorg Thank you for pointing out this flaw in my example. I will edit the question/code and be more careful next time!

Does “at least until it reaches 10^25 or 0” mean the program is allowed to continue after it reaches 0 (presumably with −1, −2, −3, …)?

@AndersKaseorg it can continue after 0 even though it is not so interesting. The goal is to have the right terms until 0 or 10^25

Pyth, 28 26 bytes
.V2JbL&bs.e*^hJykb_jbJ=ty

The trailing newline is significant.
Try it online! (This link includes an extra Q not needed by the current version of Pyth.)
How it works
.V2JbL&bs.e*^hJykb_jbJ=ty
.V2                          for b in [2, 3, 4, ...]:
   Jb                          assign J = b
     L                         def y(b):
      &b                         b and
                   jbJ             convert b to base J
                  _                reverse
         .e                        enumerated map for values b and indices k:
             hJ                      J + 1
            ^  yk                    to the power y(k)
           *     b                   times b
(newline)                      print Q (autoinitialized to the input)
                        y      y(Q)
                       t       subtract 1
                      =        assign back to Q

It’s important that y is redefined in each loop iteration to prevent memoization across changes to the global variable J.

Haskell, 77 bytes
(&2) is an anonymous function taking an Integer and returning a (potentially very long) list of Integers, use as (&2) 13.
(&2)
n&b|n<0=[]|let _?0=0;e?n=(e+1)?div n b+mod n b*(b+1)^0?e=n:(0?n-1)&(b+1)

Try it online! (cuts off at 10^25.)
How it works

(&2) starts the sequence with base 2.
n&b calculates the subsequence starting with the number n and base b.

It halts with an empty list if n<0, which generally happens the step after n==0.
Otherwise, it prepends n to the list returned recursively by the expression (0?n-1)&(b+1).

? is a local function operator. 0?n gives the result of converting n to hereditary base b, then incrementing the base everywhere.

The conversion recurses with the variable e keeping track of the current exponent. e?n converts the number n*b^e.
The recursion halts with 0 when n==0.
Otherwise, it divides n by the base b.

(e+1)?div n b handles the recursion for the quotient and next higher exponent.
mod n b*(b+1)^0?e handles the remainder (which is the digit corresponding to the current exponent e), the increment of base, and converting the current exponent hereditarily with 0?e.


text:
What is the missing number (divisibility by 9)
Challenge
Given a whole number divisible by 9 and one missing digit, find the missing digit.
The missing digit may be represented by any character other than the digits 0-9 as long as it is consistent.
If the missing digit could be 0 or 9, output something to signify so.
Assume the user is intelligent enough to put only one missing digit and one number etc.
Test Cases
In the test cases the missing digit is represented by a question mark
123? -> 3
?999 -> 0 or 9
?0023 -> 4
000?1 -> 8

Can we output 0? What about [0, 9]  (array or list of 2 numbers)?

Assuming you mean instead of 0 or 9, I think I will edit this requirement to be any value indicating it could be either. Thank you!

Is just ? a possible input?

Is it necessary to support leading zeros?

@xnor yes, it could be. It would output the 0 or 9 ouput

@mbomb007 The program should, I don't foresee any bytes lost on account of it. Test case #2 is mainly why.

@NK1406 I don't recommend requiring leading zeroes, I can see additional bytes needed to support it at least for some languages.

Wait, so the question mark is input? Or is the challenge to find any place where the digit could go?

All of the cases on the left for the test cases are valid input. The goal is to find the digit represented by the question mark for each case (which can be any non-numerical character as you choose). You can do this because all of the digits of a number divisible by 9 add up to a multiple of 9.

The condition that you signify “0 or 9” instead of just “0” is significant. By saying, “anything” that signifies both is a big loophole. At least one of the answers below says “0 means 0 or 9”.

@Dúthomhas: I think 0 is legit: at any place-value position, if 0 makes the number a multiple of 9, then so does 9.  (Because 90, 900, and so on are all multiples of 9).  So there's no ambiguity with 0 or 9 vs. 0, because 0 but not 9 isn't a possibility.  Using 9 as the filler is bogus though: 000x needs to be 9, not 0.

@PeterCordes I agree, but the question is pretty specific about it, devoting both a complete sentence and an example to it.

@NK1406: should 0000 be considered divisible by 9?  Or should ?00 (or any pattern with all zeros other than the missing digit) be considered a corner case where 9 but not 0 is the only possible answer?

@Dúthomhas: Yeah, but the right solution in code golf (and programming in general) is often to recognize that a corner case isn't really a corner case.  The question was even edited to remove the wording that required the signifier to be 0 or 9 exactly, so I think this is intentionally being allowed.  What I'm not sure about is whether 0 should be considered divisible by 9.  It wouldn't normally be considered a multiple of 9, but that's not quite the same thing as evenly divisible.

@PeterCordes Point taken. And, since 0 ≡ 9 (mod 9), then yes, zero is evenly divisible by nine. This challenge is to find the missing number (mod 9), so the missing digit could be either zero or nine. Also not a corner case. :O)

@Dúthomhas: Agreed, I'm leaning towards the x % 9 == 0 criterion now, which allows x == 0.  Also, disallowing it now would invalidate all the answers by requiring extra conditional behaviour, so there's a stack-exchange reason for allowing this interpretation, as well as sound mathematics.  I was just getting hung up on 0 not being a whole-number multiple of 9.

Python, 21 bytes
lambda s:-int(s,19)%9

Try it online!
I used I to represent a missing digit.

Alice, 12 bytes
/o&
\i@/+R9%

Try it online!
Outputs 0 if the result can be either 0 or 9.
Explanation
/   Switch to Ordinal mode.
i   Read all input as a string.
&   Fold the next operation over the characters of this strings.
/   Switch to Cardinal mode (not an operation).
+   Add. Implicitly converts each character to the integer value it represents
    and adds it to the top of the stack. The top of the stack is initially, implicitly
    zero. When the character is "?", it is simply discarded, which adds the top of
    the stack to another implicit zero beneath, so the "?" is effectively skipped.
R   Negate. Multiplies the sum by -1.
9%  Modulo 9. This gives the result.
\   Switch to Ordinal mode.
o   Implicitly convert the result to a string and print it.
@   Terminate the program.

The & can be removed, since cardinal mode interprets the original input as at most 2 integers.

JavaScript (ES6), 40 bytes
Outputs 9 if could be 0 or 9.

f=_=>9-([..._].reduce((a,b)=>a+~~b,0)%9)

Welcome to PPCG! Nice first post!

You don't need to count f=; anonymous functions are perfectly valid.

The outermost parentheses are not necessary because of the operator precedence ;)

Japt, 7 bytes
Tried a few solutions but the shortest was similar to most others except we don't need to replace the ? at the start.
Can take any non-numeric character as the missing digit. Outputs 0 when the solution can be that or 9.
¬x*J u9

Try it

Explanation
Implicit input of string U. ¬ splits to an array of individual characters, x reduces the array by addition ignoring any non-numeric elements, *J multiplies each element by -1 and u9 gets the positive modulus of the result.

JavaScript (ES6), 18 bytes
Expects a + as the missing digit. Returns 9 for 0 or 9.
s=>9-eval(9+s+9)%9

Test cases

let f =

s=>9-eval(9+s+9)%9

console.log(f('123+'))  // -> 3
console.log(f('+999'))  // -> 0 or 9
console.log(f('+0023')) // -> 4
console.log(f('000+1')) // -> 8

Python 2, 44 41 35 bytes
-6 bytes thanks to RiaD

lambda n:-sum(ord(c)-3for c in n)%9

Try it online!
Users ] for missing digit.
Outputs 0 if the missing digit could be 0 or 9.

Hm, in all the test cases I tried it outputs 0 for an ambiguous case, which makes sense since 9%9 == 0

if you do int(c) -> ord(c) - 3 that you don't need if, if you choose appropriate character for bad character

05AB1E, 7 6 bytes
An output of 0 means the result could be either 0 or 9.
þSO(9%

Try it online!
or as a Test suite
Explanation
þ        # remove non-digits from input
 S       # split to list of digits
  O      # sum list
   (     # negate
    9%   # mod by 9

Jelly, 11 9 6 bytes
|0SN%9

Explanation
|0     # Read input while removing non-digits (question marks) and removing leading zeros
  S    # Sum the digits
   N   # Negate
    %9 # Mod by 9

An output of 0 means the result could be either 0 or 9.
Try it online!
Saved 2 bytes thanks to Mr. Xcoder. When using the Each quick (€) during evaluation, splitting the number into digits was redundant.
Saved 3 bytes thanks to Dennis. Can bitwise OR the input with 0 instead of manually parsing the input as a number while removing leading zeros and non-digits.

9 bytes. Welcome to Jelly golfing!

This doesn't handle the case where the answer could be 0 or 9. Also, indeed, welcome to Jelly. I am new too but it's been very fun so far.

@dylnan Addressed this

@Poke oh, nevermind, I didn't see the requirement had been changed

|0 works instead of fØDV€.

@Dennis it does indeed. How does that work?

My explanation is my best guess

Bitwise operators attempt to cast to integer and replace the argument with 0 if they cannot, so digits get mapped to their numerical values and non-digits to 0.

Pyth, 9 7 bytes
%_s-Qd9

Uses space as the delimiter and returns 0 if the result could be 0 or 9.
Try it online
Explanation
%_s-Qd9
   -Qd   Remove the space from the input.
  s      Convert it to an integer.
%_    9  Negate mod 9.

Prolog (SWI), 59 bytes
0*[].
X*[H|T]:-between(0,9,H),U is mod(X+H,9),U*T.
+X:-0*X.

Try it online!
Yay for Logical programming!
Explanation
First we make a predicate *, which holds when applied to zero and the empty list.  Our predicate also holds when the front of the list is between 0 and 9 and when we add the leading digit mod 9 the predicate holds.
We then define + to just be this predicate with 0 as the first argument.  That is we want the digital sum to be a multiple of 9.
Prolog does all the grunt work of actually finding solutions for us.

Befunge-93, 16 bytes
1+!_#@3#.--9%~:#

Try it online!
A one line version of James Holderness’ Befunge answer that manages to shave off two bytes. This essentially compresses the code down to one line, reverses the direction and takes advantage of the fact that Befunge doesn’t skip at the end of the line. He suggested I post a separate answer with an explanation. The code takes an * as representing the missing digit and outputs a 9 for either 0 or 9.
How It Works
1+!_  3  --9% Initialises the pointer going right and initialises the digitsum with 3

1+!_         ~: Gets input and checks whether it is end of input (-1)

      3  - Subtract three from the input.
           This turns the ASCII values of digits into their mod 9 equivalent ("0"(48)=>45(mod 9)=>0)

          -9% Subtract the value from the digitsum and mod it with 9
              This keeps the digitsum as a negative digit greater than -9
              Repeat this until the input ends

Now this is where it gets tricky.
At the end of input, the stack looks like this:
  -(Digitsum%9), Copy of EOF input (-1)
The pointer is moving left from the _
 +!_ Invert the -1 to get 0 and add it to the digitsum (does nothing but get rid of the -1)
1           %~ Adds 1 mod -1 (no input) = 0 to the stack
         --9 Subtracts 9 from 0, yielding -9 and subtracts that from the digitsum.
             This makes the digitsum positive and equal to 9-(digitsum%9), our desired value
     @  . Finally, print and exit

* (ASCII value 42) was chosen as the missing character because it counteracts the initial value of the digitsum, 3.

I'm amazed that you can still keep squeezing bytes off of this. Well done!

J, 14 12 bytes
-2 bytes thanks to @BolceBussiere
9|9-[:+/"."0

I honestly don't know why "."0 interprets ? as 0 but it does so on my interpreter and on TIO so I'm not going to question it. (Update: see comments for an explanation why).
This approach very simply takes the sum of the digits, negates it by subtracting from 9, and takes it modulo 9.
Try it online!

You don't need to ravel before you sum ;)

Also, ". doesn't interpret '?' as 0, it interprets it as an empty list. In order to make it fit, J pads it with filler characters, which in this case (a numeric array) is 0.

LaTeX, many bytes (1000 628 614)
\RequirePackage{expl3}
\ExplSyntaxOn
\tl_new:N \l_divnine_input_tl
\int_new:N \l_divnine_sum_int
\def \getnum {
  \typein [ \l_divnine_input_tl ] { Input\space a\space number }
  \tl_map_function:NN \l_divnine_input_tl \divnine_sum:n
  \int_set:Nn \l_tmpa_int { 9 - \int_mod:nn { \l_divnine_sum_int } { 9 } }
  \typeout
    { The\space missing\space digit\space is:\space
      \int_use:N \l_tmpa_int
      \int_compare:nNnT { \l_tmpa_int } = { 0 } { \space or\space 9 }
    }
}
\cs_new:Nn \divnine_sum:n {
  \regex_match:nnT { \d } { #1 } { \int_add:Nn \l_divnine_sum_int { #1 } }
}
\ExplSyntaxOff
\getnum
\stop

LaTeX, illegible (348 334 bytes)
\RequirePackage{expl3}\ExplSyntaxOn\int_new:N\1\tl_new:N\2\def\3{\typein[\2]{Input\space a\space number}\tl_map_function:NN\2\4\int_set:Nn\1{9-\int_mod:nn{\1}{9}}\typeout{The\space missing\space digit\space is:\space\int_use:N\1\int_compare:nNnT{\1}={0}{\space or\space9}}}\def\4#1{\regex_match:nnT{\d}{#1}{\int_add:Nn\1{#1}}}\3\stop

LaTeX, 132 bytes
\RequirePackage{expl3}\typein[\1].\newcount\2{\ExplSyntaxOn\int_gset:Nn\2{9-\int_mod:nn\19}}\typeout{\the\2 \ifnum\2=9or 0\fi}\stop

Only space is allowed as unknown digit in this code.

Befunge-93, 28 27 19 18 bytes
Credit must go to Mistah Figgins, whose PyFunge answer showed me that you didn't need a special check for the missing digit character, if you just made sure the ASCII value was a multiple of nine.
Additional thanks to Jo King who showed that you didn't need to fully convert the characters to their numeric equivalent, and could simply subtract 3 to get a value that is relative to base 9 (ASCII 0 minus 3 is 45, a multiple of 9).
3_v#`0:~--
%9_@.+9

Try it online!
For this to work, you should use the character * for the missing digit (there are others that could also work, but that's the nicest).
Outputs 9 if the missing digit could be 0 or 9.
Explanation
3             Push 3 onto the stack.
 _            Since this is non-zero, drop the 3 and branch left.
3             Now executing right to left, push 3 again.
        --    Negate twice, leaving the value unchanged as our starting sum.

       ~      Now we start the main loop, reading a character from stdin.
    `0:       Duplicate and check if it's > 0, i.e. not end-of-stream.
 _ #          If so, continue to the left.
3        -    Subtract 3 to make the number relative to base 9.
        -     Then subtract it from the total, and repeat the loop.

  v           Once we reach the end of the input, we go down.
  _           Drop the EOF character from the stack and go left.
%9   +9       Mod the total with 9, and add 9.
   @.         Output the result and exit.

Essentially we are calculating the sum of all digits, plus 45 per digit (which will ultimately be cancelled out when we mod with 9). This sum is subtracted from 3 (our starting total), and an additional 39 is subtracted by the missing digit (ASCII * minus three). Again that 3 minus 39 is a multiple of 9, so it's cancelled out when we mod with 9.
So in the end we're calculating the negative sum of all the digits, mod 9, plus 9, i.e.
9 - (digitsum % 9)

And that's gives us the missing digit.

-1 byte if you subtract 3 instead of 48. Most of it gets cancelled out by needing to get the add 9 to the modulo

@JoKing Thanks! Never would have thought of that. Pity we still need the +9 now, but I can't see any way to get rid of that.

Managed to remove one more byte by compressing it down to one line! I changed it to %9 the total every loop and then reuses the 9-- on the way back to add 9 to the total.

@JoKing I know it's only saving one more byte, but that's brilliant! It's worth posting that as a new answer. You'll definitely get my vote, if nothing else.

Posted it! Managed to shave off one last byte too! I think that’s the last one I can do

Swift, 51 bytes
{9-Int("0"+$0.filter{"?" != $0})!%9}as(String)->Int

Try it online!

Befunge-98 (PyFunge), 15 13 bytes
I realized that I don't need to use ? to represent the absent digit, so I used one that is a multiple of 9 after subtracting 48: x
This let me golf off the 3+.
#v~'0-+
q>-9%

Try it online!
Uses an x as the missing digit, because it's ASCII value is divisible by 9 after subtracting 48 (and it's nice because its commonly used as a variable in math).
Outputs via exit code (because q is one byte shorter than .@)
Outputs 0 if the missing digit could be 0 or 9.
This only works in the PyFunge interpreter for reasons explained below.
Explanation
In the first line of the program, we sum the digits, including the x, which is treated like a 72 because of it's ASCII value. However, the sum will be the same once we've modded by 9, so this is irrelevant.
#v~'0-+    THE FIRST LINE
#v~        Pushes the next character from input, and goes to the second line on EOF
   '0-     Subtracts 48 to account for taking in ASCII values
      +    Adds this adjusted value to the sum

If we just modded by 9, we would be left with the wrong digit, because we want 9 - (sum % 9). However, we can do better than 9\-, which would subtract the remainder from 9: if we make the sum negative before modding by 9, we will get a positive result, equivalent to 9 - (sum % 9) in some interpreters. This is what requires us to use the PyFunge interpreters for both Befunge 93 and 98, as it is the only one on TIO that does this. The others give us a value between -8 and 8 instead of 0 and 8.
q>-9%    THE SECOND LINE
 >       Redirects the IP onto this line
  -      Subtracts the sum from an implicit 0, making it negative
   9%    Mods the sum by 9
q        Outputs via exit code, ending the program

Befunge-93 (PyFunge), 22 21 bytes
I realized that I don't need to use ? to represent the absent digit, so I used one that is a multiple of 9 after subtracting 48: x
This let me golf off the 3+, but it only saved me 1 byte because of the length of the first line before the conditional :(

A port of my Befunge-98 answer:
5 more bytes in order to check if we've reached EOF,
1 more byte to push 48 ("0" vs '0),
1 more byte to print the answer with .@,
and 1 more byte, because the second line has a space
for a total of 8 more bytes.
~:0`!#|_"0"-+
 @.%9-<

Try it online!
Outputs 0 if the missing digit could be 0 or 9.
This only works in the PyFunge interpreter for reasons explained below.
Explanation
Much of this explanation is copy-pasted from my Befunge-98 explanation, as that program is very similar to this one. shameless plug
In the first line of the program, we sum the digits, including the x, which is treated like a 72 because of it's ASCII value. However, the sum will be the same once we've modded by 9, so this is irrelevant.
~:0`!#|_"0"-+    THE FIRST LINE
~                Gets a character from input - If it is negative, we've reached EOF
 :0`!            Pushes 0 if the character is positive, 0 otherwise
     #|_         Goes to the next line if the value if 0
                     This also gets the negative value off the stack by using a |
        "0"-     Subtracts 48 to account for taking in ASCII values
            +    Adds this adjusted value to the sum

If we just modded by 9, we would be left with the wrong digit, because we want 9 - (sum % 9). However, we can do better than 9\-, which would subtract the remainder from 9: if we make the sum negative before modding by 9, we will get a positive result, equivalent to 9 - (sum % 9) in some interpreters. This is what requires us to use the PyFunge interpreters for both Befunge 93 and 98, as it is the only one on TIO that does this. The others give us a value between -8 and 8 instead of 0 and 8
 @.%9-<    THE SECOND LINE
      <    Redirects the IP onto this line
     -     Subtracts the sum from an implicit 0, making it negative
   %9      Mods the sum by 9
 @.        Prints the digit and exits

Nice answer! Never thought about using a custom character for the missing digit to avoid the extra check. I hope you don't mind that I stole that trick in my updated answer - I wanted to see if I could get the same concept working in the reference interpreter.

Ruby, 46, 41 bytes
-5 thanks to @Unihedron
->s{-s.chars.sum{|i|?<>i ? i.to_i : 0}%9}

Try it online!

we have chars instead of .split(//), 2. '<' can be replaced with ?<

I have crafted a shorter program in the same tool (Ruby) that is different enough (it deals with input and output) to be its own submission, you can find it here: https://codegolf.stackexchange.com/a/151869/21830

@Unihedron thanks, can't believe that I forgot about chars

Ruby, 22 bytes
Uses ' (any char that has a distance to 0 that is divisible by "0" will do, including 0 itself).
An output of 0 signifies either 0 or 9.
p -(gets.sum+6*~/$/)%9

Try it online!
Explanation
p     # print after inspecting
  -(  # unary negative, for reversing result of modulus (a-b%a)
    gets.sum # ascii value of string
    + 6*~/$/ # add six for each size (in chars) of input, so "0" translates to 0
  )%9 # mod 9
      # find remainder after dividing 9
      # except it's inverted so it's remainder to add to divide 9

APL (Dyalog), 13 bytes
{9-9|+/,↑⍎¨⍵}

Try it online!
The missing digit is ⍬.

brainfuck, 50 bytes
+>,[---[<-[<<]>[<+++++++++<]>>-],]-[<+>-----]<---.

Try it online!
Prints a 9 for either 0 or 9. Missing character is represented by :
How It Works
Tape Format:
    0 Total Input 0

The total is represented as 9-digitSum%9

+>,[ Start loop with 1 as the total
    --- Subtract 3 from the inputted byte to make the value%9 equal to the digit
    [   While the input byte exists
      <-                 Decrement the total
      [<<]>[<+++++++++<] If the total is 0, reset it to 9
      >>-                Decrement the input byte
    ]
,] Continue loop until there is no input
-[<+>-----]<---. Add 48 to the total to convert the digit to the ascii value and output it

The missing character needs to be a character that has a mod 9 of 4, +3 because we subtract 3 from the normal digits and +1 for the initialisation of the total as 1.
As a side note, there is a lot of inefficiency in the code for the sake of golfing, as each digit will reset the total 5 times each, rather than just once sometimes if I subtracted 48 instead of 3.

Befunge-98 (PyFunge), 8 bytes
#q~3--9%

Try it online!
Outputs via exit code. As with Mistah Figgin's answer, it only works with Pyfunge, where a negative number mod 9 becomes positive. Uses an x as the missing digit.

Java 8, 36 34 bytes
s->9-s.map(c->c>57?0:c-48).sum()%9

Returns 9 when both 0 and 9 are valid.
Explanation:
Try it online.
s->                               // Method with IntStream parameter and int return-type
   9-                             //  Return 9, minus:
     s.map(c->c>57?0:c-48).sum()  //   The sum of the digits (ignoring the question mark)
     %9                           //   modulo-9

Vyxal, 7 bytes
19βN9%‹

Try it Online!

5 bytes

PowerShell, 40 bytes
param($a)0..9|?{!(($a-replace'x',$_)%9)}

Try it online! or Verify all test cases
Takes input like '123x' into $a. Constructs a range 0 to 9 and uses Where-Object (here abbreviated as |?) to pull out those integers that match the clause. The clause takes $a, performs a regex -replace to replace the x with the current digit $_ and gets the mod 9 with %9. Thus if 9 evenly divides, this will be zero. We take the Boolean-not thereof, which turns the zeros truthy and everything else falsey, so that satisfies the Where-Object clause. Those result(s) are left on the pipeline and output is implicit.

Retina, 35 34 25 bytes
If the ? can be 0 or 9, the result is shown as 9.
.
$*
1{9}

^
9$*;
+`;1

.

Try it online
Explanation
.       Sum of the digits in unary + 1
$*
1{9}    Modulo 9

^       Prepend 9 semicolons, for subtracting
9$*;
+`;1    Subtract from 9

.       Back to decimal

I believe the \d can be changed into just . and the following line into $*.

Ah, right. I hadn't removed the ? yet when I wrote that.

33 bytes.

25: https://tio.run/##K0otycxL/K@q4Z7wX49LRYvLsNqylosrjstSRcuaSzvB2pCLS@//f0MjY3sue0tLSy57AwMjYy4DAwN7QwA

@totallyhuman Ah, yeah. Another remnant from an earlier version.

@MartinEnder Nice!

><>, 35 33 25 21 15 bytes
An output of 0 means the result could be either 0 or 9.
0i:&0(?n&3--9%!

Try it online!
Saved 6 bytes thanks to Jo King by using ' to represent missing digits.

15 bytes if you use a ' character instead of a ?

Pyth, 8 bytes
%_iz19 9

Try it online!
Uses I instead of ?.

Convert to base 19.
Negate.
Modulo 9.

Haskell, 35 bytes
f s=9-sum[read[i]|i<-s,i<':']`mod`9

Try it online!

Perl 5, 23 bytes
$_=- s/\D//r%9;s/0/0|9/

Try it online!
Doesn't care what character signifies the missing digit as long as it isn't a digit.

Tcl, 53 bytes
puts [expr 9-([regsub -all (\\d)\\D? 0$argv +\\1])%9]

As with other answers, this is made shorter by not explicitly saying “0 or 9”.
Instead, a result of “9” means either 0 or 9.
Try it online!
Explanation
It works pretty simply. It employs a regular expression to:

split the argument into individual digits
eliminate any question mark(s) non-digit(s)
interleave the digits with plus signs

It then evaluates 9 - (sum_of_digits mod 9) to arrive at a final value in 1..9, which it then puts.
The leading 0 (in 0$argv) is required just in case the question mark comes first in the input; a leading plus sign in the transformed sequence is not a problem for expr.