1. Список говнокодов пользователя 3.14159265

    Всего: 150

  2. Python / Говнокод #23921

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    Pyhton 2:
    >>> (2**54/1) + 10 - 10 == 2**54
    True
    
    >>> (2**64/1) + 10  == 2**64
    False
    
    Pyhton 3:
    
    >>> (2**54/1) + 10 - 10 == 2**54
    False
    
    >>> (2**64/1) + 10  == 2**64
    True

    Pyhton 2: https://ideone.com/iqwl8L
    Pyhton 3: https://ideone.com/ltG9Fq

    Ну охуеть теперь.
    x + 10 - 10 != x в общем случае - это норма?
    Я всё понимаю - тяжёлое детство, инты, прибитые к железу, но на кой чёрт в современных интерпретируемых языках такое говнище?

    3.14159265, 13 Марта 2018

    Комментарии (30)
  3. C# / Говнокод #23905

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    using System;
    
    public class Test
    {
    
        class R { }
        class A : R { }
        class B : R { }
    
        static void pituh(A x, R y){
            Console.WriteLine("A R");
        }
    
        static void pituh(R x, B y){
            Console.WriteLine("R B");
        }
        
       static void pituh(R x, R y){
            Console.WriteLine("R R");
        }
        
        
    
        static void d(R x, R y)
        {
            dynamic a = x;
            dynamic b = y;
            pituh(a, b);
        }
    
        public static void Main(string[] args)
        {
        	d(new A(),new R());
        	d(new A(),new B()); //Runtime error
    	d(new B(),new A()); //Runtime error
    	
        }	
    }

    Пробуем мультиметоды в до-диезе.
    https://ideone.com/Jm5LJA

    3.14159265, 09 Марта 2018

    Комментарии (15)
  4. Си / Говнокод #23832

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    typedef unsigned int uint;
    
    uint inc(uint i) {
        return i+1;
    }
    uint dec(uint i) {
        return i-1;
    }
    uint add(uint a, uint b) {
        return 0==b ? a : add(inc(a),dec(b));
    }
    
    inline uint _mul(uint a, uint b, uint r) {
        return 0==b ? r : _mul(a,b-1,r+a);
    }
    uint mul(uint a, uint b) {
        return _mul(a,b,0);
    }
    
    uint dec_mul(uint a, uint b, uint r) {
        return 0==b ? r : dec_mul(a,dec(b),r+a);
    }
    
    //gcc 7 здесь сходит с ума на O3, шланг невозмутимо ставит  imul    edi, esi
    uint crazy_mul(uint a, uint b, uint r) {
        return 0==b ? r : crazy_mul(a,dec(b),add(r,a));
    }
    //арифметическая прогрессия. 
    inline uint _sum(uint a,uint s) {
        return a==0 ? s :_sum(a-1,s+a);
    }
    //gcc: сложна нипанятна
    uint sum(uint a) {
        return _sum(a,0);
    }
    //шланг:
    //        imul    rcx, rax
    //        shr     rcx
    uint sum1(uint a) {
        uint s=0;
        for (int i=0;i<a;++i){
            s+=i;
        }
        return s;
    }

    Смотрим как компиляторы решают разные упоротые рекурентные задачки.
    https://godbolt.org/g/4JZuPr

    3.14159265, 27 Февраля 2018

    Комментарии (27)
  5. C++ / Говнокод #23801

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    // Read option name (can contain spaces)
         while (is >> token && token != "value")
    -        name += string(" ", name.empty() ? 0 : 1) + token;
    +        name += (name.empty() ? "" : " ") + token;

    terminate called after throwing an instance of 'std::length_error'
    what(): basic_string::_M_create


    Replacing string(" ", name.empty() ? 0 : 1) with (name.empty() ? "" : " ") and the same in the while() loop for value fixes the problem (for me).

    Does anyone know if "string(" ", 0)" is invalid C++ ?

    Кресты такие кресты.

    3.14159265, 18 Февраля 2018

    Комментарии (17)
  6. Куча / Говнокод #23668

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Alice: balls have zero to me to me to me to me to me to me to me to me to
    
    Bob: you i everything else
    
    Alice: balls have a ball to me to me to me to me to me to me to me to me
    
    Bob: i . . . . . .. . . . .  .
    
    Alice: balls have zero to me to me to me to me to me to me to me to me to

    http://www.ibtimes.com/facebook-ai-project-generates-own-language-chat-transcript-baffles-humans-2572297

    Фейсбук тоже инвестирует в вореционные технологии. Однако как видим кобенанта просто зациклилась.

    This might look like nonsense, but according to Facebook, this conversation was yet another example of AI dynamically generating its own contextual language and the ability to understand conversations. Dhruv Batra, a visiting Facebook AI research scientist from Georgia Tech, told Fast Company that for the AI agents, there wasn’t any guidance to stick to typical English sentence structure, so they made up the difference on their own.

    3.14159265, 24 Января 2018

    Комментарии (13)
  7. Куча / Говнокод #23651

    −1

    1. 1
    2. 2
    3. 3
    https://software.intel.com/sites/default/files/managed/2b/80/5-level_paging_white_paper.pdf
    
    http://lkml.iu.edu/hypermail/linux/kernel/1612.1/00383.html

    x86-64 is currently limited to 256 TiB of virtual address space and 64 TiB
    of physical address space. We are already bumping into this limit: some
    vendors offers servers with 64 TiB of memory today.

    To overcome the limitation upcoming hardware will introduce support for
    5-level paging. It is a straight-forward extension of the current page
    table structure adding one more layer of translation.

    It bumps the limits to 128 PiB of virtual address space and 4 PiB of physical address space.
    This "ought to be enough for anybody" Â.

    https://imgs.xkcd.com/comics/supported_features.png

    3.14159265, 11 Января 2018

    Комментарии (79)
  8. Куча / Говнокод #21836

    −15

    1. 1
    2. 2
    3. 3
    4. 4
    >Сложность получается лучше O(1).
    
    >Не надо бросаться грудью на амбразуру, посиди — подумай. 
    >Как оказалось, самый быстрый алгоритм — это линейный поиск и никакие map/bitset не нужны.

    Будни мамкиного питимизатора
    https://habrahabr.ru/post/317588/

    3.14159265, 14 Декабря 2016

    Комментарии (61)
  9. Си / Говнокод #20277

    −48

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    * if you know a switch stmt will not exceed the lowest or highest case values.  
    switch [] is a little faster because it doesn't check.
    
    * switch stmts always use a jump table.  Don't use them with cases with really 
    big, sparse ranges.
    
    * Allows ranges like "case 4...7:" in switch stmts.
    
    * A no case number causes next higher int case in switch stmts.  See 
    ::/Demo/NullCase.CPP.
    
      I64 i;
      for (i=0;i<20;i++) 
        switch (i) {
          case: "Zero\n";   break; //Starts at zero
          case: "One\n";    break; //One plus prev case.
          case: "Two\n";    break;
          case: "Three\n";  break;
          case 10: "Ten\n"; break;
          case: "Eleven\n"; break; //One plus prev case.
      }
    
    * Switch statements can be nestled with a single switch expression!  This is 
    known as a "sub_switch" statement.  start/end are used to group cases.  Don't 
    goto out of, throw an exception out of, or return out of the start front porch 
    area.  See ::/Demo/SubSwitch.CPP.
    
      I64 i;
      for (i=0;i<10;i++)
        switch (i) {
          case 0: "Zero ";  break;
          case 2: "Two ";           break;
          case 4: "Four ";  break;
          start:
            "[";
            case 1: "One";  break;
            case 3: "Three";        break;
            case 5: "Five"; break;
          end:
            "] ";
            break;
        }
      OutPut:
      >Zero [One] Two [Three] Four [Five]

    http://www.templeos.org/Wb/Doc/HolyC.html
    j123123 форсит заморского Царя сделавшего Священный Си и TempleOS

    3.14159265, 27 Июня 2016

    Комментарии (58)
  10. JavaScript / Говнокод #20230

    −45

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    var fn={ 
         '+':{priority:0,exec:function(a,b){return a+b}}
        ,'-':{priority:0,exec:function(a,b){return a-b}}
        ,'*':{priority:1,exec:function(a,b){return a*b}}
        ,'/':{priority:1,exec:function(a,b){return a/b}}
        ,'&':{priority:1,exec:function(a,b){return a&b}}
        ,'|':{priority:1,exec:function(a,b){return a|b}}
        ,'»':{priority:2,exec:function(a,b){return a>>b}}
        ,'«':{priority:2,exec:function(a,b){return a<<b}}
    }
    
    function exec(str){
        var machine=putin();
        var out=[];
        console.log("Executing: "+str);
        (str.trim()+" END").split(/\s+/).forEach(parser(function (e){
            if (!e) throw "empty:"+e;
            out.push(e);
            machine.send(e);
        }));
        console.log(out.slice())   
        return machine.top();
    }
        
    
    function putin(){
        // раз "единственно полезная структура данных"
        var stack = [];
        return {
            send:function(e){
                if (fn[e]){
                    b = stack.pop();
                    a = stack.pop();
                    r=fn[e].exec(a, b);
                }else{
                  r=+e;
                }
                console.log(e,r);
                stack.push(r);
            },top:function(){return stack[0];}
        }
    }    
    
    function parser(output){
        // джва "единственно полезная структура данных"
        var ops=[];
        var op2;
        return function(e){
            if (/[0-9]+/.test(e)) {
                output(e);
            }else if (null!=fn[e]){
                op2=ops.slice(-1)[0];
                while (fn[op2] &&  (fn[e].priority <= fn[op2].priority) ){
                    output(op2);
                    ops.pop(); 
                    op2 = ops.slice(-1)[0];
                }
                ops.push(e);
            }else if (e == "(") {
                ops.push(e); 
            }else if (e == ")") { 
                while (ops.slice(-1)[0] != "("){ 
                    output(ops.pop())
                }
                ops.pop(); 
            }else if ("END" == e){
                var x;
                while (x=ops.pop(),x) {
                    output(x);
                }    
            }else{
                throw 'invalid pituh:'+e;
            }
        }
    }
    [
        [-1187,"1 + 22 - 13 * ( 44 + 51 ) + 150 / 3 « 1"]
        ,[13,"1 + 3 * 4"]
        ,[16,"( 1 + 3 ) * 4"]
        ,[17,"  1 + 2 * 3 - 4 * 5 + 10 * ( 12 - 9 )"]
    ]
    .forEach(function (a){
        if (a[0]!=exec(a[1])) throw ("Shit:"+ a[0]+" != "+ a[1])
    });

    После того как я заявил что массив — "единственно полезная структура данных", и можно парсить выражения без деревьев.
    Гумно начало брать на «слабо».
    Поточный парсер выражений, который принимает пайпом поток токенов и «на лету» пайпает свой выхлоп в интерпретатор.
    Таким образом по мере прохождения потока он потихоньку исполняется и упрощается.

    3.14159265, 19 Июня 2016

    Комментарии (60)
  11. C++ / Говнокод #19184

    +3

    1. 1
    2. 2
    3. 3
    try{
          throw Exception();
    }

    Мне в сонном бреду пришла мысль, а нахера обязательный catch?
    finally везде необязательно.
    try{ //исключения не пройдут
    }
    //вполне по крестоблядски

    3.14159265, 15 Декабря 2015

    Комментарии (20)