Similar presentations:
Checkpoint3 training
1. Checkpoint 3
дайындық2.
CamelToSnakeCamelCase-тен жолды snake_case-ге түрлендіретін
функция жазыңыз.
• Егер жол бос болса, бос жолды қайтарыңыз.
• Егер жол camelCase болмаса, жолды өзгеріссіз
қайтарыңыз.
• Егер жол camelCase болса, snake_case нұсқасын
қайтарыңыз.
Бұл жаттығу үшін camelCase-те қабылданатын екі түрлі
жазу баламасы бар екенін білуіңіз керек:
кіші CamelCase UpperCamelCase CamelCase-те жазу
ережелері:
• Сөз бас әріппен аяқталмайды (CamelCasE).
• Екі бас әріп бір-бірін тікелей жалғастырмайды
(CamelCAse).
• Сөзде сандар мен тыныс белгілері еш жерде рұқсат
етілмейді (camelCase1).
Write a function that converts a string from camelCase to snake_case.
• If the string is empty, return an empty string.
• If the string is not camelCase, return the string unchanged.
• If the string is camelCase, return the snake_case version of the string.
For this exercise you need to know that camelCase has two different
writing alternatives that will be accepted:
• lowerCamelCase
• UpperCamelCase
Rules for writing in camelCase:
• The word does not end on a capitalized letter (CamelCasE).
• No two capitalized letters shall follow directly each other
(CamelCAse).
• Numbers or punctuation are not allowed in the word anywhere
(camelCase1).
3.
4.
WorldFlipКіріс ретінде жолды қабылдап, жолды кері тәртіппен қайтаратын WordFlip() функциясын жазыңыз.
• Шығыстан кейін жаңа жол \n болуы керек.
• Егер жол бос болса, Invalid Output-ты қайтарыңыз.
• Сөздер арасындағы бірнеше бос орындарды елемей, жолдағы алдыңғы немесе соңғы бос
орындарды қысқартыңыз.
Write a function WordFlip() that takes a string as input and returns it in reverse order.
• The output should be followed by a newline \n.
• If the string is empty, return Invalid Output.
• Ignore multiple spaces between words and trim any leading or trailing spaces in the string.
5.
6.
SaveAndMissSaveAndMiss() деп аталатын функцияны жазыңыз, ол аргумент ретінде жол мен int-ті алады. Функция int
арқылы анықталған жиындарда жолды өтуі керек, бірінші жиынды сақтап, екіншісін алып тастайды,
үшіншісін сақтайды және т.б. жолдың соңына дейін 'сақтау' және 'miss' түрінде жалғасады. Сақталған
таңбаларды қамтитын жолды қайтарыңыз.
Егер int 0 немесе теріс сан болса, бастапқы жолды қайтарыңыз.
Write a function called SaveAndMiss() that takes a string and an int as an argument. The function should move
through the string in sets determined by the int, saving the first set, omitting the second, saving the third, and so
on, in a 'save' and 'miss' fashion until the end of the string is reached. Return a string containing the saved
characters.
If the int is 0 or a negative number return the original string.
7.
8.
ConcatAlternateConcatAlternate() функциясын жазыңыз, ол int-тің екі кесіндісін аргумент ретінде қабылдап, әр кесіндінің
алмастырылған мәндерінің нәтижесімен жаңа слайс қайтарады.
• Кіріс кесінділері әртүрлі ұзындықта болуы мүмкін.
• Жаңа тілім ең үлкен тілімнің элементінен басталуы керек.
• Егер кесінділер бірдей ұзындықта болса, жаңа кесінді алдымен бірінші кесіндінің элементтерін, содан
кейін екінші кесіндінің элементтерін қайтаруы керек.
Write a function ConcatAlternate() that receives two slices of an int as arguments and returns a new slice with
the result of the alternated values of each slice.
• The input slices can be of different lengths.
• The new slice should start with an element of the largest slice.
• If the slices are of equal length, the new slice should return the elements of the first slice first and then the
elements of the second slice.
9.
10.
RevConcatAlternateRevConcatAlternate() функциясын жазыңыз, ол int-тің екі кесіндісін аргумент ретінде қабылдап,
әр слайстың мәндері кері ретпен ауыстырылған жаңа слайс қайтарады.
• Кіріс кесінділерінің ұзындығы әртүрлі болуы мүмкін.
• Жаңа кесінді ең үлкен кесіндіден бастап элементтерден басталып, олар тең өлшемге
айналғанда, бірінші кесіндінің элементін қосуы керек.
• Егер кесінділер бірдей ұзындықта болса, жаңа тілім бірінші тілімнің элементінен басталуы
керек.
Write a function RevConcatAlternate() that receives two slices of int as arguments and returns a new slice with
alternated values of each slice in reverse order.
• The input slices can have different lengths.
• The new slice should start with the elements from the largest slice first and when they became equal size
slices, it should add an element of the first given slice.
• If the slices are of equal length, the new slice should start with an element of the first slice.
11.
12.
RetainFirstHalfRetainFirstHalf() деп аталатын функцияны жазыңыз, ол аргумент ретінде жолды алып, осы жолдың бірінші
жартысын қайтарады.
• Егер жіптің ұзындығы тақ болса, оны төмендетіңіз.
• Егер жол бос болса, бос жолды қайтарыңыз.
• Егер жіп ұзындығы бірге тең болса, жіпті қайтарыңыз.
Write a function called RetainFirstHalf() that takes a string as an argument and returns the first half of this string.
• If the length of the string is odd, round it down.
• If the string is empty, return an empty string.
• If the string length is equal to one, return the string.
13.
14.
SliceФункция жолдар мен бір немесе бірнеше бүтін сандарды қабылдайды, содан кейін жолдар кесіндісін
қайтарады. Қайтарылған слайс қабылданған жолдың бөлігі болып табылады, бірақ бірінші int-те
көрсетілген позициядан кейінгі екінші int-пен көрсетілген позицияға дейін қиылады.
Егер тек бір int болса, алынған slice int көрсетілген позицияда басталып, қабылданған кесіндінің соңында
аяқталады.
Бүтін сандар теріс болуы мүмкін.
The function receives a slice of strings and one or more integers, and returns a slice of strings. The returned slice is
part of the received one but cut from the position indicated in the first int, until the position indicated by the
second int.
In case there only exists one int, the resulting slice begins in the position indicated by the int and ends at the end of
the received slice.
The integers can be negative.
15.
16.
ZipStringБерілген жолдағы қатарынан қайталанатын таңбаларды санап, оларды санмен ауыстырып, содан
кейін таңбаның өзін таңбамен ауыстыратын функция жасаңыз. Қосымша қайталануларды жойып,
шығыс тек латын алфавитінен алынған таңбаларды сақтап, басқа таңбаларды сәйкес өңдейтінін
қамтамасыз ету керек.
Сreate a function that transforms a given string by counting consecutive duplicate characters and replacing
them with the count followed by the character itself. You will eliminate extra duplications and ensure the
output retains only characters from the Latin alphabet, handling any other characters accordingly.
17.
Шығыс \ Output18.
FifthAndSkip'FifthAndSkip()' деп аталатын функция құрыңыз, ол әр бес таңбаны біріктіріп, алтыншы таңбаны өткізіп
жіберіп, жолды өңдейді. Бос орындарды тек бос орын емес таңбаларды санау арқылы бес таңбаға
жеткенше өңдейсіз. Жарамсыз енгізулерді тексеріп, жолдың ұзындығына немесе бос болғанына
байланысты тиісті хабарламаларды қайтаруыңыз керек.
create a function named `FifthAndSkip()` that processes a string by grouping every five characters together,
while skipping the sixth character. You will handle spaces by only counting non-space characters until you
reach five. You must check for invalid inputs and return appropriate messages based on the string's length or
if it is empty.