text:
Measuring Mountains
Sum-It is a language I created (quite late) for the Language Design Contest in TNB, for which the theme was "Range". Naturally I interpreted this as "Mountain Range" and created a language about mountains.
Sum-It code takes the form of several ASCII art mountains, using only the / and \ characters. The mountains are then parsed to a number representing the size of the mountain, and that number is used as either an opcode or a data value.
While developing the parser for this language, I noticed something quite interesting regarding mountain sizes:
The size of a standalone (ie: not overlapped) mountain is equivalent to double the sum of all integers lower than the mountain's height in characters.
So for example, the following mountain:
  /\   <- 1
 /  \  <- 2
/    \ <- 3

Has a character height of 3. Its "size" as far as Sum-It is concerned, is calculated as such:
  /\
 /##\
/####\

And is therefore 6.
This lines up with the above formula, because the sum of all integers lower than 3 is 1 + 2 = 3, which doubled is 6.
The challenge
Your challenge is, given a positive integer representing a mountain's height, output the Sum-It size of the mountain, using the above formula.
Scoring
This is code-golf, so fewest bytes wins!
Test Cases
Test cases are represented as input => output => formula
1 => 0 => 2()
2 => 2 => 2(1)
3 => 6 => 2(1+2)
4 => 12 => 2(1+2+3)
5 => 20 => 2(1+2+3+4)
6 => 30 => 2(1+2+3+4+5)
7 => 42 => 2(1+2+3+4+5+6)
8 => 56 => 2(1+2+3+4+5+6+7)
9 => 72 => 2(1+2+3+4+5+6+7+8)
10 => 90 => 2(1+2+3+4+5+6+7+8+9)
15 => 210 => 2(1+2+3+4+5+6+7+8+9+10+11+12+13+14)
20 => 380 => 2(1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19)
25 => 600 => 2(1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24)
30 => 870 => 2(1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29)
40 => 1560 => 2(1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39)
50 => 2450 => 2(1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49)
60 => 3540 => 2(1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59)
70 => 4830 => 2(1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69)
80 => 6320 => 2(1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79)
90 => 8010 => 2(1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79+80+81+82+83+84+85+86+87+88+89)
100 => 9900 => 2(1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79+80+81+82+83+84+85+86+87+88+89+90+91+92+93+94+95+96+97+98+99)

"using the above formula." so, the code has to calculate all these additions?

Basically 2×triangular number.

@FelixPalmen no, provided it outputs the correct answer

@Skidsdev good! unfortunately, makes it too simple once you found the simpler formula ;)

@user202729 hmm good point, given that challenge I think this one is really just a trivial modification to that challenge, with context around it. Guess I should've stuck to my original idea which was to take the ASCII mountains as input and output the size of the mountains.

APL+WIN, 8 6 bytes
+/2×⍳⎕

Prompts for input integer, creates a vector of integers from 1 to integer -1, multiplies by 2 and sums the result.
Saved 2 bytes thanks to Adam by switching to index origin zero.

Save two bytes by using ⎕IO←0 and removing -1. Save an additional byte by switching to Dyalog APL and removing ⎕. Try it online!

@Adám Thanks for the two bytes which was of course trivial. Switching to Dyalog not so trivial ;(

Why not? Apply for a free license or use unregistered version or just use TryAPL.

@Adám I am conscious that we should take this elsewhere but I was sent a copy of v13 several years ago by some guys I know in Dyalog but the effort of converting the vast library of code I have in APL+WIN seemed overwhelming. I commented before that I might migrate when an Android version emerges

Let's continue this conversation in chat…

C (gcc), 31 bytes
i;f(n,a){for(;--n;i+=n);a=i*2;}

Try it online!
EDIT: By using a global variable multiple execution of the functions wil lget wrong results. I'm not sure wether that's ok or no. Pretty new to PPCG.
Here's the corrected version:
C (gcc), 34 bytes
f(n,i,a){for(i=0;--n;i+=n);a=i*2;}

Try it online!

Japt -mx, 1 bytes
Ñ

-m implicity flag creates a range from 0 to input - 1
Ñ multiply each value in the range by 2
Flag -x implicity outputs the sum of the result
Try it online!

1 byte with the -mx flag.

C (gcc), 13 bytes
f(x){x*=x--;}

Try it online!

Haskell, 10 bytes
(*)=<<pred

Try it online, using (<*>) would work too since multiplication is commutative..
Alternative, 9 bytes
I'm not completely sure if this is allowed, according to this I believe it is:
id<>(-1+)

Takes input as Product type, try it online!

Catholicon, 2 bytes
*Ẏ

Explanation:
*    multiply (the implicit input)
 Ẏ   by the implicit input decremented


text:
Walk Across a Keyboard
Given a word (or any sequence of letters) as input, you must interpolate between each letter such that each adjacent pair of letters in the result is also adjacent on a QWERTY keyboard, as if you typed the input by walking on a giant keyboard. For example, 'yes' might become 'ytres', 'cat' might become 'cxzawert'.
Rules:

This is the keyboard format you should use:
qwertyuiop
 asdfghjkl
  zxcvbnm
Any pair of keys which is touching in this layout is considered adjacent. For instance, 's' and 'e' are ajacent, but 's' and 'r' are not.
The input "word" will consist of any sequence of letters. It will have only letters, so you don't have do deal with special characters.
The input can be in any convenient form: stdin, a string, a list, etc. Letter case does not matter; you can take whatever is more convenient.
The output can be in any convenient form: stdout, a string, a list, etc. Letter case does not  matter, and it does not need to be consistent.
Any path across the keyboard is valid, except that you cannot cross the previous letter again before getting to the next letter. For example, 'hi' could become 'hji' or 'hjnbgyui', but not 'hbhui'.
A letter is not ajacent with itself, so 'poll' cannot become 'poll'. Instead it would need to become something like 'polkl'.
No output letters are allowed before or after the word. For example, 'was' cannot become 'trewas' or 'wasdfg'.

This is code golf, the shortest answer in bytes wins.

So we're outputting any valid 'walk' per input? This seems like it'd be better as given two inputs, determine if it's a valid walk.

It seems like dewqwerty is a valid path for dy. Could you confirm that?

@Arnauld yes, it is.

@Veskah That's right; output any valid walk for an input. This is to allow for optimizations which might not be possible if, for instance, it had to be a shortest walk.

Japt -g, 23 bytes
;D·ÎÔ+D·Årí)pUl)fUq".*?

Try it online!
Takes input as an array of capital letters. Very similar to the other answers otherwise.
Explanation:
;                          :Set D to the keyboard layout
 D·Î                       :Get the first row of keys
    Ô                      :Reversed
     +                     :Concat
      D·Å                  :The other two rows
         rí)               :Interleaved
            p              :Repeat that string
             Ul)           : A number of times equal to the length of the input
                f          :Get the substrings that match
                 U         : The input
                  q".*?    : joined with ".*?"
                           :Implicitly output just one of the matches

Python 2, 83 bytes
lambda s:re.findall('.*?'.join(s),'qwertyuioplkmnjhbvgfcxdsza'*len(s))[0]
import re

Try it online!
Walks the entire keyboard until the word is written.

How come the import re comes after the code, not before?

@BruceWayne The re.findall would be evaluated when the lambda runs, so importing after the lambda's definition is ok. That being said, it is clearer to import before, there's just no need to

@pushkin ah, I didn't know that thanks for clarifying! Did you import after just as a personal preference/choice or does it help with byte count at all?

@BruceWayne It's a bit of a convention for this forum. It's just so that it works with the way the TiO site organizes the code. Try clicking on the "Try it online!" link to see what I mean.

-3 by outputting a singleton list (remove [0]).

@Makonede Doesn't work for the second case ("cat")

Python 2 + NetworkX, 274 bytes (optimal solution)
296 300 302 308 315 319 324 327 328 430 432 bytes
-4 bytes thanks to mypetlion
from networkx import*
i=input()
M,z='qwertyuiop  asdfghjkl   zxcvbnm'.center(55),i[:1]
G=from_edgelist([(M[e],M[e+h])for h in[-1,1,11,12,-11,-12]for e in range(44)if' '!=M[e]and' '!=M[e+h]])
for y,x in zip(i,i[1:]):z+=[shortest_path(G,y,x)[1:],list(G[y])[0]+y][x==y]
print z

Try it online!
This solution gives the shortest possible output. The keyboard is transformed into a graph used to find the shortest path to compute the output string:
puzzles     --> poiuhbvcxzazxcvbhjklkiuytres
programming --> poiuytrtyuioijhgtresasdcvbnmkmkijnbg
code        --> cvbhjioijhgfde
golf        --> ghjiolkjhgf
yes         --> ytres
hi          --> hji
poll        --> polpl

274 bytes: Try it online!

@mypetlion u made an important reduction, u can update the answer :)

JavaScript (ES6), 70 bytes
Same strategy as TFeld.
s=>'qazsxdcfvgbhnjmklpoiuytrew'.repeat(s.length).match(s.join`.*?`)[0]

Try it online!

-3 by outputting a singleton list (remove [0]).

05AB1E, 43 33 31 bytes
ü2εUžV`.ιJsRìD«Œ.ΔнÅ?XyθÅ¿}¨}JIθ«

Not the right language for this challenge, since it cannot use regex like the other answers did.. EDIT: proven wrong by @Makonede's 05AB1E answer using the Elixir eval builtin .E.
Try it online or verify all test cases.
Explanation:
ü2             # Split the input into overlapping pairs
               #  i.e. "poll" → ["po","ol","ll"]
  ε            # Map each to:
   U           #  Pop and store the current pair in variable `X`
   žV          #  Push ["qwertyuiop","asdfghjkl","zxcvbnm"]
     `         #  Pop and push all three separated to the stack
      .ι       #  Interweave the top two with each other
        J      #  Join the list of characters to a single string
               #   → "azsxdcfvgbhnjmkl"
         s     #  Swap so "qwertyuiop" is at the top
          R    #  Reverse it to "poiuytrewq"
           ì   #  Prepend it in front of the earlier string
               #   → "poiuytrewqazsxdcfvgbhnjmkl"
            D« #  Duplicate it, and append it to itself
               #   → "poiuytrewqazsxdcfvgbhnjmklpoiuytrewqazsxdcfvgbhnjmkl"
   Œ           #  Get all substrings of this strings
    .Δ         #  Find the first substring which is truthy for:
      Á        #   Rotate the current string once towards the right
       2£      #   Only leave the first 2 letters
         R     #   Reverse it
          XQ   #   Check if it's equal to pair `X`
     }¨        #  After the find_first, remove the last character
  }            # Close the map
   J           # Join everything together
    Iθ«        # Append the last character of the input
               # (after which the result is output implicitly)

Charcoal, 48 bytes
≔”&⌈″⌊5ＥWＸＶＮa…-εW¶ζR”η≔⌕η§θ⁰ζＦθＦ⊕﹪⁻⌕ηιζ²⁶«§ηζ≦⊕ζ

Try it online! Link is to verbose version of code. Explanation:
≔”&⌈″⌊5ＥWＸＶＮa…-εW¶ζR”η

Get the string qwertyuioplkmjnhbgvfcdxsza.
≔⌕η§θ⁰ζ

Find the position of the first character of the word. This index is normally one past the character just reached, but this value fakes out the first iteration of the loop to print the first character of the word.
Ｆθ

Loop over each character.
Ｆ⊕﹪⁻⌕ηιζ²⁶«

Compute how many characters to print to include the next character of the word and loop that many times.
§ηζ≦⊕ζ

Print the next character cyclically indexed and increment the index.

Have you tried rotating the string “qwertyuioplkmjnhbgvfcdxsza” and seeing if any of the rotations happen to be more compressible? I'm not familiar with charcoal's compression; maybe this isn't possible.

@Vaelus I don't know either so I tried all 26 rotations but they all compress to 20 bytes. Of course, those aren't all of the possible walks...

