What are the short, but awesome, code you've written?

Source: Internet
Author: User

Reply content:

JS 115-Character Hanoi algorithm
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)

By changing the value of the first variable n, you can change the order of the Hanoi.

The following are the effects that run in the browser console
sudo rm-rf/*
The master must try, the effect tension pile 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)))

A python line of code solves 1-100 of all prime numbers solved. Efficiency I haven't tested it, I wrote it in the pythontips answer.

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

Praise, thank you son Chima test, performance is not good, 10000 within the relatively fast, 10 0000 or more is not good to make

Thanks to at sack (at not, the knowledge of the search function is a bit weak ~), lambda x:not any (x%i for I in range (2,X/2)), y with any () is also very good, any () support python2.5 version ZSHRC the various aliasp Rint ("awesome") drop Databasesave/write
Every time you finish the switch you have to knock, do not knock on white. Main () {main ();} Linux under Input:


:() {: |: &};



Then enter Mian ...
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.