More Exercise: Regular Expressions
Loading...
+ Нов въпрос
arnold avatar arnold 36 Точки

Winning Ticket (C#)

Здравейте, малко помощ за тази задача с регекс, докарах я до 70/100, но не знам какво пропускам в условието и защо не мога да я докарам до 100. Най-вероятно нещо в регекса бъркам.   

https://pastebin.com/B2HEsv4E

 

Промених регекса малко и докарах до 80/100:

https://pastebin.com/WEaQkgxR

Ако някой има по-добро предложение за регекса, ще се радвам да го обясня, все още са ми трудни за разбиране тези регекси

 

 

 

https://judge.softuni.bg/Contests/Practice/Index/1754#0

More Exercise: Regular Expressions

Problems for exercise and homework for the "C#  Fundamentals" course @ SoftUni
You can check your solutions in Judge

1.Winning Ticket

Lottery is exciting. What is not, is checking a million tickets for winnings only by hand. So, you are given the task to create a program which automatically checks if a ticket is a winner.

You are given a collection of tickets separated by commas and spaces. You need to check every one of them if it has a winning combination of symbols.

A valid ticket should have exactly 20 characters. The winning symbols are '@', '#', '$' and '^'. But in order for a ticket to be a winner the symbol should uninterruptedly repeat for at least 6 times in both the tickets left half and the tickets right half.

For example, a valid winning ticket should be something like this:

"Cash$$$$$$Ca$$$$$$sh"

The left half "Cash$$$$$$" contains "$$$$$$", which is also contained in the tickets right half "Ca$$$$$$sh". A winning ticket should contain symbols repeating up to 10 times in both halves, which is considered a Jackpot (for example: "$$$$$$$$$$$$$$$$$$$$").

Input

The input will be read from the console. The input consists of a single line containing all tickets separated by commas and one or more white spaces in the format:

  • "{ticket}, {ticket}, … {ticket}"

Output

Print the result for every ticket in the order of their appearance, each on a separate line in the format:

  • Invalid ticket - "invalid ticket"
  • No match - "ticket "{ticket}" - no match"
  • Match with length 6 to 9 - "ticket "{ticket}" - {match length}{match symbol}"
  • Match with length 10 - "ticket "{ticket}" - {match length}{match symbol} Jackpot!"

Constrains

  • Number of tickets will be in range [0 … 100]

Examples

Input

Output

Cash$$$$$$Ca$$$$$$sh

ticket "Cash$$$$$$Ca$$$$$$sh" - 6$

$$$$$$$$$$$$$$$$$$$$, aabb  , th@@@@@@eemo@@@@@@ey

ticket "$$$$$$$$$$$$$$$$$$$$" - 10$ Jackpot!

invalid ticket

ticket "th@@@@@@eemo@@@@@@ey" - 6@

validticketnomatch:(

ticket "validticketnomatch:(" - no match

0
Fundamentals Module 12/08/2021 11:07:18
svephoto avatar svephoto 1061 Точки

Здравей, arnold,

 

Нямам представа доколко ще ти бъде от полза, но докарах едно решение за 100/100 на базата на твоя код. Има доста промени, с един регекс израз е и се получи като че ли по-изчистено. Виж го, ако искаш: https://pastebin.com/M1Z7wXAJ.

2
arnold avatar arnold 36 Точки

Благодаря, ще ми е от полза определено :)

0
svephoto avatar svephoto 1061 Точки

Моля, радвам се. yes laugh

1