Everyone Knows AdFly and their Sister Sites.
If we see the Page Source of an ad.fly site we can see this perticular line:
Believe it or not This is actually the Encoded url which you would skip to.
The Algorithm is as Follows:
```
1) The ysmm value is broken like this
ysmm   = 0 1 2 3 4 5 6 7 8 9  = "0123456789"
code1  = 0   2   4   6   8    = "02468"
code2  =   9   7   5   3   1  = "97531"
2) code1+code2 is base64 Decoded
3) The result will be of this form :
https://adf.ly/go.php?u=
4)  has to be further decoded and the result is to be returned
```
Your Task:
```
Make a function to Encode text to ysmm value.
and a function to Decode ysmm value.
```
Note: Take random values for The first 2 int values.
I personally hate trivial error checking like giving integer input in place of string. 
```
Input For Decoder & Encoder: Strings
Return "Invalid" for invalid Strings
```
import base64

def adFly_decoder(sc):
    #your code here
    code1 = ''
    code2 = ''
    flg = True
    for ch in sc:
        if flg:
            code1 += ch
        flg = not flg
        
    flg = True
    for ch in sc[::-1]:
        if flg:
            code1 += ch
        flg = not flg
        
    try:
        s = base64.b64decode(code1 + code2).decode('utf-8')
        s = s.split('//adf.ly/go.php?u=')[1]
        return base64.b64decode(s).decode('utf-8')
    except: 
        return 'Invalid'

def adFly_encoder(url):
    s = '96https://adf.ly/go.php?u='
    e_url = base64.b64encode(bytes(url, 'utf-8')).decode('utf-8')
    s += e_url
    b64 = list(base64.b64encode(bytes(s, 'utf-8')).decode('utf-8'))
    
    yummy = ''
    flg = True
    while b64:
        if flg:
            yummy += b64.pop(0)
        else:
            yummy += b64.pop()
        flg = not flg
    
    return yummy
import base64

def adFly_decoder(sc):
    #your code here
    code1 = ''
    code2 = ''
    flg = True
    for ch in sc:
        if flg:
            code1 += ch
        flg = not flg
        
    flg = True
    for ch in sc[::-1]:
        if flg:
            code1 += ch
        flg = not flg
        
    try:
        s = base64.b64decode(code1 + code2).decode('utf-8')
        s = s.split('//adf.ly/go.php?u=')[1]
        return base64.b64decode(s).decode('utf-8')
    except: 
        return 'Invalid'

def adFly_encoder(url):
    s = '96https://adf.ly/go.php?u='
    e_url = base64.b64encode(bytes(url, 'utf-8')).decode('utf-8')
    s += e_url
    b64 = list(base64.b64encode(bytes(s, 'utf-8')).decode('utf-8'))
    
    yummy = ''
    flg = True
    while b64:
        if flg:
            yummy += b64.pop(0)
        else:
            yummy += b64.pop()
        flg = not flg
    
    return yummy