02. Emoji Detector
pastebin: https://pastebin.com/TbXbiPM2
judge: https://judge.softuni.bg/Contests/Practice/Index/2302#1
Дава 60/100. Не можах да намеря грешката. Ако може някой, да погледне.
pastebin: https://pastebin.com/TbXbiPM2
judge: https://judge.softuni.bg/Contests/Practice/Index/2302#1
Дава 60/100. Не можах да намеря грешката. Ако може някой, да погледне.
Здравей,
Поправих ти кода и вече дава 100/100. Много малки корекции на редове 33, 35 и 44:
Поздрави!
Благодаря!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace _01.Activation_Keys
{
class Program
{
static void Main(string[] args)
{
string emojiPattern = @"(\*{2}|:{2})(?<emoji>[A-Z][a-z]{2,})\1";
string digitPattern = @"\d";
string input = Console.ReadLine();
MatchCollection emojis = Regex.Matches(input, emojiPattern);
MatchCollection digits = Regex.Matches(input, digitPattern);
int count = emojis.Count;
long treshold = 1;
foreach (Match digit in digits)
{
treshold *= int.Parse(digit.Value);
}
Console.WriteLine($"Cool threshold: {treshold}");
Console.WriteLine($"{count} emojis found in the text. The cool ones are:");
foreach (Match emoji in emojis)
{
int coolnes = 0;
string emj = emoji.Groups["emoji"].Value;
for (int i = 0; i < emj.Length; i++)
{
coolnes += emj[i];
}
if (coolnes >= treshold)
{
Console.WriteLine(emoji);
}
}
}
}
}