your.js daemon not running or user not authorized to stop process

즉, node your.js start 명령을 내린 유저만 해당 프로세스를 종료시킬 수 있다. 슈퍼 유저도 종료 못한다.

강제로 프로세스를 죽이면 다시 살아남..

Posted by 웹눈
   1: package
   2: {
   3:     import flash.display.Sprite;
   4:     import flash.text.TextField;
   5:     import flash.text.TextFieldAutoSize;
   6:     import flash.utils.Dictionary;
   7:     
   8:     public class sudoku extends Sprite
   9:     {
  10:         private const ROW_COUNT:int = 9;
  11:         private const COL_COUNT:int = 9;
  12:         /*private var problem:Vector.<int> = new <int>[
  13:             5,3,-1, -1,7,-1, -1,-1,-1,
  14:             6,-1,-1, 1,9,5, -1,-1,-1,
  15:             -1,9,8, -1,-1,-1, -1,6,-1,
  16:             
  17:             8,-1,-1, -1,6,-1, -1,-1,3,
  18:             4,-1,-1, 8,-1,3, -1,-1,1,
  19:             7,-1,-1, -1,2,-1, -1,-1, 6,
  20:             
  21:             -1,6,-1, -1,-1,-1, 2,8,-1,
  22:             -1,-1,-1, 4,1,9, -1,-1,5,
  23:             -1,-1,-1, -1,8,-1, -1,7,9
  24:         ];*/
  25:         private var problem:Vector.<int> = new <int>[
  26:             -1,-1,8,3,-1,-1,4,-1,2,
  27:             -1,-1,-1,4,-1,-1,3,-1,-1,
  28:             2,-1,-1,6,-1,-1,5,9,1,
  29:             6,1,9,-1,-1,4,-1,-1,-1,
  30:             -1,-1,-1,-1,9,-1,-1,-1,-1,
  31:             -1,-1,-1,2,-1,-1,9,1,5,
  32:             1,4,3,-1,-1,7,-1,-1,9,
  33:             -1,-1,6,-1,-1,3,-1,-1,-1,
  34:             9,-1,2,-1,-1,5,8,-1,-1
  35:         ];
  36:         
  37:         private var possibleNumbers:Dictionary = new Dictionary;
  38:         
  39:         public function sudoku()
  40:         {
  41:             
  42:             for(var i:int=0; i<6; i++)
  43:             {
  44:                 findXAndSetupPossibleNumbers();
  45:                 reducePossibleNumbers3x3();
  46:                 reducePossibleNumberRows();
  47:                 reducePossibleNumberCols();
  48:                 makeOnePossibleLengthCellClear();
  49:             }
  50:             
  51:             debugGetCombinationCount();
  52:         }
  53:         
  54:         private function findXAndSetupPossibleNumbers():void
  55:         {
  56:             possibleNumbers = new Dictionary;
  57:             var row:int, col:int, i:int;
  58:             for(row=0; row<ROW_COUNT; row++)
  59:             {
  60:                 for(col=0; col<COL_COUNT; col++)
  61:                 {
  62:                     if(problem[getIndexFromRowCols(row, col, ROW_COUNT)] < 0) {} else
  63:                         continue;
  64:                     var key:String = row + "," + col;
  65:                     if(possibleNumbers[key] == null)
  66:                         possibleNumbers[key] = new Vector.<int>;
  67:                     var impossibleNumbers:Vector.<int> = new Vector.<int>;
  68:                     get3x3Numbers(row, col, impossibleNumbers);
  69:                     getRowLineNumbers(row, col, impossibleNumbers);
  70:                     getColLineNumbers(row, col, impossibleNumbers);
  71:                     for(i=1; i<10; i++)
  72:                     {
  73:                         if(impossibleNumbers.indexOf(i) < 0) {} else
  74:                             continue;
  75:                         possibleNumbers[key].push( i );
  76:                     }
  77:                 }
  78:             }
  79:         }
  80:         
  81:         private function get3x3Numbers(row:int, col:int, result:Vector.<int>):void
  82:         {
  83:             var startRow:int = int(row/3)*3;
  84:             var startCol:int = int(col/3)*3;
  85:             for(var i:int=startRow; i<startRow+3; i++)
  86:             {
  87:                 for(var j:int=startCol; j<startCol+3; j++)
  88:                 {
  89:                     if(problem[getIndexFromRowCols(i, j)] < 0)
  90:                         continue;
  91:                     result.push(problem[getIndexFromRowCols(i, j)]);
  92:                 }
  93:             }
  94:         }
  95:         
  96:         private function getRowLineNumbers(row:int, col:int, result:Vector.<int>):void
  97:         {
  98:             for(var i:int=0; i<COL_COUNT; i++)
  99:             {
 100:                 var value:int = problem[getIndexFromRowCols(row, i)];
 101:                 if(value < 0)
 102:                     continue;
 103:                 result.push(value);
 104:             }
 105:         }
 106:         
 107:         private function getColLineNumbers(row:int, col:int, result:Vector.<int>):void
 108:         {
 109:             for(var i:int=0; i<ROW_COUNT; i++)
 110:             {
 111:                 var value:int = problem[getIndexFromRowCols(i, col)];
 112:                 if(value < 0)
 113:                     continue;
 114:                 result.push(value);
 115:             }
 116:         }
 117:         
 118:         private function getIndexFromRowCols(row:int, cols:int, colsCount:int=9):int
 119:         {
 120:             return cols + row*colsCount;
 121:         }
 122:         
 123:         private function reducePossibleNumbers3x3():void
 124:         {
 125:             var i:int, j:int, k:int;
 126:             for(var key:String in possibleNumbers)
 127:             {
 128:                 var possibleNumber:Vector.<int> = Vector.<int>(possibleNumbers[key]).concat();
 129:                 var index:Array = key.split(",");
 130:                 var startRow:int = int(int(index[0])/3)*3;
 131:                 var startCol:int = int(int(index[1])/3)*3;
 132:                 for(i=startRow; i<startRow+3; i++)
 133:                 {
 134:                     for(j=startCol; j<startCol+3; j++)
 135:                     {
 136:                         if(i == int(index[0]) && j == int(index[1]))
 137:                             continue;
 138:                         var relatePossibleNumber:Vector.<int> = possibleNumbers[i+","+j];
 139:                         if(relatePossibleNumber == null)
 140:                             continue;
 141:                         for(k=0; k<relatePossibleNumber.length; k++)
 142:                         {
 143:                             var value:int = relatePossibleNumber[k];
 144:                             if(possibleNumber.indexOf(value) < 0)
 145:                                 continue;
 146:                             possibleNumber.splice(possibleNumber.indexOf(value), 1);
 147:                         }
 148:                     }
 149:                 }
 150:                 if(possibleNumber.length == 0)
 151:                     continue;
 152:                 Vector.<int>(possibleNumbers[key]).length = 0;
 153:                 for(k=0; k<possibleNumber.length; k++)
 154:                     Vector.<int>(possibleNumbers[key]).push(possibleNumber[k]);
 155:             }
 156:         }
 157:         
 158:         private function reducePossibleNumberCols():void
 159:         {
 160:             var i:int, k:int;
 161:             for(var key:String in possibleNumbers)
 162:             {
 163:                 var possibleNumber:Vector.<int> = Vector.<int>(possibleNumbers[key]).concat();
 164:                 var index:Array = key.split(",");
 165:                 var col:int = int(index[1]);
 166:                 for(i=0; i<ROW_COUNT; i++)
 167:                 {
 168:                     if(i == int(index[0]) && col == int(index[1]))
 169:                         continue;
 170:                     var relatePossibleNumber:Vector.<int> = possibleNumbers[i+","+col];
 171:                     if(relatePossibleNumber == null)
 172:                         continue;
 173:                     for(k=0; k<relatePossibleNumber.length; k++)
 174:                     {
 175:                         var value:int = relatePossibleNumber[k];
 176:                         if(possibleNumber.indexOf(value) < 0)
 177:                             continue;
 178:                         possibleNumber.splice(possibleNumber.indexOf(value), 1);
 179:                     }
 180:                 }
 181:                 if(possibleNumber.length == 0)
 182:                     continue;
 183:                 Vector.<int>(possibleNumbers[key]).length = 0;
 184:                 for(k=0; k<possibleNumber.length; k++)
 185:                     Vector.<int>(possibleNumbers[key]).push(possibleNumber[k]);
 186:             }
 187:         }
 188:         
 189:         private function reducePossibleNumberRows():void
 190:         {
 191:             var i:int, k:int;
 192:             for(var key:String in possibleNumbers)
 193:             {
 194:                 var possibleNumber:Vector.<int> = Vector.<int>(possibleNumbers[key]).concat();
 195:                 var index:Array = key.split(",");
 196:                 var row:int = int(index[0]);
 197:                 for(i=0; i<COL_COUNT; i++)
 198:                 {
 199:                     if(row == int(index[0]) && i == int(index[1]))
 200:                         continue;
 201:                     var relatePossibleNumber:Vector.<int> = possibleNumbers[row+","+i];
 202:                     if(relatePossibleNumber == null)
 203:                         continue;
 204:                     for(k=0; k<relatePossibleNumber.length; k++)
 205:                     {
 206:                         var value:int = relatePossibleNumber[k];
 207:                         if(possibleNumber.indexOf(value) < 0)
 208:                             continue;
 209:                         possibleNumber.splice(possibleNumber.indexOf(value), 1);
 210:                     }
 211:                 }
 212:                 if(possibleNumber.length == 0)
 213:                     continue;
 214:                 Vector.<int>(possibleNumbers[key]).length = 0;
 215:                 for(k=0; k<possibleNumber.length; k++)
 216:                     Vector.<int>(possibleNumbers[key]).push(possibleNumber[k]);
 217:             }
 218:         }
 219:     
 220:         private function makeOnePossibleLengthCellClear():void
 221:         {
 222:             for(var key:String in possibleNumbers)
 223:             {
 224:                 var possible:Vector.<int> = possibleNumbers[key];
 225:                 if(possible.length == 1) {} else
 226:                     continue;
 227:                 var index:Array = key.split(",");
 228:                 problem[getIndexFromRowCols(int(index[0]), int(index[1]))] = possible[0];
 229:             }
 230:         }
 231:         
 232:         private function debugGetCombinationCount():void
 233:         {
 234:             var i:int;
 235:             var result:Number = 1;
 236:             for each(var possibles:Vector.<int> in possibleNumbers)
 237:             {
 238:                 result = result*possibles.length;
 239:             }
 240:             trace( "combination count is " + result );
 241:             
 242:             result = 0;
 243:             for(i=0; i<problem.length; i++)
 244:             {
 245:                 if(problem[i] < 0)
 246:                     result++;
 247:             }
 248:             trace("problem x count is " + result );
 249:             
 250:             var textResult:String = problem.join("_");
 251:             i = 1;
 252:             while(textResult.indexOf("_") >= 0)
 253:             {
 254:                 if(i%27 == 0)
 255:                     textResult = textResult.replace("_", "\n\n");
 256:                 else if(i%9 == 0)
 257:                     textResult = textResult.replace("_", "\n");
 258:                 else if(i%3 == 0)
 259:                     textResult = textResult.replace("_", "\t");
 260:                 else
 261:                     textResult = textResult.replace("_", ",");
 262:                 i++;
 263:             }
 264:             while(textResult.indexOf("-1") >= 0)
 265:             {
 266:                 textResult = textResult.replace("-1", "x");
 267:             }
 268:             trace(textResult);
 269:             
 270:             var tf:TextField = new TextField;
 271:             addChild(tf);
 272:             tf.wordWrap = true;
 273:             tf.autoSize = TextFieldAutoSize.LEFT;
 274:             tf.width = stage.stageWidth;
 275:             tf.text = textResult;
 276:         }
 277:     }
 278: }
Posted by 웹눈

http://www.codezealot.org/archives/55


OBB - 2D 에 대한 설명이 잘되어 있는 곳.

'프로그래밍' 카테고리의 다른 글

OBB - 2D 설명이 잘되어 있는 곳(영문 사이트)  (0) 2012.10.31
중복을 최소로 하는 프로그래밍 하기  (4) 2010.07.01
CDATA !?  (1) 2009.04.22
Posted by 웹눈