Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

arnold avatar arnold 50 Точки

Problem 2. Emoji Detector

Някой идеи къде мога да греша - 70/100

https://pastebin.com/f0DHBvgA

https://judge.softuni.bg/Contests/Practice/Index/2302#1

 

Programming Fundamentals Final Exam 04.04.2020

Problem 2. Emoji Detector

Your task is to write program which extracts emojis from a text and find the threshold based on the input.

You have to get your cool threshold. It is obtained by multiplying all the digits found in the input.  The cool threshold could be a very big number, so be mindful.

An emoji is valid when:

  • Is surrounded by either :: or ** (exactly 2)
  • Is at least 3 characters long (without the surrounding symbols)
  • Starts with a capital letter
  • Continues with lowercase letters only

Examples of valid emojis: ::Joy::, **Banana**, ::Wink::

Examples of invalid emojis: ::Joy**, ::fox:es:, **Monk3ys**, :Snak::Es::

You need to count all valid emojis in the text and calculate their coolness. The coolness of the emoji is determined by summing all the ASCII values of all letters in the emoji.

Examples: ::Joy:: - 306, **Banana** - 577, ::Wink:: - 409

You need to print the result of cool threshold and after that to take all emojis out of the text, count them and print the only the cool ones on the console.

Input

  • On the single input you will receive a piece of string.

Output

  • On the first line of the output print the obtained Cool threshold in format:
  • Cool threshold: {coolThresholdSum}

On the next line print the count of all emojis found in the text in format:

  • {countOfAllEmojis} emojis found in the text. The cool ones are:
  • {cool emoji 1}
  • {cool emoji 2}
  • {…}

If there are no cool ones, just don't print anything in the end.

Constraints

There will always be at least one digit in the text!

Examples

Input

Output

In the Sofia Zoo there are 311 animals in total! ::Smiley:: This includes 3 **Tigers**, 1 ::Elephant:, 12 **Monk3ys**, a **Gorilla::, 5 ::fox:es: and 21 different types of :Snak::Es::. ::Mooning:: **Shy**

Cool threshold: 540

4 emojis found in the text. The cool ones are:

::Smiley::

**Tigers**

::Mooning::

Comments

You can see all the valid emojis in green. There are various reasons why the rest are not valid, examine them carefully. The "cool threshold" is 3*1*1*3*1*1*2*3*5*2*1 = 540.

::Smiley:: -> 83 + 109 + 105 + 108 + 101 + 121 = 627 > 540 -> cool

**Tigers** -> 84 + 105 + 103 + 101 + 114 + 115 = 622 > 540 -> cool

::Mooning:: -> 77 + 111 + 111 + 110 + 105 + 110 + 103 = 727 > 540 -> cool

**Shy** -> 83 + 104 + 121 = 308 < 540 -> not cool

At the end we print the count of all valid emojis found and each of the cool ones on a new line.

Input

Output

5, 4, 3, 2, 1, go! The 1-th consecutive banana-eating contest has begun! ::Joy:: **Banana** ::Wink:: **Vali** ::valid_emoji::

Cool threshold: 120

4 emojis found in the text. The cool ones are:

::Joy::

**Banana**

::Wink::

**Vali**

Input

Output

It is a long established fact that 1 a reader will be distracted by 9 the readable content of a page when looking at its layout. The point of using ::LoremIpsum:: is that it has a more-or-less normal 3 distribution of 8 letters, as opposed to using 'Content here, content 99 here', making it look like readable **English**.

Cool threshold: 17496

1 emojis found in the text. The cool ones are:

Comments

You can see **English** is a valid emoji, but the sum of ascii is not bigger than cool threshold, that's why we don't print anything in the end.

1
Fundamentals Module
svephoto avatar svephoto 1191 Точки
Best Answer

Здравей, arnold,

 

Направи групата, която хваща заобикалящите символи да изглежда така:

([*]{2}|[:]{2})

и после всичко се оправя. laugh

Ето и цялото решение с въпросната корекция: https://pastebin.com/M4rUqM4R.

1
04/08/2021 23:59:38
arnold avatar arnold 50 Точки

Благодаря за поправката :) Тези регекси още ме тормозят и явно трябва много работа с тях laugh понякога просто не мога да им хвана логиката.

1
05/08/2021 11:46:01
svephoto avatar svephoto 1191 Точки

Моля. yes Според мен не са тормоз само за теб, а за всички. laugh Полека-лека се учим, няма страшно - с практиката се напредва все повече и повече.

1
krum_43 avatar krum_43 750 Точки

Ето и вариант без регекси:(40/100).

https://pastebin.com/Lyg0PyDK

-1
07/08/2021 11:55:19
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.