using
System;
class
GFG
{
static
int
findCost(
string
s1,
string
s2,
int
a,
int
b,
int
c,
int
d,
int
n)
{
int
cost = 0;
for
(
int
i = 0; i < n; i++)
{
if
(s1[i] == s2[i])
continue
;
else
{
if
((s1[i] ==
'1'
&& s2[i] ==
'2'
)
|| (s2[i] ==
'1'
&& s1[i] ==
'2'
))
cost +=Math.Min(d,Math.Min(a, b + c));
else
if
((s1[i] ==
'2'
&& s2[i] ==
'3'
)
|| (s2[i] ==
'2'
&& s1[i] ==
'3'
))
cost +=Math.Min(d,Math.Min(b, a + c));
else
if
((s1[i] ==
'1'
&& s2[i] ==
'3'
)
|| (s2[i] ==
'1'
&& s1[i] ==
'3'
))
cost +=Math.Min(d,Math.Min(c, a + b));
}
}
return
cost;
}
public
static
void
Main()
{
string
s1 =
"121"
;
string
s2 =
"223"
;
int
a = 2, b = 3, c = 4, d = 10;
int
n = s1.Length;
Console.WriteLine(findCost(s1, s2, a, b, c, d, n));
}
}