text: function LinkedList(t,i,e){return this.payload=t||1,this.next=i||{payload:1,next:null},this.next.show=function(){return this.name+":"+this.next.payload+"->"},this.name=e,this.show=function(){return this.name+":"+this.payload+"->"+this.next.show()},this.toString=function(){return"LinkedList("+this.show()+")"},this}function Node(t,i,e){return this.payload=t||1,this.next=i,this.prev=e,this.traverse=function(){this.next&&this.next.traverse(),Essence.say("payload: "+this.payload)},this.print=function(){null!=this.next&&this.next.print(),Essence.print(this.payload+"=>")},this.printList=function(){null===this.next?Essence.txt2print+="->"+this.payload:this.next.printList(),Essence.print("")},this.last=function(){return null===this.next?this:this.next.last()},this.append=function(t){null===this.next?(this.next=new Node(t),this.next.prev=this):this.next.append(t)},this.remove=function(){var t=this.next
  this.next=t.next,t.next.prev=this},this.reverse=function(){if(null==this.next)return this
  var t=this.next.reverse()
  return t.next=this,t.prev=null,this.prev=t,this.next=null,t},this.toString=function(){return"Node(payload = "+this.payload+", previous = "+this.prev+", next = "+this.next+")"},this.equals=function(t){return this.payload===t.payload&&this.next.equals(t.next)&&this.prev.equals(t.prev)},this.find=function(t,i){return i||(i=0),this.payload===t?i:this.next?this.next.find(t,i+1):[-1,i]},this}function Vertex(t,i,e,n,r){return this.g=t||0,this.h=i||0,this.f=this.g+this.h||1,this.pos=e||[0,0],this.parent=null,this.payload=n||"",this.edges=r||[],this.back=function(t){return isNon(t)||t<=1?this.parent:this.parent.back(t-1)},this.isCloser=function(t){return this.f<=t.f},this.toString=function(){var t=this.edges.length>0?this.edges.map(function(t){try{return t.toString()}catch(t){return null}}):""
  return"Vertex(g="+this.g+", h="+this.h+", f="+this.f+", pos=["+this.pos.toStr(!0)+"], payload="+this.payload+", edges=["+t+"], parent="+(null===this.parent?null:this.parent.toString())+")"},this.join=function(t){for(var i=0;i<t.length;i++)isType(this.edges[i],"Edge")?(this.edges[i].startNode=this,this.edges[i].endNode=t[i]):this.edges[i]=new Edge(this,t[i]),t[i].edges.push(this.edges[i]),t[i].edges.last().startNode=this,t[i].edges.last().endNode=t[i]},this.getVertexInEdge=function(t){var i=this.edges[t||0]
  return i.startNode.equals(this)?i.endNode:i.startNode},this.getConnectedVertices=function(){for(var t=[],i=0;i<this.edges.length;i++)t.push(this.getVertexInEdge(i))
  return t},this.find=function(t,i){if(i||(i=0),this.payload===t)return i
  var e=this.getConnectedVertices().map(function(e){try{return e.find(t,i+1)}catch(t){return[-1,i]}}),n=e.filter(function(t){return!isType(t,"Array")})
  return n.length>0?n:[-1,i]},this.getNetwork=function(){var t=this,i=function(e){var n=e.getConnectedVertices().remove([t,null],!0)
  return n.length>0?n.map(i):n}
  return this.getConnectedVertices().map(i)},this.size=function(){return this.getNetwork().linearise().length},this.distanceFrom=function(t){return euclidianDist(this.pos,t.pos)},this.getNearestVertex=function(){var t=this,i=this.edges.filter(function(i){return i.length===t.edges.map(function(t){return t.length}).min()})
  return i.startNode.equals(this)?i.endNode:i.startNode},this}function Edge(t,i,e){this.startNode=t||null,this.endNode=i||null,this.length=e||(isNon(t)||isNon(i)?0:euclidianDist(t.pos,i.pos)),this.line=new Line(t?t.pos:[0,0],i?i.pos:[0,0]),this.toString=function(){return"Edge(startNode="+this.startNode+", endNode="+this.endNode+", length="+this.length+")"},this.draw=function(){this.line.draw()},this.getSurroundingEdges=function(){var t=this.startNode?this.startNode.getNetwork():[]
  return t.append(this.endNode?this.endNode.getNetwork():[]),t.map(function(t){return t.edges}).linearise().remove(this,!0)},this.getNeighbours=function(){var t=this.startNode?this.startNode.getConnectedVertices():[]
  return t.append(this.endNode?this.endNode.getConnectedVertices():[]),t.map(function(t){return t.edges}).linearise().remove(this,!0)}}function TreeNode(t,i,e){return this.left=i,this.right=e,this.payload=t||0,this.add=function(t,i){this.left=t,this.right=i},this.addLeft=function(t){for(var i=0;i<t.length;i++)0===i?this.left=t[0]:t[i-1].left=t[i]},this.addRight=function(t){for(var i in t)t.hasOwnProperty(i)&&(0===i?this.right=t[0]:t[i-1].right=t[i])},this.traverse=function(){return this.left&&this.left.traverse(),this.right&&this.right.traverse(),this},this.printInOrder=function(){this.left&&this.left.printInOrder(),Essence.addToPrinter(this.payload+"->"),this.right&&this.right.printInOrder(),Essence.addToPrinter("\r\n")},this.printPreOrder=function(){Essence.addToPrinter(this.payload+"->"),this.left&&this.left.printPreOrder(),this.right&&this.right.printPreOrder(),Essence.addToPrinter("\r\n")},this.printPostOrder=function(){this.left&&this.left.printPreOrder(),this.right&&this.right.printPreOrder(),Essence.addToPrinter(this.payload+"->"),Essence.addToPrinter("\r\n")},this.inOrder=function(t,i,e,n){t||(t=""),i||(i="&nbsp;&nbsp;"),e||(e=0),n||(n="|-"),this.left&&this.left.inOrder(t+i,i,e+1,n),println(t+n+this.payload+i+" (depth="+e+")"),this.right&&this.right.inOrder(t+i,i,e+1,n)},this.preOrder=function(t,i,e,n){t||(t=""),i||(i="&nbsp;&nbsp;"),e||(e=0),n||(n="|-"),println(t+n+this.payload+i+" (depth="+e+")"),this.left&&this.left.preOrder(t+i,i,e+1,n),this.right&&this.right.preOrder(t+i,i,e+1,n)},this.postOrder=function(t,i,e,n){t||(t=""),i||(i="&nbsp;&nbsp;"),e||(e=0),n||(n="|-"),this.left&&this.left.postOrder(t+i,i,e+1,n),this.right&&this.right.postOrder(t+i,i,e+1,n),println(t+n+this.payload+i+" (depth="+e+")")},this.getInOrder=function(t){t||(t="->")
  var i=""
  return this.left&&(i+=this.left.getInOrder(t)),i+=t+this.payload,this.right&&(i+=this.right.getInOrder(t)),i},this.getPreOrder=function(t){t||(t="->")
  var i=""
  return i+=t+this.payload,this.left&&(i+=this.left.getPreOrder(t)),this.right&&(i+=this.right.getPreOrder(t)),i},this.getPostOrder=function(t){t||(t="->")
  var i=""
  return this.left&&(i+=this.left.getPostOrder(t)),this.right&&(i+=this.right.getPostOrder(t)),i+t+this.payload},this.isLeaf=function(){return!this.left&&!this.right},this.find=function(t,i){return"bfs"===i.normal()?this.bfs(t):this.dfs(t)},this.dfs=function(t){var i=0,e=0,n=[]
  for(n.push(this);!n.equals([]);){i=0
  var r=n.pop()
  try{if(r.payload===t)return[i,e]}catch(t){return[-1,e]}r.left&&n.push(r.left),r.right&&n.push(r.right),i++,e++}},this.bfs=function(t){var i=0,e=0,n=[]
  for(n.unshift(this);!n.equals([]);){i=0
  var r=n.pop()
  try{if(r.payload===t)return[i,e]}catch(t){return[-1,e]}r.left&&n.unshift(r.left),r.right&&n.unshift(r.right),i++,e++}},this.sum=function(){var t=this.payload
  return this.left&&(t+=this.left.sum()),this.right&&(t+=this.right.sum()),t},this.min=function(){var t=this.payload
  return this.left&&(t=Math.min(t,this.left.min())),this.right&&(t=Math.min(t,this.right.min())),t},this.max=function(){var t=this.payload
  return this.left&&(t=Math.max(t,this.left.max())),this.right&&(t=Math.max(t,this.right.max())),t},this.nbOfBranches=function(t){return t||(t=0),this.left&&(t=this.left.nbOfBranches(t+1)),this.right&&(t=this.right.nbOfBranches(t+1)),t},this.avg=function(){return this.sum()/this.nbOfBranches()},this.printBFS=function(t){t||(t="->")
  var i=[],e=""
  for(i.unshift(this);!i.equals([]);){var n=i.pop()
  e+=n+t
  try{n.left&&i.unshift(n.left),n.right&&i.unshift(n.right)}catch(i){Essence.say(i+" caused "+this+".printBFS("+t+") to go wrong","erro")}}return e},this.toString=function(){var t="TreeNode(payload = "+this.payload+", "
  return this.left&&(t+="left = "+this.left.toString()),this.right&&(t+="right = "+this.right.toString()),t.substring(0,t.length)+")"},this.toArray=function(t){var i=[]
  return this.left&&(t?i.push(this.left.toArray().toString().split(",")):i.push(this.left.toArray())),i.push(this.payload),this.right&&(t?i.push(this.right.toArray().toString().split(",")):i.push(this.right.toArray())),t?i.toString().split(","):i},this.count=function(t){return this.getInOrder().countWord(t,"->")},this}function NTreeNode(t,i){return this.payload=t||0,this.child=i||[],this.add=function(t){this.child.push(t)},this.remove=function(t){this.child.remove(t)},this.traverse=function(){for(var t in this.child)this.child.hasOwnProperty(t)&&t.traverse()
  return this},this.printInOrder=function(){for(var t=0;t<this.child-1;t++)this.child[t].printInOrder(),Essence.addToPrinter(this.payload+"->"),this.child[t+1].printInOrder(),Essence.addToPrinter("\r\n")
  Essence.addToPrinter("\b")},this.printPreOrder=function(){for(var t=0;t<this.child-1;t++)Essence.addToPrinter(this.payload+"->"),this.child[t].printInOrder(),this.child[t+1].printInOrder(),Essence.addToPrinter("\r\n")
  Essence.addToPrinter("\b")},this.printPostOrder=function(){for(var t=0;t<this.child-1;t++)this.child[t].printInOrder(),this.child[t+1].printInOrder(),Essence.addToPrinter(this.payload+"->"),Essence.addToPrinter("\r\n")
  Essence.addToPrinter("\b")},this.inOrder=function(t,i,e,n){t||(t=""),i||(i="&nbsp;&nbsp;"),e||(e=0),n||(n="|-")
  for(var r=0;r<this.child;r++)this.child[r].inOrder(t+i,i,e+1,n),println(t+n+this.payload+i+" (depth="+e+")"),this.child[r].inOrder(t+i,i,e+1,n)},this.preOrder=function(t,i,e,n){t||(t=""),i||(i="&nbsp;&nbsp;"),e||(e=0),n||(n="|-"),println(t+n+this.payload+i+" (depth="+e+")")
  for(var r=0;r<this.child-1;r++)console.log("this.child[i]=",this.child[r]),this.child[r].preOrder(t+i,i,e+1,n)},this.postOrder=function(t,i,e,n){t||(t=""),i||(i="&nbsp;&nbsp;"),e||(e=0),n||(n="|-")
  for(var r=0;r<this.child;r++)this.child[r].postOrder(t+i,i,e+1,n)
  println(t+n+this.payload+i+" (depth="+e+")")},this.getOrder=function(t){t||(t="->")
  var i=function(i){return i.isLeaf()?i.payload:i.payload+t+i.getOrder(t)}
  return this.payload+t+this.child.map(i).join(t)},this.isLeaf=function(){return 0===this.child.length},this.find=function(t,i){return i&&"bfs"===i.toLowerCase()?this.bfs(t):this.dfs(t)},this.dfs=function(t,i,e){i||(i=0),e||(e=0)
  for(var n in this.child)if(this.child.hasOwnProperty(n)){if(!isType(n,"NTreeNode"))throw new TypeError("The child '"+n+"' is not a NTreeNode")
  n.dfs(t,i+1,e++)}return[-1,e]},this.bfs=function(t,i,e){i||(i=0),e||(e=0)
  var n=[]
  for(n.unshift(this);!n.equals([]);){i=0
  var r=new NTreeNode(n.pop())
  if(r.payload===t)return[i,e]
  r.left&&n.unshift(r.left),r.right&&n.unshift(r.right),i++,e++}return[-1,e]},this.sum=function(){var t=this.payload
  for(var i in this.child)this.child.hasOwnProperty(i)&&(t+=i.payload)
  return t},this.min=function(){var t=this.payload
  for(var i in this.child)this.child.hasOwnProperty(i)&&(t=Math.min(t,i.payload))
  return t},this.max=function(){var t=this.payload
  for(var i in this.child)this.child.hasOwnProperty(i)&&(t=Math.max(t,i.payload))
  return t},this.nbOfBranches=function(t){t||(t=0)
  for(var i in this.child)this.child.hasOwnProperty(i)&&(t=i.nbOfBranches(t+1))
  return t},this.avg=function(){return this.sum()/this.nbOfBranches()},this.printBFS=function(t){for(var i=[this],e=t||"-";!i.isEmpty();){var n=new NTreeNode(i.pop())
  println(e+">"+n.payload),e+="-"
  for(var r in this.child)this.child.hasOwnProperty(r)&&i.unshift(r)}},this.toString=function(){var t="NTreeNode(payload="+this.payload+", child=["
  for(var i in this.child)this.child.hasOwnProperty(i)&&(t+=this.child[i].toString()+", ")
  return(t.substring(0,t.length)+"])").replace(", ]","]")},this.toArray=function(t){var i=[]
  i.push(this.payload)
  for(var e in this.child)this.child.hasOwnProperty(e)&&(t?i.push(e.toArray().toString().split(",")):i.push(e.toArray()))
  return t?i.toString().split(","):i},this.getChild=function(t){return this.child[t]},this.see=function(t,i){traverseTree(this,t),Buffer.show(i,!i,!0)
  var e=Buffer.log
  return Buffer.clear(),e},this.count=function(t){return this.getOrder().countWord(t,"->")},this}function traverseTree(t,i,e,n){n||(n=0),e||(e="|"),Buffer.add("  ".repeat(n)+e+(i||"--")+t.payload),n++
  for(var r=0;r<t.child.length;r++)traverseTree(t.getChild(r),i,e,n)
  return Buffer.log}function Set(t){return this.value=(isType(t,"Array")?rmDuplicates(t):[t])||[],this.size=function(){return this.value.length},this.add=function(t){if(isType(t,"Array"))for(var i=0;i<t.length;i++)this.add(t[i])
  this.value.indexOf(t)===-1&&this.value.push(t)},this.remove=function(t){if(this.value.has(t))if(isType(t,"Array"))for(var i=0;i<t.length;i++)this.remove()
  else this.value=this.value.remove()},this.clear=function(t){t?this.value=this.value.remove():this.value=[]},this.isEmpty=function(){return 0===this.value.length},this.contains=function(t){if(isType(t,"Array")){for(var i=!0,e=0;e<t.length;e++){if(!i)return!1
  i=i&&this.contains(t[e])}return i}return this.value.has(t)},this.equals=function(t){return this.value.toString()===t.value.toString()},this.isSame=function(t){if(this.equals(t))return!0
  for(var i=!0,e=0;e<t.size();e++){if(!i)return!1
  i=i&&this.contains(t.value[e])}return i},this.toString=function(){return"Set("+this.value.toString()+")"},this.subset=function(t,i){return this.value.slice(t,i+1)},this.get=function(t){return this.value[t]},this.indexOf=function(t){return this.value.indexOf(t)},this.set=function(t,i){this.value[t]=i},this.first=function(){return this.value[0]},this.last=function(){return this.value.last()},this.min=function(t,i){return this.value.min(t,i)},this.max=function(t,i){return this.value.max(t,i)},this.median=function(){return this.value.median()},this.forEach=function(t){for(var i=0;i<this.size();i++)t(this.get(i))},this}function SortedSet(t){return this.value=Copy(t).quickSort()||[],this.add=function(t){isType(t,"Array")?this.value.multiPlace(t):this.value.place(t),this.value=rmDuplicates(this.value)},this.toString=function(){return"SortedSet("+this.value.toString()+")"},this}function Stack(t,i){return this.value=isType(i,"Number")?new Array(i):[],this.limit=i||null,t&&this.value.push(t),this.peek=function(){return this.value.last()},this.ground=function(){return this.value[0]},this.push=function(t){if(this.isFull())throw new Error("Stack overflow !")
  isType(t,"Array")?this.value.append(t):this.value.push(t)},this.pop=function(){if(this.isEmpty())throw new Error("Stack underflow !")
  return this.value.pop()},this.isEmpty=function(){return 0===this.value.length},this.isFull=function(){return null!=this.limit&&this.value.length>=this.limit},this.size=function(){return this.value.length},this.toString=function(){return"Stack("+this.value.toString()+")"},this}function StackArray(t){return this.value=new Array(t),this.top=-1,this.peek=function(){return this.value[this.top]},this.ground=function(){return this.value[0]},this.push=function(t){if(this.isFull())throw new Error("Stack overflow !")
  if(isType(t,"Array"))for(var i=0;i<t.length;i++)this.push(t[i])
  else this.top++,this.value[this.top]=t},this.pop=function(t){if(this.isEmpty())throw new Error("Stack underflow !")
  if(!isType(t,"Array")){var i=this.peek()
  return this.top--,i}for(var e=0;e<t.length;e++)this.pop(t[e])},this.isEmpty=function(){return this.top<=-1},this.isFull=function(){return this.top>=this.value.length},this.size=function(){return this.top+1},this.toString=function(){return"Stack("+this.value.toString()+")"},this}function StackList(t){return this.top=null,this.ground=function(){return this.isEmpty()||null===this.top?null:null===this.top.next?this.top.payload:this.top.next.payload},this.peek=function(){return this.top.payload},this.push=function(t){if(isType(t,"Array"))for(var i=0;i<t.length;i++)this.push(t[i])
  else this.top=new Node(t,this.top)
  return this},t&&this.push(t),this.pop=function(t){if(!this.isEmpty())throw new Error("I can't pop from an empty stack list")
  if(!t){var i=this.top.payload
  return this.top=this.top.next,i}for(var e=0;e<t;e++)this.pop()},this.isEmpty=function(){return null==this.top},this.size=function(){for(var t=0,i=this.top;null!=i;)i=i.next,t++
  return t},this.toString=function(){var t="",i=this.top
  do t+=i.payload+"->",i=i.next
  while(null!=i)
  return"StackList("+t+")"},this}function Queue(t,i){return this.value=isType(i,"Number")?new Array(i):[],this.limit=i||null,t&&this.value.push(t),this.enqueue=function(t){if(this.isFull())throw new Error("Queue overflow !")
  isType(t,"Array")?this.value.prepend(t):this.value.unshift(t)},this.dequeue=function(){if(this.isEmpty())throw new Error("Queue underflow !")
  var t=this.head()
  return this.value.pop(),t},this.head=function(){return this.value.last()},this.tail=function(){return this.value[0]},this.isEmpty=function(){return 0===this.value.length},this.isFull=function(){return null!=this.limit&&this.value.length>=this.limit},this.size=function(){return this.value.length},this.toString=function(){return"Queue(head="+this.head()+", tail="+this.tail()+", value="+this.value.toString()+")"},this}function QueueArray(t){return this.value=t||[],this.front=-1,this.back=-1,this.enqueue=function(t){if(isType(t,"Array"))for(var i=0;i<t.length;i++)this.enqueue(t[i])
  else{if(this.isFull())throw new Error("The queue is full")
  this.isEmpty()?(this.front++,this.back++,this.value[this.back]=t):(this.back=(this.back+1)%this.value.length,this.value[this.back]=t)}},this.dequeue=function(){var t
  if(this.isEmpty())throw new Error("I can't dequeue from an empty queue")
  return this.front===this.back?(t=this.value[this.front],this.front=this.back=-1):(t=this.value[this.front],this.front=(this.front+1)%this.value.length),t},this.isEmpty=function(){return this.front===-1&&this.back===-1},this.isFull=function(){return this.back>(this.front+1)%this.value.length},this.size=function(){return this.value.length},this.toString=function(){return"Queue(front="+this.front+", back="+this.back+", value="+this.value.toString()+")"},this}function QueueList(){return this.front=new Node(null),this.back=new Node(null),this.len=0,this.enqueue=function(t){if(isType(t,"Array"))for(var i=0;i<t.length;i++)this.enqueue(t[i])
  else{var e=null!=this.back?new Node(t,this.back,null):new Node(t)
  this.back.prev=e,this.back=e,this.len++}return this},this.dequeue=function(){if(this.isEmpty())throw new Error("I can't dequeue an empty queue list")
  return this.front=this.front.prev,this.len--,this.front},this.isEmpty=function(){return 0===this.len||null===this.back},this.size=function(){return this.len},this.toString=function(){for(var t="",i=this.front;null!=i;)t+="<-"+i.payload,i=i.prev
  return t},this.remove=function(t){for(var i=this.front;null!=i;)null==i.payload||i.payload!=t&&!i.payload.equals(t)||(i=null),i=i.next},this.insertAt=function(t,i){this.back.next=new Node(i),0===t?this.front=new Node(i):t===this.len?this.back=new Node(i):t>this.len&&this.enqueue(i)},this}function Astar(t,i){for(var e,n,r=i,s=[t],a=[];s.length>0;){var o=[],u=s[0].f
  for(var l in s)s.hasOwnProperty(l)&&(o.push(s[l].f),u=Math.min(u,s[l].f))
  if(e=s.filter(function(t){if(t.f===u)return t})[0],s=s.filter(function(t){if(t.f!=u)return t}),e===r){for(var f in e)if(e.hasOwnProperty(f)){f.f=e.f+h(f,e)
  var c=lookfor(f,s)
  if(c!=-1){if(c=c[0],e.f<s[c]||lookfor(f,a)!=-1&&e.f<s[lookfor(f,a)][0].f)continue
  s=s.remove(),a=a.remove(),f.parent=e,n=h(f,r),s.push(f)}a.push(e)}throw"Solution found ! With h="+n}}}function A(t,i,e){if(!isCustomType(t,"Vertex")||!isCustomType(i,"Vertex"))throw new InvalidParamError("The boundary nodes needs to be Vertex objects !")
  var n,r=[],s=[t],h={},a={},o={}
  for(a[t]=0,t.f=euclidianDist(t.pos,i.pos),o[t]=euclidianDist(t.pos,i.pos);!s.isEmpty();){if(n=s.filter(function(t){return t.f===s.map(function(t){return t.f}).min()}),n.equals(i))return reconPath(h,n)
  s.remove(n),r.push(n)
  var u=lookfor(n,e),l=0
  e.neighbour(u[0],u[1]).map(function(t){l=n.g+manhattanDist(u,t.pos),s.has(t)||s.push(t),h[t]=n,t.g=a[t]=l,t.f=o[t]=t.g+euclidianDist(t.pos,i.pos)})}return null}function reconPath(t,i){for(var e=[i];i in keyList(t);)i=t[i],e.append(i)
  return e}function IDAstar(){}function alphabetSort(t){if(!t.isIterable())throw new TypeError("alphabetSort cannot sort non iterable objects")
  if(isType(t,"String"))return t.split("").quickSort().join("")
  for(var i=t.uniform(),e=!0,n=1;e;){e=!1
  for(var r=0;r<i.maxLength();r++){for(var s=0;s<i.length-n;s++)0==r&&i[s].charAt(r)>i[s+1].charAt(r)?(swap(i,s,s+1),e=!0):i[s].charAt(r-1)===i[s+1].charAt(r-1)&&i[s].charAt(r)>i[s+1].charAt(r)&&(swap(i,s,s+1),e=!0)
  n++}}return i.trimAll("rad")}function occurrenceSort(t){var i=t.map(function(i){return t.count(i)}),e=rmDuplicates(t),n=new Map(i),r=[]
  return e.map(function(i){n.add(t.count(i),i)}),n.forEach(function(t){r.prepend(t)},!0),r}function binarySearch(t,i){t.quickSort()
  for(var e=2,n=t[Math.floor(t.length/e)],r=0;n!=i&&e<t.length;){if(n===i)return!0
  e*=2,n=n<i?t[Math.floor(t.length/e)]:t[3*Math.floor(t.length/e)],debugging&&Essence.say("i="+e+"\nterm="+n+"\nloops="+r),r++}return n===i}function search(t,i){var e=0,n=t.length-1,r=Math.floor((n-e)/2)
  if(t[r]===i)return r
  for(;t[r]!=i;){if(n<e)return-1
  t[r]<i?e=r+1:n=r-1,r=Math.floor((n-e)/2)}}function Archive(t,i){return this.name=t||"Archive",this.data=i||"",this.dictionary=[],this.result=[],this.updateDict=function(){for(var t,e=[],n=alphabetSort(i),r=0;r<this.data.length-1;r++)n[r]!=n[r+1]&&e.push(n[r])
  for(e=rmDuplicates(e),t=new Array(e.length),n=[],r=0;r<e.length;r++)t[r]=i.count(e[r]),n[r]=e[r]+t[r]
  for(this.dictionary=occurrenceSort(this.data),r=0;r<this.dictionary.length;r++)this.result[r]=conv(r,10,2)},this.getResult=function(){this.updateDict()
  for(var t=this.data,i=0;i<this.data.length;i++)console.log(i+"// "+this.dictionary[this.dictionary.indexOf(this.data[i])]),t=t.replace(RegExpify(this.dictionary[this.dictionary.indexOf(this.data[i])]),this.result[i])
  return t},this}function virtualHistory(t){return this.src=t,this.DEFAULT_STATE=t,this.states=new Set(this.src),this.state=0,this.reset=function(){this.src=this.DEFAULT_STATE},this.update=function(t){this.src!=t&&this.add(t)},this.add=function(t){if(isType(t,"Array"))for(var i=0;i<t.length;i++)this.add(t[i])
  else this.src=t,this.states.add(this.src),this.state++},this.get=function(t){return this.states.get(t)},this.undo=function(){if(0===this.state)throw new Error("Set underflow, it's not possible to undo to a non-existent state.")
  this.state--,this.src=this.get(this.state)},this.redo=function(){if(this.state===this.states.size()-1)throw new Error("Set overflow, it's not possible to redo to a non-existent state.")
  this.state++,this.src=this.get(this.state)},this.getStates=function(){return this.states.toString()},this.isStateDefault=function(){return this.src===this.DEFAULT_STATE},this}function occurrenceList(t){if(!t.isIterable())throw new TypeError("It must be an iterable object !")
  for(var i=t.getOccurrences(!0),e=[],n=t.getOccurrences(),r={},s=0;s<n.length;s++)e[s]=n[s].split(":")[0]
  for(s=0;s<i.length;s++)r[e[s]]=i[s]
  return r}function Stream(initVal,formula,nbVals){if(this.start=initVal||0,this.formula=formula||"x + 1",this.data=[this.start],this.next=function(){this.data.push(eval(this.formula.multiReplace([[/x/g,this.data.last()],[/x0/g,this.start],[/pi/gi,Math.PI],[/e/gi,Math.E],[/sqrt(2)/gi,Math.SQRT2],[/(pow|max|min)\((.*?),(| )(.*?)\)/,"Math.$1($2, $3)"],[/(sqrt|cbrt|cos|sin|tan|acos|asin|cosh|sinh|tanh|acosh|asinh|atanh|exp|abs)\((.*?)\)/,"Math.$1($2)"],[/(ln|log|nthroot|clampTop|clampBottom)\((.*?),(| )(.*?)\)/,"$1($2, $3)"],[/(clamp)\((.*?),(?:| )(.*?),(?:| )(.*?)\)/,"$1($2, $3, $4)"]])))},nbVals)for(var i=1;i<nbVals;i++)this.next()
  return this.toString=function(){return"Stream(start="+this.start+", formula="+this.formula+", data="+this.data.toStr(!0)+")"},this}function MultiStream(initVal,formula,nbVals){if(this.start=initVal||0,this.formula=formula||"x + y",this.data=[this.start],this.results=[],this.next=function(){this.data.push(this.data.last().map(function(t){return t+1})),this.results.push(this.compute(this.data.last()))},this.compute=function(data){return eval(this.formula.multiReplace([[/x/g,data[0]],[/x0/g,this.start[0]],[/y/g,data[1]],[/y0/g,this.start[1]],[/z/g,data[2]],[/z0/g,this.start[2]],[/pi/gi,Math.PI],[/e/gi,Math.E],[/sqrt(2)/gi,Math.SQRT2],[/(pow|max|min)\((.*?),(| )(.*?)\)/,"Math.$1($2, $3)"],[/(sqrt|cbrt|cos|sin|tan|acos|asin|cosh|sinh|tanh|acosh|asinh|atanh|exp|abs|e\^)\((.*?)\)/,"Math.$1($2)"],[/(ln|log|nthroot|clampTop|clampBottom)\((.*?),(| )(.*?)\)/,"$1($2, $3)"],[/(clamp)\((.*?),(| )(.*?),(| )(.*?)\)/,"$1($2, $3, $4)"]]))},this.results=[this.compute(this.start)],nbVals>1)for(var i=1;i<nbVals;i++)this.next()
  return this.toString=function(){return"MultiStream(start="+this.start.toStr(!0)+", formula="+this.formula+", data="+this.data.toStr(!0)+", results="+this.results.toStr(!0)+")"},this}function Graph(t,i,e,n,r){this.labels=e||["x","y"],this.name=n||"Graph",this.dimension=i||new Array(this.labels.length).fill(50),this.equation=new Equation(t),this.data=r?range(0,r,this.dimension[0],Number(r).length()[1]):range(this.dimension[0])
  for(var s=0;s<this.data.length;s++)this.data[s]=[this.data[s],this.equation.compute({x:this.data[s]})]
  return this.toString=function(){return"Graph(name="+this.name+", labels="+this.labels.toStr(!0)+", dimension="+this.dimension+", this.equation="+this.equation.toString()+", data="+this.data+")"},this}function Perm(t){if(t.length<=1)return t
  if(2===t.length)return[t,Copy(t).reverse()]
  if(3===t.length)return Perm(t.get(1)).map(function(i){return t[0]+i}).append(Perm(t.get(-1)).map(function(i){return t.last()+i})).append(Perm(t.remove(t[1])).map(function(i){return t[1]+i}))
  for(var i=Perm(t.get(1)).map(function(i){return t[0]+i}),e=1;e<t.length;e++)i.append(Perm(t.remove()).map(function(i){return t[e]+i}))
  return rmDuplicates(i)}function Comb(t,i){for(var e=new Array(t*factorial(i.length)),n=Perm(i.join("")),r=i.lastIndex(),s=0;s<2*i.length&&!(s>r+1);s+=2)i.splice(s+1,i.binaryIndexOf(i[s]),i[s].repeat(t))
  return n.append(complement(i,n)),console.log(e.length,n,"\nset="+i),alphabetSort(n).filter(function(i){return i.length===t})}function EventTable(t,i){return this.name=t||"Event table",this.sources=i||[getFilename(!0)],this.table=[["Source","Event","Timestamp"]],this.add=function(t){this.table.push([t.source||getFilename(!0),t.event,t.timestamp||(new Date).getTime()]),this.sources.uniquePush(t.source||getFilename(!0))},this.make=function(t,i){var e=(new Date).getTime()
  i||(i=1)
  for(var n=0;n<(t||1e3);n+=i)this.add({timestamp:e+n})},this.fill=function(t,i){var e=(new Date).getTime(),n=lookfor(e,this.table)
  n===-1&&e>this.table.last()[2]?this.add({source:t,event:i,timestamp:e}):(this.table[n[0]][0]=t,this.table[n[0]][1]=i)},this.getCleanTable=function(){for(var t=[],i=0;i<this.table.length;i++)isNon(this.table[i][1])||t.push(this.table[i])
  return t},this.lookAt=function(t){var i=lookfor(t||(new Date).getTime(),this.table)[0]
  return"'"+this.table[i][1]+"' at "+this.table[i][0]},this}function Map(t){return this.keys=new SortedSet(t||[]),this.values=Tablify(this.keys.value),this.add=function(t,i){if(isType(t,"Array"))for(var e=0;e<t;e++)this.add(t[e],isType(i,"Array")?i[e]:i)
  this.keys.add(t),void 0===this.values[t]&&(this.values[t]=[]),this.values[t].push(i||null)},this.clear=function(t){t?this.values[t]=[]:this.keys=new Set},this.has=function(t){for(var i in this.keys)if(this.keys.hasOwnProperty(i)&&this.keys[i].has(t))return!0
  return!1},this.hasKey=function(t){return this.keys.contains(t)},this.size=function(){var t=this.values
  return this.keys.value.map(function(i){return t[i].length})},this.elements=function(t){var i=this.values
  return this.keys.value.map(function(e){return t?i[e].toStr(!0):i[e].toString()}).toStr(!0)},this.isEmpty=function(){return this.keys.isEmpty()},this.get=function(t){return this.values[t]},this.remove=function(t,i){i?this.values[t]=this.values[t].remove():this.keys.remove()},this.toString=function(){return"Map(key/values="+this.values.toArray().toStr(!0)+")"},this.forEach=function(t,i){for(var e=0;e<this.keys.size();e++)i?t(this.values[this.keys.get(e)],e):t(this.keys.get(e),e)},this.merge=function(t){this.keys.add(t.keys.value,t.values)},this.set=function(t,i){this.keys.set(this.keys.indexOf(t),i)},this.replace=function(t,i,e){this.values[t].has(i)&&(this.values[t]=this.values[t].replace(i,e))},this.replaceAll=function(t,i){var e=this
  this.forEach(function(n){e.replace(n,t,i)})},this}function DomTree(){var t=document.children[0],i=function(t){return debugging&&Essence.say("Stepping in %c"+DOMA.nameOf(t)+"%c","info","color: #00f","color: #000"),DOMA.kidsOf(t).isEmpty()?new NTreeNode(DOMA.nameOf(t)):new NTreeNode(DOMA.nameOf(t),DOMA.kidsOf(t).map(function(t){return DOMA.kidsOf(t).isEmpty()?new NTreeNode(DOMA.nameOf(t)):i(t)}))}
  return i(t)}function DomStructure(){var t={},i=document.children[0],e=function(t,i){return i||(i={}),i[DOMA.nameOf(t)]={},DOMA.kidsOf(t).map(function(n){i[DOMA.nameOf(t)][DOMA.nameOf(n)]={},DOMA.kidsOf(n).isEmpty()||DOMA.kidsOf(n).map(function(r){i[DOMA.nameOf(t)][DOMA.nameOf(n)]=e(r,i[DOMA.nameOf(t)][DOMA.nameOf(n)])})}),i}
  return e(i,t)}function DomList(){var t="",i="  ",e="",n={},r=document.children[0],s=function(n,r,h,a){return r||(r={}),r[DOMA.nameOf(n)]={},t+=h+"|-"+DOMA.nameOf(n)+"   (d="+a+")\n",DOMA.kidsOf(n).map(function(o){r[DOMA.nameOf(n)][DOMA.nameOf(o)]={},t+=h+i.repeat(a)+"|-"+DOMA.nameOf(o)+"   (d="+(a+1)+")\n",DOMA.kidsOf(o).isEmpty()||DOMA.kidsOf(o).map(function(t){r[DOMA.nameOf(n)][DOMA.nameOf(o)]=s(t,r[DOMA.nameOf(n)][DOMA.nameOf(o)],e+i+i,a+2)})}),r}
  return s(r,n,e,0),t}function object2tree(t,i,e,n){i||(i=n?"&nbsp;&nbsp;":"\t"),e||(e="|-")
  var r=function(t){return i+e+keyList(t,!0)+(n?"<br />":"\n")},s=r(t)
  console.log("tree",s)
  for(var h in t)t.hasOwnProperty(h)&&(s+=object2tree(t[h],i+i,e,n))
  return s}function Kruskal(t){for(var i=[],e=t.edges[0].getSurroundingEdges();e.length>0;){var n=e.filter(function(t){return t.length===e.map(function(t){return t.length}).min()}).map(function(t){return t.length})[0],r=n.startNode.edges.remove(this,!0),s=n.endNode.edges.remove(this,!0),h=(r.map(function(t){return[t.startNode,t.endNode]}).linearise(),s.map(function(t){return[t.startNode,t.endNode]}).linearise()),a=rmDuplicates(r.concat(h)).filter(function(t){return!t.startNode.equals(t.endNode)&&(!t.startNode.equals(n.startNode)||!t.endNode.equals(n.startNode)||t.startNode.equals(n.endNode)||!t.endNode.equals(n.endNode))})
  n.startNode!=n.endNode&&a.length>0&&i.push(n)}return i}function Dijkstra(t,i){i||(i=t.getNetwork())
  for(var e=[],n={},r={},s=0;s<i.length;s++){var h=i[s]
  n[h]=1/0,r[h]=void 0,e.push(h)}for(n[t]=0;e.length>0;){var a=e.filter(function(t){return e.filter(function(t){return n[t]===e.map(function(t){return n[t]}).min()}).has(t)})[0]
  e.remove(a)
  var o=a.getConnectedVertices()
  for(s=0;s<o.length;s++)if(e.has(o[s])){var u=n[a]+a.distanceFrom(o[s])
  u<n[o[s]]&&(n[o[s]]=u,r[o[s]]=a)}}return{dist:n,prev:r}}function Prim(t){for(var i=[t],e=t;!i.has(e.getNearestVertex());)e=e.getNearestVertex(),i.push(e)
  return i}function TableSort(t,i,e){i||(i=0)
  var n=Copy(t),r=function(t,e,n,s){n||s||(n=0,s=t.lastIndex()),e||(e="asc")
  var h
  if(t.length>1){console.log("arr",t[Math.floor((s+n)/2)])
  var a=t[Math.floor((s+n)/2)][i],o=s
  if(console.log("pivot=",a,"pivot pos:",Math.floor((s+n)/2)),h=n,e&&"asc"!==e.toLowerCase().get(0,2)){if("des"!==e.toLowerCase().get(0,2))throw new InvalidParamError('Order can either be false|undefined||"asc"|"des" to make it work')
  for(;h>=o;){for(;t[h][i]>a;)h++
  for(;t[o][i]<a;)o--
  h>=o&&(swap(t,h,o),h++,o--)}}else for(;h<=o;){for(;t[h][i]<a;)h++
  for(;t[o][i]>a;)o--
  h<=o&&(swap(t,h,o),h++,o--)}n<h-1&&r(t,n,h-1,e),h<s&&r(t,h,s,e)}return t}
  return r(n,e)}function sortNamedTable(t,i,e){return[t[0]].concat(TableSort(t.get(1),i,e))}var DataStruct=new Module("DataStruct","Data structures",["DOM","Maths","Files","Misc"])
  NTreeNode.inheritsFrom(TreeNode),SortedSet.inheritsFrom(Set)
  var DOMA=function(){function t(t){return t.localName||t.tagName.toLowerCase()}function i(t){return t.children.toArray()}function e(t,i,e,n,r){i||(i=""),e||(e="&nbsp;&nbsp;"),n||(n=0),r||(r="|-")
  for(var s in t)t.hasOwnProperty(s)&&s.postOrder(i+e,e,n+1,r)
  println(i+r+t+e+" (depth="+n+")")}return{nameOf:t,kidsOf:i,printOrder:e}}()
  