Advertisement
bullit3189

Vapor Winter Sale-Dictionary

Apr 1st, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5. using System.Text;
  6.  
  7. public class Program
  8. {
  9. public static void Main()
  10. {
  11. string[] input = Console.ReadLine().Split(", ");
  12.  
  13. Dictionary<string,double> gamePrice = new Dictionary<string,double>();
  14. Dictionary <string,string> gameDlc = new Dictionary <string,string>();
  15.  
  16. foreach (string game in input)
  17. {
  18. if (!game.Contains(":"))
  19. {
  20. string[] tokens = game.Split("-");
  21. string gameName = tokens[0];
  22. double price = double.Parse(tokens[1]);
  23.  
  24. gamePrice.Add(gameName,price);
  25. }
  26. else
  27. {
  28. string[] tokens = game.Split(":");
  29. string gameName = tokens[0];
  30. string dlc = tokens[1];
  31.  
  32. if (gamePrice.ContainsKey(gameName))
  33. {
  34. gameDlc.Add(gameName,dlc);
  35. gamePrice[gameName]*=1.20;
  36. }
  37. }
  38. }
  39. foreach (var currGame in gameDlc)
  40. {
  41. if (gamePrice.ContainsKey(currGame.Key))
  42. {
  43. gamePrice[currGame.Key]*=0.50;
  44. }
  45.  
  46. }
  47.  
  48. foreach (var kvp in gamePrice.OrderBy(x=>x.Value))
  49. {
  50. string game = kvp.Key;
  51. double price = kvp.Value;
  52.  
  53. if (gameDlc.ContainsKey(game))
  54. {
  55. string dlc = gameDlc[game];
  56.  
  57. Console.WriteLine("{0} - {1} - {2:f2}",game,dlc,price);
  58. }
  59. }
  60.  
  61. Dictionary<string,double> noDlcGamePrice = new Dictionary<string,double>();
  62.  
  63. foreach (var kvp in gamePrice)
  64. {
  65. string game = kvp.Key;
  66. double price = kvp.Value;
  67.  
  68. if (gameDlc.ContainsKey(game)==false)
  69. {
  70. noDlcGamePrice.Add(game,price);
  71. }
  72. }
  73.  
  74. foreach (var kvp in noDlcGamePrice.OrderByDescending(x=>x.Value))
  75. {
  76. Console.WriteLine("{0} - {1:f2}",kvp.Key,kvp.Value*0.8);
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement