Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The cleverest person on /prog? (currently) challenge!

Name: Anonymous 2016-08-19 12:32

challenges tba by challengers!
1 on 1 battles!

Name: Anonymous 2016-08-19 14:15

I challenge >>1 to make better threads.

Name: Anonymous 2016-08-19 15:10

>>1
The cleverest person here is Autistic Human-Frog Hybrid from /lounge/. /prog/ doesn't have anything smarter! Challenge him for 1v1 battle!
http://bbs.progrider.org/lounge/read/1471326078

Name: Anonymous 2016-08-19 19:14

>>2
Write a depth-first tree traversal using constant space.

Name: Anonymous 2016-08-20 6:28

>>4
[pseudocode]
Node Fields : .Id | .Dir | .Val | .LeftId | .RightId | .AboveId

function RoteDir(dir)

case dir == above: dir = left
case dir == left: dir = right
case dir == right: dir = above

return dir

function getNodeVal(Val, Nodelist, rootId){

Name: Anonymous 2016-08-20 10:21

>>4
Like all other programming problems this is best solved in QBasic.

10 REM TREE is an adjacency matrix describing a tree
20 REM NNODES is the number of nodes in the tree
25 REM For this task, the program must traverse the nodes
26 REM so the adjacency matrix is irrelevant
30 FOR I=1 TO NNODES
40 PRINT "FOUND NODE ";I
50 NEXT I
60 PRINT "WHAT ACCEPTABLE LISP IS THIS?"

Name: Anonymous 2016-08-20 10:30

>>6
The presence of line numbers means you're not a true QBasic'er.

Name: Anonymous 2016-08-20 10:36

>>7
This is platform agnostic Basic. It will run on a Commodore 64, Commodore 128, BBC Electron, Acorn Archimedes, AmigaBASIC, Apple II, TRS 80, VZ300, GW Basic and QBasic.

Before Java, you could write a program in Basic in a restricted style, and it would work across multiple platforms.

Name: Anonymous 2016-08-20 14:41

>>8
Of course. But >>6 mentioned he was solving it specifically in QBasic, but didn't present idiomatic QBasic.

Name: Cudder !cXCudderUE 2016-08-20 17:06

>>5 >>4 did not specify it must be a binary tree

>>4
Here's a general tree traversal:
void traverse(Node *e, void (*pre)(Node*,void*), void *prectx,
void (*post)(Node*,void*), void *postctx) {
Node *i = e;
goto child:
while(e->firstchild) {
e = e->firstchild;
child:
pre(e, prectx);
}
for(;;) {
post(e, postctx);
if(e->nextsib) {
e = e->nextsib;
goto childloop;
}
if(e == i || !e->parent)
return;
e = e->parent;
}
}

Name: Anonymous 2016-08-20 17:14

(this space left intentionally blank)

Name: Anonymous 2016-08-20 19:37

>>10
for(;;)
Terrible!

Name: Anonymous 2016-08-20 20:18

C-dder is all talk and no action.

Name: Anonymous 2016-08-20 20:34

>>13
At least she understands pointers, unlike 99% of /prog/.

Name: Anonymous 2016-08-21 0:46

>>14
she
Umm... I've got some bad news for you, anon-kun...

Name: Cudder !cXCudderUE 2016-08-21 13:13

>>12
Did you want a goto instead?

Here's the Asm version. Amusingly enough, it's also 20 lines like the C version, but only 33 bytes compared to the 68 bytes the compiler output with max optimisations. Without opts, it's 112(!) bytes.

traverse: ; ecx:prectx edx:postctx ebx:e esi:pre edi:post
mov ebp, ebx
loop1:
mov eax, ebx
call esi
mov ebx, [eax+Node.firstchild]
test ebx, ebx
jnz loop1
loop2:
call edi
mov ebx, [eax+Node.nextsib]
test ebx, ebx
jnz loop1
cmp eax, ebp
jz traverse_ret
mov eax, [eax+Node.parent]
test eax, eax
jnz loop2
traverse_ret:
ret

Name: Anonymous 2016-08-21 13:36

>>16
stop being a namefag

Name: Anonymous 2016-08-21 14:40

>>17
This is not /g/.

Name: Anonymous 2016-08-21 14:53

C-dder is all talk and no action.

Name: Anonymous 2016-08-21 21:59

Cudder is a kike!

Name: Anonymous 2016-08-21 22:49

Cudder is a girl!

Name: Cudder !cXCudderUE 2016-08-22 3:39

>>21
More like mature woman... when I was a "girl" the Internet didn't even exist.

Name: Anonymous 2016-08-22 6:01

>>23
You don't exist as a "woman" either, faggot.

Name: Anonymous 2016-08-22 11:20

>>22
stop being a namefag

Name: Anonymous 2016-08-22 15:35

>>24
stop being a fa/g/

Name: Anonymous 2016-08-22 16:12

>>23,24
Stop bullying Cudder-sama.

Name: Anonymous 2016-08-22 16:20

>>22
Cudder is an Oneechan!

Name: Anonymous 2016-08-22 18:28

Okay, so is Cudder a tranny?

Name: Anonymous 2016-08-22 19:10

>>28
Cudder is just another piece of shit white nigger russian or east european faggot. Tranny would be a step up for this loser, requiring actually doing something with your life.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List