V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
harmy
V2EX  ›  2015

用你熟悉的语言写出 2015 吧

  •  
  •   harmy · 2015-01-01 20:38:24 +08:00 · 10793 次点击
    这是一个创建于 3613 天前的主题,其中的信息可能已经有所发展或是发生改变。

    刚才看到一条有意思的微博:

    程序员的新年祝福:1024 + 512 + 256 + 128 + 64 + 16 + 8 + 4 + 2 + 1 = 2015

    于是稍微想一下就翻译成python代码了:

    sum([2**i for i in range(0, 11) if i!=5])
    

    以上就作为抛砖引玉,有兴趣的话大家用自己熟悉的语言写出2015吧。

    121 条回复    2015-01-02 20:46:00 +08:00
    1  2  
    honeyshine75
        1
    honeyshine75  
       2015-01-01 20:42:23 +08:00
    2015
    orvice
        2
    orvice  
       2015-01-01 20:42:28 +08:00
    <h1>2015</h1>
    honeyshine75
        3
    honeyshine75  
       2015-01-01 20:42:56 +08:00
    <?php
    2015
    ?>
    tatsuteng
        4
    tatsuteng  
       2015-01-01 20:47:23 +08:00   ❤️ 1
    二零一五 - -
    crazyxin1988
        5
    crazyxin1988  
       2015-01-01 20:48:32 +08:00
    print “2015”
    Yien
        6
    Yien  
       2015-01-01 20:49:18 +08:00 via iPhone
    echo 2015
    orvice
        7
    orvice  
       2015-01-01 20:50:16 +08:00
    @honeyshine75 这样不会出错嘛- -
    yesmeck
        8
    yesmeck  
       2015-01-01 20:52:22 +08:00   ❤️ 1
    Happy = Time
    Happy.new.year
    blacktulip
        9
    blacktulip  
       2015-01-01 20:54:33 +08:00
    不美,少了 32
    messyidea
        10
    messyidea  
       2015-01-01 20:58:47 +08:00 via Android
    puts(“2015”)
    nilennoct
        11
    nilennoct  
       2015-01-01 20:59:14 +08:00 via iPad
    (function(exp){var sum=x=1;while(exp-->0){sum+=(x<<=1,exp==5?0:x);}return sum;})(10);
    bellchu
        12
    bellchu  
       2015-01-01 20:59:32 +08:00
    11111011111
    lvfujun
        13
    lvfujun  
       2015-01-01 21:00:55 +08:00
    <?php
    echo 2015;
    ?>
    lvfujun
        14
    lvfujun  
       2015-01-01 21:01:22 +08:00
    <script>document.wirte('2015')</script>
    873681136
        15
    873681136  
       2015-01-01 21:01:45 +08:00
    printf("2015");
    evlos
        16
    evlos  
       2015-01-01 21:01:46 +08:00
    System.out.println("2015"); //最近写 Bukkit 插件 Java 写多了。。。
    lvfujun
        17
    lvfujun  
       2015-01-01 21:02:02 +08:00
    0x7DF
    cismous
        18
    cismous  
       2015-01-01 21:02:14 +08:00
    F12
    console.log(2015);
    lvfujun
        19
    lvfujun  
       2015-01-01 21:02:17 +08:00
    03737
    pagecho
        20
    pagecho  
       2015-01-01 21:03:26 +08:00
    二〇一五
    harmy
        21
    harmy  
    OP
       2015-01-01 21:04:11 +08:00
    base64和汇编还没出现 :)
    Hashell
        22
    Hashell  
       2015-01-01 21:10:12 +08:00
    <style>
    .reply_content:after{content:"\32\30\31\35";}
    </style>
    Septembers
        23
    Septembers  
       2015-01-01 21:10:25 +08:00   ❤️ 1
    JavaScript: "ߟ".charCodeAt(0)
    Python/PHP: ord("ߟ")
    jkjoke
        24
    jkjoke  
       2015-01-01 21:10:33 +08:00
    cout<<2015
    Xiaobaixiao
        25
    Xiaobaixiao  
       2015-01-01 21:12:30 +08:00
    two zero one five
    honeyshine75
        26
    honeyshine75  
       2015-01-01 21:36:44 +08:00
    @orvice 哦哦 ,我是业余的,嘿嘿 echo 2015
    Mac
        27
    Mac  
       2015-01-01 21:38:49 +08:00
    10 LET A=2015
    20 PRINT A
    30 END
    bian
        28
    bian  
       2015-01-01 21:43:12 +08:00
    (display 2015)
    orancho
        29
    orancho  
       2015-01-01 21:44:24 +08:00
    def happy(newyear)
    n = 0
    2015.time { n = n +1 }
    puts n.to_s
    end
    happy "new year!"
    orancho
        30
    orancho  
       2015-01-01 21:45:12 +08:00
    啊,少打一个's'

    def happy(newyear)
    n = 0
    2015.times { n = n +1 }
    puts n.to_s
    end
    happy "new year!"
    760974873
        31
    760974873  
       2015-01-01 21:46:55 +08:00
    2015
    Xs0ul
        32
    Xs0ul  
       2015-01-01 21:46:57 +08:00
    @orvice matlab里就行
    messyidea
        33
    messyidea  
       2015-01-01 21:52:57 +08:00   ❤️ 1
    brainfuck :D
    ++++++++++++++++++++++++++++++++++++++++++++++++++.--.+.++++.
    joshryo
        34
    joshryo  
       2015-01-01 21:54:52 +08:00   ❤️ 1
    MjAxNQ==
    loveuqian
        35
    loveuqian  
       2015-01-01 21:55:01 +08:00
    那我只好<title>2 0 1 5</title>咯
    NewYear
        36
    NewYear  
       2015-01-01 22:01:45 +08:00
    dos
    echo 2015
    mimzy
        37
    mimzy  
       2015-01-01 22:04:50 +08:00
    Console.WriteLine(2015);
    frankenstein
        38
    frankenstein  
       2015-01-01 22:08:24 +08:00
    贰零壹伍
    frankenstein
        39
    frankenstein  
       2015-01-01 22:10:27 +08:00
    ..--- ----- .---- .....
    hjc4869
        40
    hjc4869  
       2015-01-01 22:12:51 +08:00
    2015年(にせんじゅうごねん)
    wusibacg
        41
    wusibacg  
       2015-01-01 22:14:53 +08:00
    printf("2015\n");
    icedx
        42
    icedx  
       2015-01-01 22:25:25 +08:00
    print int('2015')
    liuchang0812
        43
    liuchang0812  
       2015-01-01 22:26:31 +08:00
    1 to 11 filter( _ != 5) map( pow(2, _) )
    zhsso
        44
    zhsso  
       2015-01-01 22:28:40 +08:00 via iPad
    2015
    liuchang0812
        45
    liuchang0812  
       2015-01-01 22:29:54 +08:00
    0 to 10 filter (_!=5) map ( pow(2, _)) reduce (_+_)
    AnotherM
        46
    AnotherM  
       2015-01-01 22:30:47 +08:00 via Android
    #include<stdio.h>
    int main()
    {
    int a,b=2;
    for(a=0;a<=8;a++)
    b=b*2;
    b+=b;
    b=b-33;
    printf("%dHappy New Year\n",b);
    }
    wuzhou69
        47
    wuzhou69  
       2015-01-01 22:34:09 +08:00
    Две тысячи пятнадцать
    alex321
        48
    alex321  
       2015-01-01 22:36:03 +08:00
    // php
    <?php
    echo '2015';
    // javascript
    console.log('2015');
    // html
    2015
    // C#
    using System.Web;

    Response.Write("2015");
    bingu
        49
    bingu  
       2015-01-01 22:40:45 +08:00
    @honeyshine75 呵呵
    oz
        50
    oz  
       2015-01-01 22:41:32 +08:00
    दो शून्य से एक पाँच
    Dibel
        51
    Dibel  
       2015-01-01 22:44:22 +08:00
    (define (loop count)
    (define (iter val n)
    (cond ((= n -1) val)
    ((= n 5) (iter val (- n 1)))
    (else (iter (+ val (expt 2 n)) (- n 1)))))
    (iter 0 count))
    (display (loop 10))
    chinafeng
        52
    chinafeng  
       2015-01-01 22:47:31 +08:00
    好像还没有易语言,补充下

    调试输出("2015")
    zangbob
        53
    zangbob  
       2015-01-01 22:48:12 +08:00
    <h1>2015</h1>被人抢了,<title>2015</title>也被人抢了。。。

    那我只能<strong>2015</strong>了。。
    bingu
        54
    bingu  
       2015-01-01 22:48:43 +08:00
    package main

    import "fmt"

    func main() {

    fmt.Println( "2015" )

    }
    loolac
        55
    loolac  
       2015-01-01 22:49:57 +08:00
    2014+1 = 2015
    LINAICAI
        56
    LINAICAI  
       2015-01-01 22:51:31 +08:00
    NSLog(@"2015");
    Tink
        57
    Tink  
       2015-01-01 22:53:52 +08:00 via iPhone
    echo 2015
    Lentin
        58
    Lentin  
       2015-01-01 22:56:40 +08:00 via Android
    Two Zero One Five
    neilp
        59
    neilp  
       2015-01-01 22:59:55 +08:00
    贰零壹伍

    我就会这个了.
    hooozer
        60
    hooozer  
       2015-01-01 23:04:00 +08:00
    p "2015"
    Registering
        61
    Registering  
       2015-01-01 23:04:40 +08:00
    ri leng yi ou ------我的母语,潮汕话
    jiang42
        62
    jiang42  
       2015-01-01 23:05:18 +08:00
    Haskell:
    sum [2^x | x <- [0..10], x /= 5]
    igboy
        63
    igboy  
       2015-01-01 23:09:14 +08:00
    425887a717c43508
    65d2ea03425887a717c435081cfc5dbb

    9cdda67ded3f25811728276cefa76b80913b4c54
    Monad
        64
    Monad  
       2015-01-01 23:18:00 +08:00 via iPhone
    召唤Erlang
    njutree
        65
    njutree  
       2015-01-01 23:18:44 +08:00
    fmt.Println("2015")
    skylooker
        66
    skylooker  
       2015-01-01 23:27:08 +08:00
    #第一种
    puts '2015'

    ---华丽的分隔符---
    //第二种
    var x="2015";
    console.log(x);

    ---华丽的分隔符---
    <!-- 第三种 -->
    <h1>2015</h1>
    endoffight
        67
    endoffight  
       2015-01-01 23:28:07 +08:00
    #!/usr/bin/env bash
    echo 2015
    roychan
        68
    roychan  
       2015-01-01 23:33:20 +08:00
    二零一五
    jarhom
        69
    jarhom  
       2015-01-01 23:38:19 +08:00
    iphone6/plus
    musics
        70
    musics  
       2015-01-01 23:44:59 +08:00
    data segment
    output db 'Hello 2015! $'
    data ends
    code segment

    start:
    assume ds:data,cs:code
    mov ax,data
    mov ds,ax

    mov dx,offset output
    mov ah,09h
    int 21h

    mov ah,4ch
    int 21h

    code ends
    end start
    adeweb
        71
    adeweb  
       2015-01-01 23:54:43 +08:00
    ..--- ----- .---- .....
    yangqi
        72
    yangqi  
       2015-01-01 23:55:22 +08:00   ❤️ 1
    אלפיים וחמש עשרה
    726332269
        73
    726332269  
       2015-01-01 23:56:09 +08:00 via Android
    echo '2015'
    jylee
        74
    jylee  
       2015-01-01 23:57:28 +08:00
    ji ling jat ng
    lilydjwg
        75
    lilydjwg  
       2015-01-02 00:06:16 +08:00
    sum $ map (2^) $ [0..4]++[6..10]
    lilydjwg
        76
    lilydjwg  
       2015-01-02 00:21:49 +08:00
    use std::iter::AdditiveIterator;
    use std::num::Int;

    fn main() {
    let year: int = range(0,5).chain(range(6,11)).map(|x| 2.pow(x)).sum();
    println!("Happy year {}!", year);
    }

    // 开头那两行 use 好讨厌啊……
    TomDu
        77
    TomDu  
       2015-01-02 00:46:01 +08:00
    cout << "2015";

    System.out.println("2015");

    print "2015";
    Chipper
        79
    Chipper  
       2015-01-02 00:46:48 +08:00
    二零一五
    sneezry
        80
    sneezry  
       2015-01-02 00:51:33 +08:00
    MOV BX, 2015
    Yvette
        81
    Yvette  
       2015-01-02 01:27:31 +08:00
    year=2015;
    disp(year)
    ck65
        82
    ck65  
       2015-01-02 01:34:40 +08:00 via iPhone
    Dos mil quince
    Yvette
        83
    Yvette  
       2015-01-02 01:35:12 +08:00
    按楼主的算法

    for i=10:-1:0
    a(i+1)=2^(10-i);
    end
    a(6)=0;
    fprintf('Happy New Year, %i',sum(a))
    byfan
        84
    byfan  
       2015-01-02 01:36:07 +08:00 via iPhone
    <p>2015</p>
    wolfan
        85
    wolfan  
       2015-01-02 02:11:54 +08:00 via Android
    body{width:2015;}
    laotaitai
        86
    laotaitai  
       2015-01-02 02:54:38 +08:00
    输出 2015
    fx
        87
    fx  
       2015-01-02 02:56:42 +08:00
    ```
    0..10 |> Enum.filter_map(&(&1!=5), &(:math.pow(2, &1))) |> Enum.sum
    ```
    baichi
        88
    baichi  
       2015-01-02 03:15:42 +08:00
    佛曰:離闍冥藐婆梵他奢集殿知冥麼哆醯帝冥有喝朋阿耨
    kawaiiushio
        89
    kawaiiushio  
       2015-01-02 04:06:59 +08:00
    </2014><2015>
    infinte
        90
    infinte  
       2015-01-02 04:52:41 +08:00
    console.log '2015'
    // 这是 patel
    lm902
        91
    lm902  
       2015-01-02 05:02:43 +08:00
    @{var year = 2015.ToString();}
    <h1>@year</h1>
    Ricepig
        92
    Ricepig  
       2015-01-02 06:52:49 +08:00
    PRINT 2015
    cassyfar
        93
    cassyfar  
       2015-01-02 06:55:18 +08:00
    year = 0;
    for (int i=0; i<11; i++) year += (1<<i);
    cout<<(year-32)<<endl;
    jooe
        94
    jooe  
       2015-01-02 07:10:45 +08:00 via Android
    &#36; 2015
    DaCong
        95
    DaCong  
       2015-01-02 07:37:55 +08:00
    begin
    write(2015)
    end.
    cxshun
        96
    cxshun  
       2015-01-02 09:02:41 +08:00
    print(2015)
    notcome
        97
    notcome  
       2015-01-02 09:09:10 +08:00
    length [0..2014]
    ai0by
        98
    ai0by  
       2015-01-02 09:14:51 +08:00 via Android
    print '2015'
    Jiangtaigong
        99
    Jiangtaigong  
       2015-01-02 09:18:47 +08:00
    @)!%
    (shift 2015)
    lujjjh
        100
    lujjjh  
       2015-01-02 09:42:23 +08:00
    @messyidea
    -[>+<-----]>-.--.+.++++.
    1  2  
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1579 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 17:02 · PVG 01:02 · LAX 09:02 · JFK 12:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.