05AB1E, 51 39 38 bytes
-1 thanks to Kevin Cruijssen.
gžV`.ιJsRì×s….*?ý’RŽ½™«.‡Ð~r/ÿ/,"ÿ"’.E

Try it online! Takes input as a list of lowercase letters and outputs as a singleton list.
This answer exists to prove Kevin Cruijssen wrong; you can use regex in 05AB1E.

Nice answer! I didn't knew you could use the Elixir eval to use Regex like that. I need to remember that for sure. :) (PS: My answer was posted before the new 05AB1E version was live. But I assume using the Python eval .E in the legacy version should be possible as well.) I've also just golfed my answer a bit, and one golf can also be applied to your answer: žVćRs`.ιJ« to žV`.ιJsRì for -1.

Vyxal, 16 bytes
Lk•÷Y$Ṙp*?‛€?jẎh

Try it Online!
Lk•÷Y$Ṙp*?‛€?jẎh
 k•              # List of rows on the keyboard: ["qwertyuiop", "asdfghjkl", "zxcvbnm"]
   ÷             # Push each item onto the stack
    Y            # Interleave the top two: "azsxdcfvgbhnjmkl"
     $           # Swap so "qwertyuiop" is on top
      Ṙ          # Reverse it
       p         # Prepend it to the other string
L       *        # Repeat it input-length number of times
         ?‛€?j   # Join each character in the input by ".*?"
              Ẏh # Get the first regex match

J-uby, 71 bytes
Again lost a few bytes by having to call Regexp.new with a string instead of using a Regexp literal with interpolation. Same technique as TField et al.
-[:+@|:*&"qazsxdcfvgbhnjmklpoiuytrew",~:join&".*?"|:new&Regexp]|:<<&:[]

Attempt This Online!
Explanation
-[
  :+@ | :* & "qazsxdcfvgbhnjmklpoiuytrew",  # Repeat string times size of input
  ~:join & ".*?" | :new&Regexp              # Also make a Regexp by joining input with ".*?"
] |                                         # then
:<< & :[]                                   # call :[] with the two values, i.e. repeated_string[regexp]

source: Stack Exchange

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

sort: votes


text:
Map the cheaters!
After all assignments are submitted, a dictionary is created that maps student number to the hash of their file.
This dictionary, or hashmap, or mapping (whatever your language calls it) will look as follows:
{100: "aabb", 104: "43a", 52: "00ab", 430: "aabb", 332: "43a"}
The key is the student number, and the value is the hash.
Our task is to pick out the cheaters! The cheaters are the ones which have identical hashes.
Given the input {100: "aabb", 104: "43a", 52: "00ab", 430: "aabb", 332: "43a"}, the function should return (or print) the following text:
100 has identical files to 430

104 has identical files to 332

Notice how the files where the hashes are unique are not mentioned.
Also, the order is important here:
{100: "aabb", 202: "aabb", 303: "ab", 404: "aabb"} should return (print) the following text:
100 has identical files to 202,404
It is incorrect to print any of the following:
202 has identical files to 100,404
100 has identical files to 404, 202
You should print it in terms of how it appears in the dictionary. In some languages, going through a dictionary is random, so in this special case, you are allowed to change the method of input such that you can go through it in an orderly fashion.
More Examples:
{} # prints nothing

{100: "ab", 303: "cd"} # prints nothing again

{100: "ab", 303: "cd", 404: "ab"}

100 has identical files to 404

{303: "abc", 304: "dd", 305: "abc", 405: "dd", 606: "abc"}

303 has identical files to 305,606

304 has identical files to 405

Shortest code wins!

"You should print it in terms of how it appears in the dictionary" -- I'm not entirely sure what this means. Otherwise I do like the challenge.

For example, given {303: "abc", 304: "dd", 305: "abc", 405: "dd", 606: "abc"}, we see that 303 appears before 305, 606 (its first in the dictionary). Thus your sentence should be 303 has identical files to 305,606. It is incorrect to have 305 has identical files to 303,606 as it is not first in the dictionary

Might I also suggest using the sandbox before posting to the main site? always helpful to get revisions to a question before posting instead of getting a million comments for clarification on main :-)

Thanks, i did not know of that !

In the case where multiple groups of cheaters are found, is there a required order between groups? For example, in the last test case can "304 has..." be printed before "303 has..."?

Are we allowed to output 303 has identical files to [305, 606] instead of 303 has identical files to 305,606?

@KevinCruijssen : I second your question, but I doubt is allowed... since the second example of incorrect order contains a space (but it might be only incorrect because of the wrong order, not the space...)

Can I output one newline between each line instead of two?

So the key is a positive integer, and the value is a string contains lowercase alphabet characters and/or numbers?

In languages where a dictionary, map, or hashmap type does not exist, are lists of tuples (or equivalent) allowed?

JavaScript (Babel Node), 113 bytes
Takes input as an array of arrays in [key, value] format. Go go gadget double flatMap!
o=>o.flatMap(([x,h],i)=>(a=o.flatMap(([y,H],j)=>j>i&H==h?(o[j]=[,j],[y]):[]))+a?x+' has identical files to '+a:a)

Try it online!

JavaScript (Babel Node), 114 bytes
Takes input as a native JS object.
o=>Object.keys(o).flatMap((x,i,a)=>(a=a.filter(y=>i--<0&o[y]==o[x]&&(o[y]=y)))+a?x+' has identical files to '+a:a)

Try it online!

Really nice! Quite a large file but then again I did not expect this problem to be as easy as the other ones. Great work! I'll look more into this flatMap

@KSplitX flatMap is not widely supported yet. I'm sure there are shorter ways, but it's getting late and I can't think anymore. :p

Python 2, 127 126 bytes
def f(x):
 for l in{`[K for K,V in x if v==V]`[1:-1]for k,v in x}:
	if','in l:print l.replace(',',' has identical files to',1)

Try it online!
Takes a list of ordered pairs (<studentNumber>,<hash>) as input.

Missed a small golf: if','in

@Vedant Kandoi: Thx!

R, 145 132 129 126 124 bytes
function(m,`!`=names)for(e in !(t=table(m))[t>1])cat(el(n<-!m[m==e]),'has identical files to',paste(n[-1],collapse=','),'
')

Try it online!
It takes a named vector as input (names are the keys)

-2 bytes thanks to Giuseppe

If ", " separator (with a space after the comma) is allowed in case of multiple duplicates, we can use this code and save 10 bytes :
R, 114 bytes
function(m,`!`=names)for(e in !(t=table(m))[t>1])cat(el(n<-!m[m==e]),'has identical files to',toString(n[-1]),'
')

Try it online!

124 bytes although my gut tells me a different approach might yield something in the 115 range...

Retina 0.8.2, 71 bytes
+m`((:.+)$(¶|.)+?)^(.+)\2$
,$4$1
:.*

G`,
%1`,
 has identical files to

Try it online! Takes input on separate lines but link includes test suite that splits the examples for you. Explanation:
+

Repeat this match until no more replacements can be made.
m`((:.+)$(¶|.)+?)^(.+)\2$
,$4$1

Look for pairs of matching hashes and append the key of the second match to that of the first match with a comma separator.
:.*

Delete all of the hashes.
G`,

