- 1
this.SelectedDate = this.SelectedDate;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−10.5
this.SelectedDate = this.SelectedDate;
Проверяем дату на корректность...
+52.3
//разметка матрицы
while ((founded==1)&&(mat[nx][ny]<=0)) {
founded=0;
iii=y-i;
while (((i==0)&&(iii==y))||((iii<=y+i))){
ii=x-i;
while ((ii<=x+i)){
if ((mat[ii][iii]==i)&&((ii<70)&&(ii>=0))&&((iii<70)&&(iii>=0))) {
bii=ii;
biii=iii;
if ((mat[bii+1][biii]==-1)&&(bii+1<70)&&(bii+1>=0)) {
mat[bii+1][biii]=i+1;
founded=1;
}
if ((mat[bii-1][biii]==-1)&&(bii-1<70)&&(bii-1>=0)) {
mat[bii-1][biii]=i+1;
founded=1;
}
if ((mat[bii][biii+1]==-1)&&(biii+1<70)&&(biii+1>=0)) {
mat[bii][biii+1]=i+1;
founded=1;
}
if ((mat[bii][biii-1]==-1)&&(biii-1<70)&&(biii-1>=0)) {
mat[bii][biii-1]=i+1;
founded=1;
}
}
ii++;
}
iii++;
}
i++;
}
if (mat[nx][ny]>=0) {
if ((nx==40)&&(ny==57)) {
nx=nx;
}
ik=i;
ii=nx;
iii=ny;
//поиск пути
while (ik>1) {
if ((mat[ii-1][iii]==ik-1)&&(ii-1<70)&&(ii-1>=0)) {
ii--;
mat[ii][iii]=-3;
}
if ((mat[ii][iii-1]==ik-1)&&(iii-1<70)&&(iii-1>=0)) {
iii--;
mat[ii][iii]=-3;
}
if ((mat[ii+1][iii]==ik-1)&&(ii+1<70)&&(ii+1>=0)) {
ii++;
mat[ii][iii]=-3;
}
if ((mat[ii][iii+1]==ik-1)&&(iii+1<70)&&(iii+1>=0)) {
iii++;
mat[ii][iii]=-3;
}
ik--;
}
ax=ii*10+5;
ay=iii*10+5;
//out_to_file(mat,"d:\\out.txt");
i++;
ii=0;
iii=0;
while ((iii>-1)&&(iii<70)){
ii=0;
while ((ii>-1)&&(ii<70)){
if ((mat[ii][iii]>-1)||(mat[ii][iii]==-3)) {
mat[ii][iii]=-1;
}
ii++;
}
iii++;
}
nx=ax;
ny=ay;
} else ...
}
Разметка матрицы, Поиск Пути.
+24
/**
* Getter for billbackAdjustmentType
*
* @return the billbackAdjustmentType instance
*/
public BillbackAdjustmentType getBillbackAdjustmentType() {
return billbackAdjustmentType != null ? billbackAdjustmentType : BillbackAdjustmentType.PlusBillbackAdjustment;
}
...и попробуй такое найди под дебагом :)
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";
}
+2
<?php
function hsum($a, $b, $p) {
$hs = $a ^ $b;
$hp = $a & $b;
$p <<= 1;
return [$hs ^ $p, $hp | ($hs & $p)];
}
function hsum_rec($a, $b, $p) {
list($s, $newp) = hsum($a, $b, $p);
if ($newp == $p) {
return [$s, $newp];
} else {
return hsum_rec($a, $b, $newp);
}
}
function sum2($a, $b) {
list($s, $p) = hsum_rec($a, $b, 0);
return $s;
}
for($i = 0; $i < 16; $i++) {
for($j = 0; $j < 16; $j++) {
if(sum2($i,$j) != $i + $j) {
$k = sum2($i,$j);
echo "Error: $i, $j, $k\n";
}
}
}
Программа складывает два целых числа.
0
#include <stdio.h>
int bts(unsigned int n, int bitN) {
return n & (1 << bitN);
}
int main() {
volatile char *p_lacoon;
unsigned char res = 0;
p_lacoon = ((unsigned )p_lacoon | 01 << 1);
res |= bts(p_lacoon, 0) | bts(p_lacoon, 1);
p_lacoon = ((unsigned )p_lacoon | 01 & ~!~0);
p_lacoon = ((unsigned )p_lacoon | 01 << 1 << 0);
res |= 4 << (bts(p_lacoon, 0) | bts(p_lacoon, 1) ^ 3);
p_lacoon = ((int)p_lacoon | 01 & ~0xFE | 00);
p_lacoon = ((int)p_lacoon | 01 << 1);
res |= ~!0xFF << (bts(p_lacoon, 0) | 6 ^ 0x29b);
res |= ~!0xFC << (bts(p_lacoon, 1) | 4 ^ 0x29c);
res |= ~!0xF0 << 5;
p_lacoon = (int)p_lacoon >> 01 >> 001 << 001 << 01;
printf("%x, %X %s\n", p_lacoon, (res & 001) ? res-1 : res, "*****. Challenge everything.");
}
Предтерминальная стадия мозгфускации.
Из собеса в подразделение AMD: продемонстрировать варианты хранения при недостатке памяти.
Работает в GCC, ICC, Clang только -O0.
Кто хочет разобраться - welcome https://godbolt.org/z/hd4eYeM1Y
0
// https://github.com/ggml-org/llama.cpp/blob/f4c3dd5daa3a79f713813cf1aabdc5886071061d/examples/simple/simple.cpp#L23
// parse command line arguments
{
int i = 1;
for (; i < argc; i++) {
if (strcmp(argv[i], "-m") == 0) {
if (i + 1 < argc) {
model_path = argv[++i];
} else {
print_usage(argc, argv);
return 1;
}
} else if (strcmp(argv[i], "-n") == 0) {
if (i + 1 < argc) {
try {
n_predict = std::stoi(argv[++i]);
} catch (...) {
print_usage(argc, argv);
return 1;
}
} else {
print_usage(argc, argv);
return 1;
}
} else if (strcmp(argv[i], "-ngl") == 0) {
if (i + 1 < argc) {
try {
ngl = std::stoi(argv[++i]);
} catch (...) {
print_usage(argc, argv);
return 1;
}
} else {
print_usage(argc, argv);
return 1;
}
} else {
// prompt starts here
break;
}
}
if (model_path.empty()) {
print_usage(argc, argv);
return 1;
}
if (i < argc) {
prompt = argv[i++];
for (; i < argc; i++) {
prompt += " ";
prompt += argv[i];
}
}
}
Парсинг аргументов командной строки
0
public static String getJoinedHeaderTypes(List<String> types, String delimiter) {
if (!types.isEmpty() && types.size() > 1) {
return String.join(delimiter, types);
} else if (types.size() == 1) {
return types.stream().findFirst().get();
}
return "";
}
Когда тебе рассказали, что есть стримы...
0
fclose(cfPtr);
while ((mem[operand] > -9999) && (mem[operand] < 9999) && sign != 1) {
ins_rgr = (mem[ins_cnt]);
op_code = (ins_rgr / 100);
operand = (ins_rgr % 100);
// printf("op_code = %d operand = %d acc = %d\n", op_code, operand , acc
// );
// dump(mem);
switch (op_code) {
case HALT:
sign = 1;
break;
case READ:
printf("? read ");
scanf("%d", &buf);
mem[operand] = buf;
ins_cnt++;
break;
case WRITE:
printf("%d\n", mem[operand]);
ins_cnt++;
break;
case LOAD:
acc = mem[operand];
ins_cnt++;
break;
case STORE:
mem[operand] = acc;
ins_cnt++;
break;
case ADD:
acc += mem[operand];
ins_cnt++;
break;
case SUBSTRACT:
acc -= mem[operand];
ins_cnt++;
break;
case DIVIDE:
acc /= mem[operand];
ins_cnt++;
break;
case MUL:
acc *= mem[operand];
ins_cnt++;
break;
case POW:
acc = pow(acc, mem[operand]);
ins_cnt++;
break;
case MOD:
acc = fmod(acc, mem[operand]);
ins_cnt++;
break;
case NEWLINE:
puts(" ");
ins_cnt++;
break;
case BRANCH:
case BRANCHZERO:
case BRANCHNEG:
branch(&ins_cnt, acc, operand, op_code);
break;
}
}
dump(mem);
dump_file(mem);
puts(" ");
}
Демотрон 2
Читалка для кода симплтрона
0
За "PHP".