• + 0 comments

    php solution with function for reuse...

    <?php
    declare(strict_types = 1);
    
    $_fp = fopen("php://stdin", "r");
    echo f(fgets($_fp), (int)fgets($_fp));
    
    function f(string $x, int $e): string
    {
        for($i=strlen($x)-1; $i--;)
            $x[$i] = ($x[$i] + $e) % 10;
        return $x;
    }
    
    ?>