{"blog_url":"https://obelisk.hatenablog.com/","width":"100%","provider_url":"https://hatena.blog","description":"\u8f9e\u66f8\u9806\uff08lexicographical order\uff09\u306b\u4e26\u3079\u3066\u4f55\u756a\u76ee\u304b\u3001\u3042\u308b\u3044\u306fn\u756a\u76ee\u306e\u3082\u306e\u306f\u4f55\u304b\u3002\u8981\u7d20\u306b\u91cd\u8907\u304c\u306a\u3044\u3068\u3057\u3066\u8003\u3048\u308b\u3002\u6570\u5217 (1, 2, .... , n) \u306e\u4e26\u3079\u66ff\u3048\u3068\u3057\u3066\u89e3\u3053\u3046\u3002 \u6570\u5217 (a1, .. , an) \u306f\u8f9e\u66f8\u9806\u3067\u4f55\u756a\u76ee\u304b\u3002 def number_in_lex_order(ary) n = ary.size return 1 if n <= 1 idx = ary.sort.bsearch_index { _1 >= ary[0] } (1..n - 1).inject(:*) * idx + number_in_lex_order(ary[1..-1]) end nu\u2026","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fobelisk.hatenablog.com%2Fentry%2F2023%2F04%2F29%2F122036\" title=\"\u8f9e\u66f8\u9806\u3067\u4f55\u756a\u76ee\u304b\uff08Ruby\uff09 - Camera Obscura\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","provider_name":"Hatena Blog","author_url":"https://blog.hatena.ne.jp/obelisk2/","published":"2023-04-29 12:20:36","categories":["Ruby"],"blog_title":"Camera Obscura","title":"\u8f9e\u66f8\u9806\u3067\u4f55\u756a\u76ee\u304b\uff08Ruby\uff09","type":"rich","url":"https://obelisk.hatenablog.com/entry/2023/04/29/122036","version":"1.0","height":"190","image_url":null,"author_name":"obelisk2"}