Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Title</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <style>
- </style>
- </head>
- <body id="body">
- <script>
- // input
- let start = 1, finish = 1003;
- let colCount = 10;
- // algorithm
- let max = finish;
- let temp;
- let columnWidth = 0;
- let output = "";
- while(max > 0){
- temp = max % 10
- max = (max - temp) / 10
- columnWidth = columnWidth + 1;
- }
- let i = start;
- let row = "";
- let j = 1;
- while(i <= finish){
- let remaining = i;
- let lastDigit;
- let duplicates = 0;
- let iDigitCount = 0;
- while(remaining > 0){
- lastDigit = remaining % 10;
- remaining = (remaining - lastDigit) / 10;
- iDigitCount = iDigitCount + 1;
- let remaining2 = remaining;
- let lastDigit2;
- while(remaining2 > 0){
- lastDigit2 = remaining2 % 10
- remaining2 = (remaining2 - lastDigit2) / 10
- if (lastDigit == lastDigit2){
- duplicates = duplicates + 1;
- }
- }
- }
- if (duplicates > 0){
- let gaps = columnWidth - iDigitCount;
- while(gaps > 0){
- row += " ";
- gaps = gaps - 1;
- }
- row += i + " ";
- j = j + 1;
- }
- i = i + 1;
- if (j % (colCount+1) == 0){
- output += row + "\n";
- j = 1;
- row = "";
- }
- }
- if (row != ""){
- output += row + "\n";
- }
- // output
- console.log(output);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement