#Quicker way to figure this out?
48 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
quicker than what?
quicker than doing it step by step on paper I guess
you could write the program yourself and see what it outputs
for this small of a program the biggest speed improvement would be to print the pseudocode and use a pen to record the state
it's not as small as it seems, really
for even more speed™️ you could use a laminate sheet and a whiteboard pen
no, it's quite small
so, what's the answer then?
i dont wanna work it out
it's because it takes half an hour
and I should do it in 7 mins for an exam
if you do a quick readthrough of the code it should take less than 30 sec
because you don't need to figure out what it actually prints
it's enough to figure out which answers it doesn't print
I thought about that, too. The answer is A, but why would D be incorrect at a first glance?
no, it is not A uuh my bad
i am dum dum
just to be sure that i understand the syntax they use here:
does for i <- 1, n mean the same thing as for(auto i = 1; i < n; i++)
i <= n instead of i < n
and they don't use zero based numbering 
so p and value are passed around as references, right?
what about i?
p passed as reference? I don't think so
this could make everything even more confusing
if p is modified in an inner scope that affects p from where that function was called, right?
otherwise there would be no point in changing the value of p at the end of the algorithm
Ok! I did it on paper (without the p referenced) and A answer is on line 9, not 10
assuming no shenanigans you can figure out the order of k values that afisare is called at
10000
12000
12300
12340
12345 - afisare
12340
12300
12304
12354 - afisare
12304
12300
12000
12030
12430
12435 - afisare
12030
12034
12534 - afisare
12034
12030
12000
12003
12403
12453 - afisare
12403
12003
12043
12543 - afisare
12043
12003
12000
10000
10200
13200
13240
13245 - afisare
13240
13200
13204
13254 - afisare
13204
13200
10200
10230
10234
15234 - afisare
@edgy burrow 😦
@oblique rain do you have any idea?
you wrote this in C++?
no, I did it on paper - but I'm doing it in C++ immediately
@edgy burrow
👍
not only that, they mix if they pass by value or reference
1 2 3 5!4
1 2 4 3 5!
1 2 5!3 4
1 2 4 5!3
1 2 5!4 3
1 3 2 4 5!
1 3 2 5!4
1 4 2 3 5!
1 5!2 3 4 ```
here you can see the pattern I mentioned more clearly
1 + 2 + 3 + 4 = 10
so you know where it will be when it will print
and you can figure out which way it took there
not really