Loading...

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

Val3ntinV avatar Val3ntinV 20 Точки

Internship - 85т Advanced

Ето  кода : https://pastebin.com/ppF1rR7p

Не мога да открия грешката !!! :(

Условие :

A software company is looking for its next star programmer, so they organize an interview in several rounds. In the first part, the candidates have to solve a few Problems, ordered in a stack, one after another, reading them from the console.

The number of Candidates may not be the same as the number of Problems prepared. The Candidates are solving the problems in a queue one by one, but only if their name is valid. A valid Candidate name consists of First and Last name in proper casing (e.g. Ivan Ivanov - is valid name; invalid names - ivan IVanov, Ivan ivanov...).

Each Candidate takes the topmost Problem to solve. If the sum of Candidate`s name letters (ASCII value) is greater from the sum of the Problem`s letters (ASCII value) => the Problem is solved. Otherwise, the Problem is unsolved. Don’t forget to include space characters.

If a Problem is solved, it is removed from the stack with problems, and the Candidate who solved it goes to the end of the queue. You should write on the console: "{candidate} solved {problem}."

If a Problem is unsolved, it goes to the bottom of the stack and the candidate fails the interview, so he leaves in tears. You should write on the console: "{candidate} failed {problem}."

If there is only one candidate left, the program ends and you should write on the console: "{candidate} gets the job!"

In case there are no more tasks to solve you should print on the console the names of the candidates, separate by comma.

Input / Constraints

The input data should be read from the console.

  • First linen – Problems count – a 32-bit integer in the range [0 … 100].
  • Second linem – Candidates count – a 32-bit integer in the range [0 … 100].
  • Next n-lines – a Problem – text in the range [1 … 100 chars].
  • Next m-lines – a Candidate name – text in the range [1 … 100 chars].
  • Allowed working time for your program: 0.1 seconds.
  • Allowed memory: 16 MB.

Output

Print on the console each message in the above specified format.

Examples

Input

Output

Comments

5

5

Sum Bytes

Word Count

Text Filter

Palindromes

Hot Potato

Filip Yordanov

Vladimir Georgiev

Borislava Pesheva

Maria Mileva

Stanislav Stoyanov

Filip Yordanov solved Hot Potato.

Vladimir Georgiev solved Palindromes.

Borislava Pesheva solved Text Filter.

Maria Mileva solved Word Count.

Stanislav Stoyanov solved Sum Bytes.

Filip Yordanov, Vladimir Georgiev, Borislava Pesheva, Maria Mileva, Stanislav Stoyanov

Filip Yordanov take the Problem – “Hot Potato”. The sum of his name letters is 1382, the sum of Problem’s name letters is – 962   -> the Problem is solved. Filip Yordanov goes to the end of the queue and the Problem is removed from the stack. Print – “Filip Yordanov solved Hot Potato.”

Vladimir Georgiev take the Problem – “Palindomes”….etc.

Finally, there are no tasks left and we print the name of Candidates.

4

5

Greeting

Snake

Array

Sum of All Elements of Matrix

Pesho Goshov

Georgi Ivanov

Petyr Petrov

Ivan ivanov

Simo Simov

Pesho Goshov failed Sum of All Elements of Matrix.

Georgi Ivanov solved Array.

Petyr Petrov solved Snake.

Simo Simov solved Greeting.

Georgi Ivanov failed Sum of All Elements of Matrix.

Petyr Petrov failed Sum of All Elements of Matrix.

Simo Simov gets the job!

 

Тагове:
0
Java Advanced 15/01/2020 20:45:45
KeepCoding avatar KeepCoding 554 Точки
Best Answer

Ето ти кодът ти с малко пипане: https://pastebin.com/jtqgXMjQ
Грешката беше в регекс-а. Не знам какъв точно стринг ти подават като име на кандидат, което ти взима точки, но ако в https://regex101.com/ си сложиш твоят регекс и отдолу сложиш "aIvan Ivanov", то тогава се приема за валидно. Поправил съм го да прави същото като твоето, с разликата че сега се уверява че няма нищо преди (чрез "^") или след (чрез "$") намереното. Също и съм махнал това с групите, не ти е нужно.

Накрая, макар и да не помага за точките, съм направил конкатенация на стрингове от колекция като биват разделени от запетайка с помощта на един метод. Просто е по-лесно така да се прави.

1
Val3ntinV avatar Val3ntinV 20 Точки

Благодаря много !!!

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