锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲av无码一区二区乱子伦as,国产亚洲人成网站观看,亚洲一区二区三区免费视频 http://www.tkk7.com/chaocai/category/45371.htmlzh-cnSun, 05 Aug 2012 21:12:00 GMTSun, 05 Aug 2012 21:12:00 GMT60The Clojure Program To solve N Queens Problemhttp://www.tkk7.com/chaocai/archive/2012/08/05/384844.html瓚呰秺宸呭嘲瓚呰秺宸呭嘲Sun, 05 Aug 2012 15:26:00 GMThttp://www.tkk7.com/chaocai/archive/2012/08/05/384844.htmlhttp://www.tkk7.com/chaocai/comments/384844.htmlhttp://www.tkk7.com/chaocai/archive/2012/08/05/384844.html#Feedback0http://www.tkk7.com/chaocai/comments/commentRss/384844.htmlhttp://www.tkk7.com/chaocai/services/trackbacks/384844.htmlThe following program is about solving N-Queens problem (http://en.wikipedia.org/wiki/Eight_queens_puzzle) by Clojure. If you have the better solution in Clojure or Haskell, welcome to provide your solution.
(ns queens)
(defn conflictInRow? [queens newqueen]
  (some #(= newqueen %) queens)
)
(defn conflictInDia? [queens newqueen]
  (let [dia (count queens) 
        n1 (fn [queen] (Math/abs (- dia (.indexOf queens queen))))
        n2 (fn [queen] (Math/abs (- newqueen queen)))]
    (some #(= (n1 %) (n2 %)) queens)
   )
 )
(defn conflict? [queens newqueen]
  (or (conflictInRow? queens newqueen) (conflictInDia? queens newqueen))
 )
(def cnt (atom 0))
(defn put-queens [queens newqueen boardSize ]
  (if (= (count queens) boardSize)  
    (do
      (println queens)
      (reset! cnt (inc @cnt))
    )
    (do 
      ;(println queens)
      (if (> newqueen boardSize)
     
           (if (and (= (peek queens) boardSize) (= (count queens) 1))
               (throw (Exception. (str "That's all " @cnt)))
               (recur (pop queens) (inc (peek queens)) boardSize )
           )
     
        (if (conflict? queens newqueen)
            
             (recur queens (inc newqueen) boardSize )
             
          (do
             (put-queens (conj queens newqueen) 1 boardSize )
             (recur queens (inc newqueen) boardSize )
           )
        )
       )
      )
    )
    
)
(defn queens [boardSize] 
    (put-queens [] 1 boardSize)
 )


Chao Cai (钄¤秴錛?/div>

Sr. Software Dev Engineer 
Amazon.com

 


]]>TDD Tipshttp://www.tkk7.com/chaocai/archive/2011/01/09/342623.html瓚呰秺宸呭嘲瓚呰秺宸呭嘲Sun, 09 Jan 2011 08:55:00 GMThttp://www.tkk7.com/chaocai/archive/2011/01/09/342623.htmlhttp://www.tkk7.com/chaocai/comments/342623.htmlhttp://www.tkk7.com/chaocai/archive/2011/01/09/342623.html#Feedback1http://www.tkk7.com/chaocai/comments/commentRss/342623.htmlhttp://www.tkk7.com/chaocai/services/trackbacks/342623.htmlHow to design the testable software? You may always find some best practices about designing for scalable, extensible or maintainable. To be testable, the best way should be TDD. Followings are some tips from my real practices on TDD.

1 TDD is design process; it let you design for testing, naturally

Write the test firstly, it does not only help you find the bugs; but the most important point is to let you design for test naturally.

Also you should keep in mind, tests not only help you find bugs, but also protect your codes; when some changes impact on your existing codes, the tests will be broken.

 

2 Keep the implementation simple

Keep your implementation simple, just let the test pass. The complex implementation may introduce the logics or codes not covered by the tests, even leads some codes not testable.

 

3 TDD in each scope.

You may get to know the concept ATDD (acceptance test driven development). TDD could be used in every phase of the development and by the different granularity.

To ATDD, you could consider on using some existing framework such as FIT, these frameworks will be bridge between business logic and implementation logic.

Recently, the concept BDD (behavior driven development) is introduced to the ATDD process, so the BDD frameworks such as JBehave is also the good choice.

 


Different TDD process could be nested and should be nested don’t let your step too large.

 

4 keep each step small enough

Always keep each step small to avoid introducing the untestable codes or logics and pass each test quickly.

 

 

6 Always refactor

This step is always overlooked in TDD process; however it is the very important step. Also, never forget refactor should involve all your tests.

 

Why can't write test firstly?

 1.not think how to meature the codes

2. The current step maybe too large, should separate into small ones

3. The codes with ugly dependencies


 http://blog.csdn.net/chaocai2004/archive/2011/01/09/6125479.aspx


Chao Cai (钄¤秴)

Sr. SDE

Amazon.com

 



]]>
綆楁硶鐨勬椂闂村鏉傚害http://www.tkk7.com/chaocai/archive/2010/06/18/323815.html瓚呰秺宸呭嘲瓚呰秺宸呭嘲Fri, 18 Jun 2010 07:26:00 GMThttp://www.tkk7.com/chaocai/archive/2010/06/18/323815.htmlhttp://www.tkk7.com/chaocai/comments/323815.htmlhttp://www.tkk7.com/chaocai/archive/2010/06/18/323815.html#Feedback1http://www.tkk7.com/chaocai/comments/commentRss/323815.htmlhttp://www.tkk7.com/chaocai/services/trackbacks/323815.html鐩鎬俊澶у瀵逛簬綆楁硶鐨勬椂闂村鏉傚害O閮戒笉浼氶檶鐢燂紝涓嶈繃浣犵煡閬撲竴涓畻娉曠殑鏃墮棿澶嶆潅搴︽槸濡備綍璁$畻鍑烘潵鐨勫悧錛?/span>

