- 1
- 2
- 3
- 4
- 5
- 6
- 7
/// Однажды придумал от скуки :) the1st.net.ru
if(!function_exists('function_exists')) {
function function_exists($f) {
return function_exists($f);
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+42.3
/// Однажды придумал от скуки :) the1st.net.ru
if(!function_exists('function_exists')) {
function function_exists($f) {
return function_exists($f);
}
}
Придумано от скуки на досуге. Довольно спонтанно вырвалась мысль и была сразу воплощена в жизнь :)
0
С днём защитника жопы Борманда вас, питухи!
День защитника Путина.
+1
board = [" ", " ", " "], \
[" ", " ", " "], \
[" ", " ", " "]
i = 1
win = True
place_chek = True
def show():
print("---------")
print("|" + board[0][0] + " " + board[0][1] + " " + board[0][2] + "|")
print("|" + board[1][0] + " " + board[1][1] + " " + board[1][2] + "|")
print("|" + board[2][0] + " " + board[2][1] + " " + board[2][2] + "|")
print("---------")
def move(i):
if i % 2 == 0:
return "X"
else:
return "0"
def choise(x, y):
board[x][y] = move(i)
def repeat(x, y):
global i
global place_chek
if board[x][y] == "0":
print()
print("Choose another location")
print()
place_chek = False
elif board[x][y] == "X":
print()
print("Choose another location")
print()
place_chek = False
elif board[x][y] == " ":
i = i + 1
place_chek = True
def win_check():
global win
if board[0][0] == board[0][1] == board[0][2] == "X" or \
board[1][0] == board[1][1] == board[1][2] == "X" or \
board[2][0] == board[2][1] == board[2][2] == "X" or \
board[0][0] == board[1][0] == board[2][0] == "X" or \
board[0][1] == board[1][1] == board[2][1] == "X" or \
board[0][2] == board[1][2] == board[2][2] == "X" or \
board[0][0] == board[1][1] == board[2][2] == "X" or \
board[0][2] == board[1][1] == board[2][0] == "X":
print("X won")
win = False
elif board[0][0] == board[0][1] == board[0][2] == "0" or \
board[1][0] == board[1][1] == board[1][2] == "0" or \
board[2][0] == board[2][1] == board[2][2] == "0" or \
board[0][0] == board[1][0] == board[2][0] == "0" or \
board[0][1] == board[1][1] == board[2][1] == "0" or \
board[0][2] == board[1][2] == board[2][2] == "0" or \
board[0][0] == board[1][1] == board[2][2] == "0" or \
board[0][2] == board[1][1] == board[2][0] == "0":
print("0 won")
win = False
show() # first time show
while win:
x, y = input("Enter the coordinates: ").split()
repeat(int(x) - 1, int(y) - 1)
if place_chek:
choise(int(x) - 1, int(y) - 1)
show()
win_check()
Крестики нолики на питоне. Самый большой позор это способ определение победы, не смог ничего придумать и сделал такой позор
+2
interface TemplateReducerInterface {
getConfigParameters(): Promise<ConfigParametersResult>
getConfig(): Record<string, any>
setConfig(config: Record<string, any>): void
getDirectoriesForRemove(): Promise<string[]>
getFilesForRemove(): Promise<string[]>
getDependenciesForRemove(): Promise<string[]>
getFilesContentReplacers(): Promise<ReplaceFileContentItem[]>
finish(): Promise<void>
getTestConfigSet(): Promise<Record<string, any>[]>
}
Какой «TypeScript» )))
https://habr.com/ru/post/487648/
−106
neTyxu BCẺ
расиянцам приготовиться к параду суевернитетов
−1
//"вирус" в стиле кулхацкеров
#include <stdlib.h>
int main() {
int i = 1;
while( i == 1) {
system("start calc");
}
return 0;
}
+1
#include <iostream>
#include <functional>
#include <array>
#include <iterator>
template <class T>
class Filter : public std::iterator<
std::input_iterator_tag,
typename std::iterator_traits<T>::value_type,
typename std::iterator_traits<T>::difference_type,
typename std::iterator_traits<T>::pointer,
typename std::iterator_traits<T>::reference
>
{
private:
typedef typename std::iterator_traits<T>::value_type value_type;
std::function<bool(value_type)> m_predicate;
T m_begin, m_end;
value_type m_current;
public:
Filter(T t_begin, T t_end, std::function<bool(value_type)> t_predicate)
: m_begin(t_begin), m_end(t_end), m_predicate(t_predicate)
{
}
Filter<T>& begin()
{
return ++*this;
}
Filter<T>& end()
{
return *this;
}
value_type operator* ()
{
return m_current;
}
Filter<T>& operator++ ()
{
do {
m_current = *m_begin;
++m_begin;
} while (m_begin != m_end && !m_predicate(m_current));
return *this;
}
bool operator!= (Filter<T>& t_right)
{
return m_begin != t_right.m_end;
}
};
int main()
{
std::array<int, 10> arr{ {4, 35, 0, 23, 0, 0, 5} };
for (auto i : Filter<typename std::array<int,10>::iterator>(arr.begin(), arr.end(), [](int x){return x != 0;})) {
std::cout << i << " ";
}
}
−99
Прошу забанить всех на один год.
админа - бессрочно.
+1
ДеФфЧоНаЧкИ с ПрАзДнИчКоМ вАс!
Всем джвумерным, трёхмерным и прочим N-мерным няшкам с клювом и без шлю чмоки-чмоки!
+3
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
enum {
HOST = INADDR_LOOPBACK,
PORT = 6666,
MAX_BUF = 1024
};
struct sock {
int sockfd;
int addrlen;
struct sockaddr_in addr;
} host, client;
int check(int x, char*msg)
{
if (!~x) {
perror(msg);
exit(1);
}
return x;
}
#define QUOTE_(...) #__VA_ARGS__
#define QUOTE(...) QUOTE_(__VA_ARGS__)
#define CHECK(...) check(__VA_ARGS__, QUOTE(line __LINE__: __VA_ARGS__))
int main(int argc, char**argv)
{
struct sock host, client;
host.sockfd = CHECK(socket(AF_INET, SOCK_STREAM, 0)),
host.addr = (struct sockaddr_in){AF_INET, htons(PORT), htonl(HOST)};
CHECK(bind(host.sockfd, &(struct sockaddr)host.addr, sizeof(host.addr)));
CHECK(listen(host.sockfd, 1));
CHECK(client.sockfd = accept(host.sockfd, (void*)&client.addr, &client.addrlen));
printf("connected: %s\n", inet_ntoa(client.addr.sin_addr));
struct {int len; char buf[MAX_BUF];} msg;
while (CHECK(msg.len = recv(client.sockfd, msg.buf, MAX_BUF - 1, 0)) && msg.len) {
msg.buf[msg.len] = 0;
printf("%s", msg.buf);
send(client.sockfd, msg.buf, msg.len, 0);
}
close(client.sockfd);
close(host.sockfd);
return 0;
}
Почему если закоментить 36-ю строчку адрес килента 0.0.0.0?