jagreygoose icon

Challenge #352 [Easy] Making Imgur-style Links

jagreygoose | PRO | 01/11/19 07:28:45 AM UTC | 0 ⭐ | 217 👁️ | Never ⏰ | []
PowerShell |

620 B

|

None

|

0 👍

/

0 👎

function Base62 {
    param(
    [ValidateRange(0, [int]::MaxValue)]
        [int]
        $NumberInput
        
    )
 
    process {
 
 
        [string]$Symbols = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
        [int]$Radix = $Symbols.Length
        [string]$Output = ""
 
        Do {
 
            $Output = '{0}{1}' -f $Output, $Symbols[($NumberInput % $Radix)]
            $NumberInput = [Math]::Floor([decimal]($NumberInput /= $Radix))
 
        }
        While ($NumberInput -gt 0)
        $Output 
        
    }
}
 
 
 
Base62 187621 # => 9OM
Base62 237860461 # => 3n26g
Base62 2187521 # => B4b9
Base62 18752 # => sS4

Comments