- 1
- 2
- 3
uint32_t getuint32(char *p){
return (*p<<24)|(*(p+1)<<16)|(*(p+2)<<8)|(*(p+3));
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−53.9
uint32_t getuint32(char *p){
return (*p<<24)|(*(p+1)<<16)|(*(p+2)<<8)|(*(p+3));
}
+31.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Govnokod.ru — Накласть говнокод</title>
<meta name="keywords" content="говнокод, смешной код, быдлокод, быдлокодеры, индусы, для программистов, про программистов, индусский код, записки программиста, говно, говнокод на php, mysql, perl" />
<meta name="description" content="Сборник говнокода на различных языках программирования" />
<link rel="stylesheet" type="text/css" href="/templates/css/style.css" />
<link rel="stylesheet" type="text/css" href="/templates/css/add.css" />
<script type="text/javascript">
<!--
var SITE_PATH = '';
//-->
</script>
<script type="text/javascript" src="/templates/external.php?type=js&files=prototype.js,govnokod.js"></script>
</head>
<body>
<div class="header">
<a href="/">
<img src="/templates/images/logo.png" alt="Говнокод.Ру" title="Да, это говно!" />
Govnokod.ru
</a>
</div>
<div class="add-govno">
<a href="http://govnokod.ru/add"><img src="/templates/images/icon-plus.png" alt="" /></a>
<a href="http://govnokod.ru/add">Накласть говнокод</a>
</div>
<ul class="menu">
<li class="active"><a href="http://govnokod.ru">Говнокод</a></li>
</ul>
<div style="clear:both"></div>
<ul class="sub-menu">
<li class="left"> </li>
<li><a href="#">Новый</a></li>
<li><a href="#">Лучший</a></li>
<li class="right"> </li>
</ul>
<div style="clear: both;"></div>
<table class="rblock">
<tr>
<td style="width:20px"><img src="/templates/images/rblock-left-top.png" alt="" /></td>
<td class="empty"> </td><td style="width:20px"><img src="/templates/images/rblock-right-top.png" alt="" /></td>
</tr>
<tr class="content">
<td> </td>
<td>
<h1>Накласть говнокод</h1>
<form action="http://govnokod.ru/add" method="post">
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td style="vertical-align: top; width: 20%;"><label for="form_category_id">Язык: <span style="color: red;">*</span></label></td>
<td style="width: 80%;"><select id="form_category_id" name="category_id">
<option selected="selected" style="font-weight: bold;" value=""> </option>
<option value="1">PHP</option>
<option value="2">JavaScript</option>
<option value="3">MySQL</option>
<option value="4">PERL</option>
<option value="5">Python</option>
</select></td>
</tr>
<tr>
<td style="vertical-align: top;"><label for="form_description">Описание:</label></td>
<td><textarea cols="50" id="form_description" name="description" rows="4"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td style="vertical-align: top;"><label for="form_text">Код: <span style="color: red;">*</span></label></td>
<td>
<div id="codeSaveContainer" class="codeInput">
<table cellpadding="0" cellspacing="0" style="width: 100%;">
<tr>
<td style="vertical-align: top; width: 5%;">
<div id="nums" class="linenumbers"></div>
</td>
<td style="vertical-align: top; width: 95%;">
<textarea class="codeArea" cols="50" id="codeArea" name="text" onkeyup="numbering(this);" rows="1" value="
" wrap="off">
</textarea>
</td>
</tr>
</table>
</div>
</td>
типичный говнокод
0
struct node
{
void *data;
struct node *head;
struct node *tail;
};
struct list
{
int size;
struct node *head;
struct node *tail;
void *(*alloc_node)(size_t);
void *(*alloc_data)(size_t);
void (*free_node)(void *);
void (*free_data)(void *);
};
typedef struct node node_t;
typedef struct list list_t;
void list_init(list_t *list)
{
list->size = 0;
list->head = (node_t*)list;
list->tail = (node_t*)list;
list->alloc_node = &malloc;
list->alloc_data = &malloc;
list->free_node = &free;
list->free_data = &free;
}
void list_link(struct node *head, struct node *tail)
{
head->tail = tail;
tail->head = head;
}
void *push_head(list_t *list, node_t *head, size_t size)
{
node_t *node = list->alloc_node(sizeof(node_t));
void *data = list->alloc_data(size);
node->data = data;
list_link(node, head->tail);
list_link(head, node);
list->size++;
return data;
}
void *push_tail(list_t *list, node_t *tail, size_t size)
{
node_t *node = list->alloc_node(sizeof(node_t));
void *data = list->alloc_data(size);
node->data = data;
list_link(tail->head, node);
list_link(node, tail);
list->size++;
return data;
}
void pop(list_t *list, node_t *node)
{
list_link(node->head, node->tail);
list->size--;
void *data = node->data;
list->free_node(node);
list->free_data(data);
}
void print(struct list *list)
{
printf("\n====\n");
printf("size: %ld \n", list->size);
int i = 0;
for(node_t *node = list->head; node != list; node = node->head)
{
printf("index: %ld number: %ld \n", i, *(int*)(node->data));
i++;
}
}
struct list lst;
list_init(&lst);
print(&lst);
void *data;
data = push_tail(&lst, lst.tail, 4);
*(int*)data = 1;
итак скажите про название функций про то каких функций не хватает + alloc и free поля не трогать это мне нужно ТОЛЬКО НЕ советуйте перейти на с++ и использовать чтото другое(std::list)
−9
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/25947"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/26133"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/26134"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/26135"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/26137"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/67335"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68057"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68069"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68120"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68134"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68139"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68240"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68257"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68261"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68335"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68367"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68368"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68369"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68371"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68372"])
govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68373"])
−1
public bool IsTrueOrFalse(string value)
{
return (value.ToString().Length == 4 value.ToString().ToLower()=="true") ? true : (value.ToString().Length == 5 value.ToString().ToLower() == "false") ? false : true;
}
−1
typedef enum {
FILE_NONE, FILE_C, FILE_ASM, FILE_OBJ, FILE_AR, FILE_DSO,
} FileType;
StringArray include_paths;
bool opt_fcommon = true;
bool opt_fpic;
static FileType opt_x;
static StringArray opt_include;
static bool opt_E;
static bool opt_M;
static bool opt_MD;
static bool opt_MMD;
static bool opt_MP;
static bool opt_S;
static bool opt_c;
static bool opt_cc1;
static bool opt_hash_hash_hash;
static bool opt_static;
static bool opt_shared;
static char *opt_MF;
static char *opt_MT;
static char *opt_o;
static StringArray ld_extra_args;
static StringArray std_include_paths;
char *base_file;
static char *output_file;
static StringArray input_paths;
static StringArray tmpfiles;
благо поиск по проекту работает
0
function main() {
let arr = [1, 2, 3];
for (const v of arr.map(x => x + 1)) print(v);
print("done.");
}
Для тех кто не понял предыдущий пример.. я упростил для вас :)
0
%% Note: set and unset are not thread-safe.
-spec set(key(), value()) -> ok.
set(Key, Value) ->
case ets:lookup(?status_tab, Key) of
[{_, {set, _OldValue}}] ->
ets:insert(?status_tab, {Key, {set, Value}});
[{_, {unset, Pid}}] ->
MRef = monitor(process, Pid),
Pid ! {set, Value},
receive
{'DOWN', MRef, _, _, _} -> ok
end;
[] ->
case ets:insert_new(?status_tab, {Key, {set, Value}}) of
true ->
ok;
false ->
set(Key, Value)
end
end,
ok.
-spec unset(key()) -> ok.
unset(Key) ->
case ets:lookup(?status_tab, Key) of
[{_, {set, _OldValue}}] -> ets:delete(?status_tab, Key);
_ -> ok
end,
ok.
-spec read(key()) -> value().
read(Key) ->
case read_or_wait(Key) of
{set, Value} ->
Value;
{wait, MRef} ->
receive
{'DOWN', MRef, _, _, {cvar_set, Value}} ->
Value;
{'DOWN', MRef, _, _, noproc} ->
read(Key)
end
end.
-spec read_or_wait(key()) -> {set, value()} | {wait, reference()}.
read_or_wait(Key) ->
case ets:lookup(?status_tab, Key) of
[] ->
{Pid, MRef} = spawn_monitor(?MODULE, waker_entrypoint, [Key, self()]),
receive
{Pid, proceed} ->
{wait, MRef};
{'DOWN', MRef, _, _, Reason} ->
cvar_retry = Reason,
read_or_wait(Key)
end;
[{_, {set, Val}}] ->
{set, Val};
[{_, {unset, Pid}}] ->
{wait, monitor(process, Pid)}
end.
-spec waker_entrypoint(key(), pid()) -> no_return().
waker_entrypoint(Key, Parent) ->
case ets_insert_new({Key, {unset, self()}}) of
false ->
exit(cvar_retry);
true ->
Parent ! {self(), proceed},
receive
{set, Value} ->
ets_insert({Key, {set, Value}}),
exit({cvar_set, Value})
end
end.
−1
#!/usr/bin/python
import sys
cache = {}
def count(start, end):
if start < end:
if start not in cache:
cache[start] = count(start + 1, end) + count(start * 2, end) + count(start ** 2, end)
return cache[start]
elif start == end:
return 1
else:
return 0
print(count(int(sys.argv[1]), int(sys.argv[2])))
Подсчитать количество путей из a в b с помощью прибавления единицы, умножения на 2 и возведения в квадрат
Чем формально ограничены возможности преобразовать рекурсию в хвостовую? Вот такое ведь не преобразовать?
0
import java.util.Arrays;
import java.util.Optional;
public class AntiVirus{
private int scanIntensity = 0;
//this method is ready for you.
public void setScanIntensity(int level){
scanIntensity = level;
}
//write this method.
public String scanFile(File file,VirusDB database){
String[] signature = database.getSignatures(scanIntensity);
String fileData = file.getData().toLowerCase();
Optional<String> res = Arrays.stream(signature)
.map(s -> s.toLowerCase())
.filter(fileData::contains).findAny();
String scan = " is safe";
if(res.isPresent()) {
System.out.println(res.get());
System.out.println("scan: " + scan);
scan = " is not safe";
System.out.println("scan after: " + scan);
}
return file.getName() + scan;
}
}
Не понимаю, почему не работает.
Задача
https://www.codewars.com/kata/5b13027eedd62c5216000001
Test Results:
AVTest
checkRandomFiles
Log
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
expected:<f4wpzFoQD is [not ]safe> but was:<f4wpzFoQD is []safe>
Stack Trace
Completed in 476ms
checkSameFilesWithDifferentIntensitySett ings
Log
virus
scan: is safe
scan after: is not safe
expected:<file1 is [not ]safe> but was:<file1 is []safe>
Stack Trace
Completed in 1ms
Completed in 496ms