http://bugrammer.hateblo.jp/entry/2014/08/16/014212 ( ããã«ã½ã¼ããããéå¹çãªã½ã¼ãã¢ã«ã´ãªãºã ãæ¢ã㦠ââ ã¹ãã¥ã¼ã¸ã½ã¼ãã¨ã¹ãã¼ã½ã¼ã ) ãèªãã§ã ã¡ããã¨çµãããã©ãã£ã¨é ãã½ã¼ããããã®ã§æ¸ãã¦ã¿ãã ãã¶ãååãã¤ãã¦ããã¨æããã ãã©ã調ã¹ã¦ãªãã®ã§å称ä¸æã ãããã奴ã def try_all_sort(s) s.permutation(s.size){ |x| return x if x.each_cons(2).all?{ |a,b| a<=b } } end typical case ã§ã¯ bogo sort ã¨åããªã¼ãã¼ã bogo sort ã¨éã£ã¦ãworst case ã¯æéãO((N+1)!)ã ã¨æãã ã§ããã³ããã¼ã¯ã 100è¦ç´ ã1000åãªãã¦å®å®ãæ¶æ» ããã¾ã§ã«çµãããªãã®ã§ã試ãã
{{#tags}}- {{label}}
{{/tags}}