text:
Lazy Click and Drag
Your task is to write a program or function which, given two nonzero integers x and y, returns a truthy value if the image at coordinates x east and y north of xkcd's click and drag comic is mostly white and a falsey value otherwise.
Specifications

The image should be retrieved from imgs.xkcd.com/clickdrag/[y]n[x]e.png, where [y] and [x] are replaced with the absolute values of the input y and x values.
If x is negative, e should be changed to a w. If y is negative, n should be changed to a s.
If a 404 error is returned, assume the image is mostly white (output truthy) if y is positive and mostly black otherwise. This is because (as far as I can tell) xkcd stores neither completely white regions of the sky nor completely black regions of the ground, leading to less data in their servers and these 404s you must handle. This error handling is not intended to deal with the images not being available.
"white" is defined as rgb #FFFFFF. You may assume that the images are only white(#FFFFFF) and black(#000000), without gray or other colors. "Mostly white" is defined as at least 2097153 pixels of the image are white (because the png the program should retrieve from img.xkcd.com is always 2048x2048 pixels).
The program may have any behavior when dealing with pixels that are not exactly #FFFFFF nor #000000 but must produce the same output as expected for the test cases.

Example
The image at x=2, y=9 should be retrieved from imgs.xkcd.com/clickdrag/9n2e.png and appears as follows (formatted as quote to show border):

It is mostly white, so the program should return a truthy value.
Input / Output
Input should be two integers or a list of two integers representing x and y.
Output should be a truthy or falsy value corresponding to if the image is mostly white.
Input and output should be through any standard I/O method.
Test Cases
Truthy (as (x,y))
2,9
7,-17
9, 5
3, 2
-5, 1
1, 3

Falsy (as (x,y))
3, 1
3, -1
7, -16
2, 1
5, 1
17, -1

@JonathanAllan Yes.

@JonathanAllan I switched the X and Y for that. I will look over any other errors I may have made.

How should we handle the greys? Can we assume that any colour that isn't exactly #fff is black or, alternatively, that any colour that isn't #000 is white?

Those exist? Interesting.

@Shaggy You may have any behavior regarding pixels which are not white nor black. Updating in the question.

Boo-urns to input validation! (handling 404s)

To elaborate on the above: there are 2 situations where a 404 might arise. Either x and/or y are "out of bounds" and therefore the image doesn't exist; that would seem, to me, to be input validation, which, from what I've seen, generally doesn't go down well in code golf. Or the images have been deleted, which we shouldn't have to account for. My apologies for not catching this in Sandbox - I was probably pressed for time - but, given that there are only 3 answers so far, I don't think it's too late to change it, leaving a comment on each answer to notify them.

@Shaggy Xkcd's servers use 404, as far as I can tell, to hold regions of the sky and ground which are all white or all black respectively (Less space than having a fully white image for empty regions of the sky and fully black images for full regions of the ground. See this full map of the comic for reference) These parts are not out of bounds: Even 2n1e gives a 404 error because it is empty sky, not out of bounds. I understand with your second situation - not having any image to look up should not be accounted for.

Ah, OK, I didn't know that. In that case, I suppose, I can see the need for error handling. I would, though, suggest expanding on that point in the spec to include this information.

One more point, again with apologies for not catching it in Sandbox: if an input is negative, is it's sign included in the URL. I'm guessing not but probably best to clarify.

MATLAB, 144 bytes
function r=f(x,y);n=@num2str;r=1;try;r=nnz(imread(['http://imgs.xkcd.com/clickdrag/',n(y),'n'+5*(y<0),n(x),'e'+18*(x<0),'.png'],'png'))>2^21;end

This function takes two arguments x,y. imread reads the image at the given path. In this case we get a black and white image where each pixel (= entry in a matrix) contains the number 0 or 255. To count the white (255) pixels, nnz is used (which conts the number of nonzero entries). To account for possible eerrors, we wrap this call in try/end and predefine the return value to 1 (nonzero numbers are truthy in MATLAB). The change of e.g. n and s depending on the sign of y is done via character arithmetic.

bash, 172 164 158 bytes
t=tr\ \\-0-9
curl imgs.xkcd.com/clickdrag/${2#-}$($t sn<<<${2::1})${1#-}$($t we<<<${1::1}).png|convert - a.pgm
echo $[$??$2>0:`grep -ao ÿ a.pgm|wc -l`>2**21]

This won't work on TIO due to the requirement for internet access.
There's an \xFF byte in the code, which is likely to be mangled due to encodings, so here's a script you can use to run all the test cases locally:
#!/bin/bash

xxd -r >clickdrag.sh <<'end'
00000000: 743d 7472 5c20 5c5c 2d30 2d39 0a63 7572  t=tr\ \\-0-9.cur
00000010: 6c20 696d 6773 2e78 6b63 642e 636f 6d2f  l imgs.xkcd.com/
00000020: 636c 6963 6b64 7261 672f 247b 3223 2d7d  clickdrag/${2#-}
00000030: 2428 2474 2073 6e3c 3c3c 247b 323a 3a31  $($t sn<<<${2::1
00000040: 7d29 247b 3123 2d7d 2428 2474 2077 653c  })${1#-}$($t we<
00000050: 3c3c 247b 313a 3a31 7d29 2e70 6e67 7c63  <<${1::1}).png|c
00000060: 6f6e 7665 7274 202d 2061 2e70 676d 0a65  onvert - a.pgm.e
00000070: 6368 6f20 245b 243f 3f24 323e 303a 6067  cho $[$??$2>0:`g
00000080: 7265 7020 2d61 6f20 ff20 612e 7067 6d7c  rep -ao . a.pgm|
00000090: 7763 202d 6c60 3e32 2a2a 3231 5d         wc -l`>2**21]
end

for x in '2 9' '7 -17' '9 5' '3 2' '-5 1' '1 3' '3 1' '3 -1' '7 -16' '2 1' '5 1' '17 -1'
do
    bash clickdrag.sh $x 2>/dev/null
done

rm clickdrag.sh

Explanation
First, an explanation of how the URL is built:
imgs.xkcd.com/clickdrag/${2#-}$($t sn<<<${2::1})${1#-}$($t we<<<${1::1}).png

Here, ${2#-} removes a leading negative sign from the second command line argument, and ${1#-} does the same for the first. The n/s and e/w are generated, respectively, with the snippets (after expanding $t)
tr '\-0-9' sn<<<${2::1}
tr '\-0-9' we<<<${1::1}

The ${_::1}s take the first character of the appropriate command line argument (which will be - if it is negative and a digit otherwise). The tr command then turns - into s/w and digits into n/e.
The URL is then passed to curl, which retrieves the image:
curl URL|convert - a.pgm

The convert command from ImageMagick turns the difficult PNG format into the much easier PGM, which uses one byte per pixel. It writes to the file a.pgm.
If the URL 404s, the convert command will fail to find an image and exit with a nonzero status code. Thus, we can effectively use $? (exit code of the last command) as an indicator of whether the URL returned a 404. This comprises the remainder of the code:
echo $[$??

If the exit code was nonzero (link was a 404), we simply check whether the y coordinate is positive:
$2>0

Otherwise, we count the number of \xFF bytes (white) in the image and test to see whether it's greater than 221:
:`grep -ao ÿ a.pgm|wc -l`>2**21]

Javascript (ES6), 317 bytes
f=(x,y)=>{l=console.log;c=document.createElement`canvas`.getContext`2d`;i=new Image;i.onload=_=>{c.drawImage(i,0,0,1,1);l(!!c.getImageData(0,0,1,1).data[0])};i.onerror=e=>l(y>=0);i.crossOrigin='anonymous';i.src=`https://crossorigin.me/https://imgs.xkcd.com/clickdrag/${(y<0?y*-1+'s':y+'n')+(x<0?x*-1+'w':x+'e')}.png`}

This works by shrinking the image to an 1*1 pixel, and checking whether the red channel of this pixel is 0 or not (if white it would be 255).
Note that it has a somehow big margin of error for 50 white/50 black cases : on my computer, if there are less than between 50% - 1024px and 50%, it will report as gray, and hence white. But, as long as there is no proof that there is an image in the list with less than 1024 px of difference between black and white, I guess it's still valid.
Ungolfed :

f=(x,y)=>{
  l=console.log; // output in the console since the function is async
  c=document.createElement`canvas`.getContext`2d`;
  i=new Image;
  i.onload=_=>{
    c.drawImage(i,0,0,1,1); // draw resized at 1px*1px
    // is the first red value of the pixel '0' ?
    l(!!c.getImageData(0,0,1,1).data[0])
    };
   // handle 404
  i.onerror= e=> l(y>=0);
  // 56 bytes only for cross-origins...
  i.crossOrigin="anonymous";
  i.src= `https://crossorigin.me/https://imgs.xkcd.com/clickdrag/${
    // there could probably be some out-golfing to do here
    (y<0?y*-1+'s':y+'n') + (x<0?x*-1+'w':x+'e')
    }.png`;
}

Here is a 319 bytes Promise based live version, for better logging of the outputs, since all this is async :

f=(x,y)=>new Promise(l=>{c=document.createElement`canvas`.getContext`2d`;i=new Image;i.onload=_=>{c.drawImage(i,0,0,1,1);l(!!c.getImageData(0,0,1,1).data[0])};i.onerror=e=>l(y>=0);i.crossOrigin='anonymous';i.src=`https://crossorigin.me/https://imgs.xkcd.com/clickdrag/${(y<0?y*-1+'s':y+'n')+(x<0?x*-1+'w':x+'e')}.png`})

var pos = [
// truthy
  {x:2,y:9},
  {x:7,y:-17},
  {x:9,y:5},
  {x:3,y:2},
  {x:-5,y:1},
  {x:1,y:3},
// falsy
  {x:3,y:1},
  {x:3,y:-1},
  {x:7,y:-16},
  {x:2,y:1},
  {x:5,y:1},
  {x:17,y:-1}
  ];
function test(i){
  let p = pos[i];
  let prom = f(p.x, p.y)
  prom.then(r=>{
    console.log(p.x, p.y, ': ', r);
    if(i < pos.length)
      test(++i);
    });
  }
test(0);

And if ever someone find an image with less than 1024px of difference between whites and blacks, here is a 378 bytes version which handles it :
f=(x,y)=>{l=console.log;o=document.createElement`canvas`;w=o.width=o.height=2048;i=new Image;i.onload=_=>{c=o.getContext`2d`;c.drawImage(i,0,0);l(c.getImageData(0,0,w,w).data.reduce((a,v,i)=>(i%4&&v?++a:a),0)/4>w*w/2)};i.onerror=e=>l(y>=0);i.crossOrigin='anonymous';i.src=`https://crossorigin.me/https://imgs.xkcd.com/clickdrag/${(y<0?y*-1+'s':y+'n')+(x<0?x*-1+'w':x+'e')}.png`}

Nice idea, shrinking the image to a single pixel (although I can't test how accurate it is on my phone). Few things: You don't need to handle errors and your function doesn't need to log the result, simply output it.

Oh, wait, in this case we do need to handle errors. Boo-urns to input validation!

@Shaggy, I have to admit I didn't really tested for exactly 2097152blacks vs 2097152 whites, and I guess that results may vary across devices and implementations, but as long as nobody shows me a perfectly 50/50 images in xkcd where it fails, I guess it holds, right ? And for the console.log, it's because the function is async... I could have returned a promise, but at the cost of 2 bytes (added it anyway though).

So after testing, there is a somewhat large gray area around 50/50 where the pixel will be set to 128,128,128, and hence my code will see it white, but once again, I'm waiting for someone to find an image in the list which would fall into this gray area.


text:
Does it repeat?
A string of characters repeats if it contains two consecutive substrings that are equivalent.
For example, 2034384538452 repeats as it contains 3845 twice, consecutively.
Therefore, your challenge is to decide whether a string contains a repeating substring. You may take the input as a string or an array of characters.
You will never receive an empty input, and the length of the substring (if it exists) may be 1 or more.
I use 1 and 0 here as my truthy and falsy values, but you may use different values, as long as they are truthy and falsy in your language.
Examples:
abcab -> 0
bdefdefg -> 1
Hello, World! -> 1
pp.pp/pp -> 1
q -> 0
21020121012021020120210121020121012021012102012021020121012021020120210121020120210201210120210121020121012021020120210121020121012021012102012021020121012021012102012101202102012021012102012021020121012021020120210121020121012021012102012021020121012021020120210121020120210201210120210121020121012021020120210121020120210201210120210201202101210201210120210121020120210201210120210121020121012021020120210121020121012021012102012021020121012021020120210121020120210201210120210121020121012021020120 -> 0

(The last example was generated from the amount of ones between each zero in the Thue-Morse sequence)

Can I use inconsistent values, as long as they're still appropriately truthy or falsey?

@EriktheOutgolfer Of course

@trichoplax I think he means consecutive subsequences of length >= 1.

@EriktheOutgolfer "consecutive" was the word I missed. Thank you - it makes perfect sense now.

Can we output 1 for falsey and 0 for truthy instead?

@KritixiLithos Only if it's truthy and falsy in your language.

I'm surprised this isn't a dupe.

@Shaggy, so am I, but it doesn't seem to be.

Why is the last one falsey? It contains 210 repeatedly.

@spraff But not consecutively.

I'm not sure I understand. Does subsequence mean non-empty substring? Does consecutive mean adjacent?

@Dennis Consecutive means adjacent. Sub-sequence means non-empty sub-string.

@Gryphon, I was thinking in the broader terms of "Execute a RegEx test in your chosen language".

Can we assume printable ASCII?

@Titus Yes, that would make sense.

Retina, 6 bytes
(.+)\1

Try it online!
Positive value for truthy; zero for falsey.
How it works
Returns the number of matches of the regex /(.+)\1/g.

Brachylog, 3 bytes
s~j

Try it online!
s~j
s    exists a sublist of input
 ~j  which is the result of a juxtaposition of something

Jelly, 6 5 bytes
Ẇµ;"f

This is a full program. TIO can't handle the last test case without truncating it.
Try it online! (last test case truncated to 250 digits)
How it works
Ẇµ;"f  Main link. Argument: s (string)

Ẇ      Words; generate all substrings of s.
 µ     New chain. Argument: A (substring array)
  ;"   Vectorized concatenation; concatenate each substring with itself.
    f  Filter; keep "doubled" substrings that are also substrings.
       This keeps non-empty string iff the output should be truthy, producing
       non-empty output (truthy) in this case and empty output (falsy) otherwise.

Mathematica, 32 bytes
StringMatchQ[___~~x__~~x__~~___]

Doesn't this require that the repeating string subsegments be adjacent?

@Svetlana, you are correct!  I hadn't  taken abcab-> 0 into account.

StringContainsQ[x__~~x__] and !StringFreeQ[#,x__~~x__]& are both shorter.

Java, 27 bytes
a->a.matches(".*(.+)\\1.*")

Pretty much a duplicate of the Retina answer, but there's no way Java's getting any shorter.

05AB1E, 5 bytes
Œ2×åZ

Try it online!
Outputs 1 as truthy value and 0 as falsy value
Explanation
Œ2×åZ
Œ     # Substrings of input
 2×   # duplicate them (vectorized)
   å  # Is the element in the input? (vectorized)
    Z # Maximum value from list of elements

Python, 38 bytes
import re
re.compile(r'(.+)\1').search

Try it online!
Yawn, a regex. Checks if the string contains a string of one of more characters .+ followed by that same string that was just captured. The output search object is Truthy if there's at least one match, as can be checked by bool.
Using compile here saves over writing a lambda:
lambda s:re.search(r'(.+)\1',s)

Python, 54 bytes
f=lambda s:s>''and(s in(s*2)[1:-1])|f(s[1:])|f(s[:-1])

Try it online!
Searches for a substring that is composed two or more equal strings concatenated, as checked by s in(s*2)[1:-1] as in this answer. Substrings are generated recursively by choosing to cut either the first or last character. This is exponential, so it times out on the large test case.
Near misses:
f=lambda s,p='':s and(s==p)*s+f(s[1:],p+s[0])+f(s[:-1])
f=lambda s,i=1:s[i:]and(2*s[:i]in s)*s+f(s[1:])+f(s,i+1)

The first one doesn't use Python's in for checking substrings, and so could be adapted to other languages.

Pyth - 10 9 8 bytes
f}+TTQ.:

Returns a list of all the repeating substrings (which if there aren't any, is an empty list, which is falsy)
Try It
Explanation:
f}+TTQ.:
      .:    # All substrings of the input (implicit):
f           # filter the list of substrings T by whether...
  +TT       # ...the concatenation of the substring with itself...
 }   Q      # ...is a substring of the input

If you assume that the input is in quotes f}+TTQ.: works from 1 Byte less:  link

PHP, 32 bytes
<?=preg_match('#(.+)\1#',$argn);

Try it online!
PHP, 38 bytes
<?=preg_match('#(.+)(?(1)\1)#',$argn);

Try it online!

Cheddar, 60 bytes
n->(|>n.len).any(i->(|>i).any(j->n.index(n.slice(j,i)*2)+1))

Try it online!

You can golf: @.test(/(.+)\1/)

@Downgoat You should just submit that as another answer, really.

Python 3, 73 66 bytes
-7 bytes thanks to @LeakyNun
lambda s:any(2*s[j:i]in s for i in range(len(s))for j in range(i))

Try it online!

71 bytes: f=lambda s:s and(any(s[:i]*2 in s for i in range(1,len(s)))or f(s[1:]))

66 bytes: lambda s:any(2*s[j:i]in s for i in range(len(s))for j in range(i))

Perl 6, 11 bytes
{?/(.+)$0/}

Test it
Expanded:
{        # bare block lambda with implicit parameter ｢$_｣

  ?      # Boolify the following
         # (need something here so it runs the regex instead of returning it)

  /      # a regex that implicitly matches against ｢$_｣
    (.+) # one or more characters stored in $0
     $0  # that string of characters again
  /
}

PHP, 32 bytes
<?=preg_match('#(.+)\1#',$argn);

Run as pipe with -F. Sorry Jörg, I hadn´t noticed You had posted the same.
non-regex version, 84 82 bytes
    for($s=$argn;++$e;)for($i=0;~$s[$i];)substr($s,$i,$e)==substr($s,$e+$i++,$e)&&die

exits with return code 0 for a repeat, times out (and exits with error) for none. Run as pipe with -nr.
assumes printable ASCII input; replace ~ with a& for any ASCII.

Japt, 8 + 1 = 9 8 bytes
f"(.+)%1

Try it online. Outputs null for falsy, and an array containing all the repeating strings for truthy.
Explanation
 f"(.+)%1
Uf"(.+)%1" # Implicit input and string termination
Uf         # Find in the input
  "(.+)%1" #   a sequence followed by itself
 f         # and return the matched substring
           # output the return value

Inconsistent output values are permitted so you could use è to return the number of matches and drop the flag.

Yeah. I could also just drop the flag to return the match itself, since no match returns null, which is falsy.

For input 00, it outputs 00. Are you sure this is truthy in Japt?

@Okx The string "00" is.

@Okx; try this. The -Q flag "prettyprints" the output so you can see that it's an array containing a single string.

JavaScript (ES6), 19 bytes
s=>/(.+)\1/.test(s)

How about /(.+)\1/.test?

That's what I have, @Luke.

@Shaggy I believe he means /(.+)\1/.test itself as the complete submission.

@Luke /(.+)\1/.test is unbound (has no this). f=/(.+)\1/.test;f('aa') wouldn't work, for example. You would need /./.test.bind(/(.+)\1/)

You can golf to: ::/(.+)\1/.test (15 bytes)

@Downgoat, could you elaborate? How would input be passed?

@Shaggy it's a function: let f= ::/(.+)\1/.test then you do f("goatgoat")

@Downgoat: Ooo, I like the potential this has. Thanks for bringing it to my attention. I'll look into in more depth when I get back to a computer in the morning.

@Shaggy I made a golfing post about the bind operator if you want to learn about it. It requires ES7 though so if you're using TIO you'll have to select Babel node

@Downgoat: Hmm, it's not working on TIO (assuming I've entered everything correctly; haven't used TIO before) nor does it work in any browsers I currently have access to.

Pyth, 15 bytes
.E.nm.bqNYtdd./

Try it!

V, 6 bytes
ø¨.«©±

Try it online!
Test Suite!
The program outputs 0 for falsey values, and a positive integer for positive values.
(Note that there was a small bug, so I had to gain 1 byte. Now after the bugfix, I will be able to replace .« with \x82)
Explanation
ø                     " This is a recent addition to V. This command takes in a regex
                      " and replaces the line with the number of matches of the regex
 ¨.«©±                " The compressed regex. This decompresses to \(.\+\)\1

Cheddar, 16 bytes
@.test(/(.+)\1/)

This is a function. Try it online!

Ruby -n, 10 bytes
Takes input on stdin. Prints the index of the first repeated substring for truthy and nil for falsey.
p~/(.+)\1/

Attempt This Online!

source: Stack Exchange

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

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

sort: votes


text:
Prime Factor Random Numbers!
Task:
Given two positive integers, generate a random integer between them (inclusive) and then output all its prime factors.
Examples:
Input:   Random Number:     Output:
1,2      2                  [2]
12,46    18                 [2,9]
142,17   40                 [2,2,2,5]

Scoring:
This is code-golf so the least bytes wins!

05AB1E, 4 bytes
Ÿ.RÒ

Explanation:
Ÿ       Create a list [a .. b]
 .R     Pick a random element
   Ò    Prime factors.

Try it online!

Jelly, 5  4 bytes
rXÆf

Try it online!
How it works
rXÆf
r     inclusive range
 X    random element's
  Æf  prime factorization

-1 byte thanks to @LeakyNun

4 bytes: rXÆf

Thanks. I thought there would be a problem with range using the first argument and the output of X applied to the second argument.

The 21 rule only applies in monadic chains.

Mathematica, 38 bytes
#&@@@FactorInteger@RandomInteger@{##}&

Pyth, 4 bytes
PO}F

Test suite.

Pyffman 1, 90 80 bytes
This is a joke language that was published today (but before the challenge!). It is based on compressing Python using a pre-made Huffman code based on a corpus of golfed Python. Since the code doesn't really consist of bytes (it's bit-based, due to its huffmannness), I give you here the hexdump obtained using xxd.
00000000: 9c23 9c8f f5fe 9e1d 744a 4ac4 860f 2fcb  .#......tJJ.../.
00000010: 1218 3cbf 70d5 9577 b8cb 4059 44a4 2dbf  ..<.p..w..@YD.-.
00000020: fbaa 9763 4a75 bbbb 90e1 7ac8 410f fbba  ...cJu....z.A...
00000030: 0c91 a0d8 528d dde3 8fd9 0e19 0c56 2ca6  ....R........V,.
00000040: c699 893b 9e1b bc47 fb29 b1a6 624e 79e8  ...;...G.)..bNy.

(The original Python code this is based on is 164 158 bytes.)

PHP, 79 bytes
for($a=rand($argv[1],$argv[$i=2]);1<$a;)$a%$i?$i++:$a/=$i+!$r[]=$i;print_r($r);

Try it online!

MATL, 5 bytes
SYrYf

Try it at MATL Online
Explanation
        % Implicitly grab input as a 1 x 2 array
S       % Sort the input such that the lower end of the range comes first
Yr      % Generate a random integer in this range
Yf      % Compute it's prime factors
        % Implicitly display the result

CJam, 13 bytes
{$~),\,-mRmf}

Anonymous block that expects an array of two numbers in the stack and replaces it by an array with the output.
Try it online!
Explanation
{       e# Begin block
  $     e# Sort array
  ~     e# Split into the two numbers, a and b, where b is greater
  )     e# Increment b
  ,     e# Range from 0 to b
  \     e# Swap
  ,     e# Range from 0 to a-1
  -     e# Set difference: range from a to b
  mR    e# Random choice
  mf    e# Array of prime factors
}       e# End block

Japt, 7 6 bytes
óV ö k

Try it online!
Explanation
oVÄ ö k
oVÄ        range of integers between first input and second input + 1
    ö      get a random item from the array
      k    return all prime factors

Saved a byte thanks to ETHproductions

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


text:
I text the correct combo of ones and zeros
I recently listed to the song I'm a Textpert about texting while driving and one particular line in the song inspired this challenge.

I never stoop so low as to text photos / Instead I text the correct combo of ones and zeros

Now obviously, this would be an almost impossible thing to do in ones head and so you should help textperts world wide by coding a program to do the same thing.
Your job is to take the name of an image file with the dimensions 500x500 pixels and output the file as binary. You may also take an image as input, if you language supports it.
You may use image files with the extensions

.jpg
.png
.gif
.bmp
.svg

Allow me to demonstrate how to convert an image into binary, for those who don't understand what I mean.
Step 1
Take the first pixel in the file and retrieve its RGB value as 3 decimal numbers: R, G and B. Let's assume, for example, that the first pixel is 255,0,0 (red).
Step 2
Convert each number into its 8-bit binary representation and concatenate into a single 24-bit number. For the example, this yields 111111110000000000000000
Step 3
Add this 24-bit number to the final output. Therefore, the final output should be 6000000 digits long and should consist of entirely 1 and 0
This is a code-golf so shortest code wins!

Can you please specify the input. Is the filename to work on the only possible input or can languages which allow images as input use that?

What kind of image formats need to be supported? Can I choose (or invent) an image format?

