|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
test?
What the hell
I tried to solve this but I think I get the wrong answer! What does subject() output?Define Compute_DA(x) { temp = (x + 1) / 4; if (temp >= 1) then return x * Compute_DA(temp+1); else //false return x; } Define Subject() { LookingFor = "Job"; Job = 'Good'; LaserRegistration = "Ultimate"; Programming = Get Pointer("Job"); Answer = Programming->; Test = 'Job="' + LaserRegistration + 'Answer"'; Job="UltimateAnswer" Evaluate(Test); Solution = Job + "=" + Compute_DA(7); return Solution; } I think it's Good=2 ![]() |
|
#2
|
||||
|
||||
|
lang?
This might be a silly question, but
what language is this? Christo
__________________
. Spiration channels: Free scripts, programming tutorials and articles Backingline: Advanced betting software, dutching calculator |
|
#3
|
|||
|
|||
|
I don't have a clue? It was for a job application I sent them my answer but I don't know if they will write me back... Since I may so far off lol
|
|
#4
|
||||
|
||||
|
If I am looking at it correctly, then it would return Good=1.5
The first macro is recursive, and stays recursive until it finds a value less than 1, which is 0.75, then multiplies it with the original value of the macro which is 2 so it comes out with 1.5. |
|
#5
|
||||
|
||||
|
so probably a chunk of pseudo.
compute_DA(x) is recursive and will reduce 7 to 1.5 then whatever all that pointer stuff in Subject() does, job is ultimately assigned the value of "UltimateAnswer" - that's just a string, innit? So then solution would be: UltimateAnswer=1.7, or am I barking up completely the wrong dog? Christo |
|
#6
|
||||
|
||||
|
You are right about the UltimateAnswer=1.5
I completely disregarded the reassign to Job. |
|
#7
|
|||
|
|||
|
Thanks guys I needed to know this, it has been eating me alive. I have alot to learn about programming...
![]() |
|
#8
|
|||
|
|||
|
sorry guys
I know it's been a long time ... but this test was re-used for a recent job application ....
The result of the recursive function is 42 ! 7*3*2=42 I don't know how you can have another result .... For the other function ... I think it's UltimateAnswer .... the pointer stuff is juste here to make the solution harder to find. HTH Kuentin Last edited by kuentin : September 6th, 2003 at 05:57 AM. |
|
#9
|
|||
|
|||
|
This is fascinating! I looked at the 'problem' at first and basically thought I have to get out of programming! But then I looked again and did manage to get an answer.... it may well be wrong but I'm pleased I managed to get some kind of result, here goes:
UltimateAnswer=42 ... I notice there is a certain kind of sense to this answer. |
|
#10
|
||||
|
||||
|
kuentin & Robin your both correct.
tbh I don't really know how I came up with 1.5. ![]() |
|
#11
|
||||
|
||||
|
Onslaught: it was over a year ago... who knows what you were thinking back then
![]() |
|
#12
|
||||
|
||||
|
lol, you know me.
![]() |
|
#13
|
|||
|
|||
|
Feeling very pleased with myself for having worked this out the first time around, I looked at it again and for the life of me I couldn't work out the DA_Compute function to 42 again, I get the 21 but not the 2 to multiply it with, anyone care to explain?
|
|
#14
|
|||
|
|||
|
1st call to compute_DA:
x=7 temp=2 return 7*compute_DA(3) --> 3*2*7=42 2nd call to compute_DA: x=3 temp=1 return 3*Compute_DA(2) --> 3*2 3rd call to compute_DA: x=2 temp=3/4 return 2 -->2 |
![]() |
| Viewing: Dev Shed Forums > Other > Dev Shed Lounge > test? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|