1. Лучший говнокод

    В номинации:
    За время:
  2. Python / Говнокод #27373

    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
    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
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    def generate_words(sample, phonemes, num=10): 
        global words, yd
        gen = True
        parens = 0
        r = random.random()
        word = ""
        i = 0
        while i < int(num):
            for j in range(0, len(sample)):
                if sample[j] == '(':
                    if gen:
                        gen = (random.randint(0,1) == 0)
                    if not gen:
                        parens += 1
                elif sample[j] == ')':
                    if not gen:
                        parens -= 1
                    if parens == 0:
                        gen = True
                elif sample[j] in phonemes.keys():
                    for n, phtype in enumerate(phonemes.keys()):
                        if gen and phtype == sample[j]:
                            #k = random.choice(phonemes[phtype])
                            n = yd.randomGen(phonemeRanks[phtype])
                            k = phonemes[phtype][n]
                            word += k
                elif gen:
                    word += sample[j]
                        
            if (not word in words) and (not isExceptional(word)):
                words.append(word)
    
            i += 1
            word = ""
    
    # ...
    
    """parsing sound changes rule with the notation X>Y/Z, where X is a set of source phonemes
    Y - a set of resulting phonemes, Z - a positional condition (optional)"""
    def parsePhNotation(inline):
        rule = inline.split('>')
        if (not len(rule) == 2):
            return []
    
        source = rule[0].split(',')
        final = rule[1].split('/')
    
        result = final[0].split(',')
        posCond = []
        rule = []
        if (len(final) > 2):
            return False
        elif (len(final) == 2):
            posCond = final[1].split('_')
            if (not len(posCond) == 2):
                return []
            posCond[0] = posCond[0].split('#')
            posCond[1] = posCond[1].split('#')
    
    
            
            if (len(posCond[0]) == 2) and len(posCond[0][0]) > 0:
                return []
            elif len(posCond[0]) == 2:
                rule.append(" "+posCond[0][1])
            else:
                rule.append(posCond[0][0])
    
            if (len(posCond[1]) == 2) and len(posCond[1][1]) > 0:
                return []
    
            rule.append(posCond[1][0])
            if len(posCond[1]) == 2:
                rule[1] += " "
            
            rule[0] = rule[0].split(",")
            rule[1] = rule[1].split(",")
    
        final = []
        if len(source) > len(result):
            for i in range(len(result)-1, len(source)-1):
                result.append("")
        elif len(source) < len(result):
            for i in range(len(source)-1, len(result)-1):
                source.append("")
    
        final.append(source)
        final.append(result)
        if (len(rule)>0):
            final.append(rule)
        return final

    Рекурсивный спуск, автомат с магазинной памятью, top-down parsing, bottom-up parsing? Не, не слышал. В свое время время делал вот такие самопальные алгоритмы для рандомной генерации слов по фонетическим шаблонам (типа "CV(C)", "VC" и т.д.) и фонетического преобразования слов и при попытке починить чета наступал на новые баги, т.к. не до конца понимал как вообще парсятся компьютерные языки.

    JaneBurt, 24 Апреля 2021

    Комментарии (1)
  3. PHP / Говнокод #27235

    +1

    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
    $txtdd = $DI_Date;
    $DI_Date = explode(".",$DI_Date);
    
    $DI_YY = $DI_Date[2];
    $DI_LYY = $DI_YY;
    $DI_NYY = $DI_YY;
    $MY = $DI_Date[1].".".$DI_Date[2];
    
    $DI_MM = $DI_Date[1]-1;
    $DI_LMM = $DI_MM-1;
    if ($DI_LMM<0) $DI_LMM = 11;
    $DI_NMM = $DI_MM+1;
    if ($DI_NMM>11) $DI_NMM = 0;
    
    if ($DI_MM==0) $DI_LYY = $DI_YY-1;
    if ($DI_MM==11) $DI_NYY = $DI_YY+1;
    
    $DI_DD = 1;
    
    $lastM = $DI_MM;
    $yy = $DI_YY;
    if ($lastM<1) {
    	$lastM = 12+$lastM;
    	$yy = $yy - 1;
    }
    $lastM = $DI_DD.".".$lastM.".".$yy;
    
    $nextM = $DI_MM+2;
    $yy = $DI_YY;
    if ($nextM>12) {
    	$nextM = $nextM-12;
    	$yy = $yy + 1;
    }
    $nextM = $DI_DD.".".$nextM.".".$yy;
    
    $lastY = $DI_DD.".".($DI_MM+1).".".($DI_YY-1);
    $nextY = $DI_DD.".".($DI_MM+1).".".($DI_YY+1);

    kib0rg, 05 Февраля 2021

    Комментарии (1)
  4. JavaScript / Говнокод #27157

    0

    1. 1
    2. 2
    3. 3
    let startMonth = Number(moment(payDate).startOf("month").format("DD"));
    let endOfMonth = Number(moment(startMonth).endOf("month").format("DD"));
    let dayOffMonth = (endOfMonth-startMonth +1)

    Это так оказывается можно посчитать число дней в месяце

    kinazarov, 09 Декабря 2020

    Комментарии (1)
  5. JavaScript / Говнокод #27013

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    handleShowScheduler() {
                    console.log(this.$parent.$parent.$parent.showScheduler, 'sch')
                    if (this.$parent.$parent.$parent.showScheduler) {
                        this.$parent.$parent.$parent.showScheduler = false;
                        setTimeout(() => {
                            this.$parent.$parent.$parent.showScheduler = true;
                        }, 200)
                    } else {
                        this.$parent.$parent.$parent.showScheduler = true;
                    }
                },

    diman_suvor, 09 Октября 2020

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

    +1

    1. 1
    https://core.telegram.org/constructor/passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow

    Какой багор )))

    rotoeb, 02 Октября 2020

    Комментарии (1)
  7. 1C / Говнокод #26994

    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
    Процедура ОбработкаПолученияПредставления(Данные, Представление, СтандартнаяОбработка)
    	СтандартнаяОбработка=Ложь;
    	Представление="";
    	Для Каждого Стр Из Данные.Ссылка.Состав Цикл
    		Представление=Представление+?(Представление="","",", ")+Стр.Автомобиль;
    		Если СтрДлина(Представление)>50 Тогда 
    			Представление=Представление+"...";
    			Прервать
    		КонецЕсли;
    	КонецЦикла;
    	//Представление=""+Данные.Ссылка.Клиент+" ("+Представление+")";
    КонецПроцедуры

    А чё это списки у нас вдруг тормозить стали?

    NioGoth, 01 Октября 2020

    Комментарии (1)
  8. Си / Говнокод #26951

    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
    #include <stdio.h>
    #include <csptr/smart_ptr.h>
    #include <csptr/array.h>
    
    void print_int(void *ptr, void *meta) {
        (void) meta;
        // ptr points to the current element
        // meta points to the array metadata (global to the array), if any.
        printf("%d\n", *(int*) ptr);
    }
    
    int main(void) {
        // Destructors for array types are run on every element of the
        // array before destruction.
        smart int *ints = unique_ptr(int[5], {5, 4, 3, 2, 1}, print_int);
        // ints == {5, 4, 3, 2, 1}
    
        // Smart arrays are length-aware
        for (size_t i = 0; i < array_length(ints); ++i) {
            ints[i] = i + 1;
        }
        // ints == {1, 2, 3, 4, 5}
    
        return 0;
    }

    Allocating a smart array and printing its contents before destruction.

    C Smart Pointers

    What this is
    This project is an attempt to bring smart pointer constructs to the (GNU) C programming language.

    Features: unique_ptr, shared_ptr macros, and smart type attribute

    https://github.com/Snaipe/libcsptr

    3.14159265, 15 Сентября 2020

    Комментарии (1)
  9. JavaScript / Говнокод #26878

    −1

    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
    updateTimer() {
                requestAnimationFrame(() => {
                    this.timeLeft = this.resendTimeDuration - (Date.now() * 0.001 - this.lastTimeLeft);
    
                    if (this.timeLeft <= 0) {
                        this.resetTimer();
                        return;
                    } else {
                        this.lastTimeLeft = this.timeLeft;
                        this.updateTimer();
                    }
                });
    }

    А как сделать таймер обратного отсчета?

    somebodyoncetoldme, 18 Августа 2020

    Комментарии (1)
  10. Python / Говнокод #26719

    +1

    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
    enchufar Chamuyo
    
    un Árbol de a es
       bien Hoja a
       bien Nodo a (Árbol de a) (Árbol de a)
    
    el máximo
       dados n m
          si n > m da n
          si no    da m
    
    la altura de Árbol de a en Numerito
      dado (Hoja _)     da 1
      dado (Nodo _ a b) da 1 + máximo (altura a)
                                      (altura b)
    
    el programa es escupir . mostrar . altura $
       Nodo 'a'
            (Nodo 'b'
                  (Hoja 'c')
                  (Hoja 'd'))
            (Nodo 'e'
                  (Hoja 'f')
                  (Hoja 'g'))

    Отсюда:
    https://qriollo.github.io/

    TEH3OPHblu_nemyx, 01 Июня 2020

    Комментарии (1)
  11. Lua / Говнокод #26683

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if number >= 0 and number <= 9 then
        string.format('00%d', number)
    end
    if number >= 10 and number <= 99 then
        string.format('0%d', number)
    end
    if number >= 100 and number <= 999 then
        string.format('%d', number)
    end

    imring, 22 Мая 2020

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