UNPKG

gitbook-plugin-pyweb

Version:
2 lines 3.3 MB
__BRYTHON__.use_VFS = true; __BRYTHON__.VFS={"builtins": [".js", "var $module = (function(){\n var obj = {__class__:__BRYTHON__.$ModuleDict,__name__:'builtins'}\n var builtin_names = ['ArithmeticError', 'AssertionError', 'AttributeError', \n 'BaseException', 'BlockingIOError', 'BrokenPipeError', 'BufferError', \n 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', \n 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', \n 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', \n 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', \n 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', \n 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError',\n 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', \n 'None', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', \n 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', \n 'ProcessLookupError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', \n 'RuntimeWarning', 'StopIteration', 'SyntaxError', 'SyntaxWarning', \n 'SystemError', 'SystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError', \n 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', \n 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', \n 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '_', \n '__build_class__', '__debug__', '__doc__', '__import__', '__name__', \n '__package__', 'abs', 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', \n 'bytes','callable', 'chr', 'classmethod', 'compile', 'complex', 'copyright', \n 'credits','delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', \n 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', \n 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', \n 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', \n 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', \n 'property', 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', \n 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', \n 'vars', 'zip']\n for(var i=0, _len_i = builtin_names.length; i < _len_i;i++){\n try{eval(\"obj['\"+builtin_names[i]+\"']=__BRYTHON__.builtins.\"+builtin_names[i])}\n catch(err){if (__BRYTHON__.$debug) {console.log(err)}}\n }\n return obj\n})()\n"], "dis": [".js", "var $module=(function($B){\n\nvar mod = {\n dis:function(src){\n $B.$py_module_path['__main__'] = $B.brython_path\n return __BRYTHON__.py2js(src,'__main__','__main__','__builtins__').to_js()\n }\n}\nreturn mod\n\n})(__BRYTHON__)"], "hashlib": [".js", "var $module=(function($B){\n\nvar _b_ = $B.builtins\n\nvar $s=[]\nfor(var $b in _b_) $s.push('var ' + $b +'=_b_[\"'+$b+'\"]')\neval($s.join(';'))\n\nvar $mod = {\n\n __getattr__ : function(attr){\n if (attr == 'new') return $hashlib_new;\n return this[attr]\n },\n md5: function(obj) {return $hashlib_new('md5', obj)},\n sha1: function(obj) {return $hashlib_new('sha1', obj)},\n sha224: function(obj) {return $hashlib_new('sha224', obj)},\n sha256: function(obj) {return $hashlib_new('sha256', obj)},\n sha384: function(obj) {return $hashlib_new('sha384', obj)},\n sha512: function(obj) {return $hashlib_new('sha512', obj)},\n\n algorithms_guaranteed: ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'],\n algorithms_available: ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']\n}\n\n\n//todo: eventually move this function to a \"utility\" file or use ajax module?\nfunction $get_CryptoJS_lib(alg) {\n var imp=$importer()\n var $xmlhttp=imp[0], fake_qs=imp[1], timer=imp[2], res=null\n\n $xmlhttp.onreadystatechange = function(){\n if($xmlhttp.readyState==4){\n window.clearTimeout(timer)\n if($xmlhttp.status==200 || $xmlhttp.status==0){res=$xmlhttp.responseText}\n else{\n // don't throw an exception here, it will not be caught (issue #30)\n res = Error()\n res.name = 'NotFoundError'\n res.message = \"No CryptoJS lib named '\"+alg+\"'\"\n }\n }\n }\n\n $xmlhttp.open('GET', $B.brython_path+'libs/crypto_js/rollups/'+alg+'.js'+fake_qs,false)\n if('overrideMimeType' in $xmlhttp){$xmlhttp.overrideMimeType(\"text/plain\")}\n $xmlhttp.send()\n if(res.constructor===Error){throw res} // module not found\n\n try{\n eval(res + \"; $B.CryptoJS=CryptoJS;\")\n } catch (err) { \n throw Error(\"JS Eval Error\", \"Cannot eval CryptoJS algorithm '\" + alg + \"' : error:\" + err);\n }\n}\n\nfunction bytes2WordArray(obj){\n // Transform a bytes object into an instance of class WordArray\n // defined in CryptoJS\n if(!_b_.isinstance(obj, _b_.bytes)){\n throw _b_.TypeError(\"expected bytes, got \"+\n $B.get_class(obj).__name__)\n }\n\n var words = []\n for(var i=0;i<obj.source.length;i+=4){\n var word = obj.source.slice(i, i+4)\n while(word.length<4){word.push(0)}\n var w = word[3] +(word[2]<<8)+(word[1]<<16)+(word[0]<<24)\n words.push(w)\n }\n return {words: words, sigBytes:obj.source.length}\n}\n\nvar hashDict = {\n __class__: $B.$type,\n __name__: 'hash'\n}\nhashDict.__mro__ = [_b_.object.$dict]\n\nhashDict.update = function(self, msg){\n self.hash.update(bytes2WordArray(msg))\n}\n\nhashDict.copy = function(self){\n return self.hash.clone()\n}\n \nhashDict.digest = function(self){\n var obj = self.hash.clone().finalize().toString(),\n res = []\n for(var i=0;i<obj.length;i+=2){\n res.push(parseInt(obj.substr(i,2), 16))\n }\n return _b_.bytes(res)\n}\n\nhashDict.hexdigest = function(self) {\n return self.hash.clone().finalize().toString()\n}\n\n\nfunction $hashlib_new(alg, obj) {\n\n var res = {\n __class__: hashDict\n }\n\n switch(alg) {\n case 'md5':\n case 'sha1':\n case 'sha224':\n case 'sha256':\n case 'sha384':\n case 'sha512':\n var ALG=alg.toUpperCase()\n if ($B.Crypto === undefined || \n $B.CryptoJS.algo[ALG] === undefined) $get_CryptoJS_lib(alg)\n\n res.hash = $B.CryptoJS.algo[ALG].create()\n if(obj!==undefined){\n res.hash.update(bytes2WordArray(obj))\n }\n break\n default:\n $raise('AttributeError', 'Invalid hash algorithm:' + alg)\n }\n \n return res\n}\n\n$hashlib_new.$type = $B.$factory\nhashDict.$factory = $hashlib_new\n$hashlib_new.$dict = hashDict\n\nreturn $mod\n\n})(__BRYTHON__)\n"], "json": [".js", "var $module = (function($B){\n\nreturn {\n loads : function(json_obj){\n return $B.jsobject2pyobject(JSON.parse(json_obj))\n },\n load : function(file_obj){\n return $module.loads(file_obj.$content);\n },\n dumps : function(obj){return JSON.stringify($B.pyobject2jsobject(obj))},\n}\n\n})(__BRYTHON__)\n"], "long_int": [".js", "/*\nModule to manipulate long integers\n*/\n\nvar $module=(function($B){\n\neval($B.InjectBuiltins())\n\nvar $LongIntDict = {__class__:$B.$type,__name__:'LongInt'}\n\nfunction add_pos(v1, v2){\n // Add two positive numbers\n // v1, v2 : strings\n // Return an instance of LongInt\n\n var res = '', carry = 0, iself=v1.length, sv=0\n for(var i=v2.length-1;i>=0;i--){\n iself--\n if(iself<0){sv=0}else{sv=parseInt(v1.charAt(iself))}\n x = (carry+sv+parseInt(v2.charAt(i))).toString()\n if(x.length==2){res=x.charAt(1)+res;carry=parseInt(x.charAt(0))}\n else{res=x+res;carry=0}\n }\n while(iself>0){\n iself--\n x = (carry+parseInt(v1.charAt(iself))).toString()\n if(x.length==2){res=x.charAt(1)+res;carry=parseInt(x.charAt(0))}\n else{res=x+res;carry=0}\n }\n if(carry){res=carry+res} \n return {__class__:$LongIntDict, value:res, pos:true}\n}\n\nfunction check_shift(shift){\n // Check the argument of >> and <<\n if(!isinstance(shift, LongInt)){\n throw TypeError(\"shift must be LongInt, not '\"+\n $B.get_class(shift).__name__+\"'\")\n }\n if(!shift.pos){throw ValueError(\"negative shift count\")}\n}\n\nfunction clone(obj){\n // Used for traces\n var obj1 = {}\n for(var attr in obj){obj1[attr]=obj[attr]}\n return obj1\n}\n\nfunction comp_pos(v1, v2){\n // Compare two positive numbers\n if(v1.length>v2.length){return 1}\n else if(v1.length<v2.length){return -1}\n else{\n if(v1>v2){return 1}\n else if(v1<v2){return -1}\n }\n return 0\n}\n\nfunction divmod_pos(v1, v2){\n // v1, v2 : strings, represent 2 positive integers A and B\n // Return [a, b] where a and b are instances of LongInt\n // a = A // B, b = A % B\n var v1_init = v1, quotient, mod\n if(comp_pos(v1, v2)==-1){ // a < b\n quotient='0'\n mod = LongInt(v1)\n }else if(v2==v1){ // a = b\n quotient = '1';\n mod = LongInt('0')\n }else{\n var quotient = '', v1_init = v1\n var left = v1.substr(0, v2.length)\n if(v1<v2){left = v1.substr(0, v2.length+1)}\n var right = v1.substr(left.length)\n // mv2 maps integers i from 2 to 9 to i*v2, used as a cache to avoid\n // having to compute i*v2 each time\n var mv2 = {}\n // Javascript \"safe integer\" with the 15 first digits in v2,\n // used in the algorithm to test candidate values\n var jsv2 = parseInt(v2.substr(0,15))\n\n // Division algorithm\n // At each step in the division, v1 is split into substrings\n // \"left\" is the left part, with the same length as v2\n // \"rest\" is the rest of v1 after \"left\"\n // The algorithm finds the one-digit integer \"candidate\" such\n // that 0 <= left - candidate*v2 < v2\n // It stops when right is empty\n while(true){\n // Uses JS division to test an approximate result\n var jsleft = parseInt(left.substr(0,15))\n var candidate = Math.floor(jsleft/jsv2).toString()\n\n // Check that candidate is the correct result\n // Start by computing candidate*v2 : for this, use the table\n // mv2, which stores the multiples of v2 already calculated\n if(mv2[candidate]===undefined){\n mv2[candidate] = mul_pos(v2, candidate).value\n }\n if(comp_pos(left, mv2[candidate])==-1){\n // If left < candidate * v2, use candidate-1\n candidate--\n if(mv2[candidate]===undefined){\n mv2[candidate] = mul_pos(v2, candidate).value\n }\n }\n\n // Add candidate to the quotient\n quotient += candidate\n\n // New value for left : left - v2*candidate\n left = sub_pos(left, mv2[candidate]).value\n\n // Stop if all digits in v1 have been used\n if(right.length==0){break}\n\n // Else, add next digit to left and remove it from right\n left += right.charAt(0)\n right = right.substr(1)\n }\n // Modulo is A - (A//B)*B\n mod = sub_pos(v1, mul_pos(quotient, v2).value)\n }\n return [LongInt(quotient), mod]\n}\n\nfunction mul_pos(v1, v2){\n // Multiply positive numbers v1 by v2\n // Make v2 smaller than v1\n if(v1.length<v2.length){var a=v1; v1=v2 ; v2=a}\n if(v2=='0'){return LongInt('0')}\n var cols = {}, i=v2.length, j\n \n // Built the object \"cols\", indexed by integers from 1 to nb1+nb2-2\n // where nb1 and nb2 are the number of digits in v1 and v2.\n // cols[n] is the sum of v1[i]*v2[j] for i+j = n\n \n while(i--){\n var car = v2.charAt(i)\n if(car==\"0\"){\n j = v1.length\n while(j--){\n if(cols[i+j]===undefined){cols[i+j]=0}\n } \n }else if(car==\"1\"){\n j = v1.length\n while(j--){\n var z = parseInt(v1.charAt(j))\n if(cols[i+j]===undefined){cols[i+j]=z}\n else{cols[i+j] += z}\n }\n }else{\n var x = parseInt(car), j = v1.length, y, z\n while(j--){\n y = x * parseInt(v1.charAt(j))\n if(cols[i+j]===undefined){cols[i+j]=y}\n else{cols[i+j] += y}\n }\n }\n }\n\n // Transform cols so that cols[x] is a one-digit integers\n i = v1.length+v2.length-1\n while(i--){\n var col = cols[i].toString()\n if(col.length>1){\n // If the value in cols[i] has more than one digit, only keep the\n // last one and report the others at the right index\n // For instance if cols[i] = 123, keep 3 in cols[i], add 2 to\n // cols[i-1] and 1 to cols[i-2]\n cols[i] = parseInt(col.charAt(col.length-1))\n j = col.length\n while(j-->1){\n var report = parseInt(col.charAt(j-1))\n var pos = i-col.length+j\n if(cols[pos]===undefined){cols[pos]=report}\n else{cols[pos] += report}\n }\n }\n }\n\n // Find minimum index in cols\n // The previous loop may have introduced negative indices\n var imin\n for(var attr in cols){\n i = parseInt(attr)\n if(imin===undefined){imin=i}\n else if(i<imin){imin=i}\n }\n\n // Result is the concatenation of digits in cols\n var res = ''\n for(var i=imin;i<=v1.length+v2.length-2;i++){res+=cols[i].toString()}\n return LongInt(res)\n}\n\nfunction sub_pos(v1, v2){\n // Substraction of positive numbers with v1>=v2\n\n var res = '', carry = 0, i1=v1.length, sv=0\n \n // For all digits in v2, starting by the rightmost, substract it from\n // the matching digit in v1\n // This is the equivalent of the manual operation :\n // 12345678\n // - 98765\n //\n // We begin by the rightmost operation : 8-5 (3, no carry),\n // then 7-6 (1, no carry)\n // then 6-7 (9, carry 1) and so on\n for(var i=v2.length-1;i>=0;i--){\n i1--\n sv = parseInt(v1.charAt(i1))\n x = (sv-carry-parseInt(v2.charAt(i)))\n if(x<0){res=(10+x)+res;carry=1}\n else{res=x+res;carry=0}\n }\n \n // If there are remaining digits in v1, substract the carry, if any\n while(i1>0){\n i1--\n x = (parseInt(v1.charAt(i1))-carry)\n if(x<0){res=(10+x)+res;carry=1}\n else{res=x+res;carry=0}\n }\n\n // Remove leading zeros and return the result\n while(res.charAt(0)=='0' && res.length>1){res=res.substr(1)}\n return {__class__:$LongIntDict, value:res, pos:true}\n}\n\n// Special methods to implement operations on instances of LongInt\n\n$LongIntDict.__abs__ = function(self){\n return {__class__:$LongIntDict, value: self.value, pos:true}\n}\n\n$LongIntDict.__add__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n // Addition of \"self\" and \"other\"\n // If both have the same sign (+ or -) we add their absolute values\n // If they have different sign we use the substraction of their\n // absolute values\n var res\n if(self.pos&&other.pos){ // self > 0, other > 0\n return add_pos(self.value, other.value)\n }else if(!self.pos&&!other.pos){ // self < 0, other < 0\n res = add_pos(self.value, other.value)\n res.pos = false\n return res\n }else if(self.pos && !other.pos){ // self > 0, other < 0\n switch (comp_pos(self.value, other.value)){\n case 1:\n res = sub_pos(self.value, other.value)\n break\n case 0:\n res = {__class__:$LongIntDict, value:0, pos:true}\n break\n case -1:\n res = sub_pos(other.value, self.value)\n res.pos = false\n break\n }\n return res\n }else{ // self < 0, other > 0\n switch(comp_pos(self.value, other.value)){\n case 1:\n res = sub_pos(self.value, other.value)\n res.pos = false\n break\n case 0:\n res = {__class__:$LongIntDict, value:0, pos:true}\n break\n case -1:\n res = sub_pos(other.value, self.value)\n break\n }\n return res\n }\n}\n\n$LongIntDict.__and__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n // Bitwise \"and\" : build the binary representation of self and other\n var v1 = $LongIntDict.__index__(self)\n var v2 = $LongIntDict.__index__(other)\n // apply \"and\" on zeros and ones\n if(v1.length<v2.length){var temp=v2;v2=v1;v1=temp}\n var start = v1.length-v2.length\n var res = ''\n for(var i=0;i<v2.length;i++){\n if(v1.charAt(start+i)=='1' && v2.charAt(i)=='1'){res += '1'}\n else{res += '0'}\n }\n // Return the LongInt instance represented by res in base 2\n return LongInt(res, 2)\n}\n\n$LongIntDict.__divmod__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n\n var dm = divmod_pos(self.value, other.value)\n if(self.pos!==other.pos){\n if(dm[0].value!='0'){dm[0].pos = false}\n if(dm[1].value!='0'){\n // If self and other have different signs and self is not a multiple\n // of other, round to the previous integer\n dm[0] = $LongIntDict.__sub__(dm[0], LongInt('1'))\n dm[1] = $LongIntDict.__add__(dm[1], LongInt('1'))\n }\n }\n return dm \n}\n\n$LongIntDict.__eq__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n return self.value==other.value && self.pos==other.pos\n}\n\n$LongIntDict.__floordiv__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n return $LongIntDict.__divmod__(self, other)[0]\n}\n\n$LongIntDict.__ge__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n if(self.value.length>other.value.length){return true}\n else if(self.value.length<other.value.length){return false}\n else{return self.value >= other.value}\n}\n\n$LongIntDict.__gt__ = function(self, other){\n return !$LongIntDict.__le__(self, other)\n}\n\n$LongIntDict.__index__ = function(self){\n // Used by bin()\n // returns a string with the binary value of self\n // The algorithm computes the result of the floor division of self by 2\n \n // XXX to do : negative integers\n \n var res = '', pos=self.value.length,\n temp = self.value, d\n while(true){\n d = divmod_pos(temp, '2')\n res = d[1].value + res\n temp = d[0].value\n if(temp=='0'){break}\n }\n return res\n}\n\n$LongIntDict.__invert__ = function(self){\n var bin = $LongIntDict.__index__(self)\n var res = ''\n for(var i=0;i<bin.length;i++){\n res += bin.charAt(i)=='0' ? '1' : '0'\n }\n return LongInt(res, 2)\n}\n\n$LongIntDict.__le__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n if(self.value.length>other.value.length){return false}\n else if(self.value.length<other.value.length){return true}\n else{return self.value <= other.value}\n}\n\n$LongIntDict.__lt__ = function(self, other){\n return !$LongIntDict.__ge__(self, other)\n}\n\n$LongIntDict.__lshift__ = function(self, shift){\n check_shift(shift)\n var res = self.value\n while(true){\n var x, carry=0, res1=''\n for(var i=res.length-1;i>=0;i--){\n x = (carry+parseInt(res.charAt(i))*2).toString()\n if(x.length==2){res1=x.charAt(1)+res1;carry=parseInt(x.charAt(0))}\n else{res1=x+res1;carry=0}\n }\n if(carry){res1=carry+res1}\n res=res1\n shift = sub_pos(shift.value, '1')\n if(shift.value=='0'){break}\n }\n return {__class__:$LongIntDict, value:res, pos:self.pos}\n}\n\n$LongIntDict.__mod__ = function(self, other){\n return $LongIntDict.__divmod__(self, other)[1]\n}\n\n$LongIntDict.__mro__ = [_b_.object.$dict]\n\n$LongIntDict.__mul__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n var res = mul_pos(self.value, other.value)\n if(self.pos==other.pos){return res}\n res.pos = false\n return res\n}\n\n$LongIntDict.__neg__ = function(obj){\n return {__class__:$LongIntDict, value:obj.value, pos:!obj.pos}\n}\n\n$LongIntDict.__or__ = function(self, other){\n var v1 = $LongIntDict.__index__(self)\n var v2 = $LongIntDict.__index__(other)\n if(v1.length<v2.length){var temp=v2;v2=v1;v1=temp}\n var start = v1.length-v2.length\n var res = v1.substr(0, start)\n for(var i=0;i<v2.length;i++){\n if(v1.charAt(start+i)=='1' || v2.charAt(i)=='1'){res += '1'}\n else{res += '0'}\n }\n return LongInt(res, 2)\n}\n\n\n$LongIntDict.__pow__ = function(self, power){\n if (typeof power == \"number\") {\n power=LongInt(_b_.str(power))\n }else if(!isinstance(power, LongInt)){\n var msg = \"power must be a LongDict, not '\"\n throw TypeError(msg+$B.get_class(power).__name__+\"'\")\n }\n if(!power.pos){\n if(self.value=='1'){return self}\n // For all other integers, x**-n is 0\n return LongInt('0')\n }else if(power.value=='0'){\n return LongInt('1')\n }\n var res = {__class__:$LongIntDict, value:self.value, pos:self.pos}\n var pow = power.value\n while(true){\n pow = sub_pos(pow, '1').value\n if(pow == '0'){break}\n res = $LongIntDict.__mul__(res, self)\n }\n return res \n}\n\n$LongIntDict.__rshift__ = function(self, shift){\n check_shift(shift)\n var res = self.value\n while(true){\n res = divmod_pos(res, '2')[0].value\n if(res.value=='0'){break}\n shift = sub_pos(shift.value, '1')\n if(shift.value=='0'){break}\n }\n return {__class__:$LongIntDict, value:res, pos:self.pos}\n}\n\n$LongIntDict.__str__ = $LongIntDict.__repr__ = function(self){\n var res = \"LongInt('\"\n if(!self.pos){res += '-'}\n return res+self.value+\"')\"\n}\n\n$LongIntDict.__sub__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n var res\n if(self.pos && other.pos){\n switch(comp_pos(self.value, other.value)){\n case 1:\n res = sub_pos(self.value, other.value)\n break\n case 0:\n res = {__class__:$LongIntDict, value:'0', pos:true}\n break\n case -1:\n res = sub_pos(other.value, self.value)\n res.pos = false\n break\n }\n return res\n }else if(!self.pos && !other.pos){\n switch(comp_pos(self.value, other.value)){\n case 1:\n res = sub_pos(self.value, other.value)\n res.pos = false\n break\n case 0:\n res = {__class__:$LongIntDict, value:'0', pos:true}\n break\n case -1:\n res = sub_pos(other.value, self.value)\n break\n }\n return res\n }else if(self.pos && !other.pos){\n return add_pos(self.value, other.value)\n }else{\n res = add_pos(self.value, other.value)\n res.pos = false\n return res\n }\n}\n\n$LongIntDict.__xor__ = function(self, other){\n var v1 = $LongIntDict.__index__(self)\n var v2 = $LongIntDict.__index__(other)\n if(v1.length<v2.length){var temp=v2;v2=v1;v1=temp}\n var start = v1.length-v2.length\n var res = v1.substr(0, start)\n for(var i=0;i<v2.length;i++){\n if(v1.charAt(start+i)=='1' && v2.charAt(i)=='0'){res += '1'}\n else if(v1.charAt(start+i)=='0' && v2.charAt(i)=='1'){res += '1'}\n else{res += '0'}\n }\n return LongInt(res, 2)\n}\n\n$LongIntDict.to_base = function(self, base){\n // Returns the string representation of self in specified base\n var res='', v=self.value\n while(v>0){\n var dm = divmod_pos(v, base.toString())\n res = parseInt(dm[1].value).toString(base)+res\n v = dm[0].value\n if(v==0){break}\n }\n return res\n}\n\nfunction digits(base){\n // Return an object where keys are all the digits valid in specified base\n // and value is \"true\"\n // Used to test if the string passed as first argument to LongInt is valid\n var is_digits = {}\n // Number from 0 to base, or from 0 to 9 if base > 10\n for(var i=0;i<base;i++){\n if(i==10){break}\n is_digits[i]=true\n }\n if(base>10){\n // Additional letters\n // For instance in base 16, add \"abcdefABCDEF\" as keys\n for(var i=0;i<base-10;i++){\n is_digits[String.fromCharCode(65+i)]=true\n is_digits[String.fromCharCode(97+i)]=true\n }\n }\n return is_digits\n}\n\nvar MAX_SAFE_INTEGER = Math.pow(2, 53)-1;\nvar MIN_SAFE_INTEGER = -Number.MAX_SAFE_INTEGER;\n\nfunction isSafeInteger(n) {\n return (typeof n === 'number' &&\n Math.round(n) === n &&\n Number.MIN_SAFE_INTEGER <= n &&\n n <= Number.MAX_SAFE_INTEGER);\n}\n\nfunction LongInt(value, base){\n if(arguments.length>2){\n throw _b_.TypeError(\"LongInt takes at most 2 arguments (\"+\n arguments.length+\" given)\")\n }\n // base defaults to 10\n if(base===undefined){base = 10}\n else if(!isinstance(base, int)){\n throw TypeError(\"'\"+$B.get_class(base).__name__+\"' object cannot be interpreted as an integer\")\n }\n if(base<0 || base==1 || base>36){\n throw ValueError(\"LongInt() base must be >= 2 and <= 36\")\n }\n if(isinstance(value, float)){\n if(value>=0){value=Math.round(value.value)}\n else{value=Math.ceil(value.value)}\n }\n if(typeof value=='number'){\n if(isSafeInteger(value)){value = value.toString()}\n else{throw ValueError(\"argument of long_int is not a safe integer\")}\n }else if(typeof value!='string'){\n throw ValueError(\"argument of long_int must be a string, not \"+\n $B.get_class(value).__name__)\n }\n var has_prefix = false, pos = true, start = 0\n // Strip leading and trailing whitespaces\n while(value.charAt(0)==' ' && value.length){value = value.substr(1)}\n while(value.charAt(value.length-1)==' ' && value.length){\n value = value.substr(0, value.length-1)\n }\n // Check if string starts with + or -\n if(value.charAt(0)=='+'){has_prefix=true}\n else if(value.charAt(0)=='-'){has_prefix=true;pos=false}\n if(has_prefix){\n // Remove prefix\n if(value.length==1){\n // \"+\" or \"-\" alone are not valid arguments\n throw ValueError('LongInt argument is not a valid number: \"'+value+'\"')\n }else{value=value.substr(1)}\n }\n // Ignore leading zeros\n while(start<value.length-1 && value.charAt(start)=='0'){start++}\n value = value.substr(start)\n\n // Check if all characters in value are valid in the base\n var is_digits = digits(base), point = -1\n for(var i=0;i<value.length;i++){\n if(value.charAt(i)=='.' && point==-1){point=i}\n else if(!is_digits[value.charAt(i)]){\n throw ValueError('LongInt argument is not a valid number: \"'+value+'\"')\n }\n }\n if(point!=-1){value=value.substr(0,point)}\n if(base!=10){\n // Conversion to base 10\n var coef = '1', v10 = LongInt(0),\n pos = value.length, digit_base10\n while(pos--){\n digit_base10 = parseInt(value.charAt(pos), base).toString()\n digit_by_coef = mul_pos(coef, digit_base10).value\n v10 = add_pos(v10.value, digit_by_coef)\n coef = mul_pos(coef, base.toString()).value\n }\n return v10\n }\n return {__class__:$LongIntDict, value:value, pos:pos}\n}\n\nLongInt.__class__ = $B.$factory\nLongInt.$dict = $LongIntDict\n$LongIntDict.$factory = LongInt\n\nreturn {LongInt:LongInt}\n\n})(__BRYTHON__)\n"], "math": [".js", "var $module=(function($B){\n\nvar _b_ = $B.builtins\nvar $s=[]\nfor(var $b in _b_) $s.push('var ' + $b +'=_b_[\"'+$b+'\"]')\neval($s.join(';'))\n\n//for(var $py_builtin in _b_){eval(\"var \"+$py_builtin+\"=_b_[$py_builtin]\")}\n\nvar float_check=function(x) {\n if (x.__class__===$B.LongInt.$dict){return parseInt(x.value)}\n return _b_.float(x)\n}\n\nvar isWholeNumber=function(x){return (x*10) % 10 == 0}\n\nvar isOdd=function(x) {return isWholeNumber(x) && 2*Math.floor(x/2) != x}\n\nvar isLargeNumber=function(x) {return x > Math.pow(2,32)}\n\n// Big number Library from jsfromhell.com\n// This library helps with producing \"correct\" results from \n// mathematic operations\n\n//+ Jonas Raoni Soares Silva\n//@ http://jsfromhell.com/classes/bignumber [rev. #4]\n\n\nvar BigNumber = function(n, p, r){\n var o = this, i;\n if(n instanceof BigNumber){\n for(i in {precision: 0, roundType: 0, _s: 0, _f: 0}) o[i] = n[i];\n o._d = n._d.slice();\n return;\n }\n o.precision = isNaN(p = Math.abs(p)) ? BigNumber.defaultPrecision : p;\n o.roundType = isNaN(r = Math.abs(r)) ? BigNumber.defaultRoundType : r;\n o._s = (n += \"\").charAt(0) == \"-\";\n o._f = ((n = n.replace(/[^\\d.]/g, \"\").split(\".\", 2))[0] = n[0].replace(/^0+/, \"\") || \"0\").length;\n for(i = (n = o._d = (n.join(\"\") || \"0\").split(\"\")).length; i; n[--i] = +n[i]);\n o.round();\n};\nwith({$: BigNumber, o: BigNumber.prototype}){\n $.ROUND_HALF_EVEN = ($.ROUND_HALF_DOWN = ($.ROUND_HALF_UP = ($.ROUND_FLOOR = ($.ROUND_CEIL = ($.ROUND_DOWN = ($.ROUND_UP = 0) + 1) + 1) + 1) + 1) + 1) + 1;\n $.defaultPrecision = 40;\n $.defaultRoundType = $.ROUND_HALF_UP;\n o.add = function(n){\n if(this._s != (n = new BigNumber(n))._s)\n return n._s ^= 1, this.subtract(n);\n var o = new BigNumber(this), a = o._d, b = n._d, la = o._f,\n lb = n._f, n = Math.max(la, lb), i, r;\n la != lb && ((lb = la - lb) > 0 ? o._zeroes(b, lb, 1) : o._zeroes(a, -lb, 1));\n i = (la = a.length) == (lb = b.length) ? a.length : ((lb = la - lb) > 0 ? o._zeroes(b, lb) : o._zeroes(a, -lb)).length;\n for(r = 0; i; r = (a[--i] = a[i] + b[i] + r) / 10 >>> 0, a[i] %= 10);\n return r && ++n && a.unshift(r), o._f = n, o.round();\n };\n o.subtract = function(n){\n if(this._s != (n = new BigNumber(n))._s)\n return n._s ^= 1, this.add(n);\n var o = new BigNumber(this), c = o.abs().compare(n.abs()) + 1, a = c ? o : n, b = c ? n : o, la = a._f, lb = b._f, d = la, i, j;\n a = a._d, b = b._d, la != lb && ((lb = la - lb) > 0 ? o._zeroes(b, lb, 1) : o._zeroes(a, -lb, 1));\n for(i = (la = a.length) == (lb = b.length) ? a.length : ((lb = la - lb) > 0 ? o._zeroes(b, lb) : o._zeroes(a, -lb)).length; i;){\n if(a[--i] < b[i]){\n for(j = i; j && !a[--j]; a[j] = 9);\n --a[j], a[i] += 10;\n }\n b[i] = a[i] - b[i];\n }\n return c || (o._s ^= 1), o._f = d, o._d = b, o.round();\n };\n o.multiply = function(n){\n var o = new BigNumber(this), r = o._d.length >= (n = new BigNumber(n))._d.length, a = (r ? o : n)._d,\n b = (r ? n : o)._d, la = a.length, lb = b.length, x = new BigNumber, i, j, s;\n for(i = lb; i; r && s.unshift(r), x.set(x.add(new BigNumber(s.join(\"\")))))\n for(s = (new Array(lb - --i)).join(\"0\").split(\"\"), r = 0, j = la; j; r += a[--j] * b[i], s.unshift(r % 10), r = (r / 10) >>> 0);\n return o._s = o._s != n._s, o._f = ((r = la + lb - o._f - n._f) >= (j = (o._d = x._d).length) ? this._zeroes(o._d, r - j + 1, 1).length : j) - r, o.round();\n };\n o.divide = function(n){\n if((n = new BigNumber(n)) == \"0\")\n throw new Error(\"Division by 0\");\n else if(this == \"0\")\n return new BigNumber;\n var o = new BigNumber(this), a = o._d, b = n._d, la = a.length - o._f,\n lb = b.length - n._f, r = new BigNumber, i = 0, j, s, l, f = 1, c = 0, e = 0;\n r._s = o._s != n._s, r.precision = Math.max(o.precision, n.precision),\n r._f = +r._d.pop(), la != lb && o._zeroes(la > lb ? b : a, Math.abs(la - lb));\n n._f = b.length, b = n, b._s = false, b = b.round();\n for(n = new BigNumber; a[0] == \"0\"; a.shift());\n out:\n do{\n for(l = c = 0, n == \"0\" && (n._d = [], n._f = 0); i < a.length && n.compare(b) == -1; ++i){\n (l = i + 1 == a.length, (!f && ++c > 1 || (e = l && n == \"0\" && a[i] == \"0\")))\n && (r._f == r._d.length && ++r._f, r._d.push(0));\n (a[i] == \"0\" && n == \"0\") || (n._d.push(a[i]), ++n._f);\n if(e)\n break out;\n if((l && n.compare(b) == -1 && (r._f == r._d.length && ++r._f, 1)) || (l = 0))\n while(r._d.push(0), n._d.push(0), ++n._f, n.compare(b) == -1);\n }\n if(f = 0, n.compare(b) == -1 && !(l = 0))\n while(l ? r._d.push(0) : l = 1, n._d.push(0), ++n._f, n.compare(b) == -1);\n for(s = new BigNumber, j = 0; n.compare(y = s.add(b)) + 1 && ++j; s.set(y));\n n.set(n.subtract(s)), !l && r._f == r._d.length && ++r._f, r._d.push(j);\n }\n while((i < a.length || n != \"0\") && (r._d.length - r._f) <= r.precision);\n return r.round();\n };\n o.mod = function(n){\n return this.subtract(this.divide(n).intPart().multiply(n));\n };\n o.pow = function(n){\n var o = new BigNumber(this), i;\n if((n = (new BigNumber(n)).intPart()) == 0) return o.set(1);\n for(i = Math.abs(n); --i; o.set(o.multiply(this)));\n return n < 0 ? o.set((new BigNumber(1)).divide(o)) : o;\n };\n o.set = function(n){\n return this.constructor(n), this;\n };\n o.compare = function(n){\n var a = this, la = this._f, b = new BigNumber(n), lb = b._f, r = [-1, 1], i, l;\n if(a._s != b._s)\n return a._s ? -1 : 1;\n if(la != lb)\n return r[(la > lb) ^ a._s];\n for(la = (a = a._d).length, lb = (b = b._d).length, i = -1, l = Math.min(la, lb); ++i < l;)\n if(a[i] != b[i])\n return r[(a[i] > b[i]) ^ a._s];\n return la != lb ? r[(la > lb) ^ a._s] : 0;\n };\n o.negate = function(){\n var n = new BigNumber(this); return n._s ^= 1, n;\n };\n o.abs = function(){\n var n = new BigNumber(this); return n._s = 0, n;\n };\n o.intPart = function(){\n return new BigNumber((this._s ? \"-\" : \"\") + (this._d.slice(0, this._f).join(\"\") || \"0\"));\n };\n o.valueOf = o.toString = function(){\n var o = this;\n return (o._s ? \"-\" : \"\") + (o._d.slice(0, o._f).join(\"\") || \"0\") + (o._f != o._d.length ? \".\" + o._d.slice(o._f).join(\"\") : \"\");\n };\n o._zeroes = function(n, l, t){\n var s = [\"push\", \"unshift\"][t || 0];\n for(++l; --l; n[s](0));\n return n;\n };\n o.round = function(){\n if(\"_rounding\" in this) return this;\n var $ = BigNumber, r = this.roundType, b = this._d, d, p, n, x;\n for(this._rounding = true; this._f > 1 && !b[0]; --this._f, b.shift());\n for(d = this._f, p = this.precision + d, n = b[p]; b.length > d && !b[b.length -1]; b.pop());\n x = (this._s ? \"-\" : \"\") + (p - d ? \"0.\" + this._zeroes([], p - d - 1).join(\"\") : \"\") + 1;\n if(b.length > p){\n n && (r == $.DOWN ? false : r == $.UP ? true : r == $.CEIL ? !this._s\n : r == $.FLOOR ? this._s : r == $.HALF_UP ? n >= 5 : r == $.HALF_DOWN ? n > 5\n : r == $.HALF_EVEN ? n >= 5 && b[p - 1] & 1 : false) && this.add(x);\n b.splice(p, b.length - p);\n }\n return delete this._rounding, this;\n };\n}\n\nvar isNegZero=function(x) {return x===0 && Math.atan2(x,x) < 0}\n\nvar _mod = {\n __getattr__ : function(attr){\n var res = this[attr]\n if(res===undefined){$raise('AttributeError','module math has no attribute '+attr)}\n return res\n },\n acos: function(x) {return float(Math.acos(float_check(x)))},\n acosh: function(x) { \n if (_b_.$isinf(x)) return float('inf');\n var y = float_check(x);\n return float(Math.log(y + Math.sqrt(y*y-1)));\n },\n asin: function(x) {return float(Math.asin(float_check(x)))},\n asinh: function(x) {\n if (_b_.$isninf(x)) return float('-inf');\n if (_b_.$isinf(x)) return float('inf');\n var y = float_check(x);\n return float(Math.log(y + Math.sqrt(y*y+1)))\n },\n atan: function(x) {\n if (_b_.$isninf(x)) return float(-Math.PI/2);\n if (_b_.$isinf(x)) return float(Math.PI/2);\n return float(Math.atan(float_check(x)))},\n atan2: function(y,x) {\n return float(Math.atan2(float_check(y),float_check(x)))\n },\n atanh: function(x) { \n var y=float_check(x);\n if (y==0) return 0;\n return float(0.5 * Math.log((1/y+1)/(1/y-1)));\n },\n ceil: function(x) {\n try{return getattr(x,'__ceil__')()}catch(err){}\n\n if (_b_.$isninf(x)) return float('-inf')\n if (_b_.$isinf(x)) return float('inf')\n if (isNaN(x)) return float('nan')\n\n var y=float_check(x);\n if (!isNaN(parseFloat(y)) && isFinite(y)) return int(Math.ceil(y));\n \n $raise('ValueError', 'object is not a number and does not contain __ceil__')\n },\n copysign: function(x,y) {\n var x1=Math.abs(float_check(x))\n var y1=float_check(y)\n var sign=y1?y1<0?-1:1:1\n if (isNegZero(y1)) sign=-1 // probably need to work on adding a check for -0\n return float(x1 * sign)\n },\n cos : function(x){return float(Math.cos(float_check(x)))},\n cosh: function(x){\n if (_b_.$isinf(x)) return float('inf')\n var y = float_check(x)\n if (Math.cosh !== undefined) return float(Math.cosh(y))\n return float((Math.pow(Math.E,y) + Math.pow(Math.E,-y))/2)\n },\n degrees: function(x){return float(float_check(x) * 180/Math.PI)},\n e: float(Math.E),\n erf: function(x) {\n // inspired from \n // http://stackoverflow.com/questions/457408/is-there-an-easily-available-implementation-of-erf-for-python\n var y =float_check(x);\n var t = 1.0 / (1.0 + 0.5 * Math.abs(y))\n var ans = 1 - t * Math.exp( -y*y - 1.26551223 +\n t * ( 1.00002368 +\n t * ( 0.37409196 + \n t * ( 0.09678418 + \n t * (-0.18628806 + \n t * ( 0.27886807 + \n t * (-1.13520398 + \n t * ( 1.48851587 + \n t * (-0.82215223 + \n t * 0.17087277)))))))))\n if (y >= 0.0) return ans\n\n return -ans\n },\n\n erfc: function(x) {\n // inspired from \n // http://stackoverflow.com/questions/457408/is-there-an-easily-available-implementation-of-erf-for-python\n var y = float_check(x);\n var t = 1.0 / (1.0 + 0.5 * Math.abs(y))\n var ans = 1 - t * Math.exp( -y*y - 1.26551223 +\n t * ( 1.00002368 +\n t * ( 0.37409196 + \n t * ( 0.09678418 + \n t * (-0.18628806 + \n t * ( 0.27886807 + \n t * (-1.13520398 + \n t * ( 1.48851587 + \n t * (-0.82215223 + \n t * 0.17087277)))))))))\n if (y >= 0.0) return 1-ans\n return 1+ans\n },\n exp: function(x){\n if (_b_.$isninf(x)) {return float(0)}\n if (_b_.$isinf(x)) {return float('inf')}\n var _r=Math.exp(float_check(x))\n if (_b_.$isinf(_r)) {throw OverflowError(\"math range error\")}\n return float(_r)\n },\n expm1: function(x){return float(Math.exp(float_check(x))-1)},\n //fabs: function(x){ return x>0?float(x):float(-x)},\n fabs: function(x){return _b_.$fabs(x)}, //located in py_float.js\n factorial: function(x) {\n //using code from http://stackoverflow.com/questions/3959211/fast-factorial-function-in-javascript\n var y=float_check(x);\n var r=1\n for (var i=2; i<=y; i++){r*=i}\n return r\n },\n floor:function(x){return Math.floor(float_check(x))},\n fmod:function(x,y){return float(float_check(x)%float_check(y))},\n frexp: function(x){var _l=_b_.$frexp(x);return _b_.tuple([float(_l[0]), _l[1]])}, // located in py_float.js\n fsum:function(x){\n /* Translation into Javascript of the function msum in an Active\n State Cookbook recipe : https://code.activestate.com/recipes/393090/\n by Raymond Hettinger\n */\n var partials = [],\n res = new Number(), \n _it = _b_.iter(x)\n while(true){\n try{\n var x = _b_.next(_it),\n i = 0\n for(var j=0, len=partials.length;j<len;j++){\n var y = partials[j]\n if(Math.abs(x) < Math.abs(y)){\n var z = x\n x = y\n y = z\n }\n var hi = x + y,\n lo = y - (hi - x)\n if(lo){\n partials[i] = lo\n i++\n }\n x = hi\n }\n partials = partials.slice(0, i).concat([x])\n }catch(err){\n if(_b_.isinstance(err, _b_.StopIteration)){break}\n throw err\n }\n }\n var res = new Number(0)\n for(var i=0; i<partials.length;i++){res += new Number(partials[i])}\n return new Number(res)\n },\n gamma: function(x){\n //using code from http://stackoverflow.com/questions/3959211/fast-factorial-function-in-javascript\n // Lanczos Approximation of the Gamma Function\n // As described in Numerical Recipes in C (2nd ed. Cambridge University Press, 1992)\n var y=float_check(x);\n var z = y + 1;\n var d1 = Math.sqrt(2 * Math.PI) / z;\n\n var d2 = 1.000000000190015;\n d2 += 76.18009172947146 / (z+1);\n d2 += -86.50532032941677 / (z+2);\n d2 += 24.01409824083091 / (z+3); \n d2 += -1.231739572450155 / (z+4); \n d2 += 1.208650973866179E-3 / (z+5);\n d2 += -5.395239384953E-6 / (z+6);\n\n return d1 * d2 * Math.pow(z+5.5,z+0.5) * Math.exp(-(z+5.5));\n },\n hypot: function(x,y){\n if (_b_.$isinf(x) || _b_.$isinf(y)) return float('inf')\n var x1=float_check(x);\n var y1=float_check(y);\n return float(Math.sqrt(x1*x1 + y1*y1))},\n inf: float('inf'),\n isclose:function(){\n var $ns = $B.args(\"isclose\",\n 4,\n {a:null,b:null,rel_tol:null,abs_tol:null},\n ['a', 'b', 'rel_tol', 'abs_tol'],\n arguments,\n {rel_tol:1e-09, abs_tol:0.0}, \n null, \n null)\n var a = $ns['a'];\n var b = $ns['b'];\n var rel_tol = $ns['rel_tol'];\n var abs_tol = $ns['abs_tol'];\n if (rel_tol < 0.0 || abs_tol < 0.0) throw ValueError('tolerances must be non-negative')\n if (a == b){return True}\n if (_b_.$isinf(a) || _b_.$isinf(b)){return false}\n var diff = _b_.$fabs(b - a);\n var result = ((diff <= _b_.$fabs(rel_tol * b)) || (diff <= _b_.$fabs(rel_tol * a))) || (diff <= _b_.$fabs(abs_tol));\n return result},\n isfinite:function(x) {return isFinite(float_check(x))},\n isinf:function(x) {return _b_.$isinf(float_check(x))},\n isnan:function(x) {return isNaN(float_check(x))},\n ldexp:function(x,i) {return _b_.$ldexp(x,i)}, //located in py_float.js\n lgamma:function(x) {\n // see gamma function for sources\n var y=float_check(x);\n var z = y + 1;\n var d1 = Math.sqrt(2 * Math.PI) / z;\n\n var d2 = 1.000000000190015;\n d2 += 76.18009172947146 / (z+1);\n d2 += -86.50532032941677 / (z+2);\n d2 += 24.01409824083091 / (z+3); \n d2 += -1.231739572450155 / (z+4); \n d2 += 1.208650973866179E-3 / (z+5);\n d2 += -5.395239384953E-6 / (z+6);\n\n return float(Math.log(Math.abs(d1 * d2 * Math.pow(z+5.5,z+0.5) * Math.exp(-(z+5.5)))));\n },\n log: function(x, base) {\n var x1=float_check(x);\n if (base === undefined) return float(Math.log(x1));\n return float(Math.log(x1)/Math.log(float_check(base)));\n },\n log1p: function(x) {return float(Math.log(1.0 + float_check(x)))},\n log2: function(x) {\n if (isNaN(x)) return float('nan')\n if (_b_.$isninf(x)) throw ValueError('')\n var x1=float_check(x)\n if (x1 < 0.0) throw ValueError('')\n //if (isLargeNumber(x1)) x1=new BigNumber(x1) \n return float(Math.log(x1)/Math.LN2)\n },\n log10: function(x) {return float(Math.log(float_check(x))/Math.LN10)},\n modf:function(x) {\n if (_b_.$isninf(x)) return _b_.tuple([0.0, float('-inf')])\n if (_b_.$isinf(x)) return _b_.tuple([0.0, float('inf')])\n if (isNaN(x)) return _b_.tuple([float('nan'), float('nan')])\n\n var x1=float_check(x);\n if (x1 > 0) {\n var i=float(x1-Math.floor(x1))\n return _b_.tuple([i, float(x1-i)])\n }\n\n var x2=Math.ceil(x1)\n var i=float(x1-x2)\n return _b_.tuple([i, float(x2)])\n },\n nan: float('nan'),\n pi : float(Math.PI),\n pow: function(x,y) {\n var x1=float_check(x)\n var y1=float_check(y)\n if (y1 == 0) return float(1) \n if (x1 == 0 && y1 < 0) throw _b_.ValueError('')\n\n if(isNaN(y1)) {if(x1==1) return float(1) \n return float('nan')\n }\n if (x1 == 0) return float(0)\n\n if(_b_.$isninf(y)) {if(x1==1||x1==-1) {return float(1)}\n if(x1 < 1 && x1 > -1) return float('inf') \n return float(0)\n }\n if(_b_.$isinf(y)) {if(x1==1||x1==-1) {return float(1)} \n if(x1 < 1 && x1 > -1) return float(0) \n return float('inf')}\n\n if(isNaN(x1)) return float('nan')\n if(_b_.$isninf(x)) {\n if (y1 > 0 && isOdd(y1)) return float('-inf')\n if (y1 > 0) return float('inf') // this is even or a float\n if (y1 < 0) return float(0)\n return float(1)\n }\n\n if(_b_.$isinf(x)) { \n if (y1 > 0) return float('inf')\n if (y1 < 0) return float(0)\n return float(1)\n }\n\n var r\n if (isLargeNumber(x1) || isLargeNumber(y1)) {\n var x=new BigNumber(x1)\n var y=new BigNumber(y1)\n r=x.pow(y)\n } else {\n r=Math.pow(x1,y1)\n }\n\n if (isNaN(r)) return float('nan')\n if (_b_.$isninf(r)) return float('-inf')\n if (_b_.$isinf(r)) return float('inf')\n\n return r\n },\n radians: function(x){return float(float_check(x) * Math.PI/180)},\n sin : function(x){return float(Math.sin(float_check(x)))},\n sinh: function(x) { \n //if (_b_.$isinf(x)) return float('inf');\n var y = float_check(x)\n if (Math.sinh !== undefined) { return float(Math.sinh(y))}\n return float((Math.pow(Math.E,y) - Math.pow(Math.E,-y))/2)\n },\n sqrt : function(x){\n var y = float_check(x)\n if (y < 0) { throw ValueError(\"math range error\")}\n if (_b_.$isinf(y)) return float('inf')\n var _r=Math.sqrt(y)\n if (_b_.$isinf(_r)) {throw OverflowError(\"math range error\")}\n return float(_r)\n },\n tan: function(x) {\n var y = float_check(x)\n return float(Math.tan(y))\n },\n tanh: function(x) {\n var y = float_check(x)\n if (Math.tanh !== undefined) return float(Math.tanh(y))\n return float((Math.pow(Math.E,y) - Math.pow(Math.E,-y))/\n (Math.pow(Math.E,y) + Math.pow(Math.E,-y))) \n },\n trunc: function(x) {\n try{return getattr(x,'__trunc__')()}catch(err){}\n var x1=float_check(x);\n if (!isNaN(parseFloat(x1)) && isFinite(x1)) {\n if (Math.trunc !== undefined) { return int(Math.trunc(x1))}\n if (x1 > 0) {return int(Math.floor(x1))}\n return int(Math.ceil(x1)) // x1 < 0\n }\n $raise('ValueError', 'object is not a number and does not contain __trunc__')\n }\n}\n\nfor(var $attr in _mod){\n if(typeof _mod[$attr]==='function'){\n _mod[$attr].__repr__=(function(func){\n return function(){return '<built-in function '+func+'>'}})($attr)\n _mod[$attr].__str__=(function(func){\n return function(){return '<built-in function '+func+'>'}})($attr)\n }\n}\n\nreturn _mod\n\n})(