# Pokemon GO Evolution Cost Calculator

Tired of always wondering how many more Pokémon you need to catch to get those high-tier evolutions? Wonder no more! Now you will write a complete program or function to calculate it for you!

## The Challenge:

As input, your program will receive a list of the costs in candy to evolve a Pokémon to the next tier. (This list may be separated by any delimiter of your choosing, or as function arguments). Your program will then return or print the number of Pokémon that must be caught, including the one that will be evolved, to evolve through all the tiers given.

How do you calculate this? Like so:
1. Add up all the candy costs: 12 + 50 = 62
2. Subtract 3 candies from the total, this being from the one Pokémon you keep for evolving: 62 - 3 = 59
3. Divide this number by 4 (3 for catching, 1 for giving it to the Professor), always taking the ceil() of the result: ceil(59/4) = 15
4. Finally, add 1 to this total to get the total number of Pokémon you must catch, 16!

Example Input -> Output:

 -> 2
 -> 13
[12, 50] -> 16
[25, 100] -> 32
[19, 35, 5, 200] -> 65


## Winning:

The app has already taken up most of the space on your phone, so your program needs to be as short as possible. The complete program or function with the smallest byte count will be accepted in two weeks! (with any ties being settled by the earliest submitted entry!)

• How is the output calculated? – Leaky Nun Aug 23 '16 at 21:55
• In the future, please use the Sandbox to work out kinks in your challenges and to get feedback on them before posting. – El'endia Starman Aug 23 '16 at 22:01
• If you want a slightly less nonsensical rationale for short code length, you could go with "because the app has almost killed your battery, you want your code to be as short as possible, so you can type it in before your battery dies." – Mego Aug 23 '16 at 22:02
• Shouldn't the formula be floor(Sum(L)/4)+1? The current formula doesn't work for sums divisible by 4. For example  would return 100, when in reality it needs to be 101 for the extra one to evolve. – Emigna Aug 23 '16 at 22:40
• I hope someone posts an answer in Go – Kodos Johnson Aug 24 '16 at 0:50

# 05AB1E, 4 bytes

O4÷>


Explanation

O    # sum
4÷  # integer division by 4
> # increment


Try it online

• ÷ is 2 bytes ... – user23127 Aug 24 '16 at 11:21
• @user23127: 05AB1E uses the CP-1252 encoding. – Emigna Aug 24 '16 at 11:27

# Jelly, 5 4 bytes

S:4‘


Try it online!

Sum, integer divide : by 4 and increment ‘.

• ;-; I'm 4 seconds late – acrolith Aug 23 '16 at 22:15
• It doesn't work when the sum is divisible by 4. – milk Aug 23 '16 at 23:56
• Gives wrong answer for . – orlp Aug 24 '16 at 0:41
• Fixes. Apparently the spec changed when I was sleeping. – PurkkaKoodari Aug 24 '16 at 4:03

# Brain-Flak 112 bytes

([]<([()])>){{}({}{})([][()])}{}{({}[()])<>(({}[()()()]<({}())>)){{}(<({}()()()()<({}[()])>)>)}{}<>}{}<>{}({}())


Try It Online!

## Explanation

It sums the stack, subtracts one, divides by four, and adds one.

• How do I run this on try it online? It only outputs 1 for me for any input scheme I've tried. – orlp Aug 24 '16 at 0:46
• Gives wrong answer for . – orlp Aug 24 '16 at 0:50
• @orlp Fixed. I put the wrong code in try it online. – Post Rock Garf Hunter Aug 24 '16 at 0:50

# C# REPL, 15 bytes

n=>n.Sum()/4+1;


Casts to Func<IEnumerable<int>, int>.

## Actually, 4 bytes

Σ¼≈u


Try it online!

Explanation:

Σ¼≈u
Σ     sum
¼    divide by 4
≈   floor

• Aren't these unicode characters 2 bytes each? – user23127 Aug 24 '16 at 11:18
• @user23127 If this were encoded in UTF-8, yes. Actually (and its predecessor Seriously) use CP437. – Mego Aug 24 '16 at 21:01

# Brachylog, 5 bytes

+:4/+


Try it online!

### Explanation

+        Sum
:4/     Integer division by 4
+    Increment


# Python 2, 21 bytes

lambda a:~-sum(a)/4+1


Ideone it!

Formula: ((sum(a)-1)//4)+1 where // is floor-div.

• Gives wrong answer for . – orlp Aug 24 '16 at 0:38

# BASH (sed + bc) 19

sed 's~)~+4)/4~'|bc


Input is a + separate list on stdin
E.g.:
echo '(19+35+5+200)'| sed 's~)~+4)/4~'|bc

(+1).(div4).sum


## Pyke, 4 bytes

seeh


Try it here!

((sum(input)/2)/2)+1


# Pyth, 5 bytes

h/sQ4


Try it here!

Sum input with sQ, divide by 4 with /4 and finally increment h.

# CJam, 7 bytes

{:+4/)}


Try it here!

Defines an unnamed block that expects the input on the stack and leaves the result there.
:+ sums the list, 4/ divides the result by 4 and ) increments that.

## Retina, 18 17 bytes

Byte count assumes ISO 8859-1 encoding.

$¶4 .+|¶$*
1111


Input is linefeed-separated.

Try it online!

• @orlp yay for rule changes. fixed. – Martin Ender Aug 24 '16 at 7:29

# R, 22 bytes

floor(sum(scan())/4+1)


# JavaScript, 29 Bytes

x=>x.reduce((a,b)=>a+b)/4+1|0


# S.I.L.O.S 100 99 103 characters + 22 for sample input

Code with testing harness.

set 512 52
set 513 10
GOSUB e
GOTO f
funce
a = 0
i = 511
lblE
i + 1
b = get i
a + b
if b E
a / 4
a + 1
return
lblf
printInt a


input as a series of set commands to modify the spots of the heap starting at spot 512.
Try it Online!

• Just because Pokemon Go doesn't have more than 8 tiers of evolution (it actually maxes out at 3), doesn't mean you aren't required to handle larget test cases. – Mego Aug 24 '16 at 4:28
• @Mego the spec clearly references pokemon go, and thus we can assume that all input will be valid input. I would have posted a much better version that does indeed handle newline separaated input terminated with a zero sentinel, but the TIO is currently borked – Rohan Jhunjhunwala Aug 24 '16 at 12:38
• @Mego let me clarify with the OP. If this is invalid I can modify it to work for even larger test casees – Rohan Jhunjhunwala Aug 24 '16 at 12:38
• This is actually a standard loophole - you're assuming rules not present in the challenge. – Mego Aug 26 '16 at 7:28
• @Mego modified for a cost of three bytes, it now should work up to 1000's of evolutions. – Rohan Jhunjhunwala Aug 26 '16 at 13:13

# Python 2, 40 bytes

import math
lambda s:math.ceil(sum(s)/4)

• This does not work because sum(s) is an integer and / in Python 2 would be integer division when both arguments are integers. – Leaky Nun Aug 23 '16 at 22:11
• @LeakyNun what do you mean? it works for me – acrolith Aug 23 '16 at 22:16
• Gives wrong answer for . – orlp Aug 24 '16 at 0:40