# Calculate the sum of ILD

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 , 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.

### 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? – Yytsi Jun 30 '16 at 16:36
• @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. – Kevin Cruijssen Jun 30 '16 at 17:36

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. :) – Kevin Cruijssen Sep 20 '16 at 12:18
• 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. – manatwork Sep 20 '16 at 12:39
• As it stands, this is invalid and needs to be fixed or deleted. – Rɪᴋᴇʀ Sep 20 '16 at 13:59
• I tried to fix my answer, is it still invalid? – Quintonn Sep 20 '16 at 19:33

# 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. – Kevin Cruijssen Feb 18 '18 at 11:05