- 1
def neg(x): return int(bin(x)[2:].rjust(8, '0').replace('1','x').replace('0','1').replace('x','0'), 2)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
def neg(x): return int(bin(x)[2:].rjust(8, '0').replace('1','x').replace('0','1').replace('x','0'), 2)
Операция "NEG"
+1
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
+1
Из-за вашей политоты Борманд ушёл.
0
def number_to_words(n):
if n == 1:
print('один')
exit()
elif n == 2:
print('два')
exit()
elif n == 3:
print('три')
exit()
elif n == 4:
print('четыре')
exit()
elif n == 5:
print('пять')
exit()
elif n == 6:
print('шесть')
exit()
elif n == 7:
print('семь')
exit()
elif n == 8:
print('восемь')
exit()
elif n == 9:
print('девять')
exit()
elif n == 10:
print('десять')
exit()
elif n == 11:
print('одиннадцать')
exit()
elif n == 12:
print('двенадцать')
exit()
elif n == 13:
print('тринадцать')
exit()
elif n == 14:
print('четырнадцать')
exit()
elif n == 15:
print('пятнадцать')
exit()
elif n == 16:
print('шестнадцать')
exit()
elif n == 17:
print('семнадцать')
exit()
elif n == 18:
print('восемнадцать')
exit()
elif n == 19:
print('девятнадцать')
exit()
elif n == 20:
print('двадцать')
exit()
elif n == 21:
print('двадцать один')
exit()
elif n == 22:
print('двадцать два')
exit()
elif n == 23:
print('двадцать три')
exit()
elif n == 24:
print('двадцать четыре')
exit()
elif n == 25:
print('двадцать пять')
exit()
elif n == 26:
print('двадцать шесть')
exit()
elif n == 27:
print('двадцать семь')
exit()
elif n == 28:
print('двадцать восемь')
exit()
elif n == 29:
print('двадцать девять')
exit()
elif n == 30:
print('тридцать')
exit()
elif n == 31:
print('тридцать один')
exit()
elif n == 32:
print('тридцать два')
exit()
так до 99. Оригинал: https://www.cyberforum.ru/python-beginners/thread2390750.html
P.S. exit-ы то зачем????
+2
Steps to reproduce:
var s = "a huge, huge, huge string...";
s = s.substring(0, 5);
Expected results: s takes five bytes of memory, plus some overhead.
Actual results: s takes a huge, huge, huge amount of memory.
Unfortunately, most String functions use substring() or no-ops internally: concatenating with empty string, trim(), slice(), match(), search(), replace() with no match, split(), substr(), substring(), toString(), trim(), valueOf().
My workaround is:
function unleakString(s) { return (' ' + s).substr(1); }
But it's not satisfying, because it breaks an abstraction and forces me to think about memory allocation.
https://bugs.chromium.org/p/v8/issues/detail?id=2869
Status: Assigned (Open)
Reported on: Sep 3, 2013
0
#Это калькулятор
t=input("Введите колличество чисел (2 или 3): ")
if t == '3':
one=float(input("Введите первое число: "))
two=float(input("Введите второе число: "))
three=float(input("Введите третье число: "))
n=input("Введите первый знак: ")
if n != '+' and n != '-' and n != '*' and n != '/' :
print("Вы написали что-то неправильно")
else:
m=input("Введите второй знак: ")
if m != '+' and m != '-' and m != '*' and m != '/' :
print("Вы написали что-то неправильно")
else:
if n == '+':
if m == '+':
rez=one+two+three
print(rez)
elif m == '-':
rez=one+two-three
print(rez)
elif m == '*':
rez=one+two*three
print(rez)
elif m == '/':
rez=one+two/three
print(rez)
else:
print("Вы написали что-то неправильно")
elif n == '-':
if m == '+':
rez=one-two+three
print(rez)
elif m == '-':
rez=one-two-three
print(rez)
elif m == '*':
rez=one-two*three
print(rez)
elif m == '/':
rez=one-two/three
print(rez)
else:
print("Вы написали что-то неправильно")
elif n == '*':
if m == '+':
rez=one*two+three
print(rez)
elif m == '-':
rez=one*two-three
print(rez)
elif m == '*':
rez=one*two*three
print(rez)
elif m == '/':
rez=one*two/three
print(rez)
else:
print("Вы написали что-то неправильно")
elif n == '/':
if m == '+':
rez=one/two+three
print(rez)
elif m == '-':
rez=one/two-three
print(rez)
elif m == '*':
rez=one/two*three
print(rez)
elif m == '/':
rez=one/two/three
print(rez)
else:
print("Вы написали что-то неправильно")
else:
print("Вы написали что-то неправильно")
elif t == '2':
z=input("Введите знак: ")
if z != '+' and z != '-' and z != '*' and z != '/' :
print("Вы написали что-то неправильно")
else:
one=float(input("Введите первое число: "))
two=float(input("Введите второе число: "))
if z == '+':
rez=one+two
print(rez)
elif z == '-':
rez=one-two
print(rez)
elif z == '*':
rez=one*two
print(rez)
elif z == '/':
rez=one/two
print(rez)
else:
print("Вы написали что-то неправильно")
else :
print("Вы написали что-то неправильно")
Как можно сократить говнокод? Просто интересно... Спасибо)
0
final class Point {
public final int x;
public final int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
// state-based implementations of equals, hashCode, toString
// nothing else
}
is "just" the data (x, y). Its representation is (x, y), its construction protocol accepts an (x, y) pair and stores it directly into the representation,
it provides unmediated access to that representation, and derives the core Object methods directly from that representation.
And in the middle, there are grey areas where we're going to have to draw a line.
Other OO languages have explored compact syntactic forms for modeling data-oriented classes: case classes in Scala, data classes in Kotlin, and record classes in C#.
These have in common that some or all of the state of a class can be described directly in the class header -- though they vary in their semantics
(such as constraints on the mutability or accessibility of fields, extensibility of the class, and other restrictions.)
Committing in the class declaration to at least part of the relationship between state and interface enables suitable defaults to be derived for many common members.
All of these mechanisms (let's call them "data classes") seek to bring us closer to the goal of being able to define Point as something like:
record Point(int x, int y) { }
[u]https://openjdk.java.net/jeps/359
https://cr.openjdk.java.net/~briangoetz/amber/datum.html[u]
+1
bool isComputerOn() noexcept {
return true;
}
Лицензия MIT. Пользуйтесь на здоровье
0
<?php
$bool1 = false;
$bool2 = true;
$info = '';
if ($bool1 || function () {
if ($bool2)
{
$info = 'Привет мир!';
}
})
{
echo 'Код выполнен';
}
echo $info . "\n";
?>
Еще бы работало:D
+1
https://github.com/oskusalerma/trelby/issues/85
Сорян за пост-ссылку, но я тут валяюсь под столом просто.
Есть тулза для написания сценариев (для чего только нет тулзы, правда?). Она опенсурсная и при этом выглядит не как говно. Но, когда начинаешь её щупать, ВНЕЗАПНО оказывается, что буквы кириллицы в ней тупо не набираются. Лезешь в FAQ, там лежит ссылка на issue из поста. А уже там просто сказка!
Короч, автор примерно в 2007 году сходил почитал спеку пдф, обнаружил, что "PDF spec is oriented towards Latin-1" и решил, что это даёт ему моральное право забить болт на Unicode, а заодно utf-8 и унтерменш, которые не осилили самый тривиальный сабсет латиницы.
В 2012-ом после, судя по всему, многочисленных недоумённых вопросов автор снова появился на горизонте с тикетом на гитхабе и объяснениями в духе "Unicode нет и не будет, потому что не для тебя моя черешня цвела". Цитата для понимания майндсета чувака: "That's how it was 5 years ago anyway when I last looked at it; maybe the spec has improved since then?"
В общем, выглядело так, будто дядя устал и решил, что пора бы всю эту хуйню переложить на чужие хрупкие плечи, у нас тут опенсурс тем более и все дела.
Но, когда в 2015-ом году появился некий анон с предложением все починить и даже какими-то наработками, автор ему сказал, что иди сука гоняй тесты (видимо, руками, потому что CI настроить он тоже не смог) на всех платформах, а то, вишь, "the old "I'll do the fun bits and let others do the boring bits" strategy. Good luck with that."
Короч чуваки ещё немного поспорили с этим аутистом, после чего съебались в туман, а тулза так кириллицу и не поддерживает.
Смешно и грустно.