v1
- by cmdcolin 3/14/202200
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
function getCigar() {
	
  let s =''
  const ops = 'MID'
  for(let i = 0; i < 10; i++) {
 	const len = Math.floor(Math.random()*100)
	const op = ops[Math.floor(Math.random()*3)]
	s+=len+op
  }
  return s
}
delete caserun single casemove downdrag and drop case


ready




const s = getCigar()
const ops = s.split(/([MIDNSHPX=])/)
let lenOnRef=0
for(let i = 0; i < ops.length; i+=2) {
	const len = +ops[i]
	const op = ops[i+1]
	
	if(op==='D'||op==='M') {
	  lenOnRef+=len
	}
}
delete caserun single casemove upmove downdrag and drop case


ready




const s = getCigar()
let currLen=''
let lenOnRef=0
for(let i = 0; i < s.length; i++) {
	const d = s.codePointAt(i)
	if(d>48&&d<57) {
		currLen+=d
	}
	else {
		len = +currLen
		op = s[i]
	    if(op==='D'||op==='M') {
	      lenOnRef+=+len
	      
	    }
	    currLen=''	
	}
}
delete caserun single casemove updrag and drop case


ready




const s = getCigar()
let currLen=''
let lenOnRef=0
for(let i = 0; i < s.length; i++) {
	const d = s[i]
	if(d>="0"&&d<="9") {
		currLen+=d
	}
	else {
		len = +currLen
		op = d
	    if(op==='D'||op==='M') {
	      lenOnRef+=+len
	      
	    }
	    currLen=''	
	}
}
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN