Advertisement
Guest User

Magic Strings

a guest
Jun 22nd, 2014
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4.  
  5. class MagicStrings
  6. {
  7. static void Main()
  8. {
  9. byte diff = byte.Parse(Console.ReadLine());
  10. byte[] numbers = { 3, 4, 1, 5};
  11. byte[] temp = new byte[8];
  12. List<string> sequences = new List<string>();
  13. string stringTemp = null;
  14. for(byte i0 = 0; i0<4; i0++)
  15. {
  16. temp[0] = numbers[i0];
  17. for (byte i1 = 0; i1 < 4; i1++)
  18. {
  19. temp[1] = numbers[i1];
  20. for(byte i2 = 0; i2<4; i2++)
  21. {
  22. temp[2] = numbers[i2];
  23. for(byte i3 = 0; i3<4; i3++)
  24. {
  25. temp[3] = numbers[i3];
  26. for(byte i4 = 0; i4<4; i4++)
  27. {
  28. temp[4] = numbers[i4];
  29. for(byte i5 = 0; i5<4; i5++)
  30. {
  31. temp[5] = numbers[i5];
  32. for(byte i6 = 0; i6<4; i6++)
  33. {
  34. temp[6] = numbers[i6];
  35. for(byte i7 = 0; i7<4; i7++)
  36. {
  37. temp[7] = numbers[i7];
  38. if(Math.Abs((temp[0]+temp[1]+temp[2]+temp[3]) - (temp[4]+temp[5]+temp[6]+temp[7]))==diff)
  39. {
  40. for(byte j = 0; j<8; j++)
  41. {
  42. if (temp[j] == 3) stringTemp += "s";
  43. if (temp[j] == 4) stringTemp += "n";
  44. if (temp[j] == 1) stringTemp += "k";
  45. if (temp[j] == 5) stringTemp += "p";
  46. }
  47. sequences.Add(stringTemp);
  48. stringTemp = null;
  49. }
  50.  
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. sequences.Sort();
  60. if (sequences.Count > 0)
  61. {
  62. for (byte j = 0; j < sequences.Count; j++) Console.WriteLine(sequences[j]);
  63. }
  64. else Console.WriteLine("No");
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement