Jump to content
BrainDen.com - Brain Teasers

Anza Power

Members
  • Posts

    79
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by Anza Power

  1. ^ 5.999999... (continue forever) is actually 6. And if it doesn't continue forever then at some point you will get 6n-2...
  2. In case the above proof seems fishy to you:
  3. Yes, the volume is in units of meter3, 1 m3 = 1000 liters.
  4. Also: http://projecteuler.net/problem=55
  5. Code: #include <iostream> #define BUF_SIZE 100 using namespace std; void putInArray(int num, int* buf){ for(int i=0;i<BUF_SIZE;i++){ buf[i] = num % 10; num = num / 10; } } bool isPalindrom(int* buf){ int i=0, j=BUF_SIZE-1; while(buf[j]==0 && j>0){ j--; } while(i<j){ if(buf[i] != buf[j]){ return false; } i++; j--; } return true; } void applyIteration(int* buf){ int i=0, j=BUF_SIZE-1; while(buf[j]==0 && j>0){ j--; } while(i<=j){ int temp = buf[i] + buf[j]; buf[i++] = temp; buf[j--] = temp; } for(int i=0;i<BUF_SIZE-1;i++){ buf[i+1] += buf[i] / 10; buf[i] = buf[i] % 10; } } bool isLychrel(int* buf){ for(int i=1;i<50;i++){ applyIteration(buf); if(isPalindrom(buf)){ return false; } } return true; } int main() { int buf[BUF_SIZE]; for(int num=0;num<10000;num++){ putInArray(num,buf); if(isLychrel(buf)){ cout << num << " is Lychrel " << endl; } } }
  6. Even though we still don't know in case of irrational numbers,, we continue. Same as last time, except this time I'm allowing you to choose a descrete generator over an infinite range, for example a Poisson random variable, can you choose one thatyou can use to generate something with probability of 1/n where you can guarantee the number of times you'll need it beforehand?
  7. In practice yeah that would be the best solution since the probability of running forever goes to 0 exponentially fast. However the question here is: can you guarantee the number of "dice throws" you need beforehand?
  8. You're on to something but the proof isn't complete. The limit M(n) is is different for each n, so for example it could be that for rng(3) you use your generator just once and for rng(7) you need it 1023 times.
  9. You must solve before reading this one. Ok so we saw that a uniform binary number generator (fair coin) isn't good for us when we want to generate stuff with probability 1/n where n isn't a power of 2. So instead of a [0.5 , 0.5] generator, I am allowing you to customize your own random generator, namely you choose some k>1 and give me {p1...pk} and I will give you a random number generator that generates numbers between 1 and k with those probabilities. What kind of generator do you choose and how will you use it to generate numbers with probability 1/n? (note again I ask that your algorithm guarantee not to run for ever, as in for every n exists M such that you use the customized generator at most M times)
  10. I don't think that the logic there quite works. Certain results could be ignored (conditional on what has been generated) to make everything divisible by 3. Actually it is correct. Let's assume the upper bound is 8 calls, but if your algorithm sees 10001 then it returns 3, then we say that all 2^3 = 8 sequences of the form 10001xxx result in 3. Congratulations to witzar...
  11. You are a programmer, you want to make a function rand(n) that takes an integer n>1 and returns a random integer in the range {1...n} with uniform probability. At you disposal is a binary random number generator which generates 0's and 1's with equal probability (a fair coin) you can use it as many times as you want. Can you do this and guarantee your program won't run forever?
  12. Hi. Can you please define random cuts? you are stepping into the problem in Bertrand's Paradox.
  13. This is a continuation on BMAD's Ok so same rules as before, assume that N>d: If d=2, which player has the winning strategy given N? If d=3, which player has the winning strategy given N? What is the general rule for arbitrary N and d?
  14. Ah ok I see, here's a better one. That's cool, now for explanation... triangle_narrow.html
  15. I think you have a problem, say the coin types were as follows: 0 1 2 3 A B C A Coin 0 will go to pile A, coin 1 to B and 2 to C, but in the process you have compared coin 0 with 2 coins so you can't compare it against coin 3.
  16. I don't see what's happening... Attached are two HTML files that do this, one that has a point moving around and one that draws a line so you can see the entire path. You'll need an updated browser to view these because they're HTML5... triangle.html triangle_history.html
  17. The cases of 3 and 4 both match my answer above, in case of four people you and the person right in front of you have 1/3 chance each and the two others who are beside you have 1/6 chance each...
×
×
  • Create New...