Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Lucky
- {
- static void Main()
- {
- //Telerik Academy
- //Two lucky numbers of 4s and 7s are entered on the console. Find the minimum operations needed to make them equal. The 2 possible operations are pair exchange or setting 4 to 7 and vice versa.
- string a = Console.ReadLine(),
- b = Console.ReadLine();
- a = a.Replace('4', '0');
- a = a.Replace('7', '1');
- b = b.Replace('4', '0');
- b = b.Replace('7', '1');
- int numsLenght = a.Length;
- int count0s = 0,
- count1s = 0;
- for (int bitposition = 0; bitposition < numsLenght; bitposition++)
- {
- if (a[bitposition] != b[bitposition])
- {
- if (a[bitposition] == '0')
- {
- count0s++;
- }
- else
- {
- count1s++;
- }
- }
- }
- int result = Math.Max(count0s, count1s);
- Console.WriteLine(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement