Skip to content

Instantly share code, notes, and snippets.

@skipme
Created January 21, 2016 07:45
Show Gist options
  • Save skipme/c5fd79f545960a591e54 to your computer and use it in GitHub Desktop.
Save skipme/c5fd79f545960a591e54 to your computer and use it in GitHub Desktop.
function toxy(num){
var strxy="x";
for(var i=0;i<num;i++){
strxy+="y";
}
strxy+="z";
return strxy;
}
function printxytonum(strxy)
{
var result = "";
var cur = [0];
var curidx = 0;
for(var i = 0;i<strxy.length;i++)
{
if(strxy[i] === 'x')// event a
cur[0]=0;
else if(strxy[i] === 'y')// event b
{
for(var i = 0;true;i++)
{
if(cur[i]<9)
{
cur[i]++;
break;
}else{
cur[i]=1;
break;
}
}
}
}
for(var i = cur.length-1;i>=0;i--){
result += cur[i].toString();
}
return result;
}
var xystr = toxy(92);
console.log(xystr, '\n',printxytonum(xystr));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment