WeixiangYan/CodeTransOcean huggingface dataset:
Task: Pseudo-random numbers_Middle-square method







Python: seed = 675248
def random():
    global seed
    seed = int(str(seed ** 2).zfill(12)[3:9])
    return seed
for _ in range(5):
    print(random())


VB: Option Explicit
Dim seed As Long
Sub Main()
    Dim i As Integer
    seed = 675248
    For i = 1 To 5
        Debug.Print Rand
    Next i
End Sub
Function Rand() As Variant
    Dim s As String
    s = CStr(seed ^ 2)
    Do While Len(s) <> 12
        s = "0" + s
    Loop
    seed = Val(Mid(s, 4, 6))
    Rand = seed
End Function
Task: Rosetta Code_Find unimplemented tasks







Python: 
from operator import attrgetter
from typing import Iterator

import mwclient

URL = 'www.rosettacode.org'
API_PATH = '/mw/'


def unimplemented_tasks(language: str,
                        *,
                        url: str,
                        api_path: str) -> Iterator[str]:
    
    site = mwclient.Site(url, path=api_path)
    all_tasks = site.categories['Programming Tasks']
    language_tasks = site.categories[language]
    name = attrgetter('name')
    all_tasks_names = map(name, all_tasks)
    language_tasks_names = set(map(name, language_tasks))
    for task in all_tasks_names:
        if task not in language_tasks_names:
            yield task


if __name__ == '__main__':
    tasks = unimplemented_tasks('Python', url=URL, api_path=API_PATH)
    print(*tasks, sep='\n')


VB: Set http= CreateObject("WinHttp.WinHttpRequest.5.1")
Set oDic = WScript.CreateObject("scripting.dictionary")

start="https://rosettacode.org"
Const lang="VBScript"
Dim oHF 

gettaskslist "about:/wiki/Category:Programming_Tasks" ,True
print odic.Count
gettaskslist "about:/wiki/Category:Draft_Programming_Tasks",True
print "total tasks " & odic.Count
gettaskslist "about:/wiki/Category:"&lang,False
print "total tasks  not in " & lang & " " &odic.Count & vbcrlf
For Each d In odic.keys
   print d &vbTab &  Replace(odic(d),"about:", start)
next
WScript.Quit(1)

Sub print(s): 
  On Error Resume Next
  WScript.stdout.WriteLine (s)  
  If  err= &h80070006& Then WScript.echo " Please run this script with CScript": WScript.quit
End Sub 

Function getpage(name)
  Set oHF=Nothing
  Set oHF = CreateObject("HTMLFILE")
  http.open "GET",name,False  
  http.send 
  oHF.write "<html><body></body></html>"
  oHF.body.innerHTML = http.responsetext 
  Set getpage=Nothing
End Function

Sub gettaskslist(b,build)
  nextpage=b
  While nextpage <>""
  
    nextpage=Replace(nextpage,"about:", start) 
    WScript.Echo nextpage
    getpage(nextpage)
    Set xtoc = oHF.getElementbyId("mw-pages")
    nextpage=""
    For Each ch In xtoc.children
      If  ch.innertext= "next page" Then 
        nextpage=ch.attributes("href").value
        
      ElseIf ch.attributes("class").value="mw-content-ltr" Then
        Set ytoc=ch.children(0) 
        
        Exit For
      End If   
    Next
    For Each ch1 In ytoc.children 
      
      For Each ch2 In ch1.children(1).children 
        Set ch=ch2.children(0)
        If build Then
           odic.Add ch.innertext , ch.attributes("href").value
        else    
           odic.Remove ch.innertext
        End if   
           
      Next 
    Next
  Wend  
End Sub
Task: Almkvist-Giullera formula for pi







Python: import mpmath as mp

with mp.workdps(72):

    def integer_term(n):
        p = 532 * n * n + 126 * n + 9
        return (p * 2**5 * mp.factorial(6 * n)) / (3 * mp.factorial(n)**6)

    def exponent_term(n):
        return -(mp.mpf("6.0") * n + 3)

    def nthterm(n):
        return integer_term(n) * mp.mpf("10.0")**exponent_term(n)


    for n in range(10):
        print("Term ", n, '  ', int(integer_term(n)))


    def almkvist_guillera(floatprecision):
        summed, nextadd = mp.mpf('0.0'), mp.mpf('0.0')
        for n in range(100000000):
            nextadd = summed + nthterm(n)
            if abs(nextadd - summed) < 10.0**(-floatprecision):
                break

            summed = nextadd

        return nextadd


    print('\nπ to 70 digits is ', end='')
    mp.nprint(mp.mpf(1.0 / mp.sqrt(almkvist_guillera(70))), 71)
    print('mpmath π is       ', end='')
    mp.nprint(mp.pi, 71)


VB: Imports System, BI = System.Numerics.BigInteger, System.Console

Module Module1

    Function isqrt(ByVal x As BI) As BI
        Dim t As BI, q As BI = 1, r As BI = 0
        While q <= x : q <<= 2 : End While
        While q > 1 : q >>= 2 : t = x - r - q : r >>= 1
            If t >= 0 Then x = t : r += q
        End While : Return r
    End Function

    Function dump(ByVal digs As Integer, ByVal Optional show As Boolean = False) As String
        digs += 1
        Dim z As Integer, gb As Integer = 1, dg As Integer = digs + gb
        Dim te As BI, t1 As BI = 1, t2 As BI = 9, t3 As BI = 1, su As BI = 0, t As BI = BI.Pow(10, If(dg <= 60, 0, dg - 60)), d As BI = -1, fn As BI = 1
        For n As BI = 0 To dg - 1
            If n > 0 Then t3 = t3 * BI.Pow(n, 6)
            te = t1 * t2 / t3 : z = dg - 1 - CInt(n) * 6
            If z > 0 Then te = te * BI.Pow(10, z) Else te = te / BI.Pow(10, -z)
            If show AndAlso n < 10 Then WriteLine("{0,2} {1,62}", n, te * 32 / 3 / t)
            su += te : If te < 10 Then
                digs -= 1
                If show Then WriteLine(vbLf & "{0} iterations required for {1} digits " & _
                    "after the decimal point." & vbLf, n, digs)
                Exit For
            End If
            For j As BI = n * 6 + 1 To n * 6 + 6
                t1 = t1 * j : Next
            d += 2 : t2 += 126 + 532 * d
        Next
        Dim s As String = String.Format("{0}", isqrt(BI.Pow(10, dg * 2 + 3) _
            / su / 32 * 3 * BI.Pow(CType(10, BI), dg + 5)))
        Return s(0) & "." & s.Substring(1, digs)
    End Function

    Sub Main(ByVal args As String())
        WriteLine(dump(70, true))
    End Sub

End Module
Task: Practical numbers







Python: from itertools import chain, cycle, accumulate, combinations
from typing import List, Tuple



def factors5(n: int) -> List[int]:
    
    def prime_powers(n):
        
        for c in accumulate(chain([2, 1, 2], cycle([2,4]))):
            if c*c > n: break
            if n%c: continue
            d,p = (), c
            while not n%c:
                n,p,d = n//c, p*c, d + (p,)
            yield(d)
        if n > 1: yield((n,))

    r = [1]
    for e in prime_powers(n):
        r += [a*b for a in r for b in e]
    return r[:-1]



def powerset(s: List[int]) -> List[Tuple[int, ...]]:
    
    return chain.from_iterable(combinations(s, r) for r in range(1, len(s)+1))



def is_practical(x: int) -> bool:
    
    if x == 1:
        return True
    if x %2:
        return False  
    f = factors5(x)
    ps = powerset(f)
    found = {y for y in {sum(i) for i in ps}
             if 1 <= y < x}
    return len(found) == x - 1


if __name__ == '__main__':
    n = 333
    p = [x for x in range(1, n + 1) if is_practical(x)]
    print(f"There are {len(p)} Practical numbers from 1 to {n}:")
    print(' ', str(p[:10])[1:-1], '...', str(p[-10:])[1:-1])
    x = 666
    print(f"\nSTRETCH GOAL: {x} is {'not ' if not is_practical(x) else ''}Practical.")


