Loading...

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

LilianaVelvheva avatar LilianaVelvheva 17 Точки

Къде ми е грешката в задача Activation keys и защо judge ми дава 0 точки?

Ето моето решение: https://pastebin.com/VxDuybEn

Това е условието на задачата:

Programming Fundamentals Final Exam 04.04.2020

Problem 1. Activation Keys

You are about to make some good money, but first you need to think of a way to verify who paid for your product and who didn`t. You have decided to let people use the software for a free trial period and then require an activation key in order to continue to use the product. The last step before you could cash out is to design a program that creates unique activation keys for each user. So, waste no more time and start typing!

The first line of the input will be your raw activation key. It will consist of letters and numbers only.

After that, until the "Generate" command is given, you will be receiving strings with instructions for different operations that need to be performed upon the raw activation key.

There are several types of instructions, split by ">>>":

  • Contains>>>{substring} – checks if the raw activation key contains the given substring.
    • If it does prints: "{raw activation key} contains {substring}".
    • If not, prints: "Substring not found!"
  • Flip>>>Upper/Lower>>>{startIndex}>>>{endIndex}
    • Changes the substring between the given indices (the end index is exclusive) to upper or lower case.
    • All given indexes will be valid.
    • Prints the activation key.
  • Slice>>>{startIndex}>>>{endIndex}
    • Deletes the characters between the start and end indices (end index is exclusive).
    • Both indices will be valid.
    • Prints the activation key.

Input

  • The first line of the input will be string and it will consist of letters and numbers only.
  • After the first line, until the "Generate" command is given, you will be receiving strings.

Output

  • After the "Generate" command is received, print:
    • "Your activation key is: {activation key}"

Examples

Input

Output

abcdefghijklmnopqrstuvwxyz

Slice>>>2>>>6

Flip>>>Upper>>>3>>>14

Flip>>>Lower>>>5>>>7

Contains>>>def

Contains>>>deF

Generate

abghijklmnopqrstuvwxyz

abgHIJKLMNOPQRstuvwxyz

abgHIjkLMNOPQRstuvwxyz

Substring not found!

Substring not found!

Your activation key is: abgHIjkLMNOPQRstuvwxyz

Comments

  1. Slice>>2>>6

abcdefghijklmnopqrstuvwxyz becomes abghijklmnopqrstuvwxyz

  1. Flip>>>Upper>>>3>>>14

abghijklmnopqrstuvwxyz becomes abgHIJKLMNOPQRstuvwxyz

  1. Flip>>>Lower>>>5>>>7

abgHIJKLMNOPQRstuvwxyz becomes abgHIjkLMNOPQRstuvwxyz

  1. Contains>>>def

abgHIjkLMNOPQRstuvwxyz does not contain def

  1. Contains>>>deF

abgHIjkLMNOPQRstuvwxyz does not contain deF

The final activation key is abgHIjkLMNOPQRstuvwxyz

Input

Output

134softsf5ftuni2020rockz42

Slice>>>3>>>7

Contains>>>-rock

Contains>>>-uni-

Contains>>>-rocks

Flip>>>Upper>>>2>>>8

Flip>>>Lower>>>5>>>11

Generate

134sf5ftuni2020rockz42

Substring not found!

Substring not found!

Substring not found!

134SF5FTuni2020rockz42

134SF5ftuni2020rockz42

Your activation key is: 134SF5ftuni2020rockz42

 

JS Input / Output

Input

Output

(["abcdefghijklmnopqrstuvwxyz",

"Slice>>>2>>>6",

"Flip>>>Upper>>>3>>>14",

"Flip>>>Lower>>>5>>>7",

"Contains>>>def",

"Contains>>>deF",

"Generate"])

abghijklmnopqrstuvwxyz

abgHIJKLMNOPQRstuvwxyz

abgHIjkLMNOPQRstuvwxyz

Substring not found!

Substring not found!

Your activation key is: abgHIjkLMNOPQRstuvwxyz

Comments

  1. Slice>>2>>6

abcdefghijklmnopqrstuvwxyz becomes abghijklmnopqrstuvwxyz

  1. Flip>>>Upper>>>3>>>14

abghijklmnopqrstuvwxyz becomes abgHIJKLMNOPQRstuvwxyz

  1. Flip>>>Lower>>>5>>>7

abgHIJKLMNOPQRstuvwxyz becomes abgHIjkLMNOPQRstuvwxyz

  1. Contains>>>def

abgHIjkLMNOPQRstuvwxyz does not contain def

  1. Contains>>>deF

abgHIjkLMNOPQRstuvwxyz does not contain deF

The final activation key is abgHIjkLMNOPQRstuvwxyz

Input

Output

(["134softsf5ftuni2020rockz42",

"Slice>>>3>>>7",

"Contains>>>-rock",

"Contains>>>-uni-",

"Contains>>>-rocks",

"Flip>>>Upper>>>2>>>8",

"Flip>>>Lower>>>5>>>11",

"Generate"])

134sf5ftuni2020rockz42

Substring not found!

Substring not found!

Substring not found!

134SF5FTuni2020rockz42

134SF5ftuni2020rockz42

Your activation key is: 134SF5ftuni2020rockz42

 

 

Тагове:
1
Fundamentals Module
krum_43 avatar krum_43 750 Точки

Здравей LilianaVelvheva,

Не знам защо съдията не ти дава точките.

Предлагам ти да разгледаш решение на C#(57/100).

https://pastebin.com/EJKemfa0

 

0
04/08/2021 13:02:16
LilianaVelvheva avatar LilianaVelvheva 17 Точки

Но къде ви е решението @krum_43?

1
krum_43 avatar krum_43 750 Точки

Yes, add it. Sorry.

0
svephoto avatar svephoto 1191 Точки

Здравей, LilianaVelvheva,

 

Някои части от кода имаха нужда от промяна. Ако имаш желание, погледни този вариант на твоето решение и направи сравнение между него и първоначалния му вид, който ти си дала: https://pastebin.com/48afppGm.

0
Blazer574 avatar Blazer574 -1 Точки

while the judge gives a prison sentence. This will show up as an error in the type equation. Given that the prison/no prison and sentence severity decisions.

 

MyCardStatement

-2
arnold avatar arnold 50 Точки

Мисля, че проблемът е подобен на моя, когато използвах Replace за uppercase и lowercase само, че в C#. Проблемът идва, когато имаме еднакви букви, заменя всичките в низа. Пробвай да изтрививаш конкретния char и да го добавяваш след това новия, като преди това си го направила в upper или lower case.

0
svephoto avatar svephoto 1191 Точки

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

                let subString = rawKeys.slice(startIndex, endIndex);

               

                if (currentCommand === "Upper") {

                    rawKeys = rawKeys.replace(subString, subString.toUpperCase());

                } else {

                    rawKeys = rawKeys.replace(subString, subString.toLowerCase());

                }

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