Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class Program
- {
- public static void Main(string[] args)
- {
- string shortestString = FindShortestString();
- Console.WriteLine(shortestString.Length);
- }
- public static string FindShortestString()
- {
- HashSet<string> combinationsSet = GenerateCombinationsSet();
- string shortestString = string.Empty;
- foreach (string combination in combinationsSet)
- {
- if (!shortestString.Contains(combination))
- {
- shortestString += combination;
- }
- }
- return shortestString;
- }
- public static HashSet<string> GenerateCombinationsSet()
- {
- HashSet<string> combinationsSet = new HashSet<string>();
- for (int i = 0; i <= 9999; i++)
- {
- string combination = i.ToString("D4");
- combinationsSet.Add(combination);
- }
- return combinationsSet;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement