text:
Calculate the sum of ILD
Input:
An integer
Output:
Sum of the input itself + the length of the input + each individual digit of the input.
nr + nr-length + {sum of digits} = output

Examples:
Input: 99
Output: 99 (nr) + 2 (nr-length) + (9 + 9) (digits) → 119
Input: 123
Output: 123 + 3 + (1 + 2 + 3) → 132
Challenge rules:

The input can also contain negative input, which are resolved special. The -/minus-sign is also +1 for the length, and is part of the first digit.
For example:
Input: -123
Output: -123 + 4 + (-1 + 2 + 3) → -115
You can assume that the input nor output will ever be outside the range of an (32-bit) integer.

General rules:

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

Test cases:
87901 → 87931
123 → 132
99 → 119
5 → 11
1 → 3
0 → 1
-3 → -4
-123 → -115
-900 → -905
-87901 → -87886

Semi-related: Count Sum of all Digits

I think that with the negative numbers, for example -123 the sum chain should be (-1 + 1 + 2 + 3) instead of (-1 + 2 + 3), right?

@TuukkaX Nope, it should be -1 + 2 + 3. For this challenge I choose to merge the -/minus-sign to the first digit as one negative digit to make it a bit more interesting.

Thunno 2 s, 7 bytes
Ðls'+jE

Try it online!
or
verify all test cases
Explanation
Ðls'+jE  '# Implicit input
Ð         # Triplicate input
 l        # Push its length
  s       # Swap to get input
   '+j   '# Join on "+"
      E   # Evaluate as Python
          # Sum the stack
          # Implicit output

Python 2, 39 bytes
lambda x:x+len(`x`)+eval("+".join(`x`))

Test suite
Using the same eval-trick as in my Pyth-answer.

I never used Python, so forget my possible ignorance, but how does the eval and join know to take the negative first digit for negative input? I would expect -123 to become something like - + 1 + 2 + 3 written out, but apparently it isn't.. (Or is it, and it automatically merged - + 1 to -1 as second step?)

@KevinCruijssen like you said -123 becomes "-+1+2+3" after joining which yields the correct result when you eval it. Try eval("-+1") for example which results in -1.

@KevinCruijssen - + 1 -> - 1. The unary plus operator exists, so - + 1 is essentially the same as -(+(1)). +a is the same as a, for numbers.

05AB1E, 28 20 18 8 bytes
ÐgsS'+ýO

Explanation
Ð           # triplicate input
 g          # get length of input
  sS'+ý     # split input and merge with '+' as separator
       O    # sum and implicitly display

Try it online
Saved 10 bytes thanks to @Adnan

Luckily, 05AB1E does auto-evaluation on arithmetic expressions, so you can do this: ÐgsS'+ýO.

@Adnan: Nice! I didn't know that it did.

Pyth, 11 10 bytes
Thanks to @LeakyNun for a byte!
++vj\+`Ql`

Test suite
Explanation

++vj\+`Ql`QQ  # Q = input, last two implicitly added

  vj\+`Q      # Join the input on '+' and eval it
        l`Q   # Length of the input
           Q  # The input itself
++            # Add those three values to obtain the result

Brachylog, 35 32 bytes

lL,?:ef+:?:L+I,(0>?h:2*:Ir-:1+.;I.)
lL,(0>?h:1--I;I0),?b:ef+:?:L:I+.

Explanation
lL,             L is the length of the Input
(
    0>?         Input < 0
       h:1--I   I is (First digit - 1) * -1
;               Or
    I0          I is 0
),
?b:ef+          Sum all digits of the Input
      :?:L:I+.  Output = sum of digits + (Input minus first digit) + L + I

CJam, 18
q_,\~__Ab(@g*\~]:+

Try it online
Explanation:
q_      read the input and make a copy
,\      get the string length and swap with the other copy
~__     evaluate the number and make 2 copies
Ab      convert to base A=10 (array of digits), it uses the absolute value
(       take out the first digit
@g*     get a copy of the number, get its sign and multiply with the digit
\~      dump the other digits on the stack
]:+     add everything together

XSLT 1.0 (without EXSLT), 673 bytes
<transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"><output method="text"/><param name="i"/><template match="/"><variable name="d"><variable name="s">0<if test="0>$i">1</if></variable><variable name="d"><call-template name="d"><with-param name="i" select="substring($i,$s+2)"/></call-template></variable><value-of select="substring($i,1,$s+1)+$d"/></variable><value-of select="$i+string-length($i)+$d"/></template><template name="d"><param name="i"/>0<if test="$i!=''"><variable name="d"><call-template name="d"><with-param name="i" select="substring($i,2)"/></call-template></variable><value-of select="substring($i,1,1)+$d"/></if></template></transform>

Lightly inflated:
<transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <output method="text"/>
    <param name="i"/>
    <template match="/">
        <variable name="d">
            <variable name="s">0<if test="0>$i">1</if></variable>
            <variable name="d">
                <call-template name="d">
                    <with-param name="i" select="substring($i,$s+2)"/>
                </call-template>
            </variable>
            <value-of select="substring($i,1,$s+1)+$d"/>
        </variable>
        <value-of select="$i+string-length($i)+$d"/>
    </template>
    <template name="d">
        <param name="i"/>0<if test="$i!=''">
            <variable name="d">
                <call-template name="d">
                    <with-param name="i" select="substring($i,2)"/>
                </call-template>
            </variable>
            <value-of select="substring($i,1,1)+$d"/>
        </if>
    </template>
</transform>

Run using xsltproc:
xsltproc --param i -87901 ild.xsl ild.xsl

Yes, ild.xsl is passed twice: Once as the XSLT document and then as the XML document to be transformed. An input document must be present because an XSLT processor generally requires one to begin running. (XSLT is designed to define a transformation from an input document to an output document; running a transform solely with command-line parameters as I've done here is atypical.) For this program, any well-formed XML document will suffice as input, and, XSLT being an application of XML, any well-formed XSLT transform is by definition a well-formed XML document.

+1 for using something that totally isn't meant for calculating number and making it work anyway.

Can't you remove some quotes to make it "invalid but good for codegolf"?

Surely you don't need space after quotes in name="i" select="..." eg <with-param name="i"select="substring($i,$s+2)"/> ?

@cat There are only three of those in the entire document, and actually removing the space causes xsltproc to choke.

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ I'm not sure I understand the point of submitting a program that doesn't work.

@psmay Oh, that's weird. Erik was saying if you remove the quotes, it can be technically invalid according to the standard but still work properly like HTML, most implementations of which will render tags without quoted attribute values <p id=hello> etc. I guess if xsltproc cares about whitespace it won't let unquoted things by.

You should note that doc.xml must exist and contain valid XML (i.e, not empty) for this to work.

Dyalog APL, 19 17 16 bytes
≢+#⍎'\d'⎕R'&+',⊢

Takes string and returns
 ≢ length
+ plus
 # in root namespace
⍎ evaluation of
 '\d'⎕R'&+' regex append digits with a plus
, followed by
 ⊢ the unmodified string
–3 thanks to ngn

MATL, 20 bytes
tVtnw48-PZ}t0<?x_]vs

Try it Online
All test cases
Explanation
        % Implicitly grab the input
tV      % Duplicate the input and convert to a string
tn      % Duplicate and find the length of this string
w       % Flip the top two stack elements to get us the string again
48-     % Subtract 48 (ASCII 'O'). Yields a negative number for a negative sign
        % and digits otherwise
P       % Flip the resulting array
Z}      % Break the array up so each element is pushed to the stack
t0<?    % If the first character was a negative sign
  x_    % Pop the negative sign off the stack and negate the first digit
]       % End of if
vs      % Vertically concatenate and sum all stack contents
        % Implicitly display the result

Clojure, 102 bytes
(fn[n](load-string(str"(+ "n" "(count(str n))" "(apply str(map #(if(= % \-)%(str %" "))(str n)))")")))

Anonymous function which constructs a string that looks like (+ -123 4 -1 2 3 ) and evals it. Everything pretty verbose as it is, construct string from number, its length, and then map each symbol of string representation of the number except minus to itself plus space and minus remains the same
You can see it running here: https://ideone.com/FG4lsB

Matlab, 76 67 bytes
n=input('');t=num2str(n)-48;if(n<0)t(1)=0;t(2)=-t(2);end
n+sum(t+1)

9 bytes saved thanks to @Luis Mendo
Explanation:
n=input('');     -- takes input
t=num2str(n)-48; -- makes it a string and then array of digits with "-" becoming -3 (48 is code for 0)
if(n<0)
t(1)=0;          -- set first element (-3) to 0
t(2)=-t(2);      -- the second element is the most significant digit, so we have to negate it
end
n+sum(t+1)       -- take sum of n, sum of all digits and length of t
                    (guaranteed by +1 of every element)

sum(t+1)+n is shorter than sum([n numel(t) t])

Whoa, I spent a while thinking why this works. Great, thanks!

dc, 57 bytes
dc -e"0 1?rdsc*d[1r]s+d0>+dZr[+la10~lc*rdsaZ1<A]sAdsaZ1<Ala+++f"

Explained:
0 1      # Push 0, then 1 on the stack
?        # Wait for input from stdin
         # If input is negative, the leading minus will subtract 1 from 0
r        # Swap (rotate) top two items on stack.
         # Stack status if input (`$') was...
         #       positive                    negative
         # TOP       1     <- coefficient ->    -1
         #           $                           $
         #           0
dsc      # Store a copy of coefficient in `c'
*        # Multiply input by coefficient:
         #  If input was positive, it stays positive.
         #  If input was negative, it's actually interpreted as positive.
         #   In this case, multiply by -1 to make it negative.
d        # Duplicate signed input
[1r]s+   # Define a function `+': Push 1 and rotate
d 0>+    # If input is negative, push 1 underneath the top of the stack
         # This 1 represents the length of the `-` in the input
         # Note that the stack now has 3 items on it, regardless of input sign
dZ       # Push the length of the input (not including leading minus)
r        # Rotate, moving a copy of the input to the top
[        # Begin function definition
 +       # Add top two items of stack
 la      # Load value from `a' (which holds nothing at time of function definition)
 10~     # Slice the last digit off `a' (spoiler: `a' is going to hold the input while
         #  we gather its digits)
 lc*     # Multiply digit by coefficient
         #  Since the input is signed, the input modulo 10 will have the same sign.
         #  We want all digits to be positive, except the leftmost digit, which should
         #   have the sign of the input.
         #  This ensures that each digit is positive.
 r       # Rotate: move remaining digits to top of stack
 dsa     # Store a copy of the remaining digits in `a'
 Z 1<A   # Count the number of digits left; if more than 1, execute A
]sA      # Store the function as `A'
d sa     # Store a copy of the input in `a'
         #  Props to you if you're still reading this
Z 1<A    # Count the number of digits left; if more than 1, execute A
la       # Load leftmost digit of input (still signed appropriately)
+++      # Add the top four items on the stack
f        # Dump stack

This was far more complicated than I had expected! Good challenge :)

I made a point of not looking at yours until mine was working to see if we had similar approaches... But I see you can get a byte back by swapping your 10~ for a A~!

Bash + coreutils, 36 bytes
bc<<<$1+${#1}+$(sed s:\\B:+:g<<<0$1)

Explanation:
     $1+                      # the input number (+)
     ${#1}+                   # the length of the number, the '-' sign included (+)
     $(sed s:\\B:+:g<<<0$1)   # insert '+' between two consecutive word characters
                              #A word character is any letter, digit or underscore.
bc<<<                         # calculate the sum

In sed, \B also matches between two consecutive non-word characters, so for a negative number it matches between '^' and '-'. Note the 0$1 trick needed for \B to give 0-1+2+3, for example.
Run example: 'input.txt' contains all the test cases in the question's statement
while read N;do echo "$N -> "$(./ILD_sum.sh "$N");done < input.txt

Output:
87901 -> 87931
123 -> 132
99 -> 119
5 -> 11
1 -> 3
0 -> 1
-3 -> -4
-99 -> -96
-123 -> -115
-900 -> -905
-87901 -> -87886

@DigitalTrauma that won't work for negative integers.

@DigitalTrauma Well, yes (but code size won't change) and no (if sed is left as is). The reason is that a backslash will be treated differently when using a command substitution with backticks compared to $(). There are two alternative ways to do it with backticks, but both give a 36 bytes solution in the end: sed 's:\B:+:g'<<<0$1 and sed s:\\\B:+:g<<<0$1.

Java 8, 174 136 122 107 105 93 78 bytes
i->{int f=0;for(int j:(i+"").getBytes())i+=j<48?f++:f-->0?50-j:j-47;return i;}

-14 bytes thanks to @LeakyNun.
-15 bytes thanks to @cliffroot.
Explanation:
Try it online.
i->{                   // Method with integer as both parameter and return-type
  int f=0;             //  Integer-flag, starting at 0
  for(int j:(i+"").getBytes())
                       //  Loop over the digits as bytes
    i+=                //   Increase the input with:
       j<48?           //    If the current byte is '-':
        f++            //     Increase the input with the flag-integer `f` (which is 0),
                       //     and increase the flag-integer `f` by 1 afterwards
       :               //    Else:
        f-->0?         //     If the flag-integer `f` is 1,
                       //     and decrease the flag-integer `f` back to 0 afterwards
         50-j          //      Increase it with 50 minus the current byte
        :              //    Else
         j-47;         //     Increase it with the byte as digit
                       //      + 1 to cover for the length part in ILD
  return i;}           //  Return the modified input as result

int c(int i){char[]c=(i+"").toCharArray();int x=i,l=c.length,s=i+l,j=-1;for(;++j<l;x=1)s+=x>0?c[j]-38:38-c[++j];return s;}

int c(int i){char[]c=(i+"").toCharArray();for(int x=i,j=-1;++j<c.length;i+=1+Integer.parseInt(x<0?"-"+--c[j+=x=1]:c[j]+""));return i;} it finally felt like golfing in Java
@LeakyNun does your variant work? it gives wrong answers at first and then crashes.

@LeakyNun Your code fails at the test case for 0.

Does it work if the x>0 is changed to x>=0?

@LeakyNun Nope, I tried that, but then it gives an incorrect answer for each test-case: 87981; 162; 139; 21; 13; 11; -14; -105; -895; -87856

Oh, how ridiculous; change the two occurrences of 38 to 48.

int c(int i){char[]c=(i+"").toCharArray();int x=i,l=c.length,s=i+l,j=-1;for(;++j<l;x=1)s+=x<0?48-c[++j]:c[j]-48;return s;}

int c(int i){byte[]c=(i+"").getBytes();for(int j=-1;++j<c.length;i+=(c[j]<48?50-c[++j]:c[j]-47));return i;} yay

@cliffroot When I saw your version and Leaky Nun posted his shorter different approach, I knew you would be able to golf his version some more. ;) Thanks.

C#, 118 bytes
int k(int a){var s=a.ToString();for(int i=0;i<s.Length;a+=s[i]<46?-(s[++i]-48)+ ++i-i:(s[i++]-48));return a+s.Length;}

The fact you need the space in 1+ ++i is completely ridiculous imo

you're right but i didn't know how to do it without this...

you can do s[i]<46 to check for minus

@ScifiDeath Can't you do ++i+1?

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ No, because of infix math's dumb order of evaluation

@cat I thought prefix ++ has higher priority than binary +. So, anyways, why you can't do 1+++i? Is it taken as 1++ +i? If yes, you're helpless.

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ It does but in his use case it's ..aBigExpression+ ++i... so he can't just flip the operands without adding lots of parentheses.

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ csharp> var i = 0; 1+++i gives
(1,14): error CS1059: The operand of an increment or decrement operator must be a variable, property or indexer but
csharp> 1+ ++i gives
2

C#, 106 bytes
I beat java my a byte, my life is complete
int r(int n){var s=n+"";return n+s.Length+s.Select((k,j)=>int.Parse(s[k==45?1:j]+"")*(k==45?-2:1)).Sum();}

Ungolfed (kinda)
    public static int r(int n)
    {
            var s = n + "";
            return n + s.Length + s.Select((k, j) =>int.Parse(s[k==45?1:j]+"")*(k==45?-2:1)).Sum();
    }

pretty sure you can replace string with var and '-' with 45

you can do (n)=>{.... for an anonymous lambda

cat could you elaborate? im trying to figure it out by myself but its not working for me. i never did that

I know it's been a while, but you can golf it to 89 bytes: n=>n+(n+"").Length+(n+"").Select((k,j)=>int.Parse((n+"")[k<48?1:j]+"")*(k<48?-2:1)).Sum() Although you'll have to add +18 for using System.Linq; which you also forgot in your current answer.

PowerShell v4, 48 bytes
param($n)$n,"$n".length+[char[]]"$n"-join'+'|iex

This should work in v2+, but I only tested in v4.
Takes input $n. Creates a new array with the , operator consisting of $n and the .length when $n is converted to a string. Concatenates with that the string $n cast as a char-array. Then, that whole array is -joined together with + before being piped to iex (similar to eval). The result is left on the pipeline and output is implicit.
For example, for input -123, the array would look like (-123, 4, -, 1, 2, 3), and the string after the -join would look like -123+4+-+1+2+3. Then the Invoke-Expression happens, and the result is -115 as expected.

Factor with load-all, 175 bytes
Well, this is not very short. The special handling of unary minus is really annoying; I guess I could do it better and I will, maybe.
[ dup [ 10 >base length ] [ [ 10 >base >array [ 48 - ] V{ } map-as ] [ 0 < ] bi [ reverse dup pop* dup pop swap [ neg ] dip dup [ push ] dip ] [ ] if 0 [ + ] reduce ] bi + + ]

Using this substitution regex:
s/(-?[\d]+)\s*->\s*(-?[\d]+)/{ $2 } [ $1 calculate-ild ] unit-test/g

We can turn the OP's test cases into a Factor test suite.
USING: arrays kernel math math.parser sequences ;
IN: sum-ild

: sum-digits ( n -- x )
    [ number>string >array [ 48 - ] V{ } map-as ]
    [ 0 < ]
    bi
    [
      reverse dup pop* dup pop swap [ neg ] dip dup [ push ] dip
    ]
    [ ] if
    0 [ + ] reduce ;

: calculate-ild ( n -- x )
  dup
  [ number>string length ]
  [ sum-digits ]
  bi + + ;

USING: tools.test sum-ild ;
IN: sum-ild.tests

{ 87931 } [ 87901 calculate-ild ] unit-test
{ 132 } [ 123 calculate-ild ] unit-test
{ 119 } [ 99 calculate-ild ] unit-test
{ 11 } [ 5 calculate-ild ] unit-test
{ 3 } [ 1 calculate-ild ] unit-test
{ 1 } [ 0 calculate-ild ] unit-test
{ -4 } [ -3 calculate-ild ] unit-test
{ -115 } [ -123 calculate-ild ] unit-test
{ -905 } [ -900 calculate-ild ] unit-test
{ -87886 } [ -87901 calculate-ild ] unit-test

SpecBAS - 147 bytes
1 INPUT a$: l=LEN a$: b$="text "+a$+"+"+STR$ l+"+": FOR i=1 TO l: b$=b$+a$(i)+("+" AND i<l): NEXT i: EXECUTE b$

Builds up a string which then gets run. Unfortunately EXECUTE doesn't work with the ? shorthand for PRINT, but TEXT saved 1 character.

Perl 5, 22 + 1 (-p) = 23 bytes
$_+=eval s//+/gr.y///c

Try it online!

C, 132 116 113 80
t,c;f(char*v){for(c=atoi(v+=t=*v==45);*v;t=0,++v)c+=t?50-*v-2*c:*v-47;return c;}

Function f() takes the input as a string and returns the result as an integer. Full program version (113 bytes):
t;main(int c,char**v){char*p=v[1];c=atoi(p+=t=*p==45);for(c=t?-c:c;*p;++p,t=0)c+=t?50-*p:*p-47;printf("%d\n",c);}

Requires one argument.

Javascript (using external library) (45 bytes)
Using a library I wrote to bring LINQ to Javascript, I was able to write the following:
(i)=>i+(i+"").length+_.From(i+"").Sum(x=>x|0)

Link to library?

https://github.com/mvegh1/Enumerable . No docs yet, sorry

JavaScript (ES6), 38 bytes
n=>eval([n+=``,n.length,...n].join`+`)

Uses the old join-and-eval trick. Save 4 bytes if I can insist on string input:

f=
n=>eval([n,n.length,...n].join`+`)
;
<input type=number oninput=o.value=f(this.value)><input id=o readonly>

"Add 4 bytes if I have to allow both integers and strings representing integers" You don't, it is optional to choose either, but probably 99.9% will choose integer. I mainly added it for the rare languages that only support strings, but I will remove that part from my question since almost every language does.

@KevinCruijssen Sorry for being unclear earlier; the 34-byte version only works on strings.

Perl 6 - 30 bytes
As literal as it gets
{$^a+$^a.chars+[+]($^a.comb)}

Use it as an anonymous function
> {$^a+$^a.chars+[+]($^a.comb)}(99)
119

C++, 255 Bytes
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main(){
    string input;
    cin >> input;
    int sum = atoi(input.c_str()) + input.length();
    for(unsigned i = 0; i < input.length(); ++i)
        sum += input.at(i) - 48;
    return 0;
}

Perl 5 - 37 Bytes
warn eval(join'+',/./g)+($_+=()=/./g)

Input is in $_

Perl, 27 bytes
22 bytes code + 5 for -paF.
$"="+";$_+=@F+eval"@F"

Explanation
Uses the -a autosplit option with an empty delimiter (-F) creating an array of the digits passed in. Uses the magic variable $" which controls which char is used to join an array when it's interpolated into a string (we use "+" here) and the fact that a list used in scalar context will return the length of the list (the number of digits).
Usage
echo -n 99 | perl -paF -e'$"="+";$_+=@F+eval"@F"'
119

Perl, 27 bytes
22 bytes code + 5 for -paF.
Alternative solution, that's a lot more readable for no more bytes. I prefer the other as it looks more cryptic!
$_+=@F+eval join"+",@F

dc, 56 bytes
?dZrdd1sa[1+r0r-_1sa]sb0>b[A~rd0<x]dsxxrla*[+z1<y]dsyxp

No shorter than Joe's above, but a somewhat different implementation (and one that takes negative numbers as input vs. a subtraction command). Can probably be golfed more, but lunch only lasts so long.
?                #input
dZrdd            #find no. of digits, rotate to bottom of stack, dup input twice
1sa              #coefficient for first digit stored in register 'a'
[1+r0r-_1sa]sb   #macro 'b' executes on negative numbers. add one (for the neg. sign)
                 #rotate this value out of the way, leave a positive copy on top
0>b              #run the above macro if negative
[A~rd0<x]dsxx    #create and run macro 'x'; mod 10 to grab least significant digit
                 #keep doing it if quotient is greater than zero
rla*             #a zero remains in the way of our most significant digit, rotate it down
                 #and multiply said digit by our coefficient 'a' from earlier
[+z1<y]dsyx      #add two top stack values (we left that zero there to ensure this always
                 #works), check stack depth and keep doing it while there's stack
p                #print!

RProgN, 30 Bytes
] '' . ] '-?.' | sum _ \ L + +

Explination
]               # Clone the input
                #
'' . ]          # Convert it to a string, then clone it again.
'-?.' | sum     # Split it into chunks via the pattern '-?.' (A - if there is one, followed by a single character). Sum the resulting array.
_               # Floor the value, purely because I hate floats.
\ L + +         # Swap the top value with the value underneith it, to work with the string again. Get it's length, add the top, middle, and bottom, which is now the length, the sum and the input respectively.

Try it Online!

R, 108 bytes
A bit late to the party again but here it goes:
s=strsplit(paste(n<-scan()),"")[[1]];n+nchar(n)+sum(as.integer(if(n<0)c(paste0(s[1],s[2]),s[1:2*-1])else s))

In order to generally split the digits of any number (e.g. to sum them), R requires us to first convert to a string and subsequently split the string into a string vector. To sum up the elements, the string vector has to be converted to numeric or integer. This together with the exception with the sum of a the digits of a negative number eats up a lot of bytes.
The exception can be golfed a bit (to 96 bytes) if warning messages are allowed.
s=as.integer(strsplit(paste(n<-scan()),"")[[1]]);if(n<0){s[2]=s[2]*-1;s=s[-1]};n+nchar(n)+sum(s)

In this case the string vector is converted to integer directly using as.integer. However, for negative numbers the first element in the vector will be a minus sign: "-". This causes some trouble, e.g.: as.numeric(c("-",1,2,3)) will return NA 1 2 3 and a warning message. To circumvent this, remove the NA and then multiply the first element with -1 before taking the sum.

AWK, 64 63 61 bytes
{s=j=0;for(;j++<n=split($1,a,"");s+=$1>0||j-2?a[j]:-a[j]);$0+=n+s}1

Try it online!
TIO link has 6 extra bytes s=j=0; to allow for multi-line input.
This is the shortest method I could come up with.  I'm curious if it can be done shorter in AWK.
Saved 2-bytes, thanks Kevin

Can't $0=n+s+$0 be golfed to $0+=n+s (-2 bytes)?

You are absolutely right @KevinCruijssen . Silly me.

Add++, 15 bytes
L,bU"+"jvAbLAvs

Try it online!
How it works
L,		; Create a lambda function. Takes a string argument
		; Example argument: 	['123']
	bU	; Unpack;	STACK = ['1' '2' '3']
	"+"j	; Join with +;	STACK = ['1+2+3']
	v	; Evaluate;	STACK = [6]
	AbL	; Arg length;	STACK = [6 3]
	Av	; Int argument;	STACK = [6 3 123]
	s	; Sum;		STACK = [132]

C# 77 bytes
Check it here
Golfed:
int r(int n){return n+(n+"").Length+(n+"").Select(c=>int.Parse(c+"")).Sum();}

Ungolfed:
 public int r(int n)
 {
     var t = n + (n+"").Length;
     t += (n + "").Select(c => int.(c + "")).Sum();
     return t;
 }

Hi, welcome to PPCG! Although it is quite a bit shorter than both other C# answers so far, it fails to comply to the -/minus rule: -123 -> -123 + 4 + (-1 + 2 + 3) -> -115. Also, one small tip for your current code, you can remove the spaces between c=>int. Again welcome, and enjoy your stay. :)

Sure this complies with ”you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs”? Looks like a snippet using a variable appearing from nowhere.

As it stands, this is invalid and needs to be fixed or deleted.

I tried to fix my answer, is it still invalid?

Pyt, 7 bytes
ĐąŁ⇹ĐŚƩ

Try it online!
Shortest as of now!

Đ         duplicate
 ąŁ       convert to array of digits, pop, and push length
   ⇹Đ     swap top two values and duplicate
     ŚƩ   sum of digits and sum everything on stack

Hi. This seems to fail for all negative test cases.


text:
Marching Through A City
There is a parade marching through a city! There are 3 main groups of marchers: the (B)and, Poster (C)arriers, and (F)lag Holders. Also, every (P)oliceman in the whole city is on duty.
Flag holders (F) can march anywhere in the parade, but two flag holders cannot march next to each other, unless three or more flag holders are together.
The band (B) has to be together. The poster carriers (C) all have to be behind the band (either together, or in two groups).
Given the number of flag holders, poster carriers, band members, and policemen separated by your choice of delimiter, print one line for every possible configuration, organized in alphabetical order.
Test case 1:
Input:
2 2 2 0
Output:
CCFBBF
CFCBBF
CFCFBB
FCCBBF
FCCFBB
FCFCBB

Test case 2:
Input:
3 3 3 0
Output:
CCCBBBFFF
CCCFFFBBB
CCFCFBBBF
CCFFFCBBB
CFCCFBBBF
CFCFCBBBF
CFFFCCBBB
FCCCFBBBF
FCCFCBBBF
FCFCCBBBF
FCFCFCBBB
FFFCCCBBB

Test case 3:
Input:
2 2 2 1
Output:
CCBBFPF
CCFBBFP
CCFBBPF
CCFPBBF
CCFPFBB
CCPFBBF
CFCBBFP
CFCBBPF
CFCFBBP
CFCFPBB
CFCPBBF
CFCPFBB
CFPCBBF
CFPCFBB
CFPFCBB
CPCFBBF
CPFCBBF
CPFCFBB
FCCBBFP
FCCBBPF
FCCFBBP
FCCFPBB
FCCPBBF
FCCPFBB
FCFCBBP
FCFCPBB
FCFPCBB
FCPCBBF
FCPCFBB
FCPFCBB
FPCCBBF
FPCCFBB
FPCFCBB
FPFCCBB
PCCFBBF
PCFCBBF
PCFCFBB
PFCCBBF
PFCCFBB
PFCFCBB

This is code-golf, so the shortest source code in bytes wins.
*Note: It doesn't count if it takes longer than 3 seconds to run each test case. I won't use integers more than 20.

What part is in alphabetical order?

I've reopened it, but at least your first example still isn't in alphabetical order.

@atlasologist the lines are sorted in alphabetical order

I might be misunderstanding the conditions in the question, but for the first example, why is CFCBBF not a valid arrangement?

@2012ssohn whoops, it is. It probably got deleted by accident during my test-case rewrite, sorry about that.

CJam, 49 bytes
l~"BCFP".*(a\s+m!:s{_"FP"-W%_$=\e`[2'F]e=!&},_&N*

Try it online!
Input format is [B C F P].

Pyth, 56 bytes
jf&!},2\FrT8!:T"B.*C|C([^C]+C+){2}|B[^B]+B"0{S.ps*V"FCBP

Try it online!

Could be golfed much further, but just post another answer if you are using Pyth.

I changed specs, but since you submitted before I changed, you don't have to redo your submission - this is valid :)

Well of course it would be easier if I can just obtain the number of police directly.

source: Stack Exchange

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

sort: votes


text:
Borders of overlapping circles
Given the coordinates of several points on a plane, and the radius of a circle surrounding each point, draw polygons representing the circles and the edges where the circles meet. Straight edges will always fall along circle-circle intersection lines, but might not follow the full length of these lines.
Per mbomb007's suggestion, imagine the behavior of 2D soap bubbles. That's technically wrong, because soap bubbles would always meet at 120° angles to minimize energy, while these circles may meet at any angle.
This is a Voronoi diagram, minus a defined area plane. Thanks Andreas. This is actually a generalization of a Voronoi diagram called a power diagram.
Examples
For example, given two points and two radii, the output might look like this:

Add another point and radius and the output might look like this:

Input
You can structure the input however you wish. Please post results with the following inputs.
Test 1

x: 10, y: 10, r: 10
x: 25, y: 12, r: 8

Test 2

x: 8, y: 10, r: 6
x: 20, y: 8, r: 4
x: 18, y: 20, r: 12

Output
Output should be graphical and should include polygon borders, but nothing else is required. Points and intersections do not need to be represented like they are in the examples.
Constraints

No point will exist within the radius of another circle.
Standard codegolf rules.
No answers with loopholes will be accepted, but feel free to have fun with it.

What do the edges in Fig. 2 radiate outwards from a point which is not a point of intersection?  Shouldn't the edges be from intersection point to intersection point?  My understanding is that the polygon in Fig. 2 should be a triangle.

I was assuming he was using the Radical Center, which is the point of intersection of their pairwise radical lines.

I find my intentions difficult to articulate. Imagine that the circles are all slowly expanding from their points. A circle will stop this expansion on an edge when it encounters another circle. The circle's unencumbered edges will continue to expand until they reach their specified radius. I don't have a strong background in geometry or math, so I apologize for perhaps not speaking accurately. Please feel free to add clarification to the question if you get my meaning.

Nate, the algorithm in your last comment is not well-defined: we don't know what rate each circle is expanding at, so we don't know where the line is. If you do mean the radical center (see the links in @Neil 's comment), I suggest you [edit] the question to indicate as much.

Nate, Finding the points of intersection of circles is clear.  How do you define the point in Fig. 2 where the three line segments meet?   How do you define (or at least describe) the line segments themselves?  The line segment in Fig. 1 is simply the line segment between the two points of intersection.

You should change the title to mention bubbles. These look like 2D bubbles.

I appreciate the input and I've added more detail at the top. I hope that the bit about circle-circle intersection lines will provide enough clarification.

Your test2 does not match the picture.

You're asking for the Voronoi tessellation of a plane given a set of points: https://en.wikipedia.org/wiki/Voronoi_diagram

@LLlAMnYP, nor does the first. They are not intended to match.

In a Voronoi diagram, "for each seed [point] there is a corresponding region consisting of all points closer to that seed than to any other".  That is clearly not the case for Figure 2.

@Andreas DavidC is right, this would be a Voronoi diagram only if all circles were of equal radius

This problem is asking for a power diagram of the circles.

Is it possible that the three line segments in Fig. 2 intersect at the centroid of the polygon with the circle centers as vertices?

@DavidC No, Neil is correct that they intersect at the radical center.

Anders, Ok, Now I understand.

Is it acceptable to produce the areas in different colours, not the border lines? The lines would only be implied by a colour change

Python 2, 473 355 bytes
L=input()
m=min
a,b,c,d=eval('m(%s-r for u,v,r in L),'*4%('u','v','-u','-v'))
e=(-c-a)/499.
H=lambda x,y:x*x+y*y
I=500
J=int(2-(d+b)/e)
print'P2',I,J,255
i=I*J
P=lambda(u,v,r):H(c+i%I*e+u,b+i/I*e-v)-r*r
while i:i-=1;p,k=m((P(k)/[1,k[2]][P(k)>0],k)for k in L);u,v,r=k;print int(255*m(1,[m([-p/r]+[(P(l)-p)/H(u-l[0],v-l[1])**.5for l in L-{k}]),p][p>0]/2/e))

This reads a set of circles as (x,y,r) tuples on stdin, and outputs an image in PGM format to stdout.  It works roughly by computing a distance function of the diagram at each pixel, and shading each pixel less than one pixel away proportionally to its distance.
{(10,10,10),(25,12,8)}

{(8,10,6),(20,8,4),(18,20,12)}

{(6, 63, 4), (16, 88, 9), (64, 94, 11), (97, 96, 3), (23, 32, 13), (54, 14, 7), (41, 81, 3), (7, 7, 4), (77, 18, 8), (98, 55, 4), (2, 56, 7), (62, 18, 5), (13, 74, 2), (33, 56, 12), (49, 48, 4), (6, 76, 2), (82, 70, 9), (21, 71, 2), (27, 5, 10), (3, 32, 6), (70, 62, 6), (74, 46, 4), (21, 60, 7), (18, 47, 7), (94, 2, 4), (39, 97, 7), (62, 63, 2), (87, 29, 8), (19, 17, 4), (61, 23, 2), (73, 1, 8), (40, 17, 13), (99, 41, 4), (81, 57, 7), (1, 68, 5), (38, 3, 4), (46, 36, 9), (4, 39, 2), (73, 77, 3), (93, 19, 10), (67, 42, 3), (96, 65, 2), (2, 16, 3), (28, 92, 3), (54, 58, 2), (39, 86, 5), (84, 82, 5), (79, 43, 4), (5, 47, 1), (34, 41, 8), (65, 5, 2), (9, 44, 3), (53, 3, 6), (1, 12, 1), (81, 95, 7), (74, 31, 2), (63, 61, 1), (35, 72, 1), (44, 71, 2), (57, 35, 5), (46, 65, 6), (57, 45, 4), (93, 94, 1), (99, 81, 13), (13, 58, 4), (68, 32, 6), (11, 2, 6), (52, 98, 7), (51, 25, 5), (84, 2, 2), (44, 92, 3), (23, 72, 2), (32, 99, 7), (13, 19, 3), (97, 29, 8), (58, 80, 3), (67, 82, 5), (59, 60, 3), (86, 87, 5), (29, 73, 2), (5, 93, 4), (42, 74, 1), (75, 85, 8), (91, 53, 5), (23, 82, 4), (19, 97, 8), (51, 88, 3), (67, 12, 6), (60, 53, 1), (66, 72, 2), (57, 64, 2), (66, 49, 2), (44, 0, 4), (11, 69, 1), (93, 60, 5), (56, 50, 3), (19, 68, 3), (64, 75, 3), (6, 17, 2), (82, 5, 2)}

Here the distance function has been divided by 32 to make it visible:
{(7, 9, 7), (1, 3, 2), (4, 0, 4), (9, 2, 4), (0, 8, 5)}

save at the top: exec"%s=m%s(%s for u,v,r in L);"*4%('a','in','u-r','b','ax','v-r','c','in','u+r','d','ax','v+r')

C# ~2746
This is a solution in C#. Probably far from optimal but C# wont win this anyway. Just wanted myself to prove that i can do it.
Input via commandline by specifying the values seperated with a space
in the order x y r
Output is a file 'l.bmp' within the executing directory.
Program accepts any ammount of circles.
Test 1 : 10 10 10 25 12 8
Test 2 : 8 10 6 20 8 4 18 20 12
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;

class Program
{
    static void Main(params string[] args) => new Program().run(args);

    class Circle
    {
        public PointF P;
        public float R;
    }

    class Line
    {
        public PointF S;
        public PointF E;
        public Circle C1;
        public Circle C2;
        public Line(Circle c1, Circle c2, PointF s, PointF e)
        {
            S = s;
            E = e;
            C1 = c1;
            C2 = c2;
        }
    }

    List<Line> lines = new List<Line>();
    List<Circle> circles = new List<Circle>();

    void run(string[] args)
    {
        for (int i = 0; i < args.Length; i += 3)
            addcircle(args[i], args[i + 1], args[i + 2]);
        circles.Sort((c1, c2) => c1.P.X.CompareTo(c2.P.X));

        int mx = (int)circles.Max(c => c.P.X + c.R) + 1;
        int my = (int)circles.Max(c => c.P.Y + c.R) + 1;

        for (int i = 0; i < circles.Count; i++)
            for (int j = i + 1; j < circles.Count; j++)
            {
                var c1 = circles[i];
                var c2 = circles[j];

                var d = dist(c1.P, c2.P);
                var a = 1 / d * sqrt((-d + c1.R - c2.R) * (-d - c1.R + c2.R) * (-d + c1.R + c2.R) * (d + c1.R + c2.R));
                var x = (sqr(d) - sqr(c2.R) + sqr(c1.R)) / (2 * d);

                var ap = angle(c1.P, c2.P);
                var la = rotate(c1.P, new PointF(c1.P.X + x, c1.P.Y + a / 2), ap);
                var lb = rotate(c1.P, new PointF(c1.P.X + x, c1.P.Y - a / 2), ap);
                var l = new Line(c1, c2, la, lb);
                lines.Add(l);
            }
        foreach (Line l in lines)
            foreach (Line lo in lines)
            {
                if (l == lo) continue;
                var intersection = intersect(l, lo);

                if (intersection != null && online(intersection.Value, l) && online(intersection.Value, lo))
                {
                    foreach (Circle circle in circles)
                    {
                        if (l.C1 == circle || l.C2 == circle)
                            continue;
                        if (dist(intersection.Value, circle.P) >= circle.R)
                            continue;

                        if (dist(l.E, circle.P) < circle.R)
                            l.E = intersection.Value;

                        if (dist(l.S, circle.P) < circle.R)
                            l.S = intersection.Value;
                    }
                }
            }

        using (Bitmap bmp = new Bitmap(mx, my))
        {
            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.Clear(Color.White);
                foreach (var c in circles)
                    draw(g, c);

                for (int i = 0; i < circles.Count; i++)
                {
                    var c1 = circles[i];
                    var p = new PointF(c1.P.X + c1.R, c1.P.Y);
                    for (int j = 0; j < circles.Count; j++)
                    {
                        if (i == j) continue;
                        var c2 = circles[j];
                        for (var f = 0f; f <= 360f; f += 0.1f)
                        {
                            var pl = rotate(c1.P, p, f);
                            if (dist(pl, c2.P) <= c2.R)
                            {
                                g.DrawRectangle(new Pen(Color.White), (int)pl.X, (int)pl.Y, 1, 1);
                            }

                        }
                    }
                }

                foreach (var l in lines)
                    draw(g, l);

            }
            bmp.Save("t.bmp");
        }
    }

    private float dist(PointF p1, PointF p2) => sqrt(sqr(p1.X - p2.X) + sqr(p1.Y - p2.Y));

    bool online(PointF p, Line l)
    {
        var lx = l.S.X < l.E.X ? l.S.X : l.E.X;
        var hx = l.S.X > l.E.X ? l.S.X : l.E.X;
        var ly = l.S.Y < l.E.Y ? l.S.Y : l.E.Y;
        var hy = l.S.Y > l.E.Y ? l.S.Y : l.E.Y;

        return p.X >= lx && p.X <= hx && p.Y >= ly && p.Y <= hy;
    }

    static PointF? intersect(Line l1, Line l2)
    {
        //Line1
        float A1 = l1.E.Y - l1.S.Y;
        float B1 = l1.S.X - l1.E.X;
        float C1 = A1 * l1.S.X + B1 * l1.S.Y;

        //Line2
        float A2 = l2.E.Y - l2.S.Y;
        float B2 = l2.S.X - l2.E.X;
        float C2 = A2 * l2.S.X + B2 * l2.S.Y;

        float det = A1 * B2 - A2 * B1;
        if (det == 0)
        {
            return null; //parallel lines
        }
        float x = (B2 * C1 - B1 * C2) / det;
        float y = (A1 * C2 - A2 * C1) / det;
        return new PointF(x, y);
    }

    void addcircle(string x, string y, string r)
    {
        var SCALE = 20f;
        Circle c1 = new Circle
        {
            P = new PointF(float.Parse(x) * SCALE, float.Parse(y) * SCALE),
            R = float.Parse(r) * SCALE
        };
        circles.Add(c1);
    }

    void draw(Graphics g, Line l) => g.DrawLine(new Pen(Color.Red), l.S.X, l.S.Y, l.E.X, l.E.Y);

    PointF rotate(PointF o, PointF p, float angle)
    {
        var sa = (float)Math.Sin(angle);
        var ca = (float)Math.Cos(angle);
        var dx = p.X - o.X;
        var dy = p.Y - o.Y;

        return new PointF((ca * dx - sa * dy + o.X), (sa * dx + ca * dy + o.Y));
    }

    float angle(PointF p1, PointF p2)
    {
        var dx = p2.X - p1.X;
        if (dx == 0)
            return 0f;
        return (float)Math.Atan((p2.Y - p1.Y) / dx);
    }

    void draw(Graphics g, Circle c)
    {
        g.DrawEllipse(new Pen(Color.Blue),
                      c.P.X - c.R,
                      c.P.Y - c.R,
                      c.R * 2,
                      c.R * 2);
    }

    float sqr(float d) => d * d;
    float sqrt(float d) => (float)Math.Sqrt(d);
}

All the Math involved here is based on this. The coordinates of the lines were easy to get using the formulars from the link. However they needed to be rotated by the angle between the two involved cricles centers.
To reduce the lines length i calculated their intersections. Then for that intersection i checked if the current lines end reaches into a circle that isnt the "parent of the line" and also contains the intersection itself. If that was the case, that end of the line was reduced to the location of the intersection.
The circles were simple to draw, the "notneeded" parts were difficult to remove, so i came up with a "rubber" solution, that removes the stuff that isnt needed anymore by painting it white again. Kind of brute forcing it. This is done by walking along each circles edge and checking if that pixel is within range of another circle.
Initially i wanted to roll my own circle-drawing method that only draws the circle withing specified angles but that didnt turn out well and took even more lines of code.
Really having a hard time explaining this if you havent noticed... English isnt my mother tounge so i am sorry for that.
Golfed
using System;using System.Collections.Generic;using System.Drawing;using System.Drawing.Imaging;using System.Linq;class P{static void Main(params string[]args)=>new P().R(args);class C{public PointF P;public float R;}class L{public PointF S;public PointF E;public C C1;public C C2;public L(C c1,C c2,PointF s,PointF e){S=s;E=e;C1=c1;C2=c2;}}List<L>_=new List<L>();List<C>c=new List<C>();void R(string[]args){for(int i=0;i<args.Length;i+=3)A(args[i],args[i+1],args[i+2]);c.Sort((c1,c2)=>c1.P.X.CompareTo(c2.P.X));int B=(int)c.Max(c=>c.P.X+c.R)+1;int e=(int)c.Max(c=>c.P.Y+c.R)+1;for(int i=0;i++<c.Count;)for(int j=i+1;j++<c.Count;){var f=c[i];var q=c[j];var d=D(f.P,q.P);var a=1/d*S((-d+f.R-q.R)*(-d-f.R+q.R)*(-d+f.R+q.R)*(d+f.R+q.R));var x=(F(d)-F(q.R)+F(f.R))/(2*d);var h=angle(f.P,q.P);var k=R(f.P,new PointF(f.P.X+x,f.P.Y+a/2),h);var m=R(f.P,new PointF(f.P.X+x,f.P.Y-a/2),h);var l=new L(f,q,k,m);_.Add(l);}foreach(L l in _)foreach(L o in _){if(l==o)continue;var n=I(l,o);if(n !=null && O(n.Value,l)&& O(n.Value,o)){foreach(C p in c){if(l.C1==p || l.C2==p)continue;if(D(n.Value,p.P)>=p.R)continue;if(D(l.E,p.P)<p.R)l.E=n.Value;if(D(l.S,p.P)<p.R)l.S=n.Value;}}}Bitmap r=new Bitmap(B,e);Graphics g=Graphics.FromImage(r);g.Clear(Color.White);foreach(var _ in c)D(g,_);for(int i=0;i++<c.Count;){var Q=c[i];var P=new PointF(Q.P.X+Q.R,Q.P.Y);for(int j=0;j++<c.Count;){if(i==j)continue;var G=c[j];for(var f=0f;f<=360f;f+=0.1f){var H=R(Q.P,P,f);if(D(H,G.P)<=G.R){g.DrawRectangle(new Pen(Color.White),(int)H.X,(int)H.Y,1,1);}}}}foreach(var l in _)D(g,l);r.Save("t.bmp");}float D(PointF p1,PointF p2)=>S(F(p1.X-p2.X)+F(p1.Y-p2.Y));bool O(PointF p,L l){var lx=l.S.X<l.E.X ? l.S.X : l.E.X;var hx=l.S.X>l.E.X ? l.S.X : l.E.X;var ly=l.S.Y<l.E.Y ? l.S.Y : l.E.Y;var hy=l.S.Y>l.E.Y ? l.S.Y : l.E.Y;return p.X>=lx && p.X<=hx && p.Y>=ly && p.Y<=hy;}static PointF? I(L l1,L l2){float a=l1.E.Y-l1.S.Y;float b=l1.S.X-l1.E.X;float d=a*l1.S.X+b*l1.S.Y;float e=l2.E.Y-l2.S.Y;float f=l2.S.X-l2.E.X;float g=e*l2.S.X+f*l2.S.Y;float h=a*f-e*b;if(h==0)return null;float x=(f*d-b*g)/h;float y=(a*g-e*d)/h;return new PointF(x,y);}void A(string x,string y,string r){var F=20f;C _=new C{P=new PointF(float.Parse(x)*F,float.Parse(y)*F),R=float.Parse(r)*F };c.Add(_);}void D(Graphics g,L l)=>g.DrawLine(new Pen(Color.Red),l.S.X,l.S.Y,l.E.X,l.E.Y);PointF R(PointF o,PointF p,float angle){var a=(float)Math.Sin(angle);var n=(float)Math.Cos(angle);var b=p.X-o.X;var x=p.Y-o.Y;return new PointF((n*b-a*x+o.X),(a*b+n*x+o.Y));}float angle(PointF p1,PointF p2){var a=p2.X-p1.X;if(a==0)return 0f;return(float)Math.Atan((p2.Y-p1.Y)/a);}void D(Graphics g,C c){g.DrawEllipse(new Pen(Color.Blue),c.P.X-c.R,c.P.Y-c.R,c.R*2,c.R*2);}float F(float d)=>d*d;float S(float d)=>(float)Math.Sqrt(d);}

More Complex examples (top circle gets into negative y values)

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


text:
What's the second non-repeating character?
Based on this question from Code Review
Given a non-empty string of printable ASCII characters, output the second non-repeating character. For example, for input DEFD, output F.
Input

A single string, in any suitable format.

Output

The second character that doesn't repeat, when reading left-to-right, again in a suitable format.
The output character is case-insensitive.
If no such character exists (e.g., all characters repeat), output an empty string.

Rules

The algorithm should ignore case. That is, D and d count as the same character.
Either a full program or a function are acceptable.
The input string will be guaranteed non-empty (i.e., at least one character in length).
The input string is ASCII. Any valid character could repeat, not just alphanumeric (this includes spaces).
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples
Input is on first line, output is on second line.
DEFD
F

FEED
D

This is an example input sentence.
x

...,,,..,,!@
@

ABCDefgHijklMNOPqrsTuVWxyz
B

AAAAAABBBBB

Thisxthis

This this.
.

If it wasn't case-insensitive, I'd consider doing it in Forth. String operations suck in that language, though.

What if my language doesn't support lowercase letters?

@Adám Does it utilize a different code page? How would it normally input an ASCII string if it doesn't support lowercase letters?

The system I had in mind had 7-bit code page; a modified standard code page where uppercase letters occupy the lowercase positions, and the uppercase positions were used for glyphs. This was done on old APL systems so that one could use Shift to access APL glyphs, while unshifted letters were classic coding-style capitals.

MATL, 11 bytes
tk&=s1=)FT)

This exits with an error (allowed by default) if there is no second non-repeated character.
Try it online!
Explanation
t      % Implicitly take input string. Duplicate
k      % Convert to lowercase
&=     % 2D array of equality comparisons
s      % Sum of each column
1=     % True for entries that equal 1
)      % Apply logical index to the input string to keep non-repeated characters
TF)    % Apply logical index to take 2nd element if it exists. Implicitly display

The ninja edit strikes again. :P

@Dennis Hahaha. Well, I guess you'll remove a couple of bytes soon

Retina, 25 bytes
i!2=`(.)(?<!\1.+)(?!.*\1)

Try it online! (The first line enables running the code on a test suite of several inputs.)
Explanation
This is just a single regex match, the regex being:
(.)(?<!\1.+)(?!.*\1)

That is, match a character and ensure it doesn't appear anywhere else in the input. The rest is configuration:

i activates case insensitivity.
! tells Retina to print the matches as opposed to counting them.
2= tells Retina to print only the second match as opposed to all of them.

Ah, thanks for teaching me about the 2=.

05AB1E, 15 12 bytes
l©v®y¢iy}}1@

Explained
l©            # store lower case string in register
  v     }     # for each char in lower case string
   ®y¢iy      # if it occurs once in string, push it to stack
         }    # end if
          1@  # push the 2nd element from stack and implicitly display

Try it online
Saved 3 bytes thanks to @Adnan

Or for 12 bytes l©v®y¢iy}}1@ :).

@Adnan: Nice! Didn't think of using @.

Jelly, 11 bytes
Œlµḟœ-Q$Ḋḣ1

Try it online! or verify all test cases.
How it works
Œlµḟœ-Q$Ḋḣ1  Main link. Argument: s (string)

Œl           Convert s to lowercase.
  µ          Begin a new, monadic chain. Argument: s (lowercase string)
       $     Combine the two links to the left into a monadic chain.
      Q        Unique; yield the first occurrence of each character.
    œ-         Perform multiset subtraction, removing the last occurrence of each
               character.
   ḟ         Filterfalse; keep characters that do not appear in the difference.
        Ḋ    Dequeue; remove the first character.
         ḣ1  Head 1; remove everything but the first character.

Python 2, 59 58 bytes
Returns a list of a single character, or an empty list if no output. (Stupid case-insensitivity...)
s=input().lower();print[c for c in s if s.count(c)<2][1:2]

Try it online

@mbomb007 http://meta.codegolf.stackexchange.com/a/7634

It's not valid input. The user should never have to escape their input.

Sure it is. We provide lists on STDIN in the language's list format. Why would strings be any different?

Batch, 171 bytes
@echo off
set a=.
set s=%~1
:l
if "%s%"=="" exit/b
set c=%s:~0,1%
call set t=%%s:%c%=%%
if "%s:~1%"=="%t%" set a=%a%%c%
set s=%t%
if "%a:~2%"=="" goto l
echo %c%

Alternative formulation, also 171 bytes:
@echo off
set a=.
set s=%~1
:l
if "%s%"=="" exit/b
set c=%s:~0,1%
set t=%s:~1%
call set s=%%s:%c%=%%
if "%s%"=="%t%" set a=%a%%c%
if "%a:~2%"=="" goto l
echo %c%

Can't make it to run on W2008R2. Line "call set ..." expands to "call set t=%s:D=%" and aborts with "The syntax of the command is incorrect" message.

@meden Sorry, some typos crept into my post. The dead giveaway was that the post was shorter than I said it was! They're fixed now.

C#, 129 128 bytes
char c(string i){var s=i.Where((n,m)=>i.ToLower().Where(o=>o==Char.ToLower(n)).Count()<2).ToArray();return s.Length>1?s[1]:' ';}

works fine.
I wish i didnt need to lowercase everything

Throws an IndexOutOfRangeException when I pass "Thisxthis" as an argument. Other than that, I think that ==1 can be changed to <2.

Pyth, 16 15 bytes
1 byte thanks to @mbomb007

=rz1.xhtfq1/zTzk
=rz1:fq1/zTz1 2

Test suite.

I don't even know Pyth, but if you say so. :D

@mbomb007 You know, the [1:2] trick.

You can save a byte with t<…2 instead of :…1 2. You can save another byte by moving the =rz1 to its first use, if you also change 1 to Z (for lowercase instead of uppercase output): t<fq1/zT=rzZ2.

Actually, 19 bytes
;╗`ù╜ùc1=`░ε;(qq1@E

Try it online!
Explanation:
;╗`ù╜ùc1=`░ε;(qq1@E
;╗                   push a copy of input to reg0
  `ù╜ùc1=`░          [v for v in s if
   ù╜ùc1=              s.lower().count(v.lower()) == 1]
           ε;(qq     append two empty strings to the list
                1@E  element at index 1 (second element)

C# lambda with Linq, 63 bytes
s=>(s=s.ToUpper()).Where(c=>s.Count(C=>c==C)<2).Skip(1).First()

You should be able to replace .Skip(1).First() with .ElementAt(1)

Even better you can convert to list and use the index .ToList()[1]

This throws an exception for inputs like "", "AABB", and "AABBC", where there is not a matching character in the 2nd position.  I think you need FirstOrDefault.

x86 machine code, 43 bytes
In hex:
FC31C031C95641AC84C0740E3C6172F63C7A77F28066FFDFEBEC5EAC49740B89F751F2AE5974F44A77F1C3

Function takes a pointer to the input string in (E)SI and an integer in (E)DX and returns the (E)DX-th non-repeating character or zero if there's no such character. As a side-effect it converts the string to upper case.
Disassembly:
fc             cld
31 c0          xor    eax,eax
31 c9          xor    ecx,ecx
56             push   esi
_loop0:                         ;Search for the NULL char,
41             inc    ecx       ;counting the length in the process
ac             lodsb
84 c0          test   al,al
74 0e          je     _break0   ;NULL found, break
3c 61          cmp    al,0x61   ;If char is
72 f6          jb     _loop0    ;between 'a' and 'z'
3c 7a          cmp    al,0x7a   ;convert this char
77 f2          ja     _loop0    ;to uppercase in-place
80 66 ff df    and    byte ptr [esi-0x1],0xdf
eb ec          jmp    _loop0
_break0:
5e             pop    esi       ;Reset pointer to the string
_loop:                          ;ECX=string length with NULL
ac             lodsb            ;Load next char to AL
49             dec    ecx
74 0b          je     _ret      ;End of string found, break (AL==0)
89 f7          mov    edi,esi   ;EDI points to the next char
51             push   ecx
f2 ae          repnz scasb      ;Search for AL in the rest of the string
59             pop    ecx
74 f4          je     _loop     ;ZF==1 <=> another instance found, continue
4a             dec    edx
77 f1          ja     _loop     ;If not yet the EDX-th non-rep char, continue
_ret:
c3             ret

APL, 32 bytes
{⊃1↓⍵/⍨1=+/∘.=⍨(⎕UCS ⍵)+32×⍵∊⎕A}

Try it || All test cases
Explanation:
                (⎕UCS ⍵)+32×⍵∊⎕A  Add 32 to uppercase letters
            ∘.=⍨                    Make an equality matrix
          +/                        Check how many matches
    ⍵/⍨1=                           Keep elements with 1 match
  1↓                                Drop the first one
⊃                                   Return the second one

I was about to post it with 16 bytes, but the I realized it had to be case-insensitive...

(⎕UCS ⍵)+32×⍵∊⎕A → 819⌶⍵

I've never seen that operator before. What version does it work in?

It is called the i-beam. It is an operator in all versions of Dyalog APL. It was originally a function in old versions of IBM's APL for special calls to the IBM system. Get it? I-B-M — i-beam?

Documentation for ⌶ in general and for service 819 ("819" ≈ "BIg"). Try it online!

Well, I've learned something new. tryapl.org doesn't seem to recognize it, so do you mind if I just use your TIO link?

I'll be happy to teach you more. ⌶ is disabled on TryAPL for security. You're welcome to use the link, but this may suit you better. Also, note that your solution actually fails to return empty strings when needed.

C#, 141 bytes
void p(){var x=Console.ReadLine().ToLower();var c=0;foreach(char i in x){if(x.Split(i).Length-1<2){if(++c==2){Console.WriteLine(i);break;}}}}

Without break(smallest), 135 bytes
void p(){var x=Console.ReadLine().ToLower();var c=0;foreach(char i in x){if(x.Split(i).Length-1<2){if(++c==2){Console.WriteLine(i);}}}}

With for(;;), 150 bytes
void p(){for(;;){var x=Console.ReadLine().ToLower();var c=0;foreach(char i in x){if(x.Split(i).Length-1<2){if(++c==2){Console.WriteLine(i);break;}}}}}

Ungolfed with comments
void p()
{
    var x=Console.ReadLine().ToLower();//Get lowercase version of input from STDIN
    var c=0; //Create "count" integer
    foreach(char i in x){//For each char in input from STDIN
        if(x.Split(i).Length-1<2)//If current char occurs once in input from STDIN
        {
            if(++c==2){ //Add 1 to count and if count is 2
                Console.WriteLine(i); //Print result to STDOUT
                break; //Exit foreach
            } //End of IF
         } //End of IF
     } //End of FOREACH
} //End of VOID

12 bytes saved by TuukkaX(change count to c).
3 bytes saved by TuukkaX(change string to var).
4 bytes saved by TuukkaX in "With for(;;)"(changed while(true) to for(;;)).
2 bytes saved by TuukkaX(changed c++;if(c==2) to if(++c==2)).
14 bytes saved by Bryce Wagner(changed x.ToCharArray() to x).

@TuukkaX oh, really. thank you!

Welcome to PPCG! That's a nice first post! Since the rules mention that answers to this problem should either be functions or full programs, your codes require little tweaks. You can also save bytes by using var instead of string and having something like c instead of count.

@TuukkaX Thank you again! Shortly I'll modify the code and change string to var.

@TuukkaX Should I add something like void program(){}???

Yes, but give a one byte function name to save bytes! :)

@TuukkaX Done. Good?

Very good! +1.  while(true) can be changed to for(;;).

You can just use Console.Write instead of Console.WriteLine.

@TuukkaX Using i+"\n" instead of i uses 5 bytes, Console.WriteLine instead of Console.Write uses 4 bytes.

Instead of incrementing c separately, you can omit the c++ line and move the incrementation to if(++c==2)....

OP doesn't mention that you should have a newline character at the end of the string.

@TuukkaX if(++c==2) doesn't increment the variable. Or does it?

@TuukkaX Yes, but it would look bad in the for() version.

if(++c==2) does increment c by one before c is used and the effect stays.

Let us continue this discussion in chat.

The .ToCharArray() is completely unnecessary, surprised nobody pointed that out.

C, 174 bytes
int c(char*s){int y=128,z=256,c[384],t;memset(c,0,z*6);for(;t=toupper(*s);s++){c[t]++?c[t]-2?0:c[z+(c[y+c[z+t]]=c[y+t])]=c[z+t]:c[z]=c[y+(c[z+t]=c[z])]=t;}return c[y+c[y]];}

This is not the most short, but quite efficient implementation. In essence it uses double-linked list to maintain ordered set of candidate characters and scans input string just once. Returns character code or zero if none found.
A little bit ungolfed version:
int c(char*s)
{
    int y=128,z=256,c[384],t;
    //It's basically c[3][128], but with linear array the code is shorter

    memset(c,0,z*6);

    for(;t=toupper(*s);s++)
    {
        c[t]++ ?        // c[0][x] - number of char x's occurrence
            c[t] - 2 ?  // > 0
                0       // > 1 - nothing to do
                : c[z + (c[y + c[z + t]] = c[y + t])] = c[z + t]  // == 1 - remove char from the list
            : c[z] = c[y + (c[z + t] = c[z])] = t; // == 0 - add char to the end of the list
    }
    return c[y + c[y]];
}

C#, 143 bytes
char c(string s){var l=s.Select(o=>Char.ToLower(o)).GroupBy(x=>x).Where(n=>n.Count()<2).Select(m=>m.Key).ToList();return l.Count()>1?l[1]:' ';}

Ruby, 53 bytes
Input is STDIN, output is STDOUT. In Ruby, out-of-index positions in an array or string return nil, which is not printed.
String#count is a strange function in Ruby because instead of counting the number of occurrences for the string that was passed in, it counts the number of occurrences for each letter in that string. It's usually annoying but we can use it to our advantage this time. String#swapcase swaps upper and lower case letters.
$><<gets.chars.reject{|c|$_.count(c+c.swapcase)>1}[1]

Old version that wasn't safe against special characters like . - 46 bytes
$><<gets.chars.reject{|c|$_=~/#{c}.*#{c}/i}[1]

Java 8, 172 157 bytes
(String s)->{s=s.toLowerCase();for(char i=0,c;s.length()>0;s=s.replace(c+"","")){c=s.charAt(0);if(!s.matches(".*"+c+".*"+c+".*")&&++i>1)return c;}return' ';}

-15 bytes.. Dang I was bad at golfing back then. ;)
Explanation:
Try it here.
(String s)->{                          // Method with String parameter and character return-type
  s=s.toLowerCase();                   // Make the input-String lowercase
  for(char i=0,c;s.length()>0;         // Loop over the characters of `s`
      s=s.replace(c+"","")){           // And after every iteration, remove all occurrences of the previous iteration
    c=s.charAt(0);                     // Get the current first character
    if(!s.matches(".*"+c+".*"+c+".*")  // If it doesn't occur more than once
     &&++i>1)                          // And this was the second one we've found
      return c;                        // Return this second characters
  }                                    // End of loop
  return' ';                           // Else: return an empty character/nothing
}                                      // End of method

TSQL, 128 bytes
Golfed:
DECLARE @ varchar(99)=',,zzzbb@kkkkkkJgg'

,@i INT=99WHILE @i>1SELECT
@i-=1,@=IIF(LEN(@)>LEN(x)+1,x,@)FROM(SELECT
REPLACE(@,SUBSTRING(@,@i,1),'')x)x PRINT SUBSTRING(@,2,1)

Ungolfed:
DECLARE @ varchar(99)=',,zzzbb@kkkkkkJgg'

,@i INT=99

WHILE @i>1
  SELECT
    @i-=1,@=IIF(LEN(@)>LEN(x)+1,x,@)
  FROM
    (SELECT
       REPLACE(@,SUBSTRING(@,@i,1),'')x
    )x

PRINT SUBSTRING(@,2,1)

Fiddle

Retina, 43 36 bytes
iM!`(.)(?<!\1.+)(?!.*\1)
!`(?<=^.¶).

Try it online!

Mathematica, 49 bytes
Cases[Tally@ToUpperCase@#,{_,1}][[2,1]]~Check~""&

Anonymous function. Takes a list of characters as input. Ignore any errors that are generated.

JavaScript (Firefox 48 or earlier), 60 bytes
f=s=>(m=s.match(/(.).*\1/i))?f(s.replace(m[1],"","gi")):s[1]

Returns undefined if there are only zero or one non-repeating characters. Works by case-insensitively deleting all occurrences of characters that appear more than once in the string. Relies on a non-standard Firefox extension that was removed in Firefox 49. 119 91 byte ES6 version:
f=s=>(m=s.match(/(.).*?(\1)(.*\1)?/i))?f((m[3]?s:s.replace(m[2],"")).replace(m[1],"")):s[1]

Recursively searches for all characters that appear at least twice in the string. If the character appears exactly twice then both occurrences are deleted otherwise only the first occurrence is deleted (the other occurrences will be deleted later). This allows the occurrences to have a difference case.

I believe you can actually adapt your Firefox 48 answer to be ES6-compliant by replacing m[1] with new RegExp(\${m[1]}`,"gi")`

@KevinLau-notKenny That wouldn't work for special characters, and it cost me 33 bytes to special-case them, taking me up to 93, unfortunately.

noooooo not the special characters! I've had to edit my Ruby answer to accommodate for them as well, now.

J, 25 bytes
(1{2{.]-.]#~1-~:)@tolower

Usage
   f =: (1{2{.]-.]#~1-~:)@tolower
   f 'DEFD'
f
   f 'FEED'
d
   f 'This is an example input sentence.'
x
   f '...,,,..,,!@'
@
   f 'ABCDefgHijklMNOPqrsTuVWxyz'
b
   f 'AAAAAABBBBB'

   f 'Thisxthis'

   f 'This this.'
.

Explanation
(1{2{.]-.]#~1-~:)@tolower  Input: s
                  tolower  Converts the string s to lowercase
              ~:           Mark the indices where the first time a char appears
            1-             Complement it
         ]                 Identity function to get s
          #~               Copy only the chars appearing more than once
      ]                    Identity function to get s
       -.                  Remove all the chars from s appearing more than once
   2{.                     Take the first 2 chars from the result (pad with empty string)
 1{                        Take the second char at index 1 and return it

Bash, 58 bytes
tr A-Z a-z>t
tr -dc "`fold -1<t|sort|uniq -u`"<t|cut -c2

Caution: This creates a temporary file named t. If it already exists, it will be overwritten.

R, 79 bytes
function(z){y=tolower(el(strsplit(z,"")));x=table(y);y[y%in%names(x[x==1])][2]}

Try it online!
I definitely feel like something can be golfed out here. But I really enjoyed this challenge.
This answer splits the string into a vector of characters, changes them all to lower case, and tables them (counts them). Characters that occur once are selected and compared to characters within the aforementioned vector, then the second value that is true is returned as output. An empty string, or a string with no repeating characters outputs NA.

Perl 6, 38 32 bytes
-6 bytes thanks to nwellnhof by changing .comb to a case-insensitive regex
{~grep({2>m:g:i/$^a/},.comb)[1]}

Try it online!

m:g:i/$^a/ for 32 bytes.

05AB1E, 9 6 bytes
lÐ¢Ï¦н

Input as a list of characters.
Try it online or verify all test cases.
Explanation:
l       # Convert the characters in the (implicit) input-list to lowercase
 Ð      # Triplicate this lowercase list
  ¢     # Pop two, and get the count of each character in the list
   Ï    # Pop the counts and remaining list, and only keep the characters at the truthy
        # (count==1) positions
    ¦   # Remove the first character
     н  # Pop and leave the new first character
        # (after which it is output implicitly as result)

Unfortunately the .m (least frequent character(s) builtin) doesn't retain its order in the legacy version of 05AB1E and will only keep the first character instead of a list in the new 05AB1E version, otherwise this could have been 5 bytes with l.m¦¬.

K (oK) / K4, 11 bytes
Solution:
*1_&1=#:'=_

Try it online!
Explanation:
*1_&1=#:'=_ / the solution
          _ / convert input to lowercase
         =  / group alike characters
      #:'   / count (#:) each group
    1=      / 1 equal to length of the group?
   &        / where true
 1_         / drop the first
*           / take the first

Thunno 2 h, 6 bytes
LDcḅịḣ

Try it online!
Explanation
LDcḅịḣ  # Implicit input
    ị   # Filter the input by:
L c     #  The count of the character lowercased
 D      #  In the input lowercased
   ḅ    #  Equals one?
     ḣ  # Remove the first character
        # Implicit output of next character
        # (or the empty string if it doesn't exist)

Vyxal, 9 bytes
⇩)ġ~₃f∑Ḣh

Try it Online!
-3 thanks to @lyxal
Explanation
⇩)ġ~₃f∑Ḣh  # Implicit input
⇩)ġ        # Group by lowercasing
   ~₃      # Filter by length == 1
     f∑    # Flatten and join
       Ḣ   # Remove the first character
        h  # Then take the next one
           # (or an empty string
           #  if it doesn't exist)
           # Implicit output

Japt -g, 8 bytes
k@oX ÅÃÅ

Try it
k@v èXv)É

Perl, 75 bytes
 my$s=<>;chomp$s;my$c;for my$i(split//,$s){my$m=@{[$s=~/$i/gi]};$m<2and++$c>=2and say$i and last}

Javascript (using external Library) (107 bytes)
Crushed this using a library I wrote. Not sure if I have to count the declaration of variable "s", which is the string in question.
(s)=>_.From(s).ToLookup(y=>y.toLowerCase(),z=>z).Where(g=>g.Value.Count()==1).Select(x=>x.Key).ElementAt(1)

This will handle an empty string input, an input with only one non-repeating character, and an input with 2+ non-repeating characters

Do you have a link to the library in question? Also, this being code golf, you gotta take out whitespace where you can

Hey, yeah it's https://github.com/mvegh1/Enumerable . No docs yet. Sorry, I will clean up this answer to reduce as much whitespace

You should probably mention and link it in the answer body. Also, regarding the bytecount, consensus is to put it into an anonymous lambda (so s=> ...)

Ok no problem. I didn't want to offend anybody by linking to my code, but I did mention I used my library. I'll update my answer with the lambda, thanks for letting me know

Jelly, 15 bytes
Œlµċ@Ị¥Ðf¹ḊḢȯ“”

Try it online!
Verify all testcases. (Slightly modified to cater for all testcases)

Clojure, 109 bytes
#(let[s(clojure.string/lower-case %)](or(second(remove(set(map(fn[[k v]](if(> v 1)k))(frequencies s)))s))""))

Ough, I hope there is a more succinct way.

JavaScript, 57 bytes
v=>(v+'\0'+v).replace(/(.)(?=.*\1.*\1)|\0.*/gi,"")[1]||""

JavaScript doesn't have Regex lookbehind, so I appended a null character and another copy of the string so that I can use lookahead.  I then remove the null character and all characters after it as part of the regex replace.

PowerShell, 55 Bytes
old but good challenge, deserves a PS answer.
([char[]]"$args".ToLower()|group|? Count -eq 1)[1].Name

Throws errors when there are no non-repeating chars, exits with no error or return if there is only one repeating char.
the .ToLower() cost a bit due to the case insensitivity, and using |% ToL*r actually costs bytes since you need to wrap it all in brackets before converting to a char[]

PHP, 76 bytes
for($a=$argn;~$c=$a[$i++];)stripos($a,$c)<strripos($a,$c)?:$r.=$c;echo$r[1];

Try it online!

Java (OpenJDK 8), 133 131 bytes
s->{String t=s.toUpperCase();int[]i=t.chars().filter(c->t.indexOf(c)==t.lastIndexOf(c)).toArray();return(char)(i.length>1?i[1]:0);}

Try it online!

Pyth, 17 bytes
Jrz1.x.(fq/JT1J1k

Test suite
Python 3 translation:
J=input().upper()
try:
    print([T for T in J if J.count(T)==1][1])
except:
    print()

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


text:
I hate Mondays!
You should a program in language X, which will only output its source code (i.e function as a quine) when it is not a monday. On monday it should output some string with a levehnstein distance of 4 from the source code. i.e if the code is aaaa on sunday it should output aaaa and on monday it could output ....aaaa or bbbb or cccc or ..aaaa.. etc

Read about Levehnstein difference here https://en.wikipedia.org/wiki/Levenshtein_distance

Rules

Your solution must be testable
No cheating quines, and any other standard loopholes allowed
Should your language "X" lack access to the date it may assume its a random date at the cost of 35 bytes
This is code golf and I will accept the shortest solution (in bytes) as winner

This is yet another generalized quine challenge...

Yes I was worried that it would be closed as such, but if the moderators would have wanted to close it as duplicate they would have by now.

Jolf, 19 13 9 bytes
?wfb+q~2q

Try it online.
Saved quite a few bytes thanks to Conor.
?wfb+q~2q

?wfb+q~2q
?          if
 wfb       the current weekday - 1 (which is 0 on Monday) is truthy
    +q~2   print the program's source code with 1000 appended to it
           else
        q  print the program's source code

It's only 1 byte longer than CJam so I wouldn't say this is that long.

@Downgoat It should be at minimum 2 bytes shorter but there's a bug

For the condition, try ='MFf3. For the extra four characters, try *4S (four newlines)

Ah. Good thing it's a Monday and not a Tuesday.

Does using a quine built-in not count as a cheating quine any more?

@MartinEnder I would consider it cheating, but it seems to be a respectable answer. Also I did not specifically warn againt apart from "reading the programs source or "standard loopholes"" I would be inclined to allow it, but what is the community consensus on this matter?

Usually to me "cheating quine" means reading the source code from the file on disk. Unfortunately there is no real community consensus on this; quines have always been kind of a murky area partially because there is no good definition of a "proper" quine

Hey, more golfing! replace *4S with ~2 and ='MFf3 with wfb.(I think, at least, on the last one.)

@CᴏɴᴏʀO'Bʀɪᴇɴ I get the wfb (I didn't know fb existed) but how does the ~2 work? Does it literally insert 1000 into the transpiled code?

Yes, it does. ~1 is 100, ~2 is 1000, ~3 is 10000, ~4 is 10000, and ~5 is 16.

Right, I knew that. I just always assumed they were treated as variables and not inserted directly (meaning that it wouldn't have casted to string)

Currently the most upvoted post on meta about this suggests that a quine consist of data and code. I feel like it is hard to argue that this quine built-in uses code to take some data to generate the quine. It is of course up to the poster to decide, but I don't personally think that this is particularly in the spirit of quine challenges.

Javascript - 47 45 43 42 34 32 29 bytes
8 bytes saved thanks to @Downgoat.
5 bytes saved thanks to @Dendrobium.
f=_=>(Date()[0]!="M"&&"f=")+f

!Date().search\Mon`` is shorter way to check if it is monday

@Downgoat cool, didn't know. how does ` work btw?

Date()[0]=='M' is even shorter

\`` uses Date().search` as a tag rather than a function. It'll still call it though but it'll pass some more properties. You can read more here under "tagged template literals"

@Downgoat that's what i had before, but why don't i need to cast?

On Safari at least Date() returns a string. new Date() returns a date objcet rather than a string

@Downgoat oic, new Date() gives date object, Date() gives string. thanks

f=_=>Date()[0]=="M"?1e3+f:"f="+f for 32 bytes

@Dendrobium how does the _ work? nice trick with 1e3 btw.

@Maltysen _ is just a variable name that goes unused inside the function.

@Dendrobium cool.

Huh, f=_=>(Date()[0]!="M"&&"f=")+f for 29 bytes. When its Monday, the function returns false_=>(Date()[0]!="F"&&"f=")+f with the difference between = and alse being 4.

@Dendrobium haha nice!

If the challange was about fridays, you could check it with Date()[0]<"G", saving one byte, but as far as I can see, you can’t make use of Unicode ordering here…

Why not f=_=>Date()[0]!="M"&&"f="+f?

CJam, 18 17 bytes
{"_~"et7=({\}|}_~

Test it here.
On Mondays, it prints:
_~{"_~"et7=({\}|}

Dennis found a 16-byte solution which will break in the year 10,000 though:
{"_~"et_7=1=<}_~

On Mondays, this prints
{"_~"et_7=1=<}_~2016

... or whatever the current year is.

{et_7=1=<"_~"}_~ works for the next ~8000 years.

@Dennis haha, that's a neat idea.

Batch, 128 bytes
@set/am=%date:~3,2%,a=(14-m)/12,y=%date:~6%-a,d=(%date:~0,2%+y+y/4-y/100+y/400+(m+47)*18/7+a*3)%%7
@if %d%==1 echo @:
@type %0

Since Windows XP, date doesn't give you the day of the week, so I must directly calculate it from the date. The leap year adjustment wants March-based years so a is used as an adjusting factor. (m+47)*18/7 is quicker than using a month-based lookup table.
Note that you need to invoke the file using its full name (e.g. monday.bat). The echo @: counts as a distance of 4 because of the extra CR/LF; I used @: because the result is still a syntactically valid batch script.

Date format is related to system setting

Mathematica, 75 bytes
StringJoin[If[DayName[] == Monday, "0001", ""], ToString[#0, InputForm]] &

Anonymous function, takes no inputs and returns the output. Replace Monday with Friday (or whatever the current day is) to test.

i see lots of spaces

@Maltysen A byproduct of the quine mechanism

oh, lol ------------

Vitsy + bash, 29 26 bytes
'&"etad","M"-)[Y4\a]?rd3*Z

'                            Take a string of everything until hitting another '.
                             This will wrap around as it finds none.
 &                           Create a new stack and push the current stack over.
  "etad"                     Push the string "date" to the stack.
        ,                    Execute the current stack through shell.
         "M"-                Subtract the character "M" from the first item of the
                             current stack.
             )[    ]         If it is equal to zero, do the stuff in brackets.
               Y             Remove the current stack.
                4\a          Push the return character to the stack four times.
                    ?        Rotate over a stack (if there is none, stay put).
                     r       Reverse the stack.
                      d3*    Push the character ' to the stack.
                         Z   Print everything in the current stack.

This cannot be tried online as it accesses shell, however, feel free to test this with the downloadable interpreter found here.
Note that this is a variant of the standard quine, 'rd3*Z.

GolfScript, 21 20 + 35 = 56 55 bytes (or 22 + 0 = 22 20)
With randomizing, no input expected (following the rules completely):
{7rand 0=2*)".~"*}.~

Alternatively, date as input, in format like Javascript's new Date().toString() (bending the rules a little):
{\.,%"M"=2*)".~"*}.~

Each solution looks like this:
{somecode2*)".~"*}.~

{                }    create a block
                  .   duplicate it
                   ~  execute one copy
 somecode             push 1 if monday or 0 otherwise
         2*           multiply by 2 (2 if monday, 0 otherwise)
           )          add 1 (3 if monday, 1 otherwise)
            ".~"      the tail...
                *     ...copied 1 or 3 times and concatenated together

Now the stack looks like this:
.~  (or .~.~.~)
{somecode2*)".~"*}

... and is printed bottom to top.
The somecode part for random:
7rand 0=

7rand          select a random number from 0 to 6, let 0 be monday
      0=       check if equal to 0 (1 if monday, 0 otherwise)

The somecode part for input:
\.,%"M"=
\             we have the input first and the block on top, so we need to swap them
 .            duplicate the input
  ,           replace the second copy with its length
   %          get every (length)-th character starting from 0, effectively fetching first (M on mondays, something else otherwise)
    "M"=      check if equal to M (1 on mondays, 0 otherwise)

Good Answer! Welcome to Programming Puzzles and code Golf! While technically quines (and quine variants) should take no input, I do like both solutions to be there and they both seem well thought out!

@RohanJhunjhunwala Yes, they shouldn't take any input, I use it as an altervative for GolfScript's non-existent date builtin.

Java "Only" 2,897 bytes
Take a look at this monstrosity. Can someone help me test this on a monday, I cant figure out how to trick Java into thinking its monday.
import java.util.Calendar;public class Quine{public static void main(String[] args){char[] s={83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,105,109,112,111,114,116,32,106,97,118,97,46,117,116,105,108,46,67,97,108,101,110,100,97,114,59,112,117,98,108,105,99,32,99,108,97,115,115,32,81,117,105,110,101,123,112,117,98,108,105,99,32,115,116,97,116,105,99,32,118,111,105,100,32,109,97,105,110,40,83,116,114,105,110,103,91,93,32,97,114,103,115,41,123,34,41,59,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,99,104,97,114,91,93,32,115,61,123,34,41,59,102,111,114,40,105,110,116,32,105,61,48,59,105,60,115,46,108,101,110,103,116,104,45,49,59,105,43,43,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,105,93,43,34,44,34,41,59,125,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,115,46,108,101,110,103,116,104,45,49,93,43,34,125,59,34,41,59,102,111,114,40,99,104,97,114,32,99,58,32,115,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,99,41,59,125,105,102,40,67,97,108,101,110,100,97,114,46,103,101,116,73,110,115,116,97,110,99,101,40,41,46,103,101,116,40,55,41,61,61,50,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,109,111,110,100,34,41,59,125,125,125,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,105,109,112,111,114,116,32,106,97,118,97,46,117,116,105,108,46,67,97,108,101,110,100,97,114,59,112,117,98,108,105,99,32,99,108,97,115,115,32,81,117,105,110,101,123,112,117,98,108,105,99,32,115,116,97,116,105,99,32,118,111,105,100,32,109,97,105,110,40,83,116,114,105,110,103,91,93,32,97,114,103,115,41,123,34,41,59,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,99,104,97,114,91,93,32,115,61,123,34,41,59,102,111,114,40,105,110,116,32,105,61,48,59,105,60,115,46,108,101,110,103,116,104,45,49,59,105,43,43,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,105,93,43,34,44,34,41,59,125,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,115,46,108,101,110,103,116,104,45,49,93,43,34,125,59,34,41,59,102,111,114,40,99,104,97,114,32,99,58,32,115,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,99,41,59,125,105,102,40,67,97,108,101,110,100,97,114,46,103,101,116,73,110,115,116,97,110,99,101,40,41,46,103,101,116,40,55,41,61,61,50,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,109,111,110,100,34,41,59,125,125,125};System.out.print("import java.util.Calendar;public class Quine{public static void main(String[] args){");System.out.print("char[] s={");for(int i=0;i<s.length-1;i++){System.out.print((int)s[i]+",");}System.out.print((int)s[s.length-1]+"};");for(char c: s){System.out.print(c);}if(Calendar.getInstance().get(7)==2){System.out.print("mond");}}}

What on earth is that char array?

Wtf 2,897 bytes

@Insane This is the only quine framework  i have come up with myself. I could rob a better quine framework from someone, but still I find my solution hilarious.

Okay now that looks really strange, I'm sure that can be golfed. At least by stripping some white space and renaming args

Yeah it could be golfed... for one I shouldn't use a char[] to store the code! Also I call the class Quine... Its golfed enough

Java, 334 characters
import java.util.Calendar;interface Q{static void main(String[]a){String p="import java.util.Calendar;interface Q{static void main(String[]a){String p=%c%s%1$c;System.out.printf(p,34,p);if(Calendar.getInstance().get(7)==2)System.out.print(0<1);}}";System.out.printf(p,34,p);if(Calendar.getInstance().get(7)==2)System.out.print(0<1);}}

Based on @RohanJhunjhunwala 's solution, just using the quine method from over here. The difference of four comes by appending true if it's monday. I think it should be possible to shorten that a bit.

Reng v.5, noncompeting, 56 bytes
Version 5 brings to you object oriented programming!
"68¹65¹84¹69¹4&A3¹A1¹B6¹68¹97¹C1¹6Ó`1e4*{Xo}2[r*]rao! ;~

This is a standard quine. Simply, "<code>rao! ;~ executes <code>, then outputs the programming, then exits.
¹ is Manhattan addition, e.g., digit concatenation. This gives the char codes of DATE, then 4& retrieves the date from the date module. (Equivalently, "DATE"4&.) This pushes a date object. (While it looks like it should be easily retrievable from the display in the stack, this is just how it prints in the stack display. It is unable to be manipulated.)
The next series provides another pseudo string, translating to getDay. Then, we get the property getDay of the date object on the stack using 6Ó. We then execute it with `. This provides JS's getDay. When it's 1, it's monday. We check for equality with 1 using 1e, then multiply by four. {Xo} pushes a code block that prints (o) char 33 (X), or !. 2[r creates a new stack with the top two items in reverse order. Then, we repeat (*) the code block 4 times (when monday) or 0 times (any other day). On monday, it prints 4 !s. Otherwise, it prints nothing. Then the string captured by wraparound is printed, and we have the rest of our source.
Output on monday:
!!!!68¹65¹84¹69¹4&A3¹A1¹B6¹68¹97¹C1¹6Ó`1e4*{Xo}2[r*]rao! ;~

On other days:
68¹65¹84¹69¹4&A3¹A1¹B6¹68¹97¹C1¹6Ó`1e4*{Xo}2[r*]rao! ;~