PA1 (D (Protected Viee)-PowerPo ntions Ansationa Slde Show Review View Storyboar
ID: 3746027 • Letter: P
Question
PA1 (D (Protected Viee)-PowerPo ntions Ansationa Slde Show Review View Storyboarding 81eEmewhat you "toe Interint can cntan vinnes Ueless you nend to edis, t's fer to stay in Protected ViwEnable Eding Pseudocode PA - Problem 1 . Write pseudocode for an algorithm that will get a string of digits as input, and then output a new string which "describes" the previous one using only digits Ex. if the initial string is "22111344, the descriptive string result would be 22311324". This is shorthand for "two 2s, three 1s, one 3, and two 4s"Explanation / Answer
Initialize the int counter = 1; string result = ""
Read input from user
// Iterating from index 0 to last but one index
for i = 0 to input.length - 1
// Checking whether adjacent character are same. If yes the counter is increased
if input[i] == input[i+1]
counter++
else
// If false then the counter is set to one and previous character is
// appended to result along with counter
result += toString(counter) + input[i]
counter = 1
print result
**Comment for any queries. Happy to help ...:)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.