VB: Imports System.Collections.Generic, System.Linq, System.Console

Module Module1
    Function soas(ByVal n As Integer, ByVal f As IEnumerable(Of Integer)) As Boolean
        If n <= 0 Then Return False Else If f.Contains(n) Then Return True
        Select Case n.CompareTo(f.Sum())
            Case 1 : Return False : Case 0 : Return True
            Case -1 : Dim rf As List(Of Integer) = f.Reverse().ToList() : Dim D as Integer = n - rf(0) 
                rf.RemoveAt(0) : Return soas(d, rf) OrElse soas(n, rf)
        End Select : Return true
    End Function

    Function ip(ByVal n As Integer) As Boolean
        Dim f As IEnumerable(Of Integer) = Enumerable.Range(1, n >> 1).Where(Function(d) n Mod d = 0).ToList()
        Return Enumerable.Range(1, n - 1).ToList().TrueForAll(Function(i) soas(i, f))
    End Function

    Sub Main()
        Dim c As Integer = 0, m As Integer = 333, i As Integer = 1 : While i <= m
            If ip(i) OrElse i = 1 Then c += 1 : Write("{0,3} {1}", i, If(c Mod 10 = 0, vbLf, ""))
            i += If(i = 1, 1, 2) : End While
        Write(vbLf & "Found {0} practical numbers between 1 and {1} inclusive." & vbLf, c, m)
        Do : m = If(m < 500, m << 1, m * 10 + 6)
            Write(vbLf & "{0,5} is a{1}practical number.", m, If(ip(m), " ", "n im")) : Loop While m < 1e4
    End Sub
End Module
Task: Literals_Floating point







Python: 2.3    
.3     
.3e4   
.3e+34 
.3e-34 
2.e34  


VB: Sub Main()
Dim d As Double 
Dim s As Single 
  d = -12.3456
  d = 1000#
  d = 0.00001
  d = 67#
  d = 8.9
  d = 0.33
  d = 0#
  d = 2# * 10 ^ 3
  d = 2E+50
  d = 2E-50
  s = -12.3456!
  s = 1000!
  s = 0.00001!
  s = 67!
  s = 8.9!
  s = 0.33!
  s = 0!
  s = 2! * 10 ^ 3
End Sub
Task: Break OO privacy







Python: >>> class MyClassName:
	__private = 123
	non_private = __private * 2

	
>>> mine = MyClassName()
>>> mine.non_private
246
>>> mine.__private
Traceback (most recent call last):
  File "<pyshell
    mine.__private
AttributeError: 'MyClassName' object has no attribute '__private'
>>> mine._MyClassName__private
123
>>>


VB: Imports System.Reflection


Public Class MyClazz
    Private answer As Integer = 42
End Class

Public Class Program
    Public Shared Sub Main()
        Dim myInstance = New MyClazz()
        Dim fieldInfo = GetType(MyClazz).GetField("answer", BindingFlags.NonPublic Or BindingFlags.Instance)
        Dim answer = fieldInfo.GetValue(myInstance)
        Console.WriteLine(answer)
    End Sub
End Class
Task: Long year







Python: 

from datetime import date



def longYear(y):
    
    return 52 < date(y, 12, 28).isocalendar()[1]




def main():
    
    for year in [
            x for x in range(2000, 1 + 2100)
            if longYear(x)
    ]:
        print(year)



if __name__ == '__main__':
    main()


VB: DEFINT A-Z

DECLARE FUNCTION p% (Yr AS INTEGER)
DECLARE FUNCTION LongYear% (Yr AS INTEGER)

DIM iYi, iYf, i

CLS
PRINT "This program calculates which are 53-week years in a range."
PRINT
INPUT "Initial year"; iYi
INPUT "Final year (could be the same)"; iYf
IF iYf >= iYi THEN
  FOR i = iYi TO iYf
    IF LongYear(i) THEN
      PRINT i; " ";
    END IF
  NEXT i
