On Sun, Mar 15, 2015 at 2:07 PM, <jonas.thornv...@gmail.com> wrote: > <SCRIPT LANGUAGE="Javascript"> > > function naiveAdd(base,arrOne,arrTwo) { > if (arrOne.length>=arrTwo.length) {length=arrOne.length;} else > {length=arrTwo.length;} > out=""; > remainder=0; > for (i=0;i<length;i++){ > one=arrOne[i]; > two=arrTwo[i]; > one=parseInt(one); > two=parseInt(two); > if (isNaN(one)) one = 0; > if (isNaN(two)) two = 0; > sum=one+two+remainder; > > if (sum>=base) { sum=sum-base; remainder=1;} else {remainder=0;} > out=","+sum+out; > } > if (remainder==1) out=remainder+out; > return out; > } > base=16; > strOne="2,2"; > strTwo="13,13"; > arrOne=strOne.split(","); > arrTwo=strTwo.split(","); > arrOne.reverse(); > arrTwo.reverse(); > naiveAdd(base,arrOne,arrTwo); > document.write("Sum = ",out,"<BR>"); > </SCRIPT> > -- > https://mail.python.org/mailman/listinfo/python-list
I'm guessing less, if your question is whether this code would be fewer lines in python. However, it would be nice if you formatted it so that it is readable, and gave a description of what you think the code is doing, or should be doing. Its an odd question in that python generally runs on a server and javascript in a browser -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list