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

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

    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
    function move1(direction: "up" | "down") {
        switch (direction) {
            case "up":
                return 1;
            case "down":
                return -1; 
        }
    
        return 0;
    }
    
    function main() {
    
        print(move1("up"));
        print(move1("down"));
    
        print("done.");
    }

    а ты умеешь так говнокодить на C/C++?

    ASD_77, 02 Января 2022

    Комментарии (19)
  3. JavaScript / Говнокод #27692

    +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
    function main() {
        let c = 0;
    
        try {
            c++;
            print("try");
            throw "except";
            c--;
            print("after catch");
        } finally {
            c++;
            print("finally");
        }
    
        assert(2 == c);
    }

    ну вот и все... проимплементил последний keyword в языке... (осталось только темплейты - ну и головняк меня ждем)

    ASD_77, 29 Сентября 2021

    Комментарии (19)
  4. Java / Говнокод #27574

    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
    package test.sandbox
    
    object Main {
      def foo(implicit a: Int): Int = a * 2
    
      def main(args: Array[String]): Unit = {
        {
          import Test._
          val result = foo
    
          println(s"Result1 = $result") // Result1 = 42
        }
        {
          implicit val x = 16
          println(s"Result2 = $foo")  // Result2 = 32
        }
      }
    }
    
    object Test {
      implicit val x: Int = 21
    }

    "Scala" — сахарная. (*^‿^*)

    PolinaAksenova, 16 Августа 2021

    Комментарии (19)
  5. Куча / Говнокод #27522

    +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
    ...
    
           fun([N1, _N2], Trace) ->
                   ?assert(
                      ?strict_causality( #{?snk_kind := "Adding table to a shard", shard := _Shard, live_change := true}
                                       , #{?snk_kind := "Shard schema change"}
                                       , ?of_node(N1, Trace)
                                       )),
                   ?assert(
                      ?strict_causality( #{?snk_kind := "Shard schema change", shard := _Shard}
                                       , #{?snk_kind := "Restarting shard server", shard := _Shard}
                                       , ?of_node(N1, Trace)
                                       )),
                   %% Schema change must cause restart of the replica process and bootstrap:
                   {_, Rest} = ?split_trace_at(#{?snk_kind := "Shard schema change"}, Trace),
                   ?assert(
                      ?strict_causality( #{?snk_kind := "Restarting shard server", shard := _Shard}
                                       , #{?snk_kind := state_change, to := bootstrap}
                                       , Rest
                                       ))
           end).

    Немного galaxy-brain тестов

    CHayT, 17 Июля 2021

    Комментарии (19)
  6. C# / Говнокод #27295

    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
    using System;
    
    namespace NoName
    {
        class TwoVariables
        {
            static void Main(string[] args)
            {
                Int32 FirstVariable = Convert.ToInt32(Console.ReadLine());
                Int32 SecondVariable = Convert.ToInt32(Console.ReadLine());
                FirstVariable = FirstVariable + SecondVariable;
                SecondVariable = FirstVariable - SecondVariable;
                FirstVariable = FirstVariable - SecondVariable;
                Console.WriteLine("First Variable is: " + FirstVariable);
                Console.WriteLine("Second Variable is: " + SecondVariable);
                Console.ReadKey();
            }
        }
    }
    
    
    
    
    
    
    
    
    
    
    // Продам гараж

    BelCodeMonkey, 15 Марта 2021

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

    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
    // -------------------------------------------
    // 2.2. binary calls
    // -------------------------------------------
    /*
        combination table:
    
          +-   | c a n
            ---|-------
             c | C A N
             a | A A N
             n | N N N
    
          *    | c a n
            ---|-------
             c | C A N
             a | A N N
             n | N N N
    
          /    | c a n
            ---|-------
             c | C N N
             a | A N N
             n | N N N
    
        argument:
          c : constant, as scalar, point, tensor, ect
          l : affine homogeneous expr argument: as field, field_indirect or field_expr_node::is_affine_homogeneous
          n : function, functor or ! field_expr_node::is_affine_homogeneous
        result:
          C : constant : this combination is not implemented here
          A,N : are implemented here
        rules:
          at least one of the two args is not of type "c"
          when c: c value is embeded in bind_first or bind_second
                  and the operation reduces to an unary one
          when a: if it is a field_convertible, it should be wrapped
                  in field_expr_v2_nonlinear_terminal_field
          when c: no wrapper is need
        implementation:
          The a and n cases are grouped, thanks to the wrapper_traits
          and it remains to cases :
            1) both args are  field_expr_v2_nonlinear or a function 
            2) one  arg  is a field_expr_v2_nonlinear or a function and the second argument is a constant
    */
    
    #define _RHEOLEF_make_field_expr_v2_nonlinear_binary(FUNCTION,FUNCTOR)	\
    template<class Expr1, class Expr2>						\
    inline										\
    typename									\
    std::enable_if<									\
         details::is_field_expr_v2_nonlinear_arg<Expr1>::value			\
      && details::is_field_expr_v2_nonlinear_arg<Expr2>::value			\
      && ! details::is_field_expr_v2_constant   <Expr1>::value			\
      && ! details::is_field_expr_v2_constant   <Expr2>::value			\
     ,details::field_expr_v2_nonlinear_node_binary<					\
        FUNCTOR									\
       ,typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr1>::type	\
       ,typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr2>::type 	\
      >										\
    >::type										\
    FUNCTION (const Expr1& expr1, const Expr2& expr2)				\
    {										\
      typedef typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr1>::type wrap1_t; \
      typedef typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr2>::type wrap2_t; \
      return details::field_expr_v2_nonlinear_node_binary <FUNCTOR,wrap1_t,wrap2_t> \
    	(FUNCTOR(), wrap1_t(expr1), wrap2_t(expr2)); 				\
    }										\
    template<class Expr1, class Expr2>						\
    inline										\
    typename 									\
    std::enable_if<									\
         details::is_field_expr_v2_constant     <Expr1>::value			\
      && details::is_field_expr_v2_nonlinear_arg<Expr2>::value			\
      && ! details::is_field_expr_v2_constant   <Expr2>::value			\
     ,details::field_expr_v2_nonlinear_node_unary<					\
        details::binder_first<							\
          FUNCTOR									\
         ,typename details::field_promote_first_argument<				\
            Expr1

    MAKAKA, 25 Февраля 2021

    Комментарии (19)
  8. JavaScript / Говнокод #27239

    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
    <!DOCTYPE html>
    <html>
        <head>
            <title>loop ass</title>
        </head>
        <body>
            <script>
            function s(){        
                var a="A and B sat on the pipe!";
                alert(a)
                alert("A fell!")
                alert("B gone!")
                alert("who stayed on the pipe?")
                prompt(" who stayed on the pipe?")==a[2]+a[3]+a[4]?alert(@):s()    
          }
    s()
            </script>
        </body>
    </html>

    Что не так?

    prefix-not, 07 Февраля 2021

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

    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
    void s_sort(int *a, size_t sz)
    {
      if ((sz == 0) || (sz == 1))
      {
        return;
      }
      if (sz  == 2)
      {
        int a_max = a[0] > a[1] ? a[0] : a[1];
        int a_min = a[0] > a[1] ? a[1] : a[0];
        a[0] = a_min;
        a[1] = a_max;
        return;
      }
      s_sort(a, sz - 1);
      s_sort(a + 1, sz - 1);
      s_sort(a, sz - 1);
    }

    Крайне тупая по своей сути рекурсивная сортировка. Есть ли у нее название?

    Вряд ли она имеет какое-то практическое применение именно как сортировка, но зато можно ее переписать на какой-нибудь Coq и об нее доказывать другие сортировки. Типа если какая-то там другая сортировка на всех возможных входных массивах выдает то же, что и выдает вот эта сортировка, то сортировка правильная.

    j123123, 03 Января 2021

    Комментарии (19)
  10. Си / Говнокод #27185

    +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
    chek_LD(void)
    {
    	LOCK_DETECT = read();
    	if (LOCK_DETECT == SAVE_LOCK_DETECT)
    	{
    		return;
    	}
    	if (LOCK_DETECT == 0)
    	{
    		LOCK_DETECT = read();
    		if (LOCK_DETECT == 0)
    		{
    			if (LOCK_DETECT != SAVE_LOCK_DETECT)
    			{
    				SAVE_LOCK_DETECT = 0;
    			}
    		}
    	}
    	else
    	{
    		delay_us(5);
    		LOCK_DETECT = read();
    		if (LOCK_DETECT == 1)
    		{
    			if (LOCK_DETECT != SAVE_LOCK_DETECT)
    			{
    				SAVE_LOCK_DETECT = 1;
    			}
    		}
    	}
    	return;
    }

    пришел на легаси проект. обожаю глобальные переменные на весь проект. еще больше обожаю логику)

    viteo, 29 Декабря 2020

    Комментарии (19)
  11. JavaScript / Говнокод #26820

    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
    import { combineEpics, ofType } from 'redux-observable'
    
    import { map, switchMap, catchError, filter, mergeAll } from 'rxjs/operators'
    import { of, from } from 'rxjs'
    import * as R from 'ramda'
    
    import * as TICKETS_ACTION_TYPES from './tickets.types'
    import * as TicketsActions from './tickets.actions'
    import * as TicketsSelectors from './tickets.selectors'
    import { /* TICKET_TYPES,*/ TICKET_STEPS } from './constants'
    import mockAPI from 'services/mockAPI'
    
    export const getTicketsEpic = (action$, state$) =>
      from(
        R.map(
          (step) =>
            action$.pipe(
              filter(
                R.either(
                  R.both(R.propEq('type', TICKETS_ACTION_TYPES.GET_TICKETS_BY_STEP), R.pathEq(['payload', 'step'], step)),
                  R.propEq('type', TICKETS_ACTION_TYPES.GET_ALL_TICKETS)
                )
              ),
              switchMap((action) => {
                if (
                  action.type !== TICKETS_ACTION_TYPES.GET_ALL_TICKETS &&
                  TicketsSelectors.ticketsAllDirtySelector(state$.value)
                ) {
                  return of(TicketsActions.getAllTickets())
                } else if (!TicketsSelectors.ticketsByStepDirtySelector(step, state$.value)) {
                  return of(TicketsActions.getTicketsByStepSuccess(step, null, true))
                }
                return from(
                  // Mocks tickets API
                  // TODO: Replace by real request
                  mockAPI.getTicketsByStep(step)
                ).pipe(
                  map((data) => TicketsActions.getTicketsByStepSuccess(step, data)),
                  catchError((err) => of(TicketsActions.getTicketsByStepError(step, err)))
                )
              })
            ),
          R.values(TICKET_STEPS)
        )
      ).pipe(mergeAll())

    Редукс нам уже не интересен, нам с поподвыподвертами подавай, чтоб тупо болванку показать.

    NickPepper, 25 Июля 2020

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