END IF
PRINT
PRINT
PRINT "End of program."
END

FUNCTION LongYear% (Yr AS INTEGER)
  LongYear% = (p%(Yr) = 4) OR (p%(Yr - 1) = 3)
END FUNCTION

FUNCTION p% (Yr AS INTEGER)
  p% = (Yr + INT(Yr / 4) - INT(Yr / 100) + INT(Yr / 400)) MOD 7
END FUNCTION
Task: Associative array_Merging







Python: base = {"name":"Rocket Skates", "price":12.75, "color":"yellow"}
update = {"price":15.25, "color":"red", "year":1974}

result = {**base, **update}

print(result)


VB: Private Type Associative
    Key As String
    Value As Variant
End Type
Sub Main_Array_Associative()
Dim BaseArray(2) As Associative, UpdateArray(2) As Associative
    FillArrays BaseArray, UpdateArray
    ReDim Result(UBound(BaseArray)) As Associative
    MergeArray Result, BaseArray, UpdateArray
    PrintOut Result
End Sub
Private Sub MergeArray(Res() As Associative, Base() As Associative, Update() As Associative)
Dim i As Long, Respons As Long
    Res = Base
    For i = LBound(Update) To UBound(Update)
        If Exist(Respons, Base, Update(i).Key) Then
            Res(Respons).Value = Update(i).Value
        Else
            ReDim Preserve Res(UBound(Res) + 1)
            Res(UBound(Res)).Key = Update(i).Key
            Res(UBound(Res)).Value = Update(i).Value
        End If
    Next
End Sub
Private Function Exist(R As Long, B() As Associative, K As String) As Boolean
Dim i As Long
    Do
        If B(i).Key = K Then
            Exist = True
            R = i
        End If
        i = i + 1
    Loop While i <= UBound(B) And Not Exist
End Function
Private Sub FillArrays(B() As Associative, U() As Associative)
    B(0).Key = "name"
    B(0).Value = "Rocket Skates"
    B(1).Key = "price"
    B(1).Value = 12.75
    B(2).Key = "color"
    B(2).Value = "yellow"
    U(0).Key = "price"
    U(0).Value = 15.25
    U(1).Key = "color"
    U(1).Value = "red"
    U(2).Key = "year"
    U(2).Value = 1974
End Sub
Private Sub PrintOut(A() As Associative)
Dim i As Long
    Debug.Print "Key", "Value"
    For i = LBound(A) To UBound(A)
        Debug.Print A(i).Key, A(i).Value
    Next i
    Debug.Print "-----------------------------"
End Sub
Task: Associative array_Iteration







Python: myDict = { "hello": 13,
	   "world": 31,
	   "!"    : 71 }


for key, value in myDict.items():
    print ("key = %s, value = %s" % (key, value))


for key in myDict:
    print ("key = %s" % key)

for key in myDict.keys():
    print ("key = %s" % key)


for value in myDict.values():
    print ("value = %s" % value)


VB: Option Explicit
Sub Test()
    Dim h As Object, i As Long, u, v, s
    Set h = CreateObject("Scripting.Dictionary")
    h.Add "A", 1
    h.Add "B", 2
    h.Add "C", 3

    
    For Each s In h.Keys
        Debug.Print s
    Next

    
    For Each s In h.Items
        Debug.Print s
    Next

    
    u = h.Keys
    v = h.Items
    For i = 0 To h.Count - 1
        Debug.Print u(i), v(i)
    Next
End Sub
Task: Define a primitive data type







Python: >>> class num(int):
    def __init__(self, b):
        if 1 <= b <= 10:
            return int.__init__(self+0)
        else:
            raise ValueError,"Value %s should be >=0 and <= 10" % b

        
>>> x = num(3)
>>> x = num(11)

Traceback (most recent call last):
  File "<pyshell
    x = num(11)
  File "<pyshell
    raise ValueError,"Value %s should be >=0 and <= 10" % b
ValueError: Value 11 should be >=0 and <= 10
>>> x
3
>>> type(x)
<class '__main__.num'>
>>>


VB: Private mvarValue As Integer

Public Property Let Value(ByVal vData As Integer)
    If (vData > 10) Or (vData < 1) Then
        Error 380   
    Else
        mvarValue = vData
    End If
End Property

Public Property Get Value() As Integer
    Value = mvarValue
End Property

Private Sub Class_Initialize()
    
    mvarValue = 1
End Sub
Task: Hash join







Python: from collections import defaultdict

def hashJoin(table1, index1, table2, index2):
    h = defaultdict(list)
    
    for s in table1:
        h[s[index1]].append(s)
    
    return [(s, r) for r in table2 for s in h[r[index2]]]

table1 = [(27, "Jonah"),
          (18, "Alan"),
          (28, "Glory"),
          (18, "Popeye"),
          (28, "Alan")]
table2 = [("Jonah", "Whales"),
          ("Jonah", "Spiders"),
          ("Alan", "Ghosts"),
          ("Alan", "Zombies"),
          ("Glory", "Buffy")]

for row in hashJoin(table1, 1, table2, 0):
    print(row)


VB: Dim t_age(4,1)
t_age(0,0) = 27 : t_age(0,1) = "Jonah"
t_age(1,0) = 18 : t_age(1,1) = "Alan"
t_age(2,0) = 28 : t_age(2,1) = "Glory"
t_age(3,0) = 18 : t_age(3,1) = "Popeye"
t_age(4,0) = 28 : t_age(4,1) = "Alan"

Dim t_nemesis(4,1)
t_nemesis(0,0) = "Jonah" : t_nemesis(0,1) = "Whales"
t_nemesis(1,0) = "Jonah" : t_nemesis(1,1) = "Spiders"
t_nemesis(2,0) = "Alan" : t_nemesis(2,1) = "Ghosts"
t_nemesis(3,0) = "Alan" : t_nemesis(3,1) = "Zombies"
t_nemesis(4,0) = "Glory" : t_nemesis(4,1) = "Buffy"

Call hash_join(t_age,1,t_nemesis,0)

Sub hash_join(table_1,index_1,table_2,index_2)
	Set hash = CreateObject("Scripting.Dictionary")
	For i = 0 To UBound(table_1)
		hash.Add i,Array(table_1(i,0),table_1(i,1))
	Next
	For j = 0 To UBound(table_2)
		For Each key In hash.Keys
			If hash(key)(index_1) = table_2(j,index_2) Then
				WScript.StdOut.WriteLine hash(key)(0) & "," & hash(key)(1) &_
					" = " & table_2(j,0) & "," & table_2(j,1)
			End If
		Next
	Next
End Sub
Task: Find words whose first and last three letters are equal







Python: import urllib.request
urllib.request.urlretrieve("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt", "unixdict.txt")

dictionary = open("unixdict.txt","r")

wordList = dictionary.read().split('\n')

dictionary.close()

for word in wordList:
    if len(word)>5 and word[:3].lower()==word[-3:].lower():
        print(word)


VB: with createobject("ADODB.Stream")
  .charset ="UTF-8"
  .open
  .loadfromfile("unixdict.txt")
  s=.readtext
end with  
a=split (s,vblf)

set d= createobject("Scripting.Dictionary")
for each aa in a
  x=trim(aa)
  l=len(x)
  if l>5 then
   d.removeall
   for i=1 to 3
     m=mid(x,i,1)
     if not d.exists(m) then d.add m,null
   next
   res=true
   for i=l-2 to l
     m=mid(x,i,1)
     if not d.exists(m) then 
       res=false:exit for 
      else
        d.remove(m)
      end if        
   next 
   if res then 
     wscript.stdout.write left(x & space(15),15)
     if left(x,3)=right(x,3) then  wscript.stdout.write "*"
     wscript.stdout.writeline
    end if 
  end if
next
Task: Address of a variable







Python: var num = 12
var pointer = ptr(num) 

print pointer 

@unsafe 
pointer.addr = 0xFFFE 


VB: Dim TheAddress as long
Dim SecVar as byte
Dim MyVar as byte
    MyVar = 10


TheAddress = varptr(MyVar)


MEMSET(TheAddress, 102, SizeOf(byte))


showmessage "MyVar = " + str$(MyVar)


MEMCPY(VarPtr(SecVar), TheAddress, SizeOf(byte))


showmessage "SecVar = " + str$(SecVar)
Task: Inheritance_Single







Python: class Animal:
  pass 

class Dog(Animal):
  pass 

class Cat(Animal):
  pass 

class Lab(Dog):
  pass 

class Collie(Dog):
  pass 


VB: Class Animal
  
End Class

Class Dog
  Inherits Animal
  
End Class

Class Lab
  Inherits Dog
  
End Class

Class Collie
  Inherits Dog
  
End Class

Class Cat
  Inherits Animal
  
End Class
Task: Associative array_Creation







Python: hash = dict()  
hash = dict(red="FF0000", green="00FF00", blue="0000FF")
hash = { 'key1':1, 'key2':2, }
value = hash[key]


VB: Option Explicit
Sub Test()
    Dim h As Object
    Set h = CreateObject("Scripting.Dictionary")
    h.Add "A", 1
    h.Add "B", 2
    h.Add "C", 3
    Debug.Print h.Item("A")
    h.Item("C") = 4
    h.Key("C") = "D"
    Debug.Print h.exists("C")
    h.Remove "B"
    Debug.Print h.Count
    h.RemoveAll
    Debug.Print h.Count
End Sub
Task: Find words which contain the most consonants







Python: print('\n'.join((f'{x[0]}: {" ".join(sorted(x[1]))}' if len(x[1]) < 30 else f'{x[0]}: {len(x[1])} words' for x in
      (x for x in ((n, [x[1] for x in l if x[0] == n]) for n in range(maxlen, -1, -1)) if x[1]))) if (maxlen := max(l := [(len(c), w)
      for w in [l for l in [l.rstrip() for l in open('unixdict.txt')] if len(l) > 10 and all(c >= 'a' and c <= 'z' for c in l)]
      if sorted(c := w.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '')) == sorted(set(c))])[0]) else None)


VB: with createobject("ADODB.Stream")
  .charset ="UTF-8"
  .open
  .loadfromfile("unixdict.txt")
  s=.readtext
end with  
a=split (s,vblf)

dim b(25)  
dim c(128) 

with new regexp
  .pattern="([^aeiou])"
  .global=true
for each i in a
  if len(trim(i))>10 then
   set matches= .execute(i)   
   rep=false
   for each m in matches  
     x=asc(m)  
     c(x)=c(x)+1
     if c(x)>1 then rep=true :exit for
   next
   erase c
   if not rep then   
     x1=matches.count
     b(x1)=b(x1)&" "&i  
   end if    
  end if
next
end with 


for i=25 to 0 step -1
  if b(i)<>"" then  wscript.echo i & "  "& b(i) & vbcrlf
next
Task: Align columns







Python: from itertools import zip_longest

txt = 
 
parts = [line.rstrip("$").split("$") for line in txt.splitlines()]
widths = [max(len(word) for word in col) 
          for col in zip_longest(*parts, fillvalue='')]
 
for justify in "<_Left ^_Center >_Right".split():
    j, jtext = justify.split('_')
    print(f"{jtext} column-aligned output:\n")
    for line in parts:
        print(' '.join(f"{wrd:{j}{wdth}}" for wdth, wrd in zip(widths, line)))
    print("- " * 52)


VB: Dim MText as QMemorystream
    MText.WriteLine "Given$a$text$file$of$many$lines,$where$fields$within$a$line$"
    MText.WriteLine "are$delineated$by$a$single$
    MText.WriteLine "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$"
    MText.WriteLine "column$are$separated$by$at$least$one$space."
    MText.WriteLine "Further,$allow$for$each$word$in$a$column$to$be$either$left$"
    MText.WriteLine "justified,$right$justified,$or$center$justified$within$its$column."

DefStr TextLeft, TextRight, TextCenter
DefStr MLine, LWord, Newline = chr$(13)+chr$(10)
DefInt ColWidth(100), ColCount
DefSng NrSpaces 


MText.position = 0
for x = 0 to MText.linecount -1
    MLine = MText.ReadLine
    for y = 0 to Tally(MLine, "$")
        LWord = Field$(MLine, "$", y+1)
        ColWidth(y) = iif (ColWidth(y) < len(LWord), len(LWord), ColWidth(y))
    next
next


MText.position = 0
for x = 0 to MText.linecount -1
    MLine = MText.ReadLine
    for y = 0 to Tally(MLine, "$")
        LWord = Field$(MLine, "$", y+1)
        NrSpaces = ColWidth(y) - len(LWord)
        
        TextLeft = TextLeft + LWord + Space$(NrSpaces+1)
        
        TextRight = TextRight + Space$(NrSpaces+1) + LWord
        
        TextCenter = TextCenter + Space$(floor((NrSpaces)/2)+1) + LWord + Space$(Ceil((NrSpaces)/2))
    next
    TextLeft = TextLeft + Newline 
    TextRight = TextRight + Newline 
    TextCenter = TextCenter + Newline 
next
Task: Base58Check encoding







Python: ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"

def convertToBase58(num):
    sb = ''
    while (num > 0):
        r = num % 58
        sb = sb + ALPHABET[r]
        num = num // 58;
    return sb[::-1]

s = 25420294593250030202636073700053352635053786165627414518
b = convertToBase58(s)
print("%-56d -> %s" % (s, b))

hash_arr = [0x61, 0x626262, 0x636363, 0x73696d706c792061206c6f6e6720737472696e67, 0x516b6fcd0f, 0xbf4f89001e670274dd, 0x572e4794, 0xecac89cad93923c02321, 0x10c8511e]
for num in hash_arr:
    b = convertToBase58(num)
    print("0x%-54x -> %s" % (num, b))


VB: Imports System.Numerics
Imports System.Text

Module Module1
    ReadOnly ALPHABET As String = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
    ReadOnly HEX As String = "0123456789ABCDEF"

    Function ToBigInteger(value As String, base As Integer) As BigInteger
        If base < 1 OrElse base > HEX.Length Then
            Throw New ArgumentException("Base is out of range.")
        End If

        Dim bi = BigInteger.Zero
        For Each c In value
            Dim c2 = Char.ToUpper(c)
            Dim idx = HEX.IndexOf(c2)
            If idx = -1 OrElse idx >= base Then
                Throw New ArgumentException("Illegal character encountered.")
            End If
            bi = bi * base + idx
        Next

        Return bi
    End Function

    Function ConvertToBase58(hash As String, Optional base As Integer = 16) As String
        Dim x As BigInteger
        If base = 16 AndAlso hash.Substring(0, 2) = "0x" Then
            x = ToBigInteger(hash.Substring(2), base)
        Else
            x = ToBigInteger(hash, base)
        End If

        Dim sb As New StringBuilder
        While x > 0
            Dim r = x Mod 58
            sb.Append(ALPHABET(r))
            x = x / 58
        End While

        Dim ca = sb.ToString().ToCharArray()
        Array.Reverse(ca)
        Return New String(ca)
    End Function

    Sub Main()
        Dim s = "25420294593250030202636073700053352635053786165627414518"
        Dim b = ConvertToBase58(s, 10)
        Console.WriteLine("{0} -> {1}", s, b)

        Dim hashes = {"0x61", "0x626262", "0x636363", "0x73696d706c792061206c6f6e6720737472696e67", "0x516b6fcd0f", "0xbf4f89001e670274dd", "0x572e4794", "0xecac89cad93923c02321", "0x10c8511e"}
        For Each hash In hashes
            Dim b58 = ConvertToBase58(hash)
            Console.WriteLine("{0,-56} -> {1}", hash, b58)
        Next
    End Sub

End Module