+ 2
Can you solve this :- Expand alphabets
Given a string S with alphabets and their count, repeat the alphabets based on their count and print the value as the output. Input Format: The first line contains S. Output Format: The first line contains the alphabets repeated based on their count. Boundary Condition: 1 <= Length of S <= 100 Example Input/Output 1: Input: a2c5z4 Output: aaccccczzzz input: a10b10c10 output: aaaaaaaaaabbbbbbbbbbcccccccccc input: a4b5c2f7g3 output: aaaabbbbbccfffffffggg
9 Antworten
+ 5
My program:
https://code.sololearn.com/cS07VeN856mJ
+ 3
got the easiest way in c++
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{int i,j;
char a;
while(cin>>a>>i)
for(j=0;j<i;j++)
cout<<a;
}
+ 1
a=input().rstrip()
c=[]
d=[]
for i in range(len(a)):
if(i%2==0):
c.append(a[i])
else:
d.append(int(a[i]))
k=0
for i in c:
for j in range(d[k]):
print(i,end=' ')
k=k+1
//Follow answers from https://vitcrack.blogspot.com
0
maxcookmax , read the examples once again
what to do if input is
a12b20c29
because here input[0]=a but the number after 'a' is 12 ,if you give input[1] then you will get only 1 not 12
0
komal, what will you do if input is
a16c10f13
(see the examples )
0
Thank you Mr.John Wells ,It was a fantastic answer,Can you do that once again for me in c++ or in python on in java .Because I don't know kotlin.