Advertisement
Guest User

Untitled

a guest
Jun 11th, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5. static void Main()
  6. {
  7. string shortestString = FindShortestString();
  8. Console.WriteLine("Shortest string: " + shortestString);
  9. Console.WriteLine(shortestString.Length);
  10. }
  11.  
  12. static string FindShortestString()
  13. {
  14. string shortestString = null;
  15.  
  16. for (int i = 0; i <= 9; i++)
  17. {
  18. for (int j = 0; j <= 9; j++)
  19. {
  20. for (int k = 0; k <= 9; k++)
  21. {
  22. for (int l = 0; l <= 9; l++)
  23. {
  24. string currentCombination = i.ToString() + j.ToString() + k.ToString() + l.ToString();
  25. shortestString += currentCombination;
  26. }
  27. }
  28. }
  29. }
  30.  
  31. return shortestString;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement