+ 1

pseudocode to python

help me to convert this pseudocode function RightToLeft(nilai) pos=1 while decimal > 0 do A[pos]=nilai%16 nilai=nilai/16 pos=pos+1 end while for i = 1 to (pos-1)/2 do temp=A[i] A[i]=A[pos-i] A[pos-i]=temp end for

5th Jan 2017, 7:34 AM
Angel
Angel - avatar
20 odpowiedzi
+ 1
endless loop, decimal don't change
5th Jan 2017, 9:19 AM
Maxim Kuzmin
Maxim Kuzmin - avatar
+ 1
if it is function def RightToLeft(nilai): global A,decimal pos=1 while decimal>0: A[pos]=nilai%16 nilai/=16 pos+=1 for i in range(1,(pos-1)/2): temp=A[i] A[i]=A[pos-1] A[pos-i]=temp
5th Jan 2017, 9:20 AM
Maxim Kuzmin
Maxim Kuzmin - avatar
+ 1
@Alex, nilai is local, you can use its value only in this function, if you define valuable in code, and want to use in function you need 'global'. Sorry for my English
5th Jan 2017, 9:39 AM
Maxim Kuzmin
Maxim Kuzmin - avatar
+ 1
def get_part(input): if len(input) <= 1: return input num=int(input.split(input[-1],2)[0]) return num*input[-1] def get_line(input): parts=[] for i in input.split(" "): parts.append(get_part(i)) return "".join(parts) n=input() inputs=[] inputs.append(n) for input in inputs: print(get_line(input)) if i input : 4bab 18c 12g outout : bbbbccccccccccccccccccgggggggggggg how to make it output is babbabbabbabccccccccccccccccccgggggggggggg
5th Jan 2017, 11:42 AM
Angel
Angel - avatar
0
function RightToLeft(nilai) pos=1 while decimal > 0 do A[pos]=nilai%16 nilai=nilai/16 pos=pos+1 end while for i = 1 to (pos-1)/2 do temp=A[i] A[i]=A[pos-i] A[pos-i]=temp end for
5th Jan 2017, 8:09 AM
Angel
Angel - avatar
0
@maxim what is the meaning of global A,decimal?
5th Jan 2017, 9:22 AM
Angel
Angel - avatar
0
@maxim oke thankyou so much. can you solve my other problem. like how to make a code with testcase like input : 4a 3c 9o 0 output : aaaacccooooooooo0 input : 11b 3k 9 output : bbbbbbbbbbbkkk9
5th Jan 2017, 9:40 AM
Angel
Angel - avatar
0
print (4*'a',3*'c',9*'o','0') Solved?
5th Jan 2017, 9:42 AM
Maxim Kuzmin
Maxim Kuzmin - avatar
0
@maxim no. user can input whats the number he want and how many he want
5th Jan 2017, 9:44 AM
Angel
Angel - avatar
0
do you understand Russian?
5th Jan 2017, 9:45 AM
Maxim Kuzmin
Maxim Kuzmin - avatar
0
oke no problem i'll use google translate to undarsading you
5th Jan 2017, 9:46 AM
Angel
Angel - avatar
0
if they both in one input, I think we need to use regulars
5th Jan 2017, 9:46 AM
Maxim Kuzmin
Maxim Kuzmin - avatar
0
yes youre right. and we can use array too
5th Jan 2017, 9:47 AM
Angel
Angel - avatar
0
Если только одна буква, можно использовать это: z=input () print (int (z[0:-1])*z [-1])
5th Jan 2017, 9:55 AM
Maxim Kuzmin
Maxim Kuzmin - avatar
0
Если букв несколько, то только регулярные выражения.
5th Jan 2017, 9:58 AM
Maxim Kuzmin
Maxim Kuzmin - avatar
0
но он использует все буквы и все цифры
5th Jan 2017, 10:02 AM
Angel
Angel - avatar
0
Я имею ввиду, что ввод не может быть таким: 1sd 134jk После цифр буква только одна, если несколько - регулярные
5th Jan 2017, 10:05 AM
Maxim Kuzmin
Maxim Kuzmin - avatar
0
r=input() for i in range(0,len(r)//2): for j in range(0,int(r[2*i])): print(r[2*i+1],end="") this code is with input :1a3b4c output : abbbcccc but if i input more than that like input : 1a3b6c7 or inpur : 11b17c8b it would be error
5th Jan 2017, 10:06 AM
Angel
Angel - avatar
0
но пользователь может ввести, Что пользователь хочет мы не знаем, что он будет вход, но он должен число слов номер слово ..... и процесс если я вход 4k 8h 18L выход kkkkhhhhhhhhlllllllllllllll поэтому мы должны сделать программу, как а * Ь с * d е * е .............. до howmany пользователь не хочет
5th Jan 2017, 10:11 AM
Angel
Angel - avatar
0
Write English. Can number of characters be >9? for example, can user input such: 13a356b? If he can, learn regulars.
5th Jan 2017, 10:16 AM
Maxim Kuzmin
Maxim Kuzmin - avatar