|
||
Title: Abstract Computer Post by irrational on Sep 14th, 2006, 10:28am Another M$ interview Question: You have an abstract computer. A variable is defined as a entity that can store a number. You can use as many variable as you need, there are no negetive numbers, all numbers are integers. You do not know the size of the integers, they could be infinitely large, so you can't count on truncating at any point. There are no comparisons allowed, no if statements or anything like that. There are only four operations you can do on a variable. a) You can set a variable to 0. b) You can set a variable = another variable. c) You can increment a variable(only by 1), and its a post increment. d) You can loop. So, if you were to say loop(v1) and v1 = 10, your loop would execute 10 times, but the value in v1 wouldn't change so the first line in the loop can change value of v1 without chaning the no of times you loop. You need to do 2 things. (i) Write a function that decrements by 1. (ii) Write a function that subtracts one variable from another. You can use as many variable as you need, there are no negetive numbers, all numbers are integers. You do not know the size of the integers, they could be infinitely large, so you can't count on truncating at any point. There are NO comparisons allowed, no if statements or anything like that. |
||
Title: Re: Abstract Computer Post by SMQ on Sep 14th, 2006, 10:55am here (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=riddles_cs;action=display;num=1147791434) --SMQ |
||
Title: Re: Abstract Computer Post by irrational on Sep 14th, 2006, 11:55am Sorry for the re-post. :-[ :-[ |
||
Title: Re: Abstract Computer Post by SMQ on Sep 14th, 2006, 12:06pm No need to be that embarrassed about it. ;) Happens all the time around here, and we all know that the Search functions are rudimentary at best... --SMQ |
||
Powered by YaBB 1 Gold - SP 1.4! Forum software copyright © 2000-2004 Yet another Bulletin Board |