浠ュ墠鍦ㄥ涔犵畻娉曞拰鏁版嵁緇撴瀯鐨勬椂鍊欙紝瀵逛簬姣忕綆楁硶鐨勫鏉傚害閮芥槸姝昏鐨勫茍娌℃湁鐪熸鐨勫幓鐮旂┒浠栦滑鏄浣曡綆楀嚭鏉ワ紝鏈榪戠獊鐒跺綆楁硶浜х敓浜嗗叴瓚o紝榪嬌鑷繁鐮旂┒浜嗕竴涓嬬畻娉曞鏉傚害鐨勮綆楁柟娉曘?/span>

姒傚康

澶?/span>O琛ㄧず娉曡〃紺烘椂闂村鏉傛э紝娉ㄦ剰瀹冩槸鏌愪竴涓畻娉曠殑鏃墮棿澶嶆潅鎬с傚ぇO琛ㄧず鍙槸璇存湁涓婄晫錛岀敱瀹氫箟濡傛灉f(n)=O(n)錛岄偅鏄劇劧鎴愮珛f(n)=O(n^2)錛屽畠緇欎綘涓涓笂鐣岋紝浣嗗茍涓嶆槸涓婄‘鐣岋紝浣嗕漢浠湪琛ㄧず鐨勬椂鍊欎竴鑸兘涔犳儻琛ㄧず鍓嶈?/span>銆?/span>

鍙﹀闄や簡榪欎釜瀹樻柟姒傚康錛屼釜浜鴻涓哄ぇO琛ㄧず鐨勬槸闂瑙勬ān鍜岀畻娉曚腑璇彞鎵ц嬈℃暟鐨勫叧緋匯?/span>

浠ヤ簩鍒嗘煡鎵句負渚嬶紝鎴戜滑姹傝В瀹冪殑鏃墮棿澶嶆潅搴?/span>

1 璁捐妯′負n涓厓绱犳椂錛岃鎵цT(n)嬈?/span>

T(n)=T(n/2)+1

T(n)=[T(n/4)+1]+1

T(n)=T(n/2^m)+m

褰?/span>n=2^m

T(n)=T(1)+log2n

T(1)=1

鎵浠ュ叾綆楁硶澶嶆潅搴︿負O錛坙og2n錛?/span>



]]>
主站蜘蛛池模板: 亚洲第一香蕉视频| 亚洲处破女AV日韩精品| 亚洲六月丁香婷婷综合| 91人成网站色www免费下载| 久久91亚洲精品中文字幕| 在线观看免费黄网站| 亚洲中文字幕无码久久2017| 久久免费香蕉视频| 国产亚洲成av人片在线观看| 久久国产精品成人免费| 亚洲国产一区二区三区青草影视| 日韩精品无码一区二区三区免费| 亚洲视频在线观看| 91九色视频无限观看免费| 亚洲已满18点击进入在线观看| 国产va免费精品观看精品| 国产日本亚洲一区二区三区 | 国产99精品一区二区三区免费| 亚洲A丁香五香天堂网| 一级毛片在线播放免费| 在线A亚洲老鸭窝天堂| 全免费a级毛片免费看| 亚洲一级毛片在线播放| 高清国语自产拍免费视频国产| 国产精品亚洲а∨无码播放不卡 | 亚洲成色WWW久久网站| 最近中文字幕mv免费高清在线| 国产精品亚洲一区二区麻豆| 日本免费人成黄页在线观看视频| 五月天婷婷免费视频| 久久亚洲AV无码精品色午夜麻| 一二三四在线观看免费高清中文在线观看| 亚洲人精品亚洲人成在线| 亚洲国产av无码精品| 99久久人妻精品免费二区| 亚洲人成色99999在线观看| 亚洲午夜日韩高清一区| 亚洲成人在线免费观看| 一级A毛片免费观看久久精品| 久久久久亚洲精品日久生情| 国产在线观看免费完整版中文版 |