Sākumlapa › Forumi › Citas tēmas › Humors un Joki › Steidzami – dāvanu saiņošanas algoritms.
Lūdzu… laika paliek arvien mazāk…
🙁
Secinājums – Elvi maisiņi nekam neder.
Packaging Algorithm
Surrounded by christmas presents of various sizes to send to family …
foreach (@closefamilymember) {
$gift = perfectgift $_;
buy($gift);
push @boughtengifts, $gift;
}
foreach (@boughtengifts) {
$box->pack($_);
}
foreach (@notsoclosemember) {
$gift = perfectgift $_;
if (!box->pack($gift)) {
$gift = giftthatwillfitinfreespace $_;
$box->pack($gift);
}
}
box->mail();
pulksteni laiku atpakaļ, lai varētu izmantot vēl šajos Ziemīšos.
.data
_$ dd FFFFFFFFh ; money
_CPC db 0Fh ; close person count
.code
main: mov ECX, _$
mov WALLET, ECX
sar ECX, 10h
jecxz @NoMore
mov LPOCKET, ECX
NoMore:
mov RPOCKET, WALLET
xor ECX, ECX ; burn all money that doesn’t fit into wallet or pocket
xor EAX, EAX
mov SHOP, FFFFFFFFh
NextShop:
inc SHOP
mov SHOP, OB1
mov WALLET, RPOCKET
NextStuff:
lfcs OB1, SHOP ; lfcs = Look For Cool Stuff
; lfcsf = Look For Cool Stuff and Fetch, SSE6 not available yet, will do it by hand
jz @NextShop
mov ECX, LPOCKET
add ECX, WALLET
jecxz @GoHome
sub ECX, PRICE
js @NextStuff
mov OB1, STUFF
mov SHOP, PRICE
mov WALLET, ECX
sar ECX, 10h
jecxz @NoMoreInHand:
mov LPOCKET, ECX
NoMoreInHand:
inc EAX
cmp EAX, _CPC
jne @NextStuff
GoHome:
mov RPOCKET, WALLET
mov HOME, OB1
cmp EAX, _CPC
je @Good
Bad: ; reduce close person count :>
mov _CPC, EAX
Good:
xor EAX, EAX
call JediSortProc
PackStuff:
pack PRESENT ; pack = ff 42 (next-gen instruction, answer of everything)
mov ZEMEGLITES, PRESENT
inc EAX
cmp _CPC, EAX
jne @PackStuff
feast
mov ZEMEGLITES, OB1
Lol:
nop ; ob1 krāc zem eglītes
loop @Lol
; mov ECX, RPOCKET
; add ECX, LPOCKET
; mov CROW, ECX
; kthx
hcf
Doh. Man vajag ārstēties 😀
[img]
samurajs
Tiešām tiem programmeriem nav visi mājās… drīz bez algoritma i glāzītes pieliet nepratīs…
Vienu glāzīti, ja gribēsies iedzert padzerties. Otra ir tukša, ja negribēsies.
Preses relīzes