Additionally for output do you want it to output the ones and zeros to standard output (does this need to be a string or can it be a array of integers) or actually create a new file with the data in it?

@IanMiller output can be any accepted method here and input can either be a file name or an image, if you support that.

Do you have any testcases?

@EriktheOutgolfer no as I don't have a piece of code to do them for me. Feel free to edit any in if you want to though

Should the output be row major or column major?

@Suever either is fine

Pyth, 14 13 bytes
-1 byte thanks to Erik the Outgolfer (z can be removed for implicit input).
sm.[\08.Bd.n'

Explanations
sm.[\08.Bd.n'

            '    # Open the path/URL given as implicit input. Return list of color triples for color images: [(255, 125, 23), ...]
          .n     # Flatten the list
 m     .Bd       # For each element of the list, convert to binary
  .[\08          # Pad with zeros on the left up to 8 characters
s                # Concatenate the list of bytes

Unfortunately, because of safety reasons, that cannot be tested with the online interpreter; you will have to clone Pyth to test it on your own computer.

You can assume quoted input and remove z.

MATL, 13 12 bytes
YiH&!8&YB!1e

Accepts a filename as a string as input. The output 24-bit numbers are displayed in row-major order.
Unfortunately this doesn't work in the online interpreters for security reasons. Here is a screenshot of it working on my local machine

Here is a slightly modified version in which I manually create a 2 x 2 x 3 image and then use (almost) the same code to process it.
Explanation
        % Implicitly grab input as a string
Yi      % Read in as an M x N x 3 image
H&!     % Permute the dimensions of the image to be 3 x N x M
8&YB    % Convert to a binary string using 8 bits for each element
!       % Transpose the result
1e      % Reshape to a row vector
        % Implicitly display the result

Mathematica, 103 bytes
F=Flatten;Export["x.txt",FromDigits@F[IntegerDigits[#,2,8]&/@F[ImageData[Import["x.bmp"],"Byte"],1],2]]

takes an image x.bmp (or any other) and converts it to x.txt file

Instead of PadLeft, you could use the third argument of IntegerDigits (i.e. IntegerDigits[#,2,8]&

you are absolutely right! I had forgotten I could use this!

The only  mistake was the missing "Import[]" because I was testing it with an image.Everything works fine now. Are you testing the updated code (?) cause I don't use PadLeft

Oops, I hadn't refreshed so I was looking at an old version.

Based on the rules you could save a bunch of bytes by writing it as a function which inputs an image and outputs to standard output rather than using Import`Export`.

C#, 309 bytes
My second code golf, if you can't tell.
Takes an image x.jpg...
using System;using System.Drawing;using System.Linq;class Program{static void Main(string[]a){Bitmap b=(Bitmap)Image.FromFile("x.jpg");Console.WriteLine(string.Join("",from i in Enumerable.Range(0,250000)select Convert.ToString(Convert.ToInt32(b.GetPixel((int)Math.Floor((double)i/500),i%500).Name,16),2)));}}

Nice attempt and welcome to the site! I don't know C# so can't give you any golfs but I'm sure others will!

Octave, 46 bytes
@(x)dec2bin(permute(imread(x),[3,1,2]),8)'(:)'

Creates an anonymous function named ans that can be called with either a filename (ans('file.png')) or a URL (ans('http://image.png'))


text:
Get me back down to 1 rep!
This is not an invitation for you to downvote everything I've posted. Just sayin' ;)
Challenge
Figure out how I can get myself back down to 1 reputation.
Details will follow input format, then followed by output.
Input
Input will consist of the my current reputation, the number of questions I have posted with an accepted answer (that is not my own), the number of questions I have posted without an accepted answer that have a valid answer that is not my own, and the number of answer downvotes that I have cast.
Details
Accepting an answer that is not my own gives me 2 rep. Unaccepting an answer takes away 2 rep from me. Undownvoting an answer gives me 1 rep (we assume that all of my answer votes are not locked in at the moment), and downvoting an answer makes me lose 1 rep (we assume there are enough answers on PPCG for me to not care about the number of answers that I can downvote). We also ignore potential serial vote reversal. Most of my reputation is going to have to be given away by bounties because I don't want to go around downvoting 5000 answers.
The challenge is to find the shortest way to get me back down to 1 rep using the shortest code. Please keep in mind that I need at least 125 rep to downvote and at least 75 rep to start a bounty. By "shortest way", I mean the way requiring the least actions, where each accept and downvote and their reverse actions and each bounty is a separate action. Note that it is impossible to award a bounty of more than +500 rep at once. Also note that you can only give out bounties in 50 rep increments.
If there is no way to get back down to 1 rep, then output some consistent error message. The error message may be output through crashing.
Output
Output the number of undownvotes, downvotes, accept-votes, unaccept-votes, and bounty actions I need to perform in any consistent order in any reasonable list format.
Test Cases
reputation, accepted_answers, no_accept_questions, answer_downvotes -> accepts, unaccepts, downvotes, undownvotes, bounties

101, 3, 2, 10 -> 0, 0, 0, 0, 1 // This one's easy, just give out a 100 rep bounty.
102, 3, 2, 10 -> 0, 1, 0, 1, 1 // Unaccept to get to 100, then undownvote to get to 101, then give a +100 bounty
103, 3, 2, 10 -> 0, 1, 0, 0, 1 // First unaccept one of those answers and then give out a 100 rep bounty or vice versa
3, 1, 0, 0 -> 0, 1, 0, 0, 0 // Unaccept that answer and lose the 2 rep
1000, 0, 1, 0 -> 1, 0, 1, 0, 2 // Accept an answer to get to 1002, then downvote an answer to get to 1001, then give out two +500 bounties

Rules

Standard Loopholes Apply
"Post a bunch of spam and get suspended" is not an answer, nor is anything similar
In the case of a tie between shortest methods, output one possible shortest method
This is code-golf, so the shortest code in bytes wins!

1.Avocad 1.52.??? 2.Profit!

Aw, you already covered the 0 byte solution of getting yourself suspended!

@Shaggy One step ahead of y'all! ;)

Mathematica, 302 bytes
Golfed version:
Unprotect@Null;Null=0;f[1,_,_,_]={,,,,};f[r_,a_,n_,d_]:=(f[r,a,n,d]=l={∞,,,,};f[r,a,n,d]=#&@@MinimalBy[{If[r>74,{,,,,1}+f[r-50Min[⌈r/50⌉-1,10],a,n,d],l],If[r>124,{,,1,,}+f[r-1,a,n,d+1],l],If[d>0,{,,,1,}+f[r+1,a,n,d-1],l],If[a>0,{,1,,,}+f[r-2,a-1,n+1,d],l],If[n>0,{1,,,,}+f[r+2,a+1,n-1,d],l]},Tr])

Normal version:
Unprotect@Null; Null = 0;
f[1, _, _, _] = {, , , ,};
l = {\[Infinity], , , ,};
f[r_, a_, n_, d_] := (
  f[r, a, n, d] = l;
  f[r, a, n, d] = # & @@ MinimalBy[{
      If[r > 74, {, , , , 1} +
        f[r - 50 Min[\[LeftCeiling]r/50\[RightCeiling] - 1, 10], a, n,
          d], l],
      If[r > 124, {, , 1, ,} + f[r - 1, a, n, d + 1], l],(*
      downvote one more *)
      If[d > 0, {, , , 1,} + f[r + 1, a, n, d - 1], l],
      (* un-downvote *)
      If[a > 0, {, 1, , ,} + f[r - 2, a - 1, n + 1, d], l],
      (* un-accept. -2 rep *)
      If[n > 0, {1, , , ,} + f[r + 2, a + 1, n - 1, d], l]
      (* accept. +2 rep *)
      }, Tr]
  )

Note:

Test this on https://sandbox.open.wolframcloud.com/ - paste the code, press Shift+Enter, then enter f[101,3,2,10] for example for first test case, then press Shift+Enter.
Use Block[{Null=0}, ...] can save some bytes, but I haven't test that.
Sometimes $IterationLimit=$RecursionLimit=∞ is necessary to get correct result.
The function will return {∞,0,0,0,0} or similar (that is, the sum of elements in list is infinite) when it is impossible, and a list with format similar to that in the sample output when it is possible.


text:
Today in the YOLD
The Discordian calendar is an alternative calendar used by Discordians.

The discordian year has 5 seasons, each lasting 73 days: Chaos, Discord, Confusion, Bureaucracy, and The Aftermath.
The discordian week has 5 days: Sweetmorn, Boomtime, Pungenday, Prickle-Prickle, and Setting Orange. Every year begins with Sweetmorn (and in Chaos).
Every fourth year (which happens to align with Gregorian leap years), an extra day is inserted between Chaos 59 and Chaos 60 called St. Tib's Day. It is outside of the Discordian week, meaning the day after St. Tib's Day will be Setting Orange, the day before Prickle-Prickle.
The Gregorian and Discordian calendars line up; both start on the same day, which is called January 1st in the Gregorian calendar, and Chaos 1 in the Discordian one.
The first Year of Our Lady of Discord (YOLD 1) was 1166 BC in the Gregorian calendar, meaning this year (2017 AD) is YOLD 3183.
The Discordian calendar also has holidays, but they are not important for this challenge and you should not output them or anything about them.

Write a program or function that outputs or returns today's date (at the time of execution):
Today is Boomtime, the 16th day of Confusion in the YOLD 3183

The format is "Today is $day_of_the_week, the $ordinal day of $season in the YOLD $year", where $day_of_the_week is the capitalized (title-case) day of the week, $ordinal is the day of the season as an ordinal (1st, 2nd, 3rd, 4th, ...), $season is the capitalized (title-case) season, and $year is the year.
If your program or function is executed on St. Tib's Day, it should instead output or return "Today is St. Tib's Day in the YOLD $year".
Rules:

Standard loopholes apply.
If your language of choice has no way of getting the current date, it may also take the current Gregorian date in any reasonable format as input.
This is code-golf, the shortest code (per language) wins.
Trailing whitespace is okay.
Capitalization matters.
Calling ddate in any way is banned
Your program should be guaranteed to work from 3067 to 3265 YOLD (1901 to 2099 AD), outside that range it can give incorrect values

See also:

Malaclypse The Younger. "Principia Discordia, Or How I Found Goddess And What I Did To Her When I Found Her". p. 00034
ddate(1)
Sandbox post for those who can see it

discord is a cool instant messaging client

I guess "St. Tib's Day" is not in Chaos either (i.e. the day-of-year mod 73 wont give the seasons accurately year-in-year-out)?

@JonathanAllan Yes, St. Tib's Day is outside the seasons.

I think today is 16th day of Confusion? What date does the example represent?

unrelated

@user202729 Yes, the date in the example is from when I originally wrote the challenge, I will update it to show today's date, which is indeed the 16th day of Confusion.

Was this sitting in the Sandbox for a while? If not, it may be a dupe; I've definitely seen this before.

@Shaggy It was in the Sandbox for about a month, and I looked for dupes but couldn't find any.

That explains it, so; I would have seen it in the Sandbox.

To be clear, as you require the current date, there is no need to handle gregorian years outside 1901 to 2099? The relevance of this is that turn of the century years such as 1900 and 2100 are not leap years, unless they are divisible by 400 (as 2000 was.)

@LevelRiverSt Your code should be able to run on any date. The only exception I'm willing to make is that it doesn't need to run when your language's native date type (if any) overflows: For example, if your native date type (that you use) uses a signed 32-bit integer, then your program doesn't have to work after 18th of January 2038.

@L3viathan in that case (for those using a language with large native type) can you clarify a) how to handle turn of the century years that aren't leap years in the gregorian cal as "every 4th year" of the discordian cal contradicts with "aligns with the gregorian"  b) how to handle years before introduction of the gregorian cal. I was suggesting the max range which is properly defined by your current spec. If you reject this, you should define what the program should do outside that range. Also you should avoid invalidating the existing answer. https://en.wikipedia.org/wiki/Gregorian_calendar

@LevelRiverSt The Principia is a bit unclear on that, but it fully aligns with the Gregorian calendar meaning the full leap-year rules apply. However, I don't want to invalidate the Mathematica answer (which appears to not take this into account), so I'll restrict the required range to 1901–2099..

Bash, 5 bytes: ddate.

Mathematica, 403 401 bytes
Version to count number of bytes: (removed spaces and newlines - unfortunately this part is quite hard)
"Setting Orange"["Sweetmorn","Boomtime","Pungenday","Prickle-Prickle"][[#~Mod~5]]<>", the "<>SpokenString@p[[Mod[#,73,1]]]~StringExtract~2<>" day of "<>{"Chaos","Discord","Confusion","Bureaucracy","The Aftermath"}[[⌈#/73⌉]]&;
Row@{"Today is ",#2," in the YOLD ",1166+#}&[#,If[4∣#,If[#2>60,%[#2-1],If[#2<60,%@#2,"St.Tib's Day"]],%@#2]]&@@FromDigits/@DateString@"ISOOrdinalDate"~StringSplit~"-"

Version to read:
"Setting Orange"["Sweetmorn", "Boomtime", "Pungenday",
     "Prickle-Prickle"][[#~Mod~5]] <>
   ", the " <>
   SpokenString@p[[Mod[#, 73, 1]]]~StringExtract~2 <>
   " day of " <>
   {"Chaos", "Discord", "Confusion", "Bureaucracy",
     "The Aftermath"}[[Ceiling[#/73]]] &;
Row@{
      "Today is ",
      #2,
      " in the YOLD ",
      1166 + #
      } &[#,
   If[4 ∣ #,
    If[#2 > 60, %[#2 - 1],
     If[#2 < 60, %@#2, "St.Tib's Day"]
     ], %@#2
    ]] & @@ FromDigits /@ DateString@"ISOOrdinalDate"~StringSplit~"-"

The answer can be tested with arbitrary date by replacing DateString@"ISOOrdinalDate" by DateString[{year,month,day},"ISOOrdinalDate"] for year, month and day replaced by numbers.

How can I test Mathematica code?

"Wot no builtin?"

Python 2, 423 Bytes
Short version:

import time
y,d=time.gmtime()[0::7]
t="Today is "
o=" in the YOLD "+`y+1166`
if y%4<1 and d>59:
 if d==60:print"%sSt. Tib's Day%s%d"%(t,o);quit()
 d-=1
s,e=divmod(d-1,73)
print t+["Sweetmorn","Boomtime","Pungenday","Prickle-Prickle","Setting Orange"][(d-1)%5]+", the %d%s day of %s"%(e+1,'tsnrthtddh'[min(e*(e/10-1 and 1)%10,4)::5],["Chaos","Discord","Confusion","Bureaucracy","The Aftermath"][s]+o)

Longer, more readable form:
import time

# now = time.strptime("2017.06.11", "%Y.%m.%d")  # for testing
now = time.gmtime()
year, day_of_year = now[0::7]
leapyear = year % 4 < 1
today = "Today is "
yold = " in the YOLD " + `y+1166`

if leapyear and day_of_year>59:
    if day_of_year==60:
        print "%sSt. Tib's Day%s%d"% (today, yold)
        quit()  # dirty, but ... hey.
    day_of_year -= 1
season, day = divmod(day_of_year-1,73)

print today + \
    ["Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"][(day_of_year-1)%5] + \
    ", the %d%s day of %s" % (
        day+1,
        'tsnrthtddh'[min(day*(day/10-1 and 1)%10,4)::5],
        ["Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"][season] + yold
    )

Update: Fixed with help of the great @Neil and @EriktheOutgolfer. But @Jonathans answer is way shorter.

Welcome on Programming Puzzles & Code Golf!

Does this produce the right suffix for 21st, 22nd, 23rd...73rd? @L3viathan y%4<1 would work, but I don't think 1-y%4 would.

44-byte trivial golf.

@EriktheOutgolfer Can't you save another 4 bytes by eliminating the e variable?

Welcome to PPCG! Nice first post. I was planning to give you a bit off here and there, but noticed and fixed the suffix problem and golfed the code more than I thought I would so I ended up submitting my own version.

@Neil I'm afraid I can't do that.

@EriktheOutgolfer Sorry, I meant the s variable... no idea why I typed e by mistake.

@Neil Hmm, it's only used once so I think I can get away without it.

The suffix generation has off-by-one errors - using (e+1) in place of the two es in the max will work (and may then be golfed).

JavaScript (ES6), 387 380 bytes
f=(d=new Date(),a=d.getDate()-1,y=d.getFullYear()+1166)=>d.getMonth()?f(d,a+d.getDate(d.setDate(0))):`Today is ${y%4-2|a<59||59-a--?`Sweetmorn,Boomtime,Pungenday,Prickle-Prickle,Setting Orange`.split`,`[a%5]+`, the ${d=a%73+1}${[,`st`,`nd`,`rd`][d-10-(d%=10)&&d]||`th`} day of `+`Chaos,Discord,Confusion,Bureaucracy,The Aftermath`.split`,`[a/73|0]:`St. Tib's Day`} in the YOLD `+y

Takes an optional date parameter. Ungolfed:
function discordian(date) {
    var a = date.getDate();
    while (date.getMonth()) {
        date.setDate(0);
        a += date.getDate();
    }
    if (date.getYear() % 4 == 0) {
        if (a == 60) return "Today is St. Tib's day in the YOLD " + (date.getYear() + 1166);
        if (a > 60) a--;
    }
    var weekday = ['Setting Orange', 'Sweetmorn', 'Boomtime', 'Pungenday', 'Prickle-Prickle'][a % 5];
    var seasonday = (a - 1) % 73 + 1;
    var ordinal = seasonday % 10 == 1 && seasonday != 11 ? 'st' : seasonday % 10 == 2 && seasonday != '12' : 'nd' : seasonday % 10 == 3 && seasonday != '13' ? 'rd' : 'th';
    var season = ['Chaos', 'Discord', 'Confusion', 'Bureaucracy', 'The Aftermath'][Math.floor((a - 1) / 73)];
    return "Today is " + weekday + ", the " + seasonday + ordinal + " day of " + season + " in the YOLD " + (date.getYear() + 1166);
}

Python 2, 346 bytes
Note: This is a golf (and fix) of jammon's answer - I originally thought I'd submit a comment, but I changed quite a bit in the end (plus the day-suffixes have been fixed).
import time
y,d=time.gmtime()[::7]
t="Today is %s in the YOLD "+`y+1166`
r=y%4<1<59<d
d-=r+1
e=d%73
print t%[["Sweetmorn","Boomtime","Pungenday","Prickle-Prickle","Setting Orange"][d%5]+", the %d%s day of "%(e+1,'snrttddh'[min(e%10+3*(e/9==1),3)::4])+["Chaos","Discord","Confusion","Bureaucracy","The Aftermath"][d/73],"St. Tib's Day"][(r*d)==58]

Try it online! or see some hard-coded test dates.

I don't suppose e%10*(e/9!=1) works?

Nope, then it would print 11st, 12st and 13st (when e/9 is 1 it would multiply by zero and the min would pick that zero)

C#, 392 bytes
using System;s=>{var t=DateTime.Now;int d=t.DayOfYear,y=t.Year,m=d%73;return"Today is "+(DateTime.IsLeapYear(y)&d==60?"St. Tib's Day":"Sweetmorn|Boomtime|Pungenday|Prickle-Prickle|Setting Orange".Split('|')[d%5-1]+", the "+ m+(m<2|m==21|m>30?"st":m==2|m==22?"nd":m==3|m==23?"rd":"th")+" day of "+"Chaos|Discord|Confusion|Bureaucracy|The Aftermath".Split('|')[d/73])+" in the YOLD "+(y+1166);}

Full/Formatted version:
using System;

class P
{
    static void Main()
    {
        Func<string, string> f = s =>
        {
            var t = DateTime.Now;
            int d = t.DayOfYear, y = t.Year, m = d % 73;

            return "Today is " + (DateTime.IsLeapYear(y) & d == 60
                   ? "St. Tib's Day"
                   : "Sweetmorn|Boomtime|Pungenday|Prickle-Prickle|Setting Orange".Split('|')[d % 5 - 1] +
                     ", the " +
                     m +
                     (m < 2 | m == 21 | m > 30 ? "st" : m == 2 | m == 22 ? "nd" : m == 3 | m == 23 ? "rd" : "th") +
                     " day of " +
                     "Chaos|Discord|Confusion|Bureaucracy|The Aftermath".Split('|')[d / 73])
                   + " in the YOLD " + (y + 1166);
        };

        Console.WriteLine(f(null));

        Console.ReadLine();
    }
}

Pyth, 295 bytes
J.d2A<J2Kt+s<+,31 28*2t*3,30 31tH@J2=Y&&!%G4<58K!qH3=N%K73%"Today is %s in the YOLD %d",@,++@c"SweetmornZBoomtimeZPungendayZPrickle-PrickleZSetting Orange"\Z%K5%", the %d%s day of ",+N1@c"stndrdth"2h.mb,3+%NT*3q1/N9@c." yNlSFk.»&ô?Z#u!%ô6'mçM«_ôvëû¹)+¬<"\Z/K73"St. Tib's Day"q*YK59+G1166

Note: contains binary, may not be safe to copy-paste from here. Copy-pasting from TIO should work.
Try it online!
You can test arbitrary dates by replacing .d2 at the start with a 3-tuple of (year, month, day) like this: (2020 2 29).
This one was a bit annoying since Pyth doesn't have any way to get "day of year" so I had to compute it myself.


text:
How many carries do I need to add these two numbers?
Task
Given two positive integers, output the number of carries needed to add them together in long addition in base 10.
Examples
¹¹¹   <-- carries
 999
+  1
----
1000

Three carries are needed.
 ¹
 348
+ 91
----
 439

One carry is needed.
Testcases
999,   1 -> 3
398,  91 -> 1
348,  51 -> 0
348,  52 -> 2
  5,  15 -> 1
999, 999 -> 3
505, 505 -> 2

Scoring
This is code-golf. Shortest answer in bytes wins. Standard loopholes apply.

Related.

Suggested test case: 190192, 90909 (has a break in the carries).

From @Jenny_mathy 's answer: the number of carries is equal to the difference between (1) the sum of the digit sum of the two inputs and (2) the digit sum of the sum of the two inputs, divided by nine. This is because when there is a carry, you subtract 10 from and add 1 to the digit sum. For instance, 9+9 gives you 18, but the digit sum is 9+9-10+1 because there is a carry.

Related anarchy endless challenge

Can we assume the numbers fit in our language's int type? In particular for Python 2, should we deal with repr appending an L for numbers above 2**63-1?

@xnor yes, you can.

Mathematica, 46 39 bytes
x=Tr@*IntegerDigits;(x@#+x@#2-x@+##)/9&

input

[348,51]

-7 bytes from JungHwan

Dang, I really like this method. The difference between (1) the sum of the digit sum of the two inputs and (2) the digit sum of the sum of the two inputs, is nine times the number of carries because when there is a carry, you subtract 10 from the digit sum and add 1 to the digit sum.

Me too! thanks for the golfing tips

Testcases say [348,51] should return 0 but I'm getting 56/3 when I run this...?

Welp, looks like it's working now. Not sure what Mathematica was doing before...

JavaScript (ES6), 50 bytes
Fixed Stolen from ovs' solution
f=(a,b,c=0)=>a|b|c&&c+f(a/10,b/10,a%10+b%10+c>=10)

Explanation
f=(a,b,c=0)=>                                      Function taking two numbers and optional carry
             a|b|c                                 If a number or the carry are nonzero
                  &&                               Then
                    c+f(a/10,b/10,a%10+b%10+c>=10) Return carry plus all other carries

Carry explanation
a%10+b%10+c     Sum of mod 10 of the numbers and c - remember these are not floordiv'ed
           >=10 Greater than or equals to 10 (we can't use greater than 9 here)

f=(a,b,c=0)=>a|b|c&&c+f(a/10,b/10,a%10+b%10+c>=10)
console.log([[999,1],[398,91],[348,51],[348,52],[5,15],[999,999],[256,64],[190192,90909]].map(test=>`${(test[0]+'').padStart(6,' ')}, ${(test[1]+'').padStart(6,' ')} -> ${f(...test)}`).join('\n'));

348 , 52 should be 2

How does this work? Could you add an explanation?

C (gcc), 65 bytes
i,l;f(a,b){for(i=l=0;a+b;a/=10,b/=10)i+=a%10+b%10+l>9?l=1:0;a=i;}

Try it online!

You don't need to initialise global variables.

@user1502040 you need to, if they're used inside the function without being initialized.

Just getting my head around the initialization here: the variables are zero-initialized automatically, but only once, so because function submissions on PPCG have to work if the function's run more than once, they need to be manually zeroed for the benefit of the second and subsequent runs.

Jelly,  13 12 11  9 bytes
-1 byte by porting Jenny_mathy's Mathematic answer.
-2 more bytes by better golfing :p
;SN$DFS:9

See the test suite.
How?
;SN$DFS:9 - Main link: list of numbers, [a,b]     e.g.   [348,53]
   $      - last two links as a monad
 S        -   sum                                            401
  N       -   negate                                        -401
;         - concatenate                             [348,53,-401]
    D     - convert to decimal lists     [[3,4,8],[5,3],[-4,0,-1]]
     F    - flatten                           [3,4,8,5,3,-4,0,-1]
      S   - sum                                               18
       :9 - integer divide by nine                             2

My 12 byte solution...
:⁵+
DUSç\>9S

A monadic link taking a pair of integers and returning the number of carries as an integer.
There is probably a shorter way though! There was!
Try it online! or see the test suite.
How
:⁵+ · Link 1: perform a carry: right-column's-digit-sum, a; left-colum's-digit-sum; b
 ⁵  · literal 10
:   · a integer-divided by 10 - the carry amount
  + · add to b

DUSç\>9S · Main link: list of summands        e.g. [348,52]
D        · convert to decimal lists                [[3,4,8],[5,2]]
 U       · upend (reverse each)                    [[8,4,3],[2,5]]
  S      · sum (add the digits up)                 [10,9,3]
    \    · cumulative reduce with:
   ç     ·   last link (1) as a dyad               [10,10,4]
      9  · literal 9
     >   · greater than?                           [ 1, 1,0]
       S · sum                                     2

The many uses of D and S...

JavaScript (ES6), 53 45 bytes
f=(a,b,d=1)=>a+b<d?0:(a%d+b%d>=d)+f(a,b,d*10)

Saved 1 byte by adding an extra do-nothing iteration for carries into 1's place. Saved 7 bytes by appropriating @xnor's carry check. I also had a more elegant 45-byte version but it suffers from floating-point inaccuracy; it would work great translated to a language with exact decimal arithmetic:
f=(a,b,c=a+b)=>c<1?0:a%1+b%1-c%1+f(a/10,b/10)

Python, 48 bytes
f=lambda a,b,m=1:m<1e99and(~a%m<b%m)+f(a,b,m*10)

Try it online!
For each place value m=1, 10, 100, ..., 10**99, checks if there is a carry at that place value. The overflow check a%m+b%m>=m is shortened to ~a%m<b%m.
A nicer 45-byte variant where floats a and b shifted down instead
f=lambda a,b:a+b and(a%1+b%1>=1)+f(a/10,b/10)

sadly runs into float precision issues.

Can't you use a+b<m as your terminating condition?

@Neil It needs to be <= which is longer.

1e99and is nasty.

Python 2, 55 bytes
f=lambda a,b,c=0:c+a+b and c+f(a/10,b/10,a%10+b%10+c>9)

Try it online!

As @JonathanAllan pointed out, if you used a call to your function, you must declare it as well. That being said, your answer is 55 bytes

@Mr.Xcoder fixed it

05AB1E, 11 10 bytes
|DO‚€SOÆ9÷

Try it online!

@JonathanAllan Fixed.

|DO‚€SOÆ9÷ for 10 bytes.

@Emigna That's pretty cool.

Neim, 10 bytes
₁₂λ

Explanation:
            ppend the two inputs into a list
             oin them together
             um the characters
   ₁₂         Push the first input, then the second
             Ad.
             um the characters
             ubtract
             Integer diision by
        λ     nine (variable)

Try it!
Alternative solution, also 10 bytes:
DS9

Explanation:
             ppend the two inputs into a list
 D            Duplicate
              oin
              um
    S          Swap
              um
              um the characters
              ubtract
              integer diide by
        λ       nine (variable)

Try it!

PHP>=7.1, 81 Bytes
for([,$x,$y]=$argv,$i=1;($x+$y)/$i|0;$i*=10)$d+=$c=$x/$i%10+$y/$i%10+$c>9;echo$d;

-2 Bytes removing |0 In this case the loop runs until $i is INF
Test Cases

When does $i become INF?

@cat I am not sure why it  is important. I have not use this. 1.0E+309is the first  INF value Try it online!

Braingolf, 20 bytes
VR{.M}d<d&+v+d&+c-9/

Try it online!
Uses the same method as everyone else.
Could've saved a byte or 2 had I had the foresight to allow d to use the greedy modifier, then I could've replaced d<d with &d ah well, next time.
Explanation
VR{.M}d<d&+v+d&+c-9/  Implicit input from commandline args
VR                    Create stack2 and return to stack1
  {..}                Foreach loop, runs on each item in stack1
   .M                 Duplicate and move duplicate to stack2
      d<d             Split both items on stack into digits
         &+           Sum entire stack
           v+         Switch to stack2 and sum last 2 items on stack
             d&+      Split result into digits and sum all digits
                c     Collapse stack2 into stack1
                 -    Subtract last item from 2nd to last
                  9/  Divide by 9
                      Implicit output of last item on stack


text:
Find the Mr of a Given Compound!
Challenge
Given the formula of a chemical, output the Mr of the compound.
Equation
Each element in the compound is followed by a number that denotes the number of said atom in the compound. If there isn't a number, there is only one of that atom in the compound.
Some examples are:

Ethanol (C2H6O) would be C2H6O where there are two carbon atoms, 6 hydrogen atoms and 1 oxygen atom
Magnesium Hydroxide (MgO2H2) would be MgO2H2 where there is one magnesium atom, two oxygen atoms and two hydrogen atoms.

Note that you will never have to handle brackets and each element is included only once in the formula.
Whilst most people will probably stick to the order they feel most comfortable with, there is no strict ordering system. For example, water may be given as either H2O or OH2.
Mr
Note: Here, assume formula mass is the same as molecular mass
The Mr of a compound, the molecular mass, is the sum of the atomic weights of the atoms in the molecule.
The only elements and their atomic weights to 1 decimal place that you have to support (hydrogen to calcium, not including noble gases) are as follows. They can also be found here
H  - 1.0      Li - 6.9      Be - 9.0
B  - 10.8     C  - 12.0     N  - 14.0
O  - 16.0     F  - 19.0     Na - 23.0
Mg - 24.3     Al - 27.0     Si - 28.1
P  - 31.0     S  - 32.1     Cl - 35.5
K  - 39.1     Ca - 40.1

You should always give the output to one decimal place.
For example, ethanol (C2H6O) has an Mr of 46.0 as it is the sum of the atomic weights of the elements in it:
12.0 + 12.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 16.0
(2*C + 6*H + 1*O)

Input
A single string in the above format. You can guarantee that the elements included in the equation will be actual elemental symbols.
The given compound isn't guaranteed to exist in reality.
Output
The total Mr of the compound, to 1 decimal place.
Rules
Builtins which access element or chemical data are disallowed (sorry Mathematica)
Examples
Input > Output
CaCO3 > 100.1
H2SO4 > 98.1
SF6 > 146.1
C100H202O53 > 2250.0

Winning
Shortest code in bytes wins.

This post was adopted with permission from caird coinheringaahing. (Post now deleted)

Do we have to handle quantifiers, such as: 2H2O?

For the curious, this is the Mathematica solution (53 bytes): NumberForm[#&@@#~ChemicalData~"MolecularMass",{9,1}]&

Jelly, 63 bytes
ḟØDOP%⁽¡ṛị“ÇṚÆ’BH+“Ḳ"ɦṀ⁷6<s¡_-¦y⁼Ḟ¡¡FPɓ‘¤÷5
fØDVȯ1×Ç
Œs>œṗ⁸ḊÇ€S

A monadic link accepting a list of characters and returning a number.
Try it online!
How?
ḟØDOP%⁽¡ṛị“ÇṚÆ’BH+“Ḳ"ɦṀ⁷6<s¡_-¦y⁼Ḟ¡¡FPɓ‘¤÷5 - Link 1, Atomic weight: list of characters
                                            -                              e.g. "Cl23"
 ØD                                         - digit yield = "0123456789"
ḟ                                           - filter discard                      "Cl"
   O                                        - cast to ordinals                [67,108]
    P                                       - product                            7236
      ⁽¡ṛ                                   - base 250 literal = 1223
     %                                      - modulo                             1121
                                        ¤   - nilad followed by link(s) as a nilad:
          “ÇṚÆ’                             -   base 250 literal  = 983264
               B                            -   convert to binary = [    1,    1,     1,     1,   0,  0,  0,   0, 0,  0,  0, 0,     1,     1,     1, 0, 0,  0,  0,   0]
                H                           -   halve             = [  0.5,  0.5,   0.5,   0.5,   0,  0,  0,   0, 0,  0,  0, 0,   0.5,   0.5,   0.5, 0, 0,  0,  0,   0]
                  “Ḳ"ɦṀ⁷6<s¡_-¦y⁼Ḟ¡¡FPɓ‘    -   code-page indexes = [177  , 34  , 160  , 200  , 135, 54, 60, 115, 0, 95, 45, 5, 121  , 140  , 195  , 0, 0, 70, 80, 155]
                 +                          -   addition          = [177.5, 34.5, 160.5, 200.5, 135, 54, 60, 115, 0, 95, 45, 5, 121.5, 140.5, 195.5, 0, 0, 70, 80, 155]
         ị                                  - index into (1-indexed and modular)
                                            -    ...20 items so e.g. 1121%20=1 so 177.5
                                         ÷5 - divide by 5                          35.5

fØDVȯ1×Ç - Link 2: Total weight of multiple of atoms: list of characters   e.g. "Cl23"
 ØD      - digit yield = "0123456789"
f        - filter keep                                                            "23"
   V     - evaluate as Jelly code                                                  23
    ȯ1   - logical or with one (no digits yields an empty string which evaluates to zero)
       Ç - call last link (1) as a monad (get the atomic weight)                   35.5
      ×  - multiply                                                               816.5

Œs>œṗ⁸ḊÇ€S - Main link: list of characters                             e.g. "C24HCl23"
Œs         - swap case                                                      "c24hcL23"
  >        - greater than? (vectorises)                                      10011000
     ⁸     - chain's left argument                                          "C24HCl23"
   œṗ      - partition at truthy indexes                          ["","C24","H","Cl23"]
      Ḋ    - dequeue                                                 ["C24","H","Cl23"]
       Ç€  - call last link (2) as a monad for €ach                  [  288,  1,  816.5]
         S - sum                                                                 1105.5

This is one of the longest Jelly answers I have ever seen, but it still is less than half the length of the program currently in second, so good job!

Python 3,  189 182  168 bytes
-14 bytes by using the hash from Justin Mariner's JavaScript (ES6) answer.
import re
lambda s:sum([[9,35.5,39.1,24.3,28.1,14,16,31,40.1,23,32.1,10.8,12,27,6.9,19,0,1][int(a,29)%633%35%18]*int(n or 1)for a,n in re.findall("(\D[a-z]?)(\d*)",s)])

Try it online!

Below is the 182 byte version, I'll leave the explanation for this one - the above just changes the order of the weights, uses int to convert the element name from base 29, and uses different dividends to compress the range of integers down - see Justin Mariner's answer.
import re
lambda s:sum([[16,31,40.1,32.1,0,24.3,12,39.1,28.1,19,0,9,10.8,23,27,35.5,6.9,14,1][ord(a[0])*ord(a[-1])%1135%98%19]*int(n or 1)for a,n in re.findall("(\D[a-z]?)(\d*)",s)])

An unnamed function accepting a string, s, and returning a number.
Try it online!
How?
Uses a regex to split the input, s, into the elements and their counts using:
re.findall("(\D[a-z]?)(\d*)",s)
\D matches exactly one non-digit and [a-z]? matches 0 or 1 lowercase letter, together matching elements. \d* matches 0 or more digits. The parentheses make these into two groups, and as such findall("...",s) returns a list of tuples of strings, [(element, number),...].
The number is simple to extract, the only thing to handle is that an empty string means 1, this is achieved with a logical or since Python strings are falsey: int(n or 1).
The element string is given a unique number by taking the product of its first and last character's ordinals (usually these are the same e.g. S or C, but we need to differentiate between Cl, C, Ca, and Na so we cannot just use one character).
These numbers are then hashed to cover a much smaller range of [0,18], found by a search of the modulo space resulting in %1135%98%19. For example "Cl" has ordinals 67 and 108, which multiply to give 7736, which, modulo 1135 is 426, which modulo 98 is 34, which modulo 19 is 15; this number is used to index into a list of integers - the 15th (0-indexed) value in the list:
[16,31,40.1,32.1,0,24.3,12,39.1,28.1,19,0,9,10.8,23,27,35.5,6.9,14,1]
is 35.5, the atomic weight of Cl, which is then multiplied by the number of such elements (as found above).
These products are then added together using sum(...).

You are a genius... Outgolfed me by over 350 bytes

PHP, 235 bytes
preg_match_all("#([A-Z][a-z]?)(\d*)#",$argn,$m);foreach($m[1]as$v)$s+=array_combine([H,Li,Be,B,C,N,O,F,Na,Mg,Al,Si,P,S,Cl,K,Ca],[1,6.9,9,10.8,12,14,16,19,23,24.3,27,28.1,31,32.1,35.5,39.1,40.1])[$v]*($m[2][+$k++]?:1);printf("%.1f",$s);

Try it online!
Instead of array_combine([H,Li,Be,B,C,N,O,F,Na,Mg,Al,Si,P,S,Cl,K,Ca],[1,6.9,9,10.8,12,14,16,19,23,24.3,27,28.1,31,32.1,35.5,39.1,40.1]) you can use [H=>1,Li=>6.9,Be=>9,B=>10.8,C=>12,N=>14,O=>16,F=>19,Na=>23,Mg=>24.3,Al=>27,Si=>28.1,P=>31,S=>32.1,Cl=>35.5,K=>39.1,Ca=>40.1] with the same Byte count

JavaScript (ES6), 150 bytes
c=>c.replace(/(\D[a-z]?)(\d+)?/g,(_,e,n=1)=>s+=[9,35.5,39.1,24.3,28.1,14,16,31,40.1,23,32.1,10.8,12,27,6.9,19,0,1][parseInt(e,29)%633%35%18]*n,s=0)&&s

Inspired by Jonathan Allan's Python answer, where he explained giving each element a unique number and hashing those numbers to be in a smaller range.
The elements were made into unique numbers by interpreting them as base-29 (0-9 and A-S). I then found that %633%35%18 narrows the values down to the range of [0, 17] while maintaining uniqueness.
Test Snippet

f=
c=>c.replace(/(\D[a-z]?)(\d+)?/g,(_,e,n=1)=>s+=[9,35.5,39.1,24.3,28.1,14,16,31,40.1,23,32.1,10.8,12,27,6.9,19,0,1][parseInt(e,29)%633%35%18]*n,s=0)&&s
Input: <input oninput="O.value=f(this.value)"><br>
Result: <input id="O" disabled>

Oh, I think your way would save me a few bytes too!

Clojure, 198 194 bytes
Update: better to for than reduce.
#(apply +(for[[_ e n](re-seq #"([A-Z][a-z]?)([0-9]*)"%)](*(if(=""n)1(Integer. n))({"H"1"B"10.8"O"16"Mg"24.3"P"31"K"39.1"Li"6.9"C"12"F"19"Al"2"S"32.1"Ca"40.1"Be"9"N"14"Na"23"Si"28.1"Cl"35.5}e))))

Original:
#(reduce(fn[r[_ e n]](+(*(if(=""n)1(Integer. n))({"H"1"B"10.8"O"16"Mg"24.3"P"31"K"39.1"Li"6.9"C"12"F"19"Al"2"S"32.1"Ca"40.1"Be"9"N"14"Na"23"Si"28.1"Cl"35.5}e))r))0(re-seq #"([A-Z][a-z]?)([0-9]*)"%))

I'm wondering if there is a more compact way to encode the look-up table.

Python 3, 253 bytes
def m(f,j=0):
 b=j+1
 while'`'<f[b:]<'{':b+=1
 c=b
 while'.'<f[c:]<':':c+=1
 return[6.9,9,23,40.1,24.3,27,28.1,35.5,31,32.1,39.1,1,10.8,12,14,16,19]['Li Be Na Ca Mg Al Si Cl P S K H B C N O F'.split().index(f[j:b])]*int(f[b:c]or 1)+(f[c:]>' 'and m(f,c))

Try it online!

Python 3 - 408 bytes
This is mainly @ovs' solution, since he golfed it down by over 120 bytes... See the initial solution below.
e='Li Be Na Ca Mg Al Si Cl P S K H B C N O F'.split()
f,g=input(),[]
x=r=0
for i in e:
 if i in f:g+=[(r,eval('6.9 9 23 40.1 24.3 27 28.1 35.5 31 32.1 39.1 1 10.8 12 14 16 19'.split()[e.index(i)]))];f=f.replace(i,' %d- '%r);r+=1
h=f.split()
for c,d in zip(h,h[1:]):
 s=c.find('-')
 if-1<s:
  if'-'in d:
   for y in g:x+=y[1]*(str(y[0])==c[:s])
  else:
   for y in g:x+=y[1]*int(d)*(str(y[0])==c[:s])
print(x)

Try it online!
Python 3 - 550 548 535 bytes (lost the count with indentation)
Saved 10 bytes thanks to @cairdcoinheringaahing and 3 saved thanks to ovs
I had a personal goal to not use any regex, and do it the fun, old-school way... It turned out to be 350 bytes longer than the regex solution, but it only uses Python's standard library...
a='Li6.9 Be9. Na23. Ca40.1 Mg24.3 Al27. Si28.1 Cl35.5 P-31. S-32.1 K-39.1 H-1. B-10.8 C-12. N-14. O-16. F-19.'.split()
e,m,f,g,r=[x[:1+(x[1]>'-')]for x in a],[x[2:]for x in a],input(),[],0
for i in e:
 if i in f:g.append((r,float(m[e.index(i)])));f=f.replace(i,' '+str(r)+'- ');r+=1;
h,x=f.split(),0
for i in range(len(h)):
 if '-'in h[i]:
    if '-'in h[i+1]:
     for y in g:x+=y[1]*(str(y[0])==h[i][:h[i].index('-')])
    else:
        for y in g:
         if str(y[0])==h[i][:h[i].index('-')]:x+=(y[1])*int(h[i+1])
 else:1
print(x)

Try it online!

If anyone is willing to golf it down (with indentation fixes and other tricks...), it will be 100% well received, feeling like there's a better way to do this...

You can replace for y in g: if str(y[0])==h[i][:h[i].index('-')]:x+=y[1] with for y in g:x+=y[1]*(str(y[0])==h[i][:h[i].index('-')])

@cairdcoinheringaahing ah, great... updating when I have access to a computer

@ovs Thanks a lot! Credited you in the answer

In Python, you can use a semicolon in place of a newline, which allows you to save bytes on indentation.

@Phoenix not if there is a if/for/while on the next line. As this is the case on every indented line, you can't save bytes by this.

I know that @Phoenix but it doesn't help in this case

Mathematica, 390 338 329 Bytes
Saved 9 bytes due to actually being awake now and actually using the shortening I intended.
Version 2.1:
S=StringSplit;Total[Flatten@{ToExpression@S[#,LetterCharacter],S[#,DigitCharacter]}&/@S[StringInsert[#,".",First/@StringPosition[#,x_/;UpperCaseQ[x]]],"."]/.{"H"->1,"Li"->3,"Be"->9,"B"->10.8,"C"->12,"N"->14,"O"->16,"F"->19,"Na"->23,"Mg"->24.3,"Al"->27,"Si"->28.1,"P"->31,"S"->32.1,"Cl"->35.5,"K"->39.1,"Ca"->40.1}/.{a_,b_}->a*b]&

Explanation:
Find the position of all the uppercase characters. Put a dot before each. Split the string at each dot. For this list of substrings do the following split it based on letters and split it based on digits. For the ones split by letters convert string to numbers. For the ones split by digits replace each chemical with its molecular weight. For any with a molecular weight and an atom count replace it with the product of them. Them find the total.
Version 1:
I'm sure this can be golfed lots (or just completely rewritten). I just wanted to figure out how to do it. (Will reflect on it in the morning.)
F=Flatten;d=DigitCharacter;S=StringSplit;Total@Apply[Times,#,2]&@(Transpose[{F@S[#,d],ToExpression@F@S[#,LetterCharacter]}]&@(#<>If[StringEndsQ[#,d],"","1"]&/@Fold[If[UpperCaseQ[#2],Append[#,#2],F@{Drop[#,-1],Last[#]<>#2}]&,{},StringPartition[#,1]]))/.{"H"->1,"Li"->3,"Be"->9,"B"->10.8,"C"->12,"N"->14,"O"->16,"F"->19,"Na"->23,"Mg"->24.3,"Al"->27,"Si"->28.1,"P"->31,"S"->32.1,"Cl"->35.5,"K"->39.1,"Ca"->40.1}&

Explanation:
First split the string up into characters. Then fold over the array joining lowercase characters and numbers back to their capital. Next append a 1 to any chemical without a number on the end. Then do two splits of the terms in the array - one splitting at all numbers and one splitting at all letters. For the first replace the letters with their molar masses then find the dot product of these two lists.


text:
Minimal Fresh Substrings
Thanks @NathanMerrill for allowing me to post this! The following is entirely his wording from this sandbox post (deleted):

We define a "Fresh" substring as a substring that is different from any other substring that starts earlier.
For example, if I take the string "abababc" and split it: ["ab","ab","a","bc"], the first and the last substring are fresh, but the middle two are not, because they can be found earlier in the string.
For this challenge, you need create a list of the smallest possible fresh substrings for each position in the string.  If there are no fresh substrings, output and empty list or empty string, etc.
For example, if you were passed "ABABCBA", you should return ["A","B","ABC","BC","C"].
Test Cases:
ABABCBA          A,B,ABC,BC,C,   // ABC instead of AB because there is an AB earlier in the string
AAAAAAA          A,,,,,,
ABCDEFG          A,B,C,D,E,F,G
ABDBABDAB        A,B,D,BA,ABDA,BDA,DA,,
ACABCACBDDABADD  A,C,AB,B,CAC,ACB,CB,BD,D,DA,ABA,BA,AD,,

The empty items are not mandatory.

Is this case sensitive i.e. in Aa can we return A,a or A? If there are no fresh substrings, then it shouldn't be included in the list.: Can we have an empty item at that position in the list?

Typo in test case ABCDEEFG -> ABCDEFG?

I think you have a few more typos in your tests, I'll post my answer and show the results. Though I might have made a mistake.

@JonathanAllan D is where you believe DD to be: smallest possible fresh substrings for each position in the string

I think you've duplicated D in the last test case by accident

Wouldn't abababc make more sense to be split: ["a","b","ab","abc"], making them all fresh substrings?

A,C,AB,B,CAC,ACB,CB,BD,D,DA,ABA,BA,AD for the last test case CBDis greater as CB and CB is not earlier in the string

ABABCBA should output A,B,ABC,BC,C,,

Semi-related question: What is the longest string with n different characters that has fresh substrings from every character? I think it reaches ∞ at n=3, but end effects may make arbitrarily large strings impossible.

Actually, it reaches arbitrarily large at 2: AA...B However, it can still be interesting if we bound the maximum size of the substrings.

PHP, 141 bytes
for($r=[];$i<$l=strlen($a=$argn);$i++)for($t=1;$t;$t*=$t<$l)in_array($s=substr($a,$i,$t),$r)|strpos($a,$s)<$i?$t++:$r[]=$s.$t="";print_r($r);

Try it online!

All cleared up - this implementation is how it should be.

@JonathanAllan Come on with your I assume python answer

...nope Jelly, was tricky - probably missed a trick or two though!

Haskell, 105 103 88 81 79 bytes
-15 24 bytes (!) thanks to user1502040
import Data.List
f s=[a|a:_<-zipWith(\\)<*>scanl(++)[]$map(tail.inits)$tails s]

Try it online!
t gets a list of lists of all of the substrings starting from each position.
f builds up that list using scanl, so at index i we have a list of all of the substrings possible before index i. At each index, we take the set difference between the substrings calculated in t and those made illegal by f, to get the legal substrings at that index.
The lists are guaranteed to be sorted by length, so we can finally just take the first item if it exists. It skips empty items, as they are "not mandatory" per the spec.
Still learning Haskell, so I'm sure I've done something odd somewhere. The map head(filter(>[]) seems especially verbose to say "take the first item if exists, else nothing."

You can use a list comprehension instead of map head$filter(>[]). Something like [x|x:_<-myList].

and you can combine the two maps in the definition of t.

Thanks @user1502040! I didn't realize you could filter by pattern in a list comprehension like that

You can compress the whole thing into one line with a little point-free magic: f s=[a|a:_<-zipWith(\\)<*>scanl(++)([])$map(tail.inits)$tails s]

Nice. certain language constructs (<*>) can seem pretty obscure until I see such a useful example

C#, 175 158 bytes
s=>{int i=0,j,l=s.Length;var a=new string[l];for(;i<l;++i)for(j=0;j<l-i;){var t=s.Substring(i,++j);if(!s.Substring(0,i).Contains(t)){a[i]=t;break;}}return a;}

Full/Formatted Version:
using System;

class P
{
    static void Main()
    {
        Func<string, string[]> f = s =>
        {
            int i = 0, j, l = s.Length;
            var a = new string[l];

            for (; i < l; ++i)
                for (j = 0; j < l - i;)
                {
                    var t = s.Substring(i, ++j);
                    if (!s.Substring(0, i).Contains(t))
                    {
                        a[i] = t;
                        break;
                    }
                }

            return a;
        };

        Console.WriteLine(string.Join(",", f("ABABCBA")));
        Console.WriteLine(string.Join(",", f("AAAAAAA")));
        Console.WriteLine(string.Join(",", f("ABCDEFG")));
        Console.WriteLine(string.Join(",", f("ABDBABDAB")));
        Console.WriteLine(string.Join(",", f("ACABCACBDDABADD")));

        Console.ReadLine();
    }
}

Python 3, 136 bytes
l=[];n=input();a=len(n)
for x in range(a):
 i=x+1
 while n[x:i]in l or n[x:i]in n[:i-1]:
  i+=1
  if i>a:x=i;break
 l+=[n[x:i]]
print(l)

Try it online!
Includes the empty items

@JörgHülsermann I think it is fixed now

Works in my opinion

Jelly,  19  17 bytes
;\0;Ṗ
ṫJ;\€µḟ"ÇZḢ

A monadic link accepting a list of characters and returning a list of lists of characters.
Try it online! (the footer formats the list separating it with commas so it does not get implicitly printed as the representation would be smashed together).
How?
;\0;Ṗ - Link 1, offset prefixes: list  e.g. [["x","xy","xyz"],["y","yz"],["z"]]
 \    - cumulative reduction with:
;     -   concatenation                     [["x","xy","xyz"],["x","xy","xyz","y","yz"],["x","xy","xyz","y","yz","z"]]
  0;  - prepend a zero                    [0,["x","xy","xyz"],["x","xy","xyz","y","yz"],["x","xy","xyz","y","yz","z"]]
    Ṗ - pop (head to penultimate)         [0,["x","xy","xyz"],["x","xy","xyz","y","yz"]]

ṫJ;\€µḟ"ÇZḢ - Main link: list of characters  e.g. "ABABC"
 J          - range of length                     [1,2,3,4,5]
ṫ           - tail                                ["ABABC","BABC","ABC","BC","C"]
   \€       - cumulative reduction for €ach with:
  ;         -   concatenation                    [["A","AB","ABA","ABAB","ABABC"],["B","BA","BAB","BABC"],["A","AB","ABC"],["B","BC"],["C"]]
     µ      - monadic chain separation, call that p
        Ç   - call last link as a monad with p - gets relevant substrings to not use (with a zero in place of an empty list for the first index)
            -                      ... that is:  [0,["A","AB","ABA","ABAB","ABABC"],["A","AB","ABA","ABAB","ABABC","B","BA","BAB","BABC"],["A","AB","ABA","ABAB","ABABC","B","BA","BAB","BABC","A","AB","ABC"],["A","AB","ABA","ABAB","ABABC","B","BA","BAB","BABC","A","AB","ABC","B","BC"]]
       "    - zip with:
      ḟ     -   filter discard                   [["A","AB","ABA","ABAB","ABABC"],["B","BA","BAB","BABC"],["ABC"],["BC"],["C"]]
         Z  - transpose                         [["A","B","ABC","BC","C"],["AB","BA"],["ABA"],["ABAB"],["ABABC"]]
          Ḣ - head                               ["A","B","ABC","BC","C"]

I love it you get the same result for the last test case

I was also going to comment the same, but saw yours and just upvoted it :)

We have now 4 programs that do the same for the last test case. I am not sure what the C# Answer make

JavaScript (ES6), 81 bytes

f=(s,t=0,u=t+1,v=s.slice(t,u))=>s.indexOf(v)<t?s[u]?f(s,t,u+1):[]:[v,...f(s,t+1)]
<input oninput=o.textContent=f(this.value).join`\n`><pre id=o>

Retina, 19 18 bytes
-1 byte because empty items can be ommitted
!&`(.+?)(?<!\1.+)

Try it online!
Explanation:
!                   Print matches as newline separated list
 &`                 Consider overlapping matches
   (.+?)            Capture the shortest possible substring
        (?<!\1.+)   Enforce freshness
              .+    Scan backwards
            \1      Fail if the match appears earlier in the string
                    If matching is impossible, skip this element

Explanation requested.

Why do you need the |?

Otherwise, impossible cases are not included in the list.

@CalculatorFeline I may have misread, but I thought you were allowed to stop once there were no more fresh substrings.

Ruby, 77 bytes
->s,*a{s.scan(""){a<<(1..$'.size).map{$'[..._1]}.find{!($`+_1)[..-2][_1]}}
a}

Attempt This Online!

Japt, 18 bytes
¬ËUsE å+ k@bX <EÃg

Try it
Outputs null when there are no fresh substrings
Explanation:
¬ËUsE å+ k@bX <EÃg
¬                  # Split the input into an array of characters
 Ë                 # For each index E:
  UsE              #  Get the suffix of the input with length E
      å+           #  Get all prefixes of that suffix
         k@     Ã  #  Remove the ones where:
           bX      #   The first time it appears in the input
              <E   #   Is before E
                 g #  Return the shortest one remaining

Japt, 9 bytes
ã ü@bXÃmg

Try it
ã ü@bXÃmg     :Implicit input of string U
ã             :Substrings
  ü           :Sort and group by
   @          :Passing each X through the following function
    bX        :  First index of X in U
      Ã       :End grouping
       m      :Map
        g     :  First element


text:
Read a password
Your challenge is to read a "password" from the keyboard / standard input.
Challenge:

Read a string s invisibly.
For each of the characters in s, print a character c.
In realtime.

Rules:

You must print c in realtime. As soon as the user enters a character you must display c.
c must be constant, i.e. it must be the same character.
c can be any visible character (i.e. it cannot be a newline, space, tab, or unprintable).
c can't be based on s, i.e. c must be defined/constant before s is read.
c must be the same every time the program is run.
c can be one of the characters in s if by accident, as long as all other rules are followed.
None of the characters of s may appear on the screen, c excepted (see previous rule).
You may use any reasonable methods of input and output as long as all other rules are followed.
You may assume that the length of s is never longer than the terminal/graphical window width.
If using a terminal, your program should terminate after a newline or EOF is entered.

Example:
If s was password01 and c was *, the output would look something like:

Winner:
The shortest submission in each language wins.

Is python with tkinter allowed for our custom input field (like the one in HTML), such that the program does not terminate when enter is pressed, but when you close the Entry's Window (X on Windows and cmd+W on mac)?

@Mr.Xcoder Yes, that's valid.

Can we use Ctrl+J to represent a literal newline in the terminal? Alternatively, can we use Ctrl+Z instead of enter?

@ConorO'Brien Clarifying how input should end in the terminal.

You cannot enter EOF, as EOF isn't a character. Should our program finish when EOF is encountered (i.e., when the input stream ends), or when the user presses a certain key combo?

Also, your own answer finishes when Ctrl-C is pressed. Is that allowed?

What should happen if the user presses backspace?

Aren't rules 4, 5, 6, and 7 covered by rule 2?

what characters can typed? special characters !?/$, Alt Shift Ctrl etc.?

str, 5 bytes
n=?,1

Due to a bug, this is 5 bytes. It should be only 1 byte:
1

Definitely saw the cmder answer coming due to your Ctrl+Z comment :P

10/10 right tool for the job

HTML, 20 bytes

<input type=password

Alternative:  HTML + JavaScript, 51 bytes
Although the OP has confirmed that to be valid, here's a solution using JS for the purists!

<input id=i oninput=i.value=i.value.replace(/./g,8)

FGITW, anyone? :P (took him literally ten seconds)

oninput=_=>i.value=i.value.replace(/./g,"*") saves a byte.

Since c can be anything, you can save two more bytes with oninput=_=>i.value=i.value.replace(/./g,1)

I'll worry about that if (when) someone declares my HTML-only solution invalid, @Arjun ;) I only threw the JS one together quickly to placate a few people!

Where's the explanation, I don't understand.

@Downvoter, a comment would be appreciated.

Thanks for the accept, @MDXF but there are plenty of solutions shorter than this.

@Shaggy The shortest submission *in each language* wins. This is the shortest HTML answer, so I can, by the rules, accept it.

Vim, 36 bytes:
:im <C-v><CR> <C-v><esc>ZQ<CR>:au I<tab><tab> * let v:char=0<CR>i

This uses vim-key notation, so <C-v> is control-v, <CR> is enter, <esc> is the escape key, and <tab> is the tab key.
c is '0'.
Here is a hexdump to prove the byte count is accurate:
00000000: 3a69 6d20 160a 2016 1b5a 510a 3a61 7520  :im .. ..ZQ.:au
00000010: 4909 0920 2a20 6c65 7420 763a 6368 6172  I.. * let v:char
00000020: 3d30 0a69                                =0.i

This works by running the following two ex commands:
:imap <CR> <esc>ZQ
:autocmd InsertCharPre * let v:char=0

The first one means
:imap               " Anytime the following is pressed in insert mode:
      <CR>          "   (the 'enter' key)
           <esc>ZQ  " Then act as if the user instead pressed '<esc>ZQ' (close the buffer)

And the second one means
:autocmd                                " Automatically as vim runs:
         InsertCharPre                  "   Any time the user is about to insert a char
                       *                "   In any type of file
                         let v:char=0   "     Then instead insert a '0' character

I think there's not a way for me to get down to this using my current method without ignoring spaces at the very least..  Nice answer!

o_O That's neat...

Ruby with Shoes, 29 characters
Shoes.app{edit_line secret:1}

Sample output:

Ruby with Shoes? Rails weren't enough?

Aceto, 8 7 6 bytes
,!`XpO

Explanation:
Read a character (,), negate it (!) and conditionally exit. Print the zero on top of the stack (p) and go back to the beginning.
Run with -F to see the effect immediately (because flushing)
My first solution was based on the sandbox post, with spaces allowed as replacement characters and no need to exit on enter (4 bytes):
,'p>

C on POSIX, 128 117 113 96 bytes
-11 thanks to Quentin searching through termios.h
-4 thanks to Quentin pointing out my stupid mistakes
-17 because Quentin is a freaking wizard.
c,t[15];f(){for(tcgetattr(1,t),t[3]&=~10,tcsetattr(1,0,t);(c=getchar())^10&&c^4;)printf(".");}

This puts STDIN into raw/invisible mode so that it can get keypresses in realtime. This takes 77 bytes and I'm sure I can golf it in a bit. Note that this does not reset STDIN upon exiting so it will mess up your terminal if you don't do so manually.
Here's how you can reset STDIN:
void stdin_reset(void)
{
    struct termios t;
    get_stdin(&t);
    t.c_lflag |= ECHO;
    t.c_lflag |= ICANON;
    set_stdin(&t);
}

Output as shown in the GIF :-)

Digging into my termios.h, ECHO is 0000010 and ICANON is 0000002. This means that ~(ECHO|ICANON) is just ~10 :)

@Quentin Edited! Cheers :D

Also, each != can be replaced with ^, and '\n' with 10 (assuming UTF-8) ;)

@Quentin Oh... duh. Can't believe I missed that!

If we go full UB, we can replace t's storage with an array of integers. Then c_lcflags ends up at t[3], and we need neither the name or the type nor the #include, totaling 94 bytes: c,t[15];f(){for(tcgetattr(1,t),t[3]&=~10,tcsetattr(1,0,t);(c=getchar())^10&&c^4;)printf(".");} -- But maybe you'd better have me post it as an answer rather than having fun with yours :)

@Quentin Oh... my. You're a wizard. And I thought I was good at C... if you'd like to post it as your own answer feel free and I'll rollback my edits, otherwise I'll leave it edited into mine.

Does f(){for(;~getch();putchar(42));} work? (I don't have a PC to test currently)

@CoolGuy That only works on Windows, and as Windows is not free software, not everyone can test it and it's not allowed.

x86 machine code on MS-DOS - 14 bytes
As usual, this is a full COM file, that can be run on DosBox, plus most DOS variants.
00000000  b4 08 b2 2a cd 21 80 f4  0a 3c 0d 75 f7 c3        |...*.!...<.u..|
0000000e

Commented assembly:
    org 100h

section .text

start:
    mov ah,8h       ; ah starts at 08h (read console, no echo)
    mov dl,'*'      ; write asterisks (we could have left whatever
                    ; startup value we have here, but given that dx=cs,
                    ; we have no guarantee to get a non-zero non-space
                    ; value)
lop:
    ; this loop runs twice per character read: the first time with
    ; ah = 08h (read console, no echo syscall), the second time with
    ; ah = 02h (write console); a xor is used to switch from one
    ; mode to the other
    int 21h         ; perform syscall
    xor ah,0ah      ; switch syscall 08h <=> 02h
    cmp al,0dh      ; check if we read a newline (if we wrote stuff
                    ; we are just checking the last value read, so
                    ; no harm done; at the first iteration al starts
                    ; at 0, so no risk here)
    jne lop         ; loop if it wasn't a newline
quit:
    ret             ; quit

...no way. That's amazing.

Thanks, but I feel that there's still something else to trim; that xor is a woppin' 3 bytes, and would be exactly as big if I made it work on the whole ax; I tried xor ax,0a0dh / test al,al, but it's just as big because stupid test is two bytes, grrr...

Python 2, 50 bytes
from msvcrt import*
while'\r'!=getch():print'\b*',

Only works on windows

Sadly it only works on Windows :((

Java 5-8, 125 122 131 124 bytes
class X{public static void main(String[]a){new java.awt.Frame(){{add(new javax.swing.JPasswordField());setVisible(1>0);}};}}

Ungolfed:
class X{
    public static void main(String[]a){
        new java.awt.Frame(){
            {
                add(new javax.swing.JPasswordField());
                setVisible(1>0);
            }
        };
    }
}

Result:

Credit:
-3 @MD XF (Pointed out my stupid mistake with String[]args)
-7 @KritixiLithos (Pointed out public class can just be class)

Is the String[]args necessary?

@MDXF if I wish to make the answer for Java 8 there is PLENTY of stuff I could do. However, I'm making this a generic Java answer. However, however, yes I can make that String[]a.

You forgot to update the golfed answer. Also, doesn't 1>0 evaluate to 1?

@MDXF in Java (< 8) - 1>0 evaluates to true, which is different. I'll post this same answer in Groovy.

@StephenS this is a generic Java answer, not a Java 8 answer.

@carusocomputing OK, mb :)

@MDXF if you want to see the shorthand of this, see my Groovy Answer.

You can remove the public from public class X

@KritixiLithos ah, so you can, I thought that gave errors in Java 6, apparently not...

can't you replace class with interface ? With that, you can remove the public on the main method, which can save you a couple of bytes?

@AlexFerretti That would make this answer Java 8 only, since static methods are only available on interfaces from Java 8. In that case, it'd be best to rewrite everything like this: o->new java.awt.Frame(){{add(new javax.swing.JPasswordField());setVisible(1>0);}}.

I didn't know that this was implemented in java 8, my bad, I learned something ^^

AHK, 17 bytes
InputBox,o,,,HIDE

Built-ins are not interesting.

Mathematica 34 bytes
 InputString["",FieldMasked->True];

An single asterisk appears, after each character is keyed in.  The empty quotation marks are for the title that appears in the pop-up input window.
The ; prevents the password from being printed.

Intentional leading space?

Forth (gforth), 54 bytes
: f begin key dup 4 - swap 13 - * while ." *" repeat ;

Explanation
begin      \ enters the loop
    key    \ waits for a single character as input, places ascii code of character on stack
    dup    \ duplicates the key value on the stack
    4 -    \ subtracts 4 from the key value (shorter way of checking for not equals)
    swap   \ swaps the top two stack values
    13 -   \ subtract 13 from the key value
    *      \ multiply top two stack values (shorter version of "and")
while      \ if top of stack is true, enter loop body, else exit loop
    ." *"  \ output *
repeat     \ go back to beginning of loop

Vim, 58 50 52 50 bytes
Added to make sure it handled spaces properly.
Thanks to @DJMcMayhem for a bunch of help and ideas
i:im 32 *Y94pVGg
kWcW<Space>
:im
 ZQ
dG@"qi

In typical Vim key syntax below.  The characters marked like with a ^ are Ctrl+<char>, so ^Q=Ctrl+q
i:im ^V^V32 *^[Y94pVGg^A
kWcW<Space>^[
:im ^V
 ZQ
dG@"qi

There's no TIO link, because you'd need to directly input to Vim (as opposed to pre-inputting like normal).  To run the code you need to type it into Vim, and then you can type your password and hit enter.  It won't do anything with the password.  It won't even know what it was.  As soon as you hit enter the Vim window will :q!
This works by mapping all printable ASCII to * in insert mode, and mapping <CR> to <ESC>:q!<CR>

Maybe clarify what the symbols are? I think they're supposed to be <C-v>, <esc> and <C-a> but it's hard to tell.

@DJMcMayhem Will do.  Incidentally I think that you can paste them into Vim and they'll show up appropriately.

Some friendly competition :D

FLTK, 47 characters
Function{}{}{Fl_Window{}{}{Fl_Input{}{type 5}}}

Sample run:
bash-4.4$ fluid -c password.fl

bash-4.4$ fltk-config --compile password.cxx
g++ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -fvisibility-inlines-hidden -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT -o 'password' 'password.cxx' -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -lfltk -lX11

bash-4.4$ ./password

Sample output:

Processing, 53 bytes
String a="";void draw(){text(keyPressed?a+=0:a,9,9);}

This takes input via keypresses from a graphical window. The character it chooses to represent passwords with is 0. Note that due to the high framerate, each keypress will appear as multiple 0s (and also due to the fact that this is keyPressed and not keyTyped (not a boolean) or keyrelease).

Bash, 54 bytes
while read -eN1 c 2>&-;[[ ${c/$'\r'/} ]];do printf X;done

For scoring purposes, $'\r' can be replaced with a literal carriage return.
Try it online! (not much to look at)

ZX81 BASIC, 54 bytes
10 IF LEN INKEY$ THEN GOTO PI
30 IF NOT LEN INKEY$ THEN GOTO EXP PI
50 IF INKEY$>"Z" THEN STOP
70 PRINT "*";
90 GOTO PI

In the ZX81 character set the printable characters are in the range space to Z, although you can't actually input a space this way as it's the break character.
ZX Spectrum BASIC, 24 bytes
10 PAUSE NOT PI: IF INKEY$>=" " THEN PRINT "*";:GOTO PI

Note that >= counts as a single-byte keyword in Sinclair BASIC (codepoint 140 in this case).

Are the spaces between the line numbers and functions necessary?

Could you shorten PRINT to ?, I know that works in a lot of old BASIC dialects

@MDXF PRINT is a 1-byte token, it's just represented on screen as the 7 characters (except after THEN, when the leading space is suppressed).

R, 29 bytes
invisible(openssl::askpass())

Built-in that handles password entries. Opens a new window and replaces the input with dots. invisible is used to suppress printing the password to STDOUT.

Tcl/Tk, 18
gri [ent .e -sh *]

Must be run on the in the interactive shell (or have abbreviations enabled):

21 bytes without the tricky command abbreviations: grid [entry .e -sh *] and -sh is an option abbreviation for -show. 23 bytes is what I'd consider a minimum for a maintainable ungolfed program doing this.

Vim, 15 keystrokes
:cal inp<S-tab>'')|q<cr>

<S-tab> means shift + tab.
Apparently, there is a builtin for this that I wasn't aware of. Since I really like my manual answer, and this approach is radically different, I figured I should post a new answer instead of editing.
This works by calling the inputsecret function, then immediately quitting after it exits.

6502 machine code (C64), 22 21 bytes
0e 08 20 9f ff 20 e4 ff f0 f8 c9 0d f0 01 a9 60 20 d2 ff 50 ed

Usage: SYS 2062
Commented disassembly listing (ACME), you can uncomment the first three commented lines to launch with RUN once loaded:
!cpu 6502
!to "password2.prg",cbm
;* = $0801                               ; BASIC starts at #2049
;!byte $0d,$08,$dc,$07,$9e,$20,$32,$30   ; BASIC to load $c000
;!byte $36,$32,$00,$00,$00               ; inserts BASIC line: 2012 SYS 2062

    GETIN  =  $FFE4
    SCNKEY =  $FF9F
    CHROUT =  $FFD2

* = $080e
keyScan:
    jsr SCNKEY  ; get key
    jsr GETIN   ; put key in A

    beq keyScan ; if no key pressed loop

    cmp #13     ; check if RETURN was pressed
    beq $081b   ; if true go to operand of next instruction (#$60 = rts)

    lda #$60    ; load char $60 into accumulator
    jsr CHROUT  ; print it

    bvc keyScan ; loop

Comments:

I haven't found anything in the docs, but it seems that, after the GETIN call, beq branches only where no new key presses have been recorded;
Using #$60 as output char, that byte can be reused as "rts" instruction when RETURN is pressed.

Python 3 + tkinter - 63 61 bytes
from tkinter import*
t=Tk();Entry(show=1).pack();t.mainloop()

Displays a 1 for every character, ends when closing window (OP said it's allowed).

Would from tkinter import* (newline) Entry(show=1).pack();Tk().mainloop() work?

@ConorO'Brien testing

@ConorO'Brien no. It produces two different tkinter windows. One with the text field, one empty. It doesn't seem right to me.

Do you need the show=?

@Challenger5 Yes, we do need the show=

Groovy, 77 73 bytes
{new java.awt.Frame(){{add(new javax.swing.JPasswordField());visible=1}}}

This is an anonymous closure, with 0 required inputs.
Ungolfed:
{
    new java.awt.Frame() {
        {
            add(new javax.swing.JPasswordField())
            visible=1
        }
    }
}

Edit 1 (-4 bytes): Component#visible can be directly accessed, read more here.

Micro, 35 bytes
"":i{L46c:\
i~+:i
i10c=if(,a)}a
i:\

explination:
"":i                      create new blank string 'i'
    {                          begin input loop
     L                         input a character
      46c:\                    display ascii char #46 (.) (it is popped, leaving the input char from 'L'
           i~+:i               push i, flip i and the char around, concatinate them, and store that to i
                i10c=if(,a)}a  OK, a lot happens here, if a NL is in i, the loop terminates, and the final i:\ will display the input

That's a pretty good first attempt at a language! +1

BF, 24 bytes
++++++[->++++++<],[>.<,]

Works with bf.doleczek.pl. You can send a zero char to the program with Ctrl+Z.
Alternative solution:
BF, 1 byte
,

This is a very tongue-in-cheek solution. My terminal is 0 characters wide, so please don't enter any passwords longer than that.

Whoa... not bad!

@MDXF Are you referring to the 24 byte one or the 1 byte one?

Clearly the 24-byte one. I completely forgot that printing \b is a thing. :P

@MDXF What do you mean by that? \b is unprintable anyways.

No I mean your solution uses \b to override the input, correct?

@MDXF No, that interpreter just doesn't print the character you typed. It's the only online interpreter I could find with that behavior.

Oh. That's another way to do it, I guess.

PowerShell, 12 bytes
Read-Host -a

This reads input from host and, with the -a flag treats it as a securestring/password. In the ISE it pops up a message box which has a similar behavior since the ISE doesn't allow keypress capture.
PS C:\Windows\system32> Read-Host -a
************

QBasic, 48 bytes
DO
a$=INPUT$(1)
IF ASC(a$)=13THEN END
?"*";
LOOP

INPUT$(1) reads the next character from keyboard input. (This can include things like tab, backspace, and escape, but since the OP didn't say anything about those I'll assume we don't have to worry about them.) If the character is \r (ASCII 13), terminate the program; otherwise, print * without a newline. Repeat ad infinitum.

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

Last one, I promise. No input = -1, end of input = 0
How it Works
-[  Enters the loop
  +>, Get input
     [<->+ If not end of input it create the ÿ character and check if the input is not -1
          [<.>[-]]] If there was input, print the ÿ character.
                    <] Exit the loop if end of input

Your code is missing a closing bracket. And why do you make it that complicated? A simple "print a 'ÿ' for every input character" could be accomplished with a simple ,[>-.,]

@Dorian The bracket was a mistake, but the complexity arises from having to handle both no input and end of input

Perl + Bash, 30 bytes
print"*"while$|=1+`read -sn 1`

c is *, uses read from bash, so isn't a pure Perl solution.

QBIC, 44 bytes
{X=inkey$~X<>@`|~X=chr$(13)|_X\Y=Y+@*`_C?Y

Explanation
{            DO
X=inkey$     Read a char, set it to X$
             Note that INKEY$ doesn't wait for keypress, but simply sends out "" if no key was pressed.
~X<>@`|      IF X$ has a value THEN
~X=chr$(13)| IF that value is ENTER
_X           THEN END
\            ELSE
Y=Y+@*`      append a literal * to Y$
_C           Clear the screen
?Y           Display Y$ (having 1 * for each char entered)
             The IF's and the DO-loop are auto-closed at EOF{            DO

Python 2 (*nix only), 75 bytes
import sys,tty
i=sys.stdin
tty.setraw(i)
while i.read(1)!='\r':print'\b*',

(Warning: messes up your stdin and doesn't fix it, so maybe run in a screen instance if you don't want to have to restart your console).
Rod has a (shorter) Python 2 answer that only works on Windows - here's a Python 2 version that works on *nix (and not Windows, I think)

Regarding the terminal messing, running reset after the script finishes solves it.

Befunge, 18 bytes
"**"~:!#@_0`!_ #,_

Enter a null byte to stop input

><>, 10 bytes
"i:?!;1+?o

Try It Here
Enter a null byte to end input

Aheui (esotope), 43 bytes
밣발따밯밧밧누
희）빠뫃쳐）뎌

Try it online!
Unfortunately, I couldn't find interactive Aheui interpreter. Aheui processer made with Javascript looks like somewhat interactive, but it doesn't print till input !!!. And input !!! just terminates program.
Many Aheui implementation put -1 into stack when there are no more input, and this code checks if input is -1. If not, just print ), because its ascii code is 40, easy to make.