Keep only the lines with commas.
%1`,
 has identical files to

Replace the first comma on each line with the desired text (including trailing space).

Japt, 34 bytes
üÌl>1 ®mgÃ®Î+` •s ÅÁÈól fÅC ‘ `+ZÅ

Try it online!
Right now it's a bit inconsistent in the ordering of lines, but within a line it outputs correctly. If the lines of the output need to be in a specific order, it will take a few more bytes. Input is just an array of [id, hash] pairs
Explanation:
üÌ                                    :Group by hash
  l>1                                 :Remove the ones that are unique
      ®mgÃ                            :Get just the Ids
          ®                           :Generate a string for each hash:
           Î                          : The first Id with that hash
            +` •s ÅÁÈól fÅC ‘ `       : Plus " has identical files to " compressed
                               +ZÅ    : Plus the remaining Ids
                                      : Implicitly comma delimited

05AB1E, 34 bytes
Σθ}.γθ}vyg1›iy€нć“ÿ€°Ê¼‡œ€„ “?',ý,

Try it online or verify all test cases.
Explanation:
Σθ}                   # Sort the (implicit) input by the string
.γθ}                  # Then group it by the string
v                     # Loop `y` over each grouped inner list
 yg1›i                #  If the group contains more than 1 key-value pairs:
      y€н             #   Only leave the keys
      ć               #   Pop and push the head and rest of the list separately
                      #   (with the head being at the top of the stack now)
       “ÿ€°Ê¼‡œ€„ “   #   Compressed string "ÿ has identical files to "
                      #   where the "ÿ" is automatically replaced with the top of the stack
                   ?  #   Print it (without trailing newline)
       ',ý           '#   Join the remaining numbers by a comma
          ,           #   And output it as well (with trailing newline)

See this 05AB1E answer of mine (section How to use the dictionary?) to understand why “ÿ€°Ê¼‡œ€„ “ is "ÿ has identical files to ".

Perl 6, 115 110 103 bytes
-2 bytes thanks to Jo King
{unique map {.[0]~" has identical files to "~join ',',.skip},grep *>1,.map:{.grep(*{*}eq$^p{*})>>.key}}

Try it online!
Takes a list of Pairs since hashes are unordered. A list of two-element lists would save a few bytes but seems unidiomatic. Returns a list of lines.
95 88 bytes if the order of lines in the result doesn't matter:
*.classify(*{*}){*}>>.key.grep(*>1).map:{.[0]~" has identical files to "~join ',',.skip}

Try it online!

.[1..*] to .skip

Ruby, 98 96 bytes
->h{h.group_by{|k,v|v}.map{|k,v|x,*y=v.to_h.keys;p"#{x} has identical files to #{y*?,}"if y[0]}}

Try it online!
Takes input as Ruby Hash, returns by printing.

Jelly, 39 bytes
Ṫ€ĠḊƇṢịẎµḢ;“]⁶ḅhṬyU⁹æṇL[Oþ⁹cƘƓ»,ṾK)j⁾¶¶

Try it online!

C# (Visual C# Interactive Compiler), 130 bytes
a=>a.GroupBy(x=>x.Value,x=>x.Key).Where(x=>x.Count()>1).Select(x=>x.First()+" has identical files to "+String.Join(",",x.Skip(1)))

Try it online!
The strange thing about this question is that the examples are given in a JSON format as key/value pairs which usually implies that they are unordered... In this case however, order is important. As such, I am using a list of tuples for input and a list of strings as output.
// a is a list of tuples
// (student #, hash)
a=>a
  // group by hash
  // grouped items are the student #'s
  .GroupBy(x=>x.Value,x=>x.Key)
  // remove single student groups
  .Where(x=>x.Count()>1)
  // format the output strings
  .Select(x=>x.First()+
    " has identical files to "+
    String.Join(",",x.Skip(1)))

Perl 5, 100 +1(-n) bytes
for$x(/[a-z]+/g){($t,@a)=${h{$x}}++?():/\d+(?= $x)/g;@a&&say"$t has identical files to ",join",",@a}

Try it online!

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


text:
Number that can eat itself
Given a positive integer, output a truthy/falsy value as to whether the number can eat itself.
Rules
Leftmost is the head, rightmost is the tail
If the head is greater than or equal to the tail, the head eats the tail and the new head becomes their sum.
If \$sum \ge 10 \$ then the head is replaced by \$sum \mod 10\$.
\$sum=0\$ cannot be ignored, however the input number will never have any leading zeroes.
Example:
number=2632
head-2, tail-2

2632 -> 463
head-4, tail-3

463 -> 76
head-7, tail-6

76 -> 3
If only one digit remains in the end, the number can eat itself.

If at any point the head cannot eat the tail, the answer will be False.
number=6724
072
False (0<2)

Test Cases:
True:
[2632, 92258, 60282, 38410,3210, 2302, 2742, 8628, 6793, 1, 2, 10, 100, 55, 121]

False:
[6724, 47, 472, 60247, 33265, 79350, 83147, 93101, 57088, 69513, 62738, 54754, 23931, 7164, 5289, 3435, 3949, 8630, 5018, 6715, 340, 2194]

This is code-golf so shortest code wins.

Can we take input as a string?

@lirtosiast, yes, but not list of digits.

They could be called Autocannibalistic Numbers.

What is the reason we can't take as a list of digits?  This problem already treats them as if they are lists of digits.  Forcing them to be numbers means that you just have to pin extra code to convert them to a list.

Can two consistent distinct values be returned instead of truthy/falsy?

Now this is real cannibalism

JavaScript (ES6),  52 51  50 bytes
Saved 1 byte thanks to @tsh
Takes input as a string. Returns a Boolean value.
f=n=>n>[n%10]?f(-(-n[0]-n)%10+n.slice(1,-1)):!n[1]

Try it online!
Commented
f = n =>                 // f = recursive function taking n (a string)
  n > [n % 10]           // The last digit is isolated with n % 10 and turned into a
                         // singleton array, which is eventually coerced to a string
                         // when the comparison occurs.
                         // So we do a lexicographical comparison between n and its
                         // last digit (e.g. '231'>'1' and '202'>'2', but '213'<'3').
  ?                      // If the above result is true:
    f(                   //   do a recursive call:
      -(-n[0] - n) % 10  //     We compute (int(first_digit) + int(n)) mod 10. There's no
                         //     need to isolate the last digit since we do a mod 10 anyway.
      + n.slice(1, -1)   //     We add the middle part, as a string. It may be empty.
    )                    //   end of recursive call
  :                      // else:
    !n[1]                //   return true if n has only 1 digit, or false otherwise

f=n=>n>[n%10]?f(-(-n[0]-n)%10+n.slice(1,-1)):!n[1]

Perl 6, 63 62 bytes
{!grep {.[*-1]>.[0]},(.comb,{.[0,*-1].sum%10,|.[1..*-2]}...1)}

Try it online!
Explanation:
{                                                            } # Anonymous code block
                     (                                  ... )       # Create a sequence
                      .comb,  # Starting with the input converted to a list of digits
                            {                          }   # With each element being
                             .[0,*-1]   # The first and last element of the previous list
                                     .sum%10  # Summed and modulo 10
                                            ,|.[1..*-2]   # Followed by the intermediate elements
                                                        ...1 # Until the list is length 1
 !grep   # Do none of the elements of the sequence
       {.[*-1]>.[0]},   # Have the last element larger than the first?

Jelly, 11 bytes
Ṛṙ-µṖÄ%⁵:ḊẠ

Try it online!
How it works
Ṛṙ-µṖÄ%⁵:ḊẠ  Main link. Argument: n

Ṛ            Reverse n, after casting it to a digit list.
 ṙ-          Rotate the result -1 units to the left, i.e., 1 unit to the right.
             Let's call the resulting digit list D.
   µ         Begin a new chain with argument D.
    Ṗ        Pop; remove the last digit.
     Ä       Accumulate; take the cumulative sum of the remaining digits.
      %⁵     Take the sums modulo 10.
         Ḋ   Dequeue; yield D without its first digit.
        :    Perform integer division between the results to both sides.
             Integer division is truthy iff greater-or-equal is truthy.
          Ạ  All; return 1 if all quotients are truthy, 0 if not.

Java (JDK), 83 bytes
n->{int r=0,h=n;while(h>9)h/=10;for(;n>9;h=(h+n)%10,n/=10)r=h<n%10?1:r;return r<1;}

Try it online!
Credits

-1 byte thanks to Kevin Cruijssen

Given the length of the Python answers, I feel like I missed something... though the test cases are ok.

I don't think you've missed anything. The Python answers both take the input as string and use indexing, and you take the input as integer and use /10 and %10 in a loop. So well done beating the Python answers; +1 from me. :)

You can golf a byte changing r+= to r= and ?1:0 to ?1:r.

@KevinCruijssen Indeed... the Python answers are suboptimal: golfs in comments are shorter than this answer. Also, thanks for the byte saved! ;-)

You could return $0$ or $1$ by starting with r=1 and doing r&=h<n%10?0:r;return r; (saving 1 byte).

@Arnauld No, I cannot because a truthy/falsy value is required. In Java, 0 and 1 aren't truthy/falsy because one can't write if(1) or if(0).

@OlivierGrégoire Oh, I see. Maybe you can ask the OP if two distinct consistent values can be returned instead.

Brachylog, 23 bytes
ẹ{bkK&⟨h{≥₁+tg}t⟩,K↰|Ȯ}

Try it online!
This is a 1 byte save over Fatalize's solution.
This uses a recursive approach instead of a iterative
Explanation
ẹ                          Input into a list of digits
 {                    }    Assert that either
  bk                       | the list has at least 2 elements (see later)
      ⟨h{     }t⟩           | and that [head, tail]
         ≥₁                |  | is increasing (head >= tail)
           +               |  | and their sum
            t              |  | mod 10 (take last digit)
             g             |  | as single element of a list
                ,          | concatenated with
  bkK            K         | the number without head and tail (this constrains the number to have at least 2 digits)
                  ↰        | and that this constraint also works on the newly formed number
                   |Ȯ      | OR is a 1 digit number

Mathematica, 62 bytes
0(IntegerDigits@#//.{a_,r___,b_}/;a>=b:>{Mod[a+b,10],r})=={0}&

First calls IntegerDigits on the input to get a list of its digits,
then repeatedly applies the following rule:
{a_,r___,b_}       (* match the first digit, 0 or more medial digits, and the last digit... *)
/;a>=b             (* under the condition that the number is edible... *)
:>{Mod[a+b,10],r}  (* and replace it with the next iteration *)

The rule is applied until the pattern no longer matches,
in which case either there is only one digit left (truthy)
or the head is less than the tail (falsy).
Instead of calling Length[__]==1,
we can save a few bytes with 0(__)=={0},
multiplying all elements in the list by 0
and then comparing with the list {0}.

In case you didn't know, TIO has Mathematica now. Try it online!

Python 2, 105 82 81 bytes
i,x=map(int,input()),1
for y in i[:0:-1]:
 if i[0]%10<y:x=0
 else:i[0]+=y
print x

Try it online!
Many thanks for a massive -23 from @ØrjanJohansen
Thanks to @VedantKandoi (and @ØrjanJohansen) for another -1

You can use for with a reverse slice, and also do the %10 only when testing: Try it online!

Swap the if-else condition, if i[0]<i[-1]:x=0 and then else:..... @ØrjanJohansen, in your answer too.

@ØrjanJohansen - Thanks. That's well cool.

Hey @VedantKandoi. Sounds good but not sure exactly what you mean. You have me beaten on that one. Can you add a TIO please?  When I try it works for all True cases but not for all of the False.

I think @VedantKandoi means this.

Python 3, 50 bytes
First line stolen from Black Owl Kai's answer.
p,*s=map(int,input())
while s:*s,k=s;p%10<k>q;p+=k

Try it online!
Output is via exit code. Fails (1) for falsy inputs and finishes (0) for truthy inputs.

Can you explain why p%10<k>q doesn't throw a NameError if p%10 >= k?

@BlackOwlKai chained comparisons are lazily evaluated in Python. This means as soon as a first false comparison appears, the chain will no longer be evaluated. In this case p%10<k>q does the same as p%10<k and k>q.

APL (Dyalog Unicode), 33 bytesSBCS
Anonymous tacit prefix function taking a string as argument.

{⊃⍵<t←⊃⌽⍵:0⋄3::1⋄∇10|t+@1⊢¯1↓⍵}⍎¨

Try it online!
⍎¨ evaluate each character (this gives us a list of digits)
{…} apply the following "dfn" to that; ⍵ is the argument (list of digits):
  ⌽⍵ reverse the argument
  ⊃ pick the first element (this is the tail)
  t← assign to t (for tail)
  ⍵< for each of the original digits, see if it is less than that
  ⊃ pick the first true/false
 : if so:
  0 return false
 ⋄ then:
 3:: if from now on, an index error (out of bounds) happens:
  1 return true
  ¯1↓⍵ drop the last digit
  ⊢ yield that (separates 1 and ¯1 so they won't form a single array)
  t+@1 add the tail to the first digit (the head)
  10| mod-10
  ∇ recurse
Once we hit a single digit, ¯1↓ will make that an empty list, and @1 will cause an index error as there is no first digit, causing the function to return true.

Python 3, 77 bytes
p,*s=map(int,input())
print(all(n<=sum(s[i+1:],p)%10for i,n in enumerate(s)))

Try it online!

And my old solution with a recursive approach
Python 3, 90 bytes
f=lambda x,a=0:2>len(x)if 2>len(x)or(int(x[0])+a)%10<int(x[-1])else f(x[:-1],a+int(x[-1]))

Try it online!
Takes input as a string.

Brachylog, 24 bytes
ẹ;I⟨⟨h{≥₁+tg}t⟩c{bk}⟩ⁱ⁾Ȯ

Try it online!
I should change ⁱ's default behaviour so that it iterates an unknown number of times (currently, it iterates 1 time by default which is completely useless). I then wouldn't need the […];I[…]⁾, saving 3 bytes
Explanation
This program contains an ugly fork inside a fork. There is also some plumbing needed to work on lists of digits instead of numbers (because if we remove the head and tail of 76 we are left with 0, which doesn't work contrary to [7,6] where we end up with []).
ẹ                          Input into a list of digits
                       Ȯ   While we don't have a single digit number…
 ;I                  ⁱ⁾    …Iterate I times (I being unknown)…
   ⟨                ⟩      …The following fork:
               c           | Concatenate…
    ⟨         ⟩            | The output of the following fork:
     h       t             | | Take the head H and tail T of the number
      {     }              | | Then apply on [H,T]:
       ≥₁                  | | | H ≥ T
         +                 | | | Sum them
          tg               | | | Take the last digit (i.e. mod 10) and wrap it in a list
                {  }       | With the output of the following predicate:
                 bk        | | Remove the head and the tail of the number

Using recursion instead of iteration and replacing the c-fork to use , instead i could remove 1 byte
Try it online!

@Kroppeb Really cool. I think you should post your own answer, because it's significantly different than mine!

Haskell, 70 64 60 bytes
f(a:b)=b==""||a>=last b&&f(last(show$read[a]+read b):init b)

Input is taken as a string.
Try it online!
Edit: -6 bytes by using @Laikoni's trick of using || instead of separate guards. Another -4 bytes thanks to @Laikoni.

read[l b] can be just read b because you only look at the last digit anyway. Saves 4 more bytes by also in-lining last: Try it online!

Python 2, 75 67 bytes
l=lambda n:n==n[0]or n[-1]<=n[0]*l(`int(n[0]+n[-1],11)%10`+n[1:-1])

Try it online!
Recursive lambda approach. Takes input as a string. Many thanks to Dennis for saving 8 bytes!

Perl 5, 64 bytes
{local$_=pop;1while s/(.)(.*)(.)/$1<$3?'':(($1+$3)%10).$2/e;/./}

Try it online!

Haskell, 69 64 bytes
f n=read[show n!!0]#n
h#n=n<10||h>=mod n 10&&mod(h+n)10#div n 10

Try it online! Example usage: f 2632 yields True.
Edit: -5 bytes because mod (h + mod n 10) 10 = mod (h + n) 10

nice use of ||, which helped me to shorten my answer, too. Thanks!

Ruby, 139 bytes
->(a){a.length==1?(p true;exit):1;(a[0].to_i>=a[-1].to_i)?(a[0]=(a[-1].to_i+a[0].to_i).divmod(10)[1].to_s;a=a[0..-2];p b[a]):p(false);exit}

Try it online! (has some extra code to process input, since it's a function)
Ungolfed code:
->(a) do
    if a.length == 1
        p true
        exit
    if a[0].to_i >= a[-1].to_i
        a[0] = (a[-1].to_i + a[0].to_i).divmod(10)[1].to_s
        a = a[0..-2]
        p b[a]
    else
        p false
        exit
    end
end

05AB1E, 26 25 24 bytes
[DgD#\ÁD2£D`›i0qëSOθs¦¦«

