- 1
console.log("Hello, World!");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
console.log("Hello, World!");
https://en.wikipedia.org/wiki/World_Hello_Day
+2
ShipType Ship::getShipTypeByLength(int length)
{
switch (length) {
case 1: return BOAT;
case 2: return CRUISER;
case 3: return DESTROYER;
case 4: return BATTLESHIP;
case 5: return AIRCRAFT_CARRIER;
default:
std::cout << "No ship meets the given length: " << length << std::endl;
return ERROR_SHIP;
}
}
int Ship::getShipLengthByType(ShipType type)
{
switch (type) {
case BOAT: return 1;
case CRUISER: return 2;
case DESTROYER: return 3;
case BATTLESHIP: return 4;
case AIRCRAFT_CARRIER: return 5;
default:
std::cout << "No ship meets the given type: " << type << std::endl;
return 0;
}
}
int Ship::getShipAmountByType(ShipType type)
{
switch (type) {
case BOAT: return 4;
case CRUISER: return 3;
case DESTROYER: return 2;
case BATTLESHIP: return 1;
case AIRCRAFT_CARRIER: return 1;
default:
std::cout << "No ship meets the given type: " << type << std::endl;
return 0;
}
}
Coordinates Ship::getFirstBlockCoordinatesByShipData(int x, int y, int length, Orientation orientation)
{
Coordinates result;
if (orientation == HORIZONTAL) {
result.x = x - (length / 2);
result.y = y;
} else {
result.x = x;
result.y = y - (length / 2);
}
return result;
}
Coordinates Ship::getLastBlockCoordinatesByShipData(int x, int y, int length, Orientation orientation)
{
Coordinates result;
if (orientation == HORIZONTAL) {
result.x = x + (length / 2) + (length % 2) - 1;
result.y = y;
} else {
result.x = x;
result.y = y + (length / 2) + (length % 2) - 1;
}
return result;
}
Вот некоторые полезные функции из игры «Морской Бой», которую я зачем-то написал.
+1
#include <iostream>
using namespace std;
int del(int s)
{
int k = 0;
for (int i = 1;i <= 20;i++)
{
if (s % i == 0)
{
k++;
};
};
return k == 20;
}
int main()
{
unsigned long int q = 1;
for (int i = 1;i <= 20;i++)
{
q = q*i;
}
for (int i=1;i<=q;i++)
{
if (del(i))
{
cout << i;
break;
}
}
return 0;
}
2520 - самое маленькое число, которое делится без остатка на все числа от 1 до 10.
Какое самое маленькое число делится нацело на все числа от 1 до 20?
Что за неоптимизированное говно я сейчас сделал.........
0
https://journal.tinkoff.ru/diary-quality-manager-moscow-950k/
0
Mi sidim v servernoy!
Vse kto nas chitaet! Mi sidim v servernoy, v zaperty, mobillnyi ne beret! Pozovonite na ohrany po telefony на okrany 762-23-96 i skagite chtobi nas vypustili!
0
#Я новичок в питоне, учусь буквально 2 недели. Это моя первая программа - типа банкомат,
#которую показал для примера учитель в очень упрощенном варианте, а я уже заинтересовался этим и стал улучшать её.
x=input('Чтобы зарегистрироваться, введите логин.\n' )
y=input('Придумайте пароль.\n')
login=x
password=y
print('Вы успешно зарегистрировались!')
print('__________________________________________________________________________________________________________________')
print('__________________________________________________________________________________________________________________')
print('Войдите в систему, чтобы получить доступ ко всем функциям.')
log=(input("Введите логин:\n"))
pas=(input("Введите пароль:\n"))
if((log==login)and(pas == password)):
balance=0
print('__________________________________________________________________________________________________________________')
print('__________________________________________________________________________________________________________________')
print("Вход выполнен успешно! У вас на счету",balance,"р.")
while 1:
print('__________________________________________________________________________________________________________________')
print('__________________________________________________________________________________________________________________')
print("Введите 1, чтобы пополнить счет, 2, чтобы снять, 3, чтобы выйти из аккаунта, и 4, чтобы узнать состояние счета.")
s=int(input('(Далее - Enter.)\n'))
if(s==1):
sum=int(input("На сколько вы хотите пополнить счет? (Далее - Enter.)\n"))
balance=balance+sum
print("Операция проведена успешно! На Вашем счету",balance,'р.')
if(s==2):
print("Сколько вы желаете снять со счета?")
sum=int(input('(Далее - Enter.)\n'))
if (sum>balance):
print('__________________________________________________________________________________________________________________')
print('__________________________________________________________________________________________________________________')
print("На счете недостаточно средств. Попробуйте ввести меньшее значение.")
else:
balance=balance-sum
print("Средства сняты со счета. Остаток:",balance,"р.")
if(s==3):
print('__________________________________________________________________________________________________________________')
print('__________________________________________________________________________________________________________________')
print('Вы вышли из аккаунта.')
raise SystemExit
if(s==4):
print('__________________________________________________________________________________________________________________')
print('__________________________________________________________________________________________________________________')
print('На вашем счету',balance,'р.')
if((log!= login)or(pas!= password)):
count=4
while ((log!=login)or(pas!=password)):
count=count-1
print("Неправильно введён логин или пароль. Осталось попыток входа:", count)
log=(input("Введите логин:\n"))
pas=(input("Введите пароль:\n"))
if ((count < 2)and((log!=login)or(pas!=password))):
print('Вход заблокирован в связи с ошибкой при входе.')
break
if ((log ==login)and(pas==password)):
balance=0
print('__________________________________________________________________________________________________________________')
print('__________________________________________________________________________________________________________________')
print("Вход выполнен успешно! У вас на счету",balance,"р.")
while ((balance > -1)):
print('__________________________________________________________________________________________________________________')
print('__________________________________________________________________________________________________________________')
print('Введите 1, чтобы пополнить счет, 2, чтобы снять, 3, чтобы выйти из аккаунта, и 4, для того чтобы узнать состояние счета.')
s=int(input('(Далее - Enter.)\n'))
if(s==1):
sum=int(input("На сколько вы хотите пополнить счет?\n"))
balance=balance+sum
print("Операция проведена успешно! На Вашем счету",balance,'р.')
if(s==2):
print("Сколько вы желаете снять со счета?")
sum=int(input('(Далее - Enter.)\n'))
if (sum>balance):
print("На счете недостаточно средств. Попробуйте ввести меньшее значение.")
else:
balance=balance-sum
print("Средства сняты со счета. Остаток:",balance,"р.")
if(s==3):
print('__________________________________________________________________________________________________________________')
print('__________________________________________________________________________________________________________________')
print('Вы вышли из аккаунта.')
raise SystemExit
if(s==4):
print('__________________________________________________________________________________________________________________')
print('__________________________________________________________________________________________________________________')
print('На вашем счету',balance,'р.')
0
Fixpoint mint_add0 {N} (i k : Fin.t N) te_i te' t0 vec
(Ht : MInt nonCommRel N k vec (te' :: t0))
(Hik : k < i)
(Hcomm0 : trace_elems_commute te_i te')
{struct Ht} :
exists t' : list TE,
MInt nonCommRel N k (vec_append i te_i vec) (te' :: t') /\
Permutation trace_elems_commute (te_i :: te' :: t0) (te' :: t').
Proof with eauto.
(* Welcome to the hell proof! *)
remember (te' :: t0) as t_.
destruct Ht as [k
|k j vec te_k t Hij Ht
|k j vec te_k te_j t Hij Hcomm Ht
];
[discriminate
|replace te' with te_k in * by congruence; clear Heqt_..
].
2:{ destruct (trace_elems_commute_dec te_i te_j).
- apply mint_add0 with (te_i := te_i) (i := i) in Ht; [|lia|assumption].
destruct Ht as [t' [Ht' Hperm']].
exists (te_j :: t'). split.
+ swap_vec_append.
eapply mint_cons2...
+ apply permut_cons with (a := te_k) in Hperm'.
eapply permut_trans...
now apply permut_head'.
- exists (te_i :: te_j :: t). split.
+ swap_vec_append.
apply mint_cons1 with (j0 := i); [lia|].
apply mint_cons2 with (j0 := j); [lia|auto..].
+ now apply permut_head'.
}
{ inversion_ Ht.
- exists [te_i]. split.
+ swap_vec_append.
apply mint_cons1 with (j0 := i); [lia|].
apply mint_cons1 with (j0 := i); [lia|].
constructor.
+ now apply permut_head'.
- rename te into te_j.
destruct (PeanoNat.Nat.lt_ge_cases j i).
2:{ exists (te_i :: te_j :: t1). split.
- swap_vec_append.
apply mint_cons1 with (j1 := i); [lia|].
apply mint_cons1 with (j1 := j); [lia|assumption].
- now apply permut_head'.
}
{ destruct (trace_elems_commute_dec te_i te_j) as [Hte_ij|Hte_ij].
- apply mint_add0 with (i := i) (te_i := te_i) in Ht; [|lia|assumption].
destruct Ht as [t' [Ht' Hperm']].
exists (te_j :: t'). split.
+ swap_vec_append.
eapply mint_cons1...
+ apply permut_cons with (a := te_k) in Hperm'.
now apply permut_head.
- exists (te_i :: te_j :: t1). split.
+ swap_vec_append.
apply mint_cons1 with (j1 := i); [lia|].
apply mint_cons2 with (j1 := j); [lia|assumption..].
+ apply permut_head; [assumption|constructor].
}
- rename j0 into i0. cbn in H0.
destruct (PeanoNat.Nat.lt_ge_cases j i).
2:{ exists (te_i :: te_i0 :: te_j :: t1). split.
+ swap_vec_append.
apply mint_cons1 with (j0 := i); [lia|].
apply mint_cons1 with (j0 := j); [lia|assumption].
+ now apply permut_head'.
}
{ destruct (trace_elems_commute_dec te_i te_i0).
- apply mint_add0 with (i := i) (te_i := te_i) in Ht; [|lia|assumption].
destruct Ht as [t' [Ht' Hperm']].
exists (te_i0 :: t'). split.
+ swap_vec_append.
eapply mint_cons1...
+ apply permut_cons with (a := te_k) in Hperm'.
now apply permut_head.
- exists (te_i :: te_i0 :: te_j :: t1). split.
+ swap_vec_append.
apply mint_cons1 with (j0 := i); [lia|].
apply mint_cons2 with (j0 := j); [lia|assumption..].
+ apply permut_head.
* assumption.
* constructor.
}
}
Qed.
Мой magnum opus. Часть доказательства про выкидывание из рассмотрения коммутирующих системных вызовов.
+1
DeliveryTruck t when t.GrossWeightClass switch
{
< 3000 => 10.00m - 2.00m,
>= 3000 and <= 5000 => 10.00m,
> 5000 => 10.00m + 5.00m,
}
С каждой новой версией C# всё меньше похож на C# и всё больше на Perl.
+1
In order to fund the development work on speeding CPython by a factor of five, something like $2M will be required.
This seems like a sizeable sum, but compared to the amount of money spent on Python development and the
cost of running Python applications, it is quite a modest sum.
---
The overall aim is to speed up CPython by a factor of (approximately) five. We aim to do this in four distinct stages,
each stage increasing the speed of CPython by (approximately) 50%.
1.5**4 ≈ 5
---
The interpreter will adapt to types and values during execution, exploiting [b]type stability[/b] in the program
---
Improved performance for [b]integers of less than one machine word[/b].
Improved peformance for [b]binary operators[/b].
---
Simple "JIT" compiler for small regions. Compile small regions of specialized code, using a relatively simple, fast compiler.
Extend regions for compilation. Enhance compiler to generate [b]superior machine code[/b].
питонисты готовят новую версию интерпретатора с революционной фичей - возможностью отъема денег у населения. Ожидается, что нововведение позволит языку быстро заработать очки на рынке пускания пыли в глаза.
https://github.com/markshannon/faster-cpython
0
bp kernelbase!VirtualAlloc " .printf \"\n\n\n\nBytes allocated: %lu (k)\n\n\n\",(@rdx/0n1024); k 8"
Давайте течь от windbg