Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:convert';
- import 'dart:io';
- main() {
- /// No. of Different Characters in the two Strings;
- int diff = 0;
- /// No. of Identical Characters in the two Strings;
- int correct = 0;
- /// Print Msg for User;
- print("hi enter string 1");
- /// Input Code
- var line = stdin.readLineSync(encoding: Encoding.getByName('utf-8'));
- /// Print Msg for User;
- print("hi enter string 2");
- /// Input Code
- var line2 = stdin.readLineSync(encoding: Encoding.getByName('utf-8'));
- /// Calculating the largest Length of the two strings to be Loop Length;
- int loopLength = line.length > line2.length ? line.length : line2.length;
- /// Looping on -
- for (int i = 0; i < loopLength; i++) {
- /// If string length <= i, then there is no string to check so counting++
- if (line.length <= i || line2.length <= i) {
- print("length <= $i");
- diff++;
- /// Stop executing the checks, we already know what we want;
- continue;
- }
- /// Normal equal between characters if not equal counting++
- if (line[i] != line2[i]) {
- print("diff at $i [${line[i]},${line2[i]}]");
- diff++;
- /// Stop executing the checks, we already know what we want;
- continue;
- }
- /// If all the checks are invalid then it's Identical Characters;
- print("correct ${line[i]}");
- correct++;
- }
- /// Printing Result;
- print("diff $diff , correct $correct");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement