Imports System
' string = "aaa"
' After Shifting the first 1 letter by 1 = "baa"
' After shifting the first 2 letters by 2 = "dca"
' After shifting the first 3 letters 3 = "gfd"
' result = "gfd"
Public Class Program
Friend Shared Function shifLetters(ByVal str As String, ByVal shifts As Integer()) As String
Dim size As Integer = shifts.Length
Dim arr As Char() = str.ToCharArray()
For i As Integer = size - 1 To 0 step -1
If i + 1 < size Then
shifts(i) += shifts(i + 1)
End If
shifts(i) = shifts(i) Mod 26
Dim asciicode As Integer = Convert.ToByte(str(i)) - 97 ' 97 = 'a'
asciicode = asciicode + shifts(i)
If asciicode > 25 Then
asciicode = asciicode - 26
End If
arr(i) = Chr(97 + asciicode)
Next
Return New String(arr)
End Function
Public Shared Sub Main(ByVal args As String())
Dim str As String = "aaa"
Dim shifts As Integer() = New Integer() {1, 2, 3}
str = shifLetters(str, shifts)
Console.Write(str)
End Sub
End Class
' run:
'
' gfd
'