Can probably be golfed a bit more.. It feels overly long, but maybe the challenge is in terms of code more complex than I thought beforehand.
Try it online or verify all test cases.
Explanation:
[                 # Start an infinite loop
 D                #  Duplicate the top of the stack
                  #  (which is the input implicitly in the first iteration)
  gD              #  Take its length and duplicate it
    #             #  If its a single digit:
                  #   Stop the infinite loop
                  #   (and output the duplicated length of 1 (truthy) implicitly)
                  #  Else:
  \               #   Discard the duplicate length
   Á              #   Rotate the digits once towards the left
    D2£           #   Duplicate, and take the first two digits of the rotated number
       D`         #   Duplicate, and push the digits loose to the stack
         ›i       #   If the first digit is larger than the second digit:
           0      #    Push a 0 (falsey)
            q     #    Stop the program (and output 0 implicitly)
          ë       #   Else (first digit is smaller than or equal to the second digit):
           SO     #    Sum the two digits
             θ    #    Leave only the last digit of that sum
           s      #    Swap to take the rotated number
            ¦¦    #    Remove the first two digits
              «   #    Merge it together with the calculated new digit

Retina 0.8.2, 42 bytes
\d
$*#;
^((#*).*;)\2;$
$2$1
}`#{10}

^#*;$

Try it online! Link include test cases. Explanation:
\d
$*#;

Convert the digits to unary and insert separators.
^((#*).*;)\2;$
$2$1

If the last digit is not greater than the first then add them together.
#{10}

Reduce modulo 10 if appropriate.
}`

Repeat until the last digit is greater than the first or there is only one digit left.
^#*;$

Test whether there is only one digit left.

C++ (gcc), 144 bytes
bool f(std::string b){int c=b.length();while(c>1){if(b[0]<b[c-1])return 0;else{b[0]=(b[0]-48+b[c-1]-48)%10+48;b=b.substr(0,c-1);--c;}}return 1;}

Try it online!
First time I'm trying something like this so if I formatted something wrong please let me know. I'm not 100% sure on the rules for stuff like using namespace to eliminate the 5 bytes "std::" so I left it in.
Ungolfed:
bool hunger(std::string input)
{
    int count=input.length();
    while (count>1)
    {
        if (input[0]<input[count-1])                         //if at any point the head cannot eat the tail we can quit the loop
                                                             //comparisons can be done without switching from ascii
        {
            return false;
        }
        else
        {
             input[0]=(input[0]-48+input[count-1]-48)%10+48; //eating operation has to occur on integers so subtract 48 to convert from ASCII to a number
             input=input.substr(0,count-1);                  //get rid of the last number since it was eaten
             --count;
        }

    }
    return true;                                             //if the end of the loop is reached the number has eaten itself
}

In theory you also need #include statements.  However, I'd propose programming in the std lib facilities subdialect of C++ with #include "std_lib_facilities.h" prepended, which also does a using namespace std;.  That header was written by the author of the language way back (lastest version is 2010) for students new to C++.

@Yakk Unless you make and publish an interpreter that does this for you, you still need to counts the include of std_lib_facilities.h.

@BenH Welcome to PPCG! You need the count all includes that are required to compile your function. The shortest method I know is #import<string>. Try it online!

@Dennis #!/usr/bin/sh newline gcc -include "std_lib_facilities.h" $@ -- if I find a C++ course that provides that shell script, would that count?

@Yakk Didn't know about that switch. Unlike #include statements, command-line arguments are free because they're essentially a new language. In C++(gcc) -include iostream, this is indeed 144 bytes.

C#, 114 bytes
static bool L(string n){return n.Skip(1).Reverse().Select(x=>x%16).Aggregate(n[0]%16,(h,x)=>h>=x?(h+x)%10:-1)>=0;}

Try it online

C (gcc) (with string.h), 110 108 bytes
c;f(char*b){c=strlen(b);if(!c)return 1;char*d=b+c-1;if(*b<*d)return 0;*b=(*b+*d-96)%10+48;*d=0;return f(b);}

Try it online!
Still relatively new to PPCG, so the correct syntax for linking libraries as a new language is foreign to me. Also note that the function returns 0 or 1 for false/true, and printing that result to stdout does require stdio. If we're being pedantic and the exercise requires output, the language requires stdio that as well.
Conceptually similar to @BenH's answer, but in C, so kudos where they are due (Welcome to PPCG, btw), but using recursion. It also uses array pointer arithmetic, because dirty code is shorter than clean code.
The function is tail recursive, with exit conditions if the first number can't eat the last or the length is 1, returning false or true, respectively. These values are found by dereferencing a pointer to the C-String (which gives a char) at the beginning and end of the string, and doing the comparisons on them. pointer arithmetic is done to find the end of the string. finally, the last char is "erased" by replacing it with a null terminator (0).
It's possible that the modulus arithmetic could be shortened by a byte or two, but I already need a shower after that pointer manipulation.
Ungolfed Version Here
Update: Saved two bytes by replacing c==1 with !c. This is essentially c == 0. It will run an additional time, and will needlessly double itself before deleting itself, but saves two bytes. A side effect is null or zero length strings won't cause infinite recursion (though we shouldn't get null strings as the exercise says positive integers).

You do not need to link libraries in the case of gcc - although warnings will be generated, gcc will happily compile your code without #includes. Also, you could save 4 bytes with -DR=return. Finally, in your test code, the \0s are unnecessary, as the string literally already include them implicitly.

Furthermore, you can return from a function by assigning to the first variable: b=case1?res1:case2?res2:res_else; is the same as if(case1)return res1;if(case2)return res2;return res_else;

Even further, you can shed some extra bytes by not using c: you can determine if the string is zero-length from head-tail.

77 bytes

Didn't realize you could use ternary (conditional) operators in C. Has that always been the case? Regardless, good to know; I'll be using them in the future. Cheers

I'm not quite sure how long they've been a part of the language, but at least since C99.

C# (Visual C# Interactive Compiler), 69 bytes
x=>{for(int h=x[0],i=x.Length;i>1;)h=h<x[--i]?h/0:48+(h+x[i]-96)%10;}

Try it online!
Success or failure is determined by presence or absence of an exception. Input is in the form of a string.
Less golfed...
// x is the input as a string
x=>{
  // h is the head
  for(int h=x[0],
    // i is an index to the tail
    i=x.Length;
    // continue until the tail is at 0
    i>1;)
      // is head smaller larger than tail?
      h=h<x[--i]
        // throw an exception
        ?h/0
        // calculate the next head
        :48+(h+x[i]-96)%10;
}

There are a couple extra bytes to deal with converting between characters and digits, but overall that didn't affect the size too much.

Powershell, 89 bytes
"$args"-notmatch'(.)(.*)(.)'-or(($m=$Matches).1-ge$m.3-and(.\g(''+(+$m.1+$m.3)%10+$m.2)))

Important! The script calls itself recursively. So save the script as g.ps1 file in the current directory. Also you can call a script block variable instead script file (see the test script below). That calls has same length.
Note 1: The script uses a lazy evaluation of logic operators -or and -and. If "$args"-notmatch'(.)(.*)(.)' is True then the right subexpression of -or is not evaluated. Also if ($m=$Matches).1-ge$m.3 is False then the right subexpression of -and is not evaluated too. So we avoid infinite recursion.
Note 2: The regular expression '(.)(.*)(.)' does not contain start and end anchors because the expression (.*) is greedy by default.
Test script
$g={
"$args"-notmatch'(.)(.*)(.)'-or(($m=$Matches).1-ge$m.3-and(&$g(''+(+$m.1+$m.3)%10+$m.2)))
}

@(
    ,(2632, $true)
    ,(92258, $true)
    ,(60282, $true)
    ,(38410, $true)
    ,(3210, $true)
    ,(2302, $true)
    ,(2742, $true)
    ,(8628, $true)
    ,(6793, $true)
    ,(1, $true)
    ,(2, $true)
    ,(10, $true)
    ,(100, $true)
    ,(55, $true)
    ,(121, $true)
    ,(6724, $false)
    ,(47, $false)
    ,(472, $false)
    ,(60247, $false)
    ,(33265, $false)
    ,(79350, $false)
    ,(83147, $false)
    ,(93101, $false)
    ,(57088, $false)
    ,(69513, $false)
    ,(62738, $false)
    ,(54754, $false)
    ,(23931, $false)
    ,(7164, $false)
    ,(5289, $false)
    ,(3435, $false)
    ,(3949, $false)
    ,(8630, $false)
    ,(5018, $false)
    ,(6715, $false)
    ,(340, $false)
    ,(2194, $false)
) | %{
    $n,$expected = $_
   #$result = .\g $n   # uncomment this line to call a script file g.ps1
    $result = &$g $n   # uncomment this line to call a script block variable $g
                       # the script block call and the script file call has same length
    "$($result-eq-$expected): $result <- $n"
}

Output:
True: True <- 2632
True: True <- 92258
True: True <- 60282
True: True <- 38410
True: True <- 3210
True: True <- 2302
True: True <- 2742
True: True <- 8628
True: True <- 6793
True: True <- 1
True: True <- 2
True: True <- 10
True: True <- 100
True: True <- 55
True: True <- 121
True: False <- 6724
True: False <- 47
True: False <- 472
True: False <- 60247
True: False <- 33265
True: False <- 79350
True: False <- 83147
True: False <- 93101
True: False <- 57088
True: False <- 69513
True: False <- 62738
True: False <- 54754
True: False <- 23931
True: False <- 7164
True: False <- 5289
True: False <- 3435
True: False <- 3949
True: False <- 8630
True: False <- 5018
True: False <- 6715
True: False <- 340
True: False <- 2194

Powershell, 90 bytes
No recursion. No file name dependency and no script block name dependency.
for($s="$args";$s[1]-and$s-ge$s%10){$s=''+(2+$s[0]+$s)%10+($s|% S*g 1($s.Length-2))}!$s[1]

A Powershell implicitly converts a right operand  to a type of a left operand. Therefore, $s-ge$s%10 calculates right operand $s%10 as integer and compare it as a string because type of the left operand is string. And 2+$s[0]+$s converts a char $s[0] and string $s to integer because left operand 2 is integer.
$s|% S*g 1($s.Length-2) is a shortcut to $s.Substring(1,($s.Length-2))

Perl 5 -pF, 53 bytes
$F[0]=($F[0]+pop@F)%10while$#F&&$F[0]>=$F[-1];$_=!$#F

Try it online!

Brachylog, 18 bytes
ẹ⟨k{z₁{≥₁+t}ᵐ}t⟩ⁱȮ

Try it online!
Takes three bytes off Fatalize's solution just by virtue of non-deterministic superscriptless ⁱ existing now, but loses another three by doing vaguely Jelly-inspired things with z₁ to avoid using c, g, or even h. (Also inspired by trying, and failing, to use a different new feature: the ʰ metapredicate.)
                 Ȯ    A list of length 1
                ⁱ     can be obtained from repeatedly applying the following
ẹ                     to the list of the input's digits:
 ⟨k{         }t⟩      take the list without its last element paired with its last element,
    z₁                non-cycling zip that pair (pairing the first element of the list with
                      the last element and the remaining elements with nothing),
      {    }ᵐ         and for each resulting zipped pair or singleton list:
       ≥₁             it is non-increasing (trivially true of a singleton list);
          t           take the last digit of
         +            its sum.

PowerShell, 94 91 bytes
for(;$n-and$n[0]-ge$n[-1]){$n=$n-replace"^.",((+$n[0]+$n[-1]-96)%10)-replace".$"}return !$n

Try it online!

Test Script
function f($n){

for(;$n-and$n[0]-ge$n[-1]){$n=$n-replace"^.",((+$n[0]+$n[-1]-96)%10)-replace".$"}return !$n

Remove-Variable n
}
Write-Host True values:
@(2632, 92258, 60282, 38410,3210, 2302, 2742, 8628, 6793, 1, 2, 10, 100, 55, 121) |
    % { Write-Host "  $_ $(' '*(6-$_.ToString().Length)) $(f $_.ToString())" }

Write-Host False values:
@(6724, 47, 472, 60247, 33265, 79350, 83147, 93101, 57088, 69513, 62738, 54754, 23931, 7164, 5289, 3435, 3949, 8630, 5018, 6715, 340, 2194) |
    % { Write-Host "  $_ $(' '*(6-$_.ToString().Length)) $(f $_.ToString())" }

Ungolfed code:
function f ($inVar){
    # While the Input exists, and the first character is greater than last
    while($inVar -and ($inVar[0] -ge $inVar[-1])){

        # Calculate the first integer -> ((+$n[0]+$n[-1]-96)%10)
        $summationChars = [int]$inVar[0]+ [int]$inVar[-1]
        # $summationChars adds the ascii values, not the integer literals.
        $summationResult = $summationChars - 48*2
        $summationModulo = $summationResult % 10

        # Replace first character with the modulo
        $inVar = $inVar -replace "^.", $summationModulo

        # Remove last character
        $inVar = $inVar -replace ".$"
    }
    # Either it doesn't exist (Returns $True), or
    # it exists since $inVar[0] < $inVar[-1] returning $False
    return !$inVar
}

You shouldn't need to check $n[0] in your for statement -- just checking $n should be enough.

You could to use -6 instead -96 because it is enough to calc %10

you could remove return  and save 7 bytes

and I think you should include a parameter declaration to the bytes count. either param($n) or function f($n).

and... the f $_.ToString() is a some cheat if rule is Given a positive integer. Your script should to work with an integer by rule.

@mazzy The poster stated in the comments that you were allowed to use strings, you just weren't allowed to give the input as a list of numbers/strings. I interpreted this as ["1","2","3"] isn't valid input but "123"is. if @VedantKandoi has an issue with it I can definitely change it!


text:
P Pr Pre Pref Prefi Prefix Prefixe Prefixes
Given some finite list, return a list of all its prefixes, including an empty list, in ascending order of their length.
(Basically implementing the Haskell function inits.)
Details

The input list contains numbers (or another type if more convenient).
The output must be a list of lists.
The submission can, but does not have to be a function, any default I/O can be used.
There is a CW answer for all trivial solutions.
This is code-golf, so the shortest code in bytes wins

Example
[] -> [[]]
[42] -> [[],[42]]
[1,2,3,4] -> [[], [1], [1,2], [1,2,3], [1,2,3,4]]
[4,3,2,1] -> [[], [4], [4,3], [4,3,2], [4,3,2,1]]

If a language does not define any types except for characters, can I take input as a string and separate the input by newlines, in the case of a full program?

@NieDzejkob I'm not sure what consensus there is for this case, but the Brainfuck answer seems to do something like that.

Can we expect the list to be null-terminated?

It's especially common in C/C++, main use being strings.

@Rogem If it is that common I think allowing it is reasonable.

Haskell, 20 bytes
Edit: Yet a byte shorter with a completely different scan.
An anonymous function slightly beating the trivial import.
scanr(\_->init)=<<id

Try it online!

Uses =<< for the abbreviation (scanr(\_->init)=<<id) l = scanr(\_->init) l l.
Scans a list l from right to left, collecting intermediate results with the function \_->init.
That function ignores the elements scanned through (they're only used to get the right total length for the collected results), so really iterates applying init to the initial value of the scan, which is also l.

brainfuck, 21 12 bytes
-9 bytes thanks to Arnauld suggesting the separator ÿ instead of newlines
-[[<]>[.>],]

Try it online!
Takes bytes through STDIN with no null bytes and prints a series of prefixes separated by the ÿ character with a leading ÿ character. For example, for the input Prefixes, the output is ÿÿPÿPrÿPreÿPrefÿPrefiÿPrefixÿPrefixeÿPrefixes.
For readability, here's a version with newlines instead.
Explanation:
-              Create a ÿ character in cell 0
 [        ,]   While input, starting with the ÿ
  [<]>           Go to the start of the string
      [.>]       Print the string
          ,      Append the input to the end of the string

This only works on BF implementations with 8-bit, unsigned, wrapping cells.

JavaScript (ES6), 33 bytes
a=>[b=[],...a.map(n=>b=[...b,n])]

Try it online!
How?
+--- a = input array
|
|       +--- initialize b to an empty array and include it as the first entry
|       |    of the output (whatever the input is)
|       |
|       |          +--- for each value n in a[]:
|       |          |
|       |          |        +--- append n to b[] and include this new array in
|       |          |        |    the final output
|       |          |        |
a => [b = [], ...a.map(n => b = [...b, n])]
               |                  |
               +---------+--------+
                         |
      spread syntax: expands all elements of
      the child array within the parent array

wow, that's a whole new level of code explanation, awesome job :O

@BrianH. Thank you! Simple tasks are good opportunities to write detailed explanations that can't be brought up in denser code.

Did you make it by hand? or did you get help from any weird software i've never heard about?

Just Notepad++ with some column mode editing.

CW for all trivial entries
Clean, 19 bytes
Haskell version works in Clean too.
import StdLib
inits

Try it online!
Haskell, 22 bytes
import Data.List
inits

Try it online!
Prolog (SWI), 6 bytes
prefix

Try it online!

So torn - to upvote or not. On the one hand, I appreciate all the built-in solutions in one place. On the other, I really dislike builtins because they're so basic...

Jelly, 3 bytes
ṭṖƤ

Try it online!
How it works
ṭṖƤ  Main link. Argument: A

  Ƥ  Map the link to the left over all non-empty(!) prefixes of A.
 Ṗ       Pop; remove the last element.
ṭ    Tack; append A to the resulting list.

R, 40 39 bytes
function(L)lapply(0:length(L),head,x=L)

Try it online!
-1 byte thanks to digEmAll
The output of R's list type is a bit weird; it uses sequential indexing, so for instance, the output for
list(1,2) is
[[1]]                     # first list element
list()

[[2]]                     # second list element
[[2]][[1]]                # first element of second list element
[1] 1

[[3]]                     # third list element
[[3]][[1]]                # first element of third list element
[1] 1

[[3]][[2]]                # etc.
[1] 2

Taking input as a vector instead gives a neater output format, although then the inputs are not technically lists.

39 using lapply

Japt, 4 bytes
²£¯Y

Try it online!
Explanation:
²       :Add an arbitrary extra item to the end of the array
 £      :For each item in the new array:
  ¯Y    : Get an array of the items that are before it

Python 2, 32 bytes
f=lambda l:(l and f(l[:-1]))+[l]

Try it online!

Also works in Python 3

Perl 6, 13 bytes
{(),|[\,] @_}

Try it online!
To explain:
In Perl 6 you can wrap an operator in square brackets as an alternate way to write a list reduction.  [+] @array returns the sum of the elements in @array, [*] @array returns the product, etc.  You can also precede the operator with a backslash to make a "triangular" reduction, which some languages call "scan."  So [\+] @array returns a list consisting of the first element of @array, then the sum of the first two elements, then the sum of the first three elements, etc.
Here [\,] @_ is a triangular reduction over the input array @_ using the list construction operator ,.  So it evaluates to a lists of lists: the first element of @_, the first two elements of @_, etc.  That's almost what's needed, but the problem calls for a single empty list first.  So the first element of the return list is a literal empty list (),, then the reduction over the input list is flattened into the rest of the return list with |.

O_o what is even happening here

@ASCII-only triangular reduction

JavaScript, 36 bytes
a=>[...a,0].map((x,y)=>a.slice(0,y))

Try it online!

Mathematica, 22 21 bytes
-1 byte thanks to Misha Lavrov!
{}~FoldList@Append~#&

Pure function. Takes a list as input and returns a list of lists as output. I believe this is the shortest possible solution.

We can write the same solution more compactly as {}~FoldList@Append~#&.

@MishaLavrov Thanks! I didn't think to use the curried 1+2-argument form like that.

Husk, 2 bytes
Θḣ

Gets all the ḣeads and then prepends Θ (in this case []):
Try it online!
(needs type annotation for empty list: Try it online!)

Ruby, 31 29 bytes
->a{[a*i=0]+a.map{a[0,i+=1]}}

Try it online!
Explanation:
->a{             # take array input a
  [a*i=0]+       # set i to 0 and add whatever comes next to [[]] (a*0 == [])
  a.map{         # for every element in a (basically do a.length times)
    a[0,i+=1]  # increment i and return the first i-1 elements of a to map
  }
}

MATL, 15 12 bytes
3 bytes saved thanks to @Giuseppe
vin:"G@:)]Xh

Try it at MATL Online.
Due to the way that MATL displays the output, you can't explicitly see the empty array in the cell array. Here is a version that shows the output a little more explicitly.
Explanation
v       # Vertically concatenate the (empty) stack to create the array []
i       # Explicitly grab the input
n       # Compute the number of elements in the input (N)
:       # Create an array from [1, ..., N]
"       # Loop through this array
  G     # For each of these numbers, M
  @:    # Create an array from [1, ..., M]
  )     # Use this to index into the initial array
]       # End of the for loop
Xh      # Concatenate the entire stack into a cell array

use v instead of []. And doesn't : use 1 as the default first argument? So this could be vin:"G@:)]Xh for 12 bytes.

@Giuseppe Thanks! My MATL is a little rusty it seems :(

J, 5 bytes
a:,<\

Try it online!

PowerShell, 65 bytes
param($a)'';$x=,0*($y=$a.count);0..--$y|%{$x[$_]=@($a[0..$_])};$x

Try it online!
PowerShell helpfully unrolls lists-of-lists when the default Write-Output happens at program completion, so you get one item per line. Tack on a -join',' to see the list-of-lists better, by converting the inner lists into strings.
(Ab)uses the fact that attempting to output an empty array (e.g., @()) results in no output, so an empty array input just has '' as the output, since the $a[0..$_] will result in nothing. It will also throw out some spectacular error messages.

Wrapping it in parens instead of assigning it saves 20 bytes. Unless you don't think that counts as returning a list of lists. I've always been fuzzy on that distinction.

@veskah Yeah, that's almost what I had before my edit to this version. The problem with your solution or my earlier solution -- it doesn't return a list-of-lists. TIO1 vs TIO2

K (ngn/k), 8 7 bytes
1_',\0,

Try it online!

This is some kind of voodoo. ,\(,()), in K4. Joining enlisted null along enlisted input? howsitwork?

@streetster () is an empty list. (,()),x prepends it to x. finally ,\  does a concat-scan. the x is omitted to form a composition. note that the trailing , is dyadic, so it's "concat", not "enlist".

@streetster in k4 it can be a byte shorter: 1_',\0, but my parser isn't smart enough to handle this...

Common Lisp, 39 bytes
(defun f(l)`(,@(if l(f(butlast l))),l))

Try it online!
Explanation
(defun f(l)                           )  ; Define a function f
           `(                        )   ; With the list (essentially capable of interpolation), containing:
             ,@                          ;     The value of, flattened to one level
               (if l              )      ;         If l is not the empty list (which is the representation of nil, i.e. the only falsy value)
                    (f(butlast l))       ;         Recurse with all of l but the tail
                                   ,l    ;     The value of l

F#, 53 bytes
I've actually got two pretty similar answers for this, both the same length. They both take a generic sequence s as a parameter.
First solution:
let i s=Seq.init(Seq.length s+1)(fun n->Seq.take n s)

Try it online!
Seq.take takes the first n elements of the sequence. Seq.init creates a new sequence with a count (in this case) of the length of sequence s plus 1, and for each element in the sequence takes the first n elements in s.
Second solution:
let i s=Seq.map(fun n->Seq.take n s){0..Seq.length s}

Similar to before, except it creates a sequence from 0 to the length of s. Then takes that number of elements from s.
Try this online too!

fun s->Seq.map(fun n->Seq.take n s){0..Seq.length s}  saves 1 byte

SWI PROLOG 22 bytes
i(X,Y):-append(X,_,Y).

Brachylog, 9 8 bytes
{∧Ė|a₀}ᶠ

Try it online!
Explanation
{     }ᶠ    Find all:
 ∧Ė          The empty list
   |         Or
    a₀       A prefix of the input

C# (Visual C# Interactive Compiler), 39 bytes
x=>x.Select((_,i)=>x.Take(i)).Append(x)

Try it online!

You need to include the using System.Linq;  in your bytecount. And it seems some of your output logic is in your outputting of the arrays. Because empty array just returns empty array.

@LiefdeWen - my understanding is that since this interpreter includes a reference to System.Linq, I don't have to include this in the byte count. My submission would be considered a different language than say .NET Core. https://github.com/dotnet/roslyn/wiki/C%23-Interactive-Walkthrough - You mention printing which is a separate issue, I'd like to get clarity on this first.

With regards to printing, here is a version that basically dumps the result to the console - https://tio.run/##XY29CsIwGEX3PEXGBGKhtVt/wEHBTdCtFInxKwZrLEmqhdJnj2kV1I733Hs5wiyEkW7TKpFu16q9geanGlKpbM5@wbzMc1zhzHVZ3gV7qEFYQo5M0jEf@BWIpDRYNQ2oM@moSxDyr6IsSmzBWIMzrOCJPwz1CH9zP7C/GEczELKILVk8n3kWsdDTwdtQddfAxYU8uJ6UfvVW08m20/5FKjIiShM0uBc - not as pretty for sure! The question I have is when is it acceptable to use Array vs IList vs IEnumerable.

F# (Mono), 45 bytes
fun x->List.mapi(fun i y->List.take i x)x@[x]

Try it online!
I am not totally sure if this is valid, but it seems like it follows the same "anonymous lambda" syntax that I've seem used in several other languages.

C (gcc), 102 97 bytes
Pretty long, as C quite obviously isn't well-suited to manipulating lists of lists. Dependent on certain behavior; running on some platforms requires changing int to short (for +2 bytes), due to wchar_t being UTF-16 rather than UTF-32. Should work on Linux as-is.
Takes in a pointer to the first element of the input array, the length of the array, and a pointer to the variable in which the pointer to output will be stored. Produces a list of lists such that the first integer in the linear array stores the number of sub-lists. Sub-lists start with the number of elements, and are stored in memory in a contiguous manner.
p(r,e,f,i,x)int*e,**r,*x;{x=*r=malloc(4-++f*~f*2);*x++=f;for(i=0;i<f;x+=++i)wmemcpy(x+1,e,*x=i);}

Try it online!
Degolf
p(r,e,f,i,x) int**r,*e,*x; // Function p(), where r is a pointer to the output variable,
                           // e is a pointer to the input location and f is the size of
                           // the input.
{
  x=*r=malloc(4-++f*~f*2); // Allocate 4*(x+1)*(x+2)/2+4 bytes of memory.
                           // This is the exact amount of memory needed.
  *x++=f;                  // Store n+1 (number of sub-lists) in the first four bytes.
  for(i=0;i<f;x+=++i)      // Iterate over [0, n]->i and
                           // increment the pointer to x by i+1 every iteration.
    wmemcpy(x+1,e,*x=i);   // Set first element at location pointed to by x to i,
                           // then copy i of either 2 or 4 byte elements, depending on
                           // the system wchar implementation, to location pointed to
                           // by x+1.
}

@ceilingcat Thanks, will edit it in later when I get back onto a PC.

Scala, 21 bytes
_.inits.toSeq.reverse

Try it online!
Not quite a trivial answer, since I had to deal with the fact that the inits method returns an iterator in the reverse of the required order.

Not sure if this is valid since this is a function, not a lambda (and you're excluding the function declaration part). Hmmmmmm

@ASCII-only This is Scala's underscore shorthand syntax. It's basically a lambda. Compare to Haskell's sections. See also https://codegolf.meta.stackexchange.com/questions/11223/untyped-functions-in-static-languages

Yes, but it can not be assigned to a variable (lambda function). On the other hand, {_.inits.toSeq.reverse} can.

@ASCII-only Nope, the braces are not needed (though you do need to use val instead of var for some reason): https://tio.run/##JYq9CgIxEAb7e4qvTCAE/KkEBXutLEWOeO7BStiLyXII4rPHqN3MMGUIMdTpeqdBcQwsoKeS3Ar2KeHVAXOIGDc40ePcX7Dd/ehvTWvvWViL16k1n2mmXKgCKbNoFDOaAxc1C4elw8phbW17v8127/oB

Oh wait, you can define functions like variables, nvm

Charcoal, 6 bytes
Ｅθ…θκθ

Try it online! Link is to verbose version of code. Explanation:
 θ      Input array
Ｅ       Map over elements
   θ    Input array
  …     Moulded to length
    κ   Current loop index
        Implicitly print each array double-spaced
     θ  Input array
        Implicitly print

It's possible at a cost of 1 byte to ask Charcoal to print an n+1-element array which includes the input as its last element, but the output is the same, although the cursor position would be different if you then went on to print something else.

05AB1E, 3 bytes
η¯š

Explanation:
η    Prefixes
  š  Prepend
 ¯   Global array (empty by default)

Try it online!

RAD, 7 bytes
(⊂⍬),,\

Try it online!
This also works in Dyalog APL as a function.
How?
This works the same for both APL and RAD, given their close relation.

(⊂⍬) the empty array
, prepended to
,\ the prefixes (which exclude the empty array.)

Groovy, 37 bytes
{x->(0..x.size()).collect{x[0..<it]}}

Try it online!

{it.inits().reverse()} will work once we get groovy 2.5 on TIO

Java 8+, 86 77 bytes
-9 bytes thanks to Kevin Cruijssen (getting rid of the import)!
x->java.util.stream.IntStream.range(0,x.size()+1).mapToObj(t->x.subList(0,t))

Try it online!
Alternative, 65 bytes
The following will print the results to stdout (due to Olivier Grégoire):
x->{for(int i=0;i<=x.size();)System.out.print(x.subList(0,i++));}

Try it online

You can golf it to 77 bytes by just using java.util.stream.IntStream directly and drop the import.

@KevinCruijssen: Oh thanks! I didn't even know that this was possible, that's certainly helpful (at least for golfing purposes).

x->{for(int i=0;i<=x.size();)System.out.println(x.subList(0,i++));} (67 bytes). This prints instead of using streams. Printing is usually the shortest way to output complex structures.

@OlivierGrégoire: In that case you can probably get away with System.out.print since the output is still unambiguous.

@BMO Indeed, that would be possible!

Japt, 5 bytes
Êò@¯Y

Try it online!

brainfuck, 43 bytes
Take a list of non-null characters as input and returns all prefixes separated by newline. Requires double-infinite or wrapping tape.
,>-[+>,]<[-<]<<++++++++++[[<]>[.>]>[-<+>]<]

Try it online!

Another answer outgolfed me by more than a half, because I didn't think about printing output while reading. Of course that method won't work with printing increasing suffixes.

40 bytes with some rearranging

Powershell, 24 bytes
,@()
$args|%{,($x+=,$_)}

Explanation:

The trivial accumulator wrapped to array by unary ,.
The script uses splatting. See parameter @a.

Test script:
$f = {

,@()
$args|%{,($x+=,$_)}

}

@(
    ,( @()        , @() )
    ,( @(42)      , @(@(),@(42)) )
    ,( @(1,2,3,4) , @(@(), @(1), @(1,2), @(1,2,3), @(1,2,3,4)) )
    ,( @(4,3,2,1) , @(@(), @(4), @(4,3), @(4,3,2), @(4,3,2,1)) )
) | % {
    $a,$expected = $_
    $result = &$f @a

    $false -notin $(
        $result -is [array]
        $result.Count -eq $expected.Count
        for($j=0; $j-lt$result.Count; $j++){
            "$($result[$j])" -eq "$($expected[$j])"
        }
    )

    # $result   # uncomment this line to display a result

}

Output:
True
True
True
True

05AB1E, 8 bytes
That was my first succesfull golf! Thanks for being such a nice community!
)UŒ¹g£Xš

Try it online!
Explanation:
)UŒ¹g£Xš
)        : Create an empty list
 U       : Save it to variable ˙X˙
  Œ      : Make the "substrings" of the implicit input
   ¹g£   : Take the first n elements of the result where n is the lenght of input
      Xš : Add the empty list to the beginning

Swift, 60 54 bytes
let f={(i:[Int])in return[[]]+i.indices.map{i[...$0]}}

Try it online!
Defines a function that takes an array of ints and returns an Array of ArraySlices (i.e, they reference the same memory as the input array). To turn into real arrays, it's 67 61 bytes.
let f={(i:[Int])in return[[]]+i.indices.map{Array(i[...$0])}}

Welcome to Code Golf, and nice answer!

Ruby, 34 31 bytes
->l{(0..l.size).map{|i|l[0,i]}}

Try it online!
Thanks @ConorO'Brien!

You can golf this a bit like so: ->l{(0..l.size).map{|i|l[0,i]}}, using [0,i] for indexing instead of .first i

@ConorO'Brien: Thanks a lot! 1 fewer byte than Python now :D

Factor, 63 bytes
USE: fry [ [ dup '[ nip _ swap head ] map-index ] keep suffix ]

Keeps a copy of the input to tack on at the end, like C#.

Z80Golf, 18 bytes
00000000: 2511 00ff 1b1a ffa7 20fa cd03 802b 7730  %....... ....+w0
00000010: f076                                     .v

Try it online!
Takes bytes through STDIN with no null bytes and prints a series of prefixes, each terminated by a null byte.
Source code:
    dec h
start:
    ld de, $ff00
.printloop:
    dec de
    ld a, (de)
    rst $38
    and a
    jr nz, .printloop
    call $8003
    dec hl
    ld (hl), a
    jr nc, start
    halt

FALSE, 57 bytes
1^[$~][\1+^]#%a:0[$a;1->~][0[$@$@>][\$a;\-ø,1+]#\%10,1+]#

Try it online! (you'll have to copy paste the code. Click "Show" and then run)
Like brainf*ck, FALSE only takes one char at a time as input, so this program splits a string into prefixes, separating them with a newline.
Explanation:
1^         {push 1 {counter) and first character onto stack}
[$~][      {while a character is input:}
  \1+^     {add 1 to the counter}
]#

%          {drop truth value from stack}
a:         {define the counter as the variable "a'}
0          {push 0 onto stack (loopvar)}
[$a;1->~][ {while loopvar is less than a-1:}

  0        {push 0 (loopvar2)}
  [$@$@>][ {while loopvar is greater than loopvar2}
    \$a;\- {a-loopvar2 (to get index of char to print)}
    ø,     {copy value at index to top of stack and print}
    1+     {increment loopvar2}
  ]#
  \%       {swap'n'drop (get rid of loopvar2)}
  10,      {print newline}
  1+       {increment loopvar}
]#

A FALSE expert could probably do this using no variables (pure stack) but since I only learnt this language yesterday I think this is alright.

MathGolf, 9 7 6 bytes
hÅ_╡]x

-1 byte thanks to @maxb.
Try it online or verify all test cases.
Explanation:
h        # Push the length of the (implicit) input-array, without popping the array
 Å       # Loop this length amount of times,
         # and do the following two commands each iteration:
  _      #  Duplicate the array at the top of the stack
   ╡     #  Remove the right-most item of the array
    ]    # After the loop, wrap everything on the stack in an array
     x   # Reverse it (and output implicitly)

hÅ_╡]x saves one byte. For doing test suites, just add one input per line, and the code will be executed separately for each input. Check my answer for an example. I should describe that feature better in the docs.

@maxb Thanks, that simplifies the test suite a lot. Need to remember that. And thanks for the golf!

MY, 7 bytes
ωωι0;↑←

Try it online!
Woah ... never thought MY would actually come in handy.
How?
ωωι0;↑←

ω = push(arg[0])
ω = push(arg[0])
ι = push([1 ... pop()])
0 = push(0)
; = push(pop() + pop())
↑ = does the prefixing work by vecifying in a stupid manner.
← output

C# (Visual C# Interactive Compiler), 48 bytes
l=>new int[l.Count()+1].Select((_,n)=>l.Take(n))

Try it online!
Explanation
l=>                                                // Function with list l as argument
   new int[l.Count()+1]                            // A new array (int is shortest type available) of length l + 1
                       .Select((_,n)=>l.Take(n))   // Where every element is mapped to the first n elements of the input list, where n is the index

Lua 5.3, 92 bytes
function f(...)t=...if#t>0then return f({table.unpack(t,1,#t-1)},...)else return{...}end end

Keeps creating a copy of the array-like table with the element at the end removed and prepending it to the varargs until the length of the table is 0, then puts the varargs in a table. Relies on defining the variable f to allow recursion.
Lua 5.1, 87 bytes
function f(...)t=...if#t>0 then return f({unpack(t,1,#t-1)},...)else return{...}end end

unpack is a global variable rather than a member of the table library. 0then is syntactically invalid in Lua 5.1, but strangely not in Lua 5.3.

Pari/GP, 23 bytes
a->[a[1..n]|n<-[0..#a]]

Try it online!

Pip, 16 bytes
{h@<a}M,1+#(h:a)

Try it online!
Explanation
      M            Map
{h@<a}                 Function returning global variable h, cut at index a, and left part taken (0-indexed)
       ,               Range from 1 to
        1+#(   )           1 + the length of
            h:a                Assign global variable h to a, evaulating to the value of h (which is also the value of a - the first parameter to the function)

Similar approach, 22

D, 49 bytes (11 imports, 38 expression)
import std;
alias prefixes = t=>iota(t.length+1).map!(i=>t.take(i));

Try it online!
edit: Do I count the alias prefixes = part? You can use the lambda without it, but you have to add parens to disambiguate, so should I count it as 42?
edit: We now got import std; as a shortcut. That solves things!

I don't program in D, but I think you don't count the alias prefixes.  Python lambdas are very similar and they act in that way.

There is one problem though. I'm pretty sure you need to count the imports.

Wait, none of the others use standard library routines? edit: I feel it'd be kind of silly to make code size dependent on what standard definitions the language chooses to make available by default. That seems more of a judgment of a language's module system than its expressivity.

Though fair enough, the Java example seems to count module names. Bleh. edit: Though it seems pretty nonsensical to count the imports and not the alias, and in any case what about the void main()... seems like it'd just become a boilerplate size contest, rather than expression size.

You don't have to count the main function nor the stdio import (which is only used in the main function), but importing algorithm and range contributes to the score.

Alright.. feels like I'm mostly counting letters in names, but sure.
I think it seems so arbitrary because I'm basically discounting pieces in the middle of the code.

One would count this as if it was import std.algorithm,std.range;t=>(t.length+1).iota.map!(i=>t.take(i))

So, in response to my above comment: this would count as 70 bytes. (Note: a golf was applied changing two imports to a single import)

MathGolf, 7 bytes
hæ_ï<\]

Try it online!
Explanation
h         length of array/string without popping
 æ        start block of length 4
  _       duplicate TOS
   ï      index of current loop, or length of last loop
    <     slice list
     \    swap top elements
      ]   end array / wrap stack in array

Nice 7 byte alternative to my 7-byter I found an hour ago. :) Actually, I see I can golf mine to 6 bytes by changing { to Å. Thanks for the implicit golf. Now I just need to fix the test suite somehow..

You could save a byte for that one by replacing { with Å and removing the }. MathGolf has 1-byte literals for blocks of size up to 8 bytes.

Just edited my comment when I realized that. Just not sure how to fix the test suite..

Clojure, 21 bytes
#(reductions conj[]%)

Gambit Scheme (gsi), 77 72 bytes
(define(p z)(if(pair?(car z))(p(cons(reverse(cdr(reverse(car z))))z))z))

Try it online!
First time using Scheme. It's a function that takes a wrapped list ((list (list 1 2 3 4))) as an argument.

I think you might want to reverse that if test.

@ØrjanJohansen Yep. Thank you.

Google Sheets, 102

Input is in Row 1
A2: COUNTA(1:1)
Output: =ArrayFormula(IF(A2,{T(SEQUENCE(1,A2));IF(SEQUENCE(A2)>=SEQUENCE(1,A2),OFFSET(A1,,,,A2),)},

Output Formatted:
=ArrayFormula(IF(
  A2,
  {
    T(SEQUENCE(1,A2));
    IF(
      SEQUENCE(A2)>=SEQUENCE(1,A2),
      OFFSET(A1,,,,A2),
    )
  },
))

Add++, 14 bytes
L*,¬b[€bFbUBpA

Try it online!
How it works
L		; Lambda function. Takes A as argument
	*,	; Return the enire stack
		; E.g. A = [1 2 3 4]
	¬b[	; Scan pair;	STACK = [[1 [1 2] [[1 2] 3] [[[1 2] 3] 4]]]
	€bF	; Flatten each;	STACK = [[[1] [1 2] [1 2 3] [1 2 3 4]]]
	bU	; Splat;	STACK = [[1] [1 2] [1 2 3] [1 2 3 4]]
	Bp	; Pop each;	STACK = [[] [1] [1 2] [1 2 3]]
	A	; Push A;	STACK = [[] [1] [1 2] [1 2 3] [1 2 3 4]]

Vyxal, 3 bytes
K¾p

Try it Online!

Unfortunately, the results have to contain the empty list.

I'm not happy that the 1 byte answer isn't valid either. But 3 bytes is the best I can think of

@lyxal oh i didn't  notice the empty list requirement before, but we have to accept our fate, whatever

Julia 1.0, 26 bytes
~l=0:length(l).|>i->l[1:i]

Try it online!
alternative solution in Julia 1.6+, 26 bytes:
~l=first.([l],0:length(l))
Try it online!

Pip, 6 bytes
_H,U#_

Anonymous function that takes an iterable and returns a list of iterables. (A full program would be the same number of bytes, but would require flags.) Attempt This Online!
Explanation
    #_  ; Length of function argument
   U    ; Incremented
  ,     ; Range from 0 up to one less than that number, i.e. 0..len
_H      ; For each of those numbers n, get the first n elements of the function argument

Go, 72 bytes
func(I[]int)(o[][]int){for i:=0;i<=len(I);i++{o=append(o,I[:i])};return}

Attempt This Online!
Generic, 77 bytes
func f[T any](I[]T)(o[][]T){for i:=0;i<=len(I);i++{o=append(o,I[:i])};return}

Attempt This Online!

Forth (gforth), 57 bytes
: x here 0 begin 2dup type cr 1+ key dup c, 5 < until ; x

Try it online!
Takes bytes through STDIN and prints a series of prefixes, each terminated by a newline.

Haskell, 27 bytes
i[]=[[]]
i l=i(init l)++[l]

Try it online!

Canvas, 6 5 bytes
）╶［｝）

Try it here!
Outputs to the stack; Linked with a trailing ｒａｗ so that's visible.
)      wrap the (currently empty) stack in an array
 ╶[}   map nothing over the prefixes of the input
    )  wrap the stack (the empty array and the prefixes) in an array

2 bytes without the starting empty array.

Tcl, 81 bytes
set i -1
set a {{}}
foreach _ $argv {lappend a [lrange $argv 0 [incr i]]}
puts $a

Try it online!

Attache, 13 bytes
{_[0...0:#_]}

Try it online!
Explanation
{_[0...0:#_]}
{           }    block taking `_` as input
 _[        ]     index from the input
       0:#_      range from 0 to the length of `_` inclusive
   0...          range from 0 to each number that range, right exclusive

Red, 76 bytes
func[b][a: copy[[]]c: b until[append/only a copy/part b c: next c tail? c]a]

Try it online!

Kotlin, 32 bytes
{l->(0..l.size).map{l.take(it)}}

{ list ->
    (0..list.size).map {  // map over range [0, length of list]
        list.take(it)  // first n items of list
    }
}

Try it online!

Pushy, 7 bytes
1@$O_vI

Try it online!

Tcl, 65 bytes
proc P {L J\ {{}}} {lmap e $L {lappend J [lappend K $e]}
list $J}

Try it online!

str, 6 bytes
e;:dno

Try it online!
Each output line corresponds to an entry in the prefix array.
Explanation
e;:dno
            -- preamble --
e           push empty string
            -- iteration --
  :         append current char to build string
   d        duplicate it
    n       push "\n"
     o      output it
            (implicitly output duplicated entry)

Perl 5 + -a, 24 bytes
say"@F[0..$_]"for-1..$#F

Try it online!

Actually, 13 bytes
;╗ru⌠╜H⌡M[]@o

Try it online!
Explanation:
;╗ru⌠╜H⌡M[]@o
;╗             save a copy of input in register 0
  ru           range(1, len(input)+1)
    ⌠╜H⌡M      for i in range:
     ╜H          first i elements of input
         []@o  prepend an empty list

Elixir, 37 bytes
fn x->Enum.scan [[]|x],&(&2++[&1])end

Try it online!
Looking at other languages, this looks rather verbose, but I'm definitely not an expert in Elixir, so please let me know if I missed something obvious.

APL (Dyalog Unicode), 12 bytes
(0,∘⍳∘≢⊢)↑¨⊂

Try it online!
Prefix tacit function. TIO link has boxing enabled to make the output more readable.
How:
(0,∘⍳∘≢⊢)↑¨⊂ ⍝ Tacit fn, taking a vector as argument, which will be called ⍵ for simplicity.
         ↑   ⍝ Take the first ⍺ (left arg) elements of ⍵
          ¨⊂ ⍝ Since the ⍺ for ↑ is a vector, we enclose the ⍵ and apply ↑ to it for each of the elements in ⍺.
(      ⊢)    ⍝ Use ⍵ as argument for
      ≢      ⍝ Tally; yields the number of elements in ⍵
    ⍳∘       ⍝ Then, yield the range [1..≢⍵]
 0,∘         ⍝ and prepend a 0.

The function returns a vector of vectors, each with the first [0..≢⍵] elements of the argument.

Bash, 34 bytes
I output each list element on a new line as someone else did - bash only has 1-D arrays:
for((;c<=$#;c++)){ echo ${*:1:c};}

Could be 1 byte less but this does not work for null case - don't see why... c++ does not get evaluated...
for((;c<=$#;)){ echo ${*:1:c++};}

This can output text as suggested by OP:
C='echo -n ';A=(${1//[],[]/ });$C[[];for((c=0;c<${#A[*]};)){ B=${A[*]::++c};$C,[${B// /,}];};echo ]

No one should have to decode that. Here is annotated version:
C='echo -n '              # basically a macro to improve my golf
A=( ${1//[],[]/ } )       # convert [,] to spaces - like magic this one
$C[[]                     # echo [[] since every list needs this
for((c=0;c<${#A[*]};)){   # for all elements of list
  B=${A[*]::++c}          # make space separated list of first c elements
  $C,[${B// /,}]          # prefix with ,[ and convert space to comma
}
echo ]                    # terminate list with ]

Reticular, 60 bytes
Bql:D=:D`:E=l[:D`@d]~*[:E`b@qM[$]:D`:E`-*:E`1-:E=]:D`1+*lbo;

Try it online!
Assumes that the input list is at the top of the stack. To test input, run the following code
'1''2''3''4''5'lbBql:D=:D`:E=l[:D`@d]~*[:E`b@qM[$]:D`:E`-*:E`1-:E=]:D`1+*lbo;

Explanation
B                         # Push every element from the input list to the stack.
 q                        # Reverse stack.
  l                       # Push the size of the stack to the stack.
   :D=                    # Save it as the variable D.
      :D`:E=              # Define the variable E = D.
            l             # Push D to the stack.
             [:D`@d]      # Push the function which duplicates the top D items in the stack
                    ~     # Swap the top two items in the stack
                     *    # Call the above function D number of times.

[                          ]            # Push a function that does the following:
 :E`b                                   # Put the top E items in a list.
     @q                                 # Reverse list that is at the top of the stack.
       M                                # Rotate stack so that top of stack -> bottom of stack.
        [$]:D`:E`-*                     # Delete the top D-E items from the stack.
                   :E`1-:E=             # Define E = E - 1.
                            :D`1+*      # Call the above function D+1 number of times.
                                  q     # Reverse stack.
                                   lb   # Put every item in the stack into a list.
                                     o; # Output the resulting list and exit.

Scala, 28 bytes
_.scanLeft(Seq[Int]())(_:+_)

Try it online!
This is longer than the Scala answer that's already here, but uses a different method. Unfortunately, the [Int] must be used to avoid Nothing being inferred.

Factor + grouping.extras, 25 bytes
[ head-clump { } prefix ]

Try it online!
Mostly a built-in. Just have to add the empty list at the beginning.
Compare to a non-trivial answer:
[ dup length [0,b] [ head ] with map ]

Try it online!

Pyth, 6 bytes
Sa._QY

Try it online!

Arturo, 31 29 bytes
$[a][map 0..size a=>[take a]]

Try it

x86 opcode, 11 bytes
xor eax, eax
inc ecx
P:
xchg eax, esi
stosd
xchg eax, esi
stosd
inc eax
loop P
ret

Take ecx(length) esi(input array) edi(output buffer) output (array,length) pairs
Somehow cheaty :)

Thunno, \$ 11 \log_{256}(96) \approx \$ 9.05 bytes
0TzreRz0sAI

Attempt This Online!
Explanation
0TzreRz0sAI  # Implicit input
0T           # Append a 0 (so the length is increased by 1)
  zr         # Length range, [0..len)
    e        # Map over this list:
     R       #   Range from 0 to this number
        sAI  #   Index this into
      z0     #   The input
             # Implicit output


text:
Bracket checking
Consider a string like:
a.push(c.push("a",["ad","bd",2,{"ard",duo}]).pop().replace(2,"tg").enc([3,{2,adf},"atr"],5)

Write a program that will verify whether a string is correctly bracketed. A correctly bracketed string can be defined as one in which all brackets are terminated (closed), and the inner brackets are terminated before outer ones. Below are example strings:
Correctly bracketed:

a.push(a,{b,[c,d]})

Incorrectly bracketed:

a.push(a,{b)}

Your program must be able to deal with the following types of brackets:

Curly (flower) brackets {}
Square brackets []
Parantheses ()

If necessary, the string may contain any of these characters:

Alphabets, uppercase and lowercase (A-Z, a-z)
Numerics (0-9)
Double quotes ("), but not single quotes
Arithmetic operators (+, -, *, /)
Dots (.)

This is code-golf, so the shortest code in terms of bytes wins. The winning answer will be chosen after 7 days from the time of the post.

Related or maybe even a duplicate.

Well written challenge, unfortunate conclusion.


text:
Satisfying Rounding
Satisfying Rounding
You know when you're in science class, and asked to round to 2 sig figs, but your answer is 5.2501...? You should round to 5.3, but that's just so unsatisfying! By rounding to 5.3, you're off by a whole 0.05, which is a large amount compared to 0.1 (the place value you're rounding to)! So help me round in a satisfying way.
To round in a satisfying way, you must round at the first digit you come across that produces a relatively small error - less than half of the maximum error possible when rounding. Basically, you need to round whenever you encounter 0, 1, 8, or 9. If that never happens, return the input as is. Do not round on leading zeroes or ones - that just doesn't feel satisfying.
Input
A string or float value that represents a nonnegative decimal number.
Output
The same decimal number rounded satisfactorily, in either string or float format.
Examples
Input -> Output
0 -> 0
0.5 -> 0.5
0.19 -> 0
0.8 -> 1
5.64511 -> 5.645
18.913 -> 20
88.913 -> 100
36.38299 -> 36.4
621 -> 620
803.22 -> 1000
547.4726 -> 547.4726

This is a code-golf challenge, so shortest code wins!

Sandbox

Are strings such as 036.40000 considered a valid output?

Can we assume that a .0 part will be given for integers? Also, 0 isn't positive.

@EriktheOutgolfer No, you may not - also thanks, changed to nonnegative.

@Arnauld No leading nor trailing zeroes, since that kind of defeats the purpose of rounding.

Is a missing leading 0 acceptable if the integer part is 0?

@EriktheOutgolfer Sure.

So 19 rounds to 20 but 0.19 rounds to 0? Why?

Actually, my code had a bug, and now rounding them as per the question now makes my code golfer, so never mind.

Floating point ought not to be allowed as an input format. Consider the input "6.68". Clearly the answer is 6.7. But if you parse 6.68 as a 64-bit floating point you get 6.67999999999999971578290569595992565155029296875 and the output would become 6.68!

Ruby, 79 77 69 67 65 bytes
->n,z=n+".0"{z[i=z=~/\./]='';n.to_f.round (z=~/(?!^)[01]|8|9/)-i}

Try it online!
Explanation

->n Take input as a string
z=n+".0" Create a temporary string z that is guaranteed to contain a dot and a relevant digit.
i=z=~/\./ Determine the position of the decimal dot in z and assign to i.
z[i]='' Drop the dot so that it doesn't get in the way further on.
z=~/(?!^)[01]|8|9/ Determine the position of non-starting 0-1 or any 8-9, whichever comes first.
(...)-i This difference will be the number of decimal places to keep, negative if we will be rounding left of the dot.
n.to_f.round ... Convert to float and do the rounding.

JavaScript (ES6),  100 99 98  78 bytes
Takes input as a string. Returns a float.
s=>+(0+s).replace(/\d/g,(d,i)=>j&&+d+((n=s[i+!++s[i]])<2&&i?--j:n>7&&j--),j=1)

Try it online!
How?
We first prepend a leading \$0\$ to the input string, so that we're guaranteed to have a digit before a possible leading \$8\$ or \$9\$, that must trigger the rounding right away.
The flag \$j\$ is set to \$1\$ as long as we are looking for a digit on which we can do a satisfying rounding, and set to \$0\$ afterwards.
Because a leading \$0\$ was added to the string that we're walking through but \$s\$ was left unchanged, \$d\$ contains the current character and \$s[i]\$ is pointing to the next character.
We use the following code to load the next digit in \$n\$, skipping a possible decimal separator:
n = s[i + !++s[i]]

Although strings are immutable in JavaScript, the expression ++s[i] will return \$s[i]+1\$ if it contains a numeric value, even though \$s[i]\$ is not actually incremented. Therefore, the expression !++s[i] is evaluated to \$false\$ (coerced to \$0\$) for all digits (including \$0\$) and to \$true\$ (coerced to \$1\$) for the decimal separator ".".
When the rounding occurs, we yield d + --j if the next digit \$n\$ is \$0\$ or \$1\$ (and it's not the leading digit of the original input) and d + j-- if \$n\$ is \$8\$ or \$9\$. Therefore, \$j\$ is set to \$0\$ in both cases but we add \$0\$ to \$d\$ in the first case (rounding down) and \$1\$ in the second case (rounding up).

And the pinball/rubber ball falls into a ditch! :)

Jelly, 34 bytes
;”.ḟ$µ»"”2e€⁽¡XṾ¤;1i1_i”.$_>¥0ɓVær

Try it online!
-1 thanks to Jonathan Allan.

Why ŒV? I think V will work too.

@JonathanAllan Nope. (basically banker's rounding quirks)

Oh, because it's not acting on the input? Try _>¥0ɓVær like mine is (I missed usage of the dyadic quick so thanks too!)

@JonathanAllan Ah, clever usage of chains, thanks.

Jelly,  30  29 bytes
-1 thanks to Erik the Outgolfer (use of dyadic quick ¥ from his answer)
O;0µ_8H1¦%8ỊTḢ_<48TḢƊ_>¥0ɓVær

A monadic link accepting a list of characters which yields a float.
Try it online! Or see the test-suite.
How
First note that the input string is made exclusively from the characters 0123456789. which have ordinals [48,49,50,51,52,53,54,55,56,57,46], which have remainders when divided by eight of [0,1,2,3,4,5,6,7,0,1,6]. The only characters which are between -1 and 1 inclusive are 0, 1, 8, and 9.
Furthermore if we subtract eight from the ordinals ([40,41,42,43,44,45,46,47,48,49,38]) the same (fairly obviously) holds. If we halve these ([20,20.5,21,21.5,22,22.5,23,23.5,24,24.5,19]) the only characters which have remainders when divided by eight which are between -1 and 1 inclusive are 8 and 9.
O;0µ_8H1¦%8ỊTḢ_<48TḢƊ_>¥0ɓVær - Link: list of characters, S
O                             - ordinal (vectorises across S)
 ;0                           - concatenate a zero
                              - (to cater BOTH for no '0', '1', '8', or '9' AND for no '.')
   µ                          - start a new monadic link (call that X)
    _8                        - subtract eight (vectorises across X)
        ¦                     - sparse application...
       1                      - ...to: indices: one
      H                       - ...do: halve (i.e. halve first ordinal)
         %8                   - modulo by eight (vectorises)
           Ị                  - insignificant (abs(v)<=1?) (vectorises)
            T                 - truthy indices
             Ḣ                - head
                    Ɗ         - last three links as a monad (i.e. f(X)):
               <48            -   less than 48? (i.e. was it a '.' in S or the added 0?)
                  T           -   truthy indices
                   Ḣ          -   head
              _               - subtract
                       ¥      - last two links as a dyad
                      < 0     -   less than zero? (1 if so 0 otherwise)
                     _        -   subtract
                         ɓ    - start a new dyadic chain (i.e. f(S,X))
                          V   - evaluate S as Jelly code (i.e. get S as a float)
                           ær - round to the nearest multiple of 10^(-X)

Retina 0.8.2, 75 bytes
^[89]
10
T`d`0`(?<=.)[01].*|(?<=8|9).*
T`89d`0d`.\.?[89]
(\.|(\..+?))0+$
$2

Try it online! Link includes test cases. Explanation:
^[89]
10

Handle the case of a leading 8 or 9.
T`d`0`(?<=.)[01].*|(?<=8|9).*

If there's a non-leading 0 or 1, then zero it and the rest of the string out. Also, if there's an 8 or 9, then leave it, but zero out the rest of the string. (But leave the decimal point unchanged in either case.)
T`89d`0d`.\.?[89]

If there's still an 8 or a 9 at this point, then zero it out, and increment the preceding digit (possibly before the decimal point).
(\.|(\..+?))0+$
$2

Delete trailing zeros if they are after a decimal point, but only delete the decimal point if there are no other digits in between.

C (gcc), 111 102 bytes
g(_,i,j,k)char*_;{for(i=*_<56?*_++:48,j=3;j;j&=k%8>1|(i=*_++)/48*2)putchar(j&1?i+(k=_[*_<48])/56:48);}

Try it online!
//_: input, as string
//i: current digit, rounded if applicable
//j: tracks whether number is rounded, and whether \0 or '.' has been encountered
//k: digit to test rounding (round if k is one of 0,1,8,9)
//'0'==48, '8'==56
g(_,i,j,k)char*_;{
    for(i=*_<56?*_++:48,j=3;                //special case: if first digit is 8 or 9, use a
                                            //placeholder digit with value 0. initialize j.
        j;                                  //only stop execution when number is rounded and
                                            //'.' or \0 has been encountered.
        j&=k%8>1|(i=*_++)/48*2)             //check if execution should stop.
        putchar(j&1?i+(k=_[*_<48])/56:48);  //print '0' if rounding had already been done;
                                            //otherwise, print digit. round up as needed.
}

C# (Visual C# Interactive Compiler), 280 bytes
c=>{int d=c.IndexOf('.');int t=c.IndexOfAny(new char[]{'8','9','0','1'},1);var m=c[0]=='8'||c[0]=='9'?1>0:0>1;var z=decimal.Parse(c);Func<decimal>q=()=>(decimal)Math.Pow(10,m?d<0?c.Length:d:d<0?c.Length-t:d>t?d-t:d-t+1);return m?Math.Round(z/q())*q():t<0?z:Math.Round(z/q())*q();}

Try it online!
It can be shorter if I used doubles instead of decimals, but I used decimals to preserve accuracy, or else a number like 547.4726 would be 547.472595214844.
C# (Visual C# Interactive Compiler), 268 bytes
c=>{int d=c.IndexOf('.');int t=c.IndexOfAny(new char[]{'8','9','0','1'},1);var m=c[0]=='8'||c[0]=='9'?1>0:0>1;var z=float.Parse(c);Func<double>q=()=>Math.Pow(10,m?d<0?c.Length:d:d<0?c.Length-t:d>t?d-t:d-t+1);return m?Math.Round(z/q())*q():t<0?z:Math.Round(z/q())*q();}

Try it online!(Less accurate version)