/* Utility Functions */ /* Many of these functions maybe poorly written/implemented as they were originally meant for one challenge and I was too lazy to rewrite them properly. :) This is a poor copy of saelo's Int64 library which can be found here - https://github.com/saelo/jscpwn/blob/master/utils.js */ String.prototype.rjust = function rjust(n,chr){ chr = chr || '0' if(this.length>n) return this.toString(); return (chr.repeat(n)+this.toString()).slice(-1*n); } String.prototype.ljust = function ljust(n,chr){ chr = chr || '0' if(this.length>n) return this.toString(); return (this.toString()+chr.repeat(n)).slice(0,n); } String.prototype.hexdecode = function hexdecode(){ inp=this.toString(); if (this.length%2 !=0) inp='0'+inp.toString(); out=[]; for(var i=0;i=0;i--){ diff=inp1[i]-inp2[i]-carry; carry=diff<0|0; inp1[i]=diff; } return inp1; } function add(inp1,inp2){ carry=0; for(var i=inp1.length-1;i>=0;i--){ sum=inp1[i]+inp2[i]+carry; carry=sum/0x100; inp1[i]=(sum%0x100); } return inp1; } /* Utility functions end */