Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _5._Lambada_Expressions
- {
- class Program
- {
- static void Main(string[] args)
- {
- var data = new Dictionary<string, string>();
- string input = Console.ReadLine();
- int dance = 1;
- while (input != "lambada")
- {
- string[] tokens = input.Split(new string[] { " => " }, StringSplitOptions.RemoveEmptyEntries);
- if (tokens[0] == "dance")
- {
- dance++;
- foreach (var item in data.ToDictionary(e => e.Key, e => e.Value))
- {
- List<string> currentDance = item.Value.Split('.').ToList();
- string selectorObject = currentDance[0];
- string property = currentDance.Last();
- string newSelector = string.Empty;
- for (int i = 0; i < dance; i++)
- {
- newSelector += selectorObject + ".";
- }
- data[item.Key] = newSelector + property;
- }
- }
- else
- {
- string key = tokens[0];
- string value = tokens[1];
- if (!data.ContainsKey(key))
- {
- data.Add(key, string.Empty);
- }
- data[key] = value;
- }
- input = Console.ReadLine();
- }
- foreach (var item in data)
- {
- Console.WriteLine($"{item.Key} => {item.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement