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.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace judge
- {
- class judge
- {
- static void Main(string[] args)
- {
- int mood = int.Parse(Console.ReadLine());
- string pattern = @"[^a-zA-Z]+";
- List<string> input = Regex.Split(Console.ReadLine(), pattern).Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
- foreach (var item in input)
- {
- if ("cram" == RemoveSpecialCharacters(item).ToLower().Trim())
- {
- mood += 2;
- }
- else if ("lembas" == RemoveSpecialCharacters(item).ToLower().Trim())
- {
- mood += 3;
- }
- else if ("apple" == RemoveSpecialCharacters(item).ToLower())
- {
- mood += 1;
- }
- else if ("melon" == RemoveSpecialCharacters(item).ToLower())
- {
- mood += 1;
- }
- else if ("honeycake" == RemoveSpecialCharacters(item).ToLower())
- {
- mood += 5;
- }
- else if ("mushrooms" == RemoveSpecialCharacters(item).ToLower())
- {
- mood -= 10;
- }
- else
- {
- mood -= 1;
- }
- }
- Console.WriteLine(mood);
- Console.WriteLine(Mood(mood));
- }
- static string Mood(int num)
- {
- if (num < -5)
- {
- return "Angry";
- }
- else if (num >= -5 && num < 0)
- {
- return "Sad";
- }
- else if (num >= 0 && num <= 15)
- {
- return "Happy";
- }
- else
- {
- return "Special JavaScript mood";
- }
- }
- public static string RemoveSpecialCharacters(string str)
- {
- StringBuilder sb = new StringBuilder();
- foreach (char c in str)
- {
- if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
- {
- sb.Append(c);
- }
- }
- return sb.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement