Jump to content

phillip1882

Senior Members
  • Posts

    58
  • Joined

  • Last visited

Everything posted by phillip1882

  1. i'm afraid your problem is poorly worded, i can't make much heads or tails of what you're looking for. it sounds like you're looking for a probabilistic model for determining what numbers occur with what frequency in each column. here would be one way you could write such a program. File = open("data.txt","r") data =[] for line in File: data += [line.split()] max = 0 for i in range(0,len(data)): for j in range(0,len(data[0])): data[i][j] = int(data[i][j]) if data[i][j] > max: max = data[i][j] array = list(range(0,max)) x = input("which column would you like to investigate?") for i in range(0,len(data)): array[data[i][x]] += 1 total = 0.0 for i in range(0,len(array)): total += array[i] for i in range(0,len(array)): array[i] = array[i] /total print("the probabilities are:") for i in range(0,len(array)): print(i,array[i]*100)
  2. whoops. hehe, i was thinking that '(A'B) <=> (AB') which of course it is not.
  3. i also might recommend wire-world cellular automata. its fairly simple to construct logic gates, and see the results.
  4. A'B'C' + A'B'C + A'BC' + AB'C' A'B'(C' +C) +A'BC' +AB'C' A'B' +C'(A'B +AB') A'B' +C' so yeah there's something wrong with the way you have the equation.
  5. i too am unsure what exactly the question is asking. logical implication, if a then b is however equivalent to not a or b ie. say i have the statement if it rains then it's cloudy. this is equiavent to its not raining, or its cloudy. the truth table is as follows. A | B | A->B 0 0 1 0 1 1 1 0 0 1 1 1
  6. at roughly multiplying two 2000 bit integers, i finally got an elapsed time recording of 0.016 seconds. doubling that, i got an elapsed time of 0.032 seconds. doubling it once more, i get roughly .125 seconds. doubling yet again, i get roughly .465 seconds. so it does indeed seem to be exhibiting n^2 behavior in terms of time, even though number of operations is linearly increasing. i guess this isn't too surprising, since I'm doubling the size of two inputs, which is more like multiplying by 4 than 2. still, it's an interesting algorithmic approach.
  7. phillip1882

    Taxes

    the best use for taxes? how about we only use them for the intended purpose, which is police, fire department, and military? i know i'm in the minorty here, but i belive that people, under their own imputus, will make much more progress the less impedement they are given. and the government has never, as far as i'm aware, been good at health care, or education. either they rack up massive debt in implementation, or they provide a substandard quality.
  8. hmm, fair enough. let's double it 3 more times. with 56 and 48 bits, 568 operations, and i still get .02 seconds with 112 and 96 bits, 1178 operations, and i still get .02 seconds. finally, with 224 and 192 bits, 2362 operations, and i still get .02 seconds. (from www.ideone.com ) <BR>edit: i tried timing it with my own cpu rather than a website, even at 224, 192 bits, it was taking 0 seconds!<BR>now that is a fast multiplication algorithm!<BR>
  9. i'm not sure its as bad as O(n^2) for peasent multiplication. for example, lets take 32767 * 8191; the worst case. with a length of 14 and 12 bits, it should take roughly 168 operations. so let's count them and see. a = 0b11111111111111 b = 0b111111111111 r1 = 0 r2 = 0 count = 0 while a > 0: if a & 1 == 1: r2 = b while r2 != 0: r1, r2 = r1^r2, (r1&r2)<<1 #add function count += 3 a >>= 1 b <<= 1 count += 2 print(count) i get 142 for an expected 168 operations. but more importantly, the above code runs in about .02 seconds. now what happens if i double the size if the input? i get roughly 290 operations, for an expected 28*24 = 672 number of operations. but agian, more importantly the code still runs in about .02 seconds.
  10. three men have watches that are all oddly set. the first man's watch gets five minutes faster every hour. he reports the current time as 3:15 pm. the second man's watch counts backward one third as fast. he reports the time as 2:30 pm. the third man's watch moves at a standard pace, but marks 20 hours in a day, and 100 minutes in an hour. he reports the time as 5:45 pm. will it ever be the case that the three men report the same time?
  11. as the previous two posters said, logarithms is the way. if you don't have a calculator, you can aproximate a logarithm using euler's method, which is quite lengthy. continuously multiplying by the factor is faster. or a slide rule could be helpful.
  12. python is what i like to call a "natural" programming language in the sense that it does what you want it to do with the least amount of fuss. for example, here would be bubble sort in python. import random def bubbleSort(array): for i in range(0,len(array)): for j in range(i+1,len(array)): if array[j-1] > array[j]: array[j-1], array[j] = array[j], array[j-1] return array arrayToSort = list(range(0,100)) random.shuffle(arrayToSort) print arrayToSort print bubbleSort(arrayToSort) if you tried doing the same program in c, you would need nearly twice the number of lines. it definitely takes some time to learn though.
  13. so, here you can use newtons method, or even a standard guess and check in a program to get a better and better approximations of the solution, assuming one exists. 85^4/((85^4/x)+ 2*85^2*x^2 +x^5) - 5 =0 here would be the guess and check program, in python. def guessCheck(value): a =1.0; b = value/2.0 mid = (a+b)/2.0 aprox = value**4/(value**4 /mid +2*value**2 *mid**2 +mid**5) -5.0 while aprox > 0.00001 or aprox < -0.00001: if aprox > 0: a = mid else: b = mid mid = (a+b)/2.0 aprox = value**4/((value**4 /mid) +2*value**2 *mid**2 +mid**5) -5.0 return mid print guessCheck(85) i haven't read your paper, so you may need to correct the above formula but hopefully you get the general gist. to execute the above code, you can either download a copy of python for free at www.python.org or you can go to the site www.ideone.com to have an online compiler, that requires no download. edit: the above isnt looking right in the the post, not sure why, but the if and else should be 3 spaces i front of the while, with the a = and b= being indented anther 3 spaces, , and the mod and aprox on the same indent as the if else.
  14. here's a fun one. the golden ratio; 1.618... is equal to... sqrt(1+sqrt(1+sqrt(1+... or more simply (1+sqrt(5))/2 newton provided an interesting method for calculating the square root; namely x1 = x0 -(x0 ^2 -a)/(2*x0) which increases the accuracy of the aproximation quadratically. as an example, sqrt(27) =? initial guess, 5. x1 = 5 - (25-27)/10 x1 = 5.2 x2 = 5.2 -(27.04 -27)/10.4 x2 = 5.196 err i think you have to have access to a unit line; other wise who's to say the 19 isn't 1? also even if i didnt, i can divide any line an equal number of times, so i certainly can contruct a line of length 1 given a line of length 19.
  15. err, the easily worded problem... is actually quite possible. asumming you have a unit length line, and a given line, the square root will simply be the concatination of the two lines, the mid point of the distance between them used to make a circle, and a perpendicular line from the meeting point to the circle.
  16. so hear is a few problems i see, and why i think God might, i emphisize the word might, be nessicary. so let's start with morality. i think most poeple can agree, there are some, though not many "concrete" rules, such as rules against murder, rape, theft, torture, etc. obviously these are relative in the sense we can disobey these rules if we see fit, but there are severe consquences for so doing. where do these rules come from? not from nature, animals use and abuse violence in abundance. not from government, who often implements such methods, at the cost of society. we can only say one of two things, either they come from ourselves, or they come from some entity outside ourselves. i could exptrapolate this futher, but for now let's move on. how about death? even if you're athiest and thus desire nothing after death, i think most resonable poeple can agree, the thousands of near death experances, suggests there just might be something there. now i must confess, i've seen the you-tube video on the "God helmet" so it's quite possible these experiances are hulicinated. never the less, people seem to have such similar experiances to the point of suggesting that there is an after life of some kind. finally, let's take the vastness of space. even assuming it really is only 13.7 billion light years across, (i have my reservations, but for now i won't argue the point.) do you really belive physics and blind chance created it? for example, take the big bang. what banged? where did all the particles and anti particles come from? i'm not suggesting that we should accept God as the final answer here. we should question deeply and search for answers. but ultamately, we come to a point where the questions themselves make little sense. I realize even a child could ask, "what created God?" and to that question, i would respond in the following way. which is more common, to get order out of disorder, or disorder out of order? unless an active outside agent acts on a disordered field, you can't get order. a billion tornadoes going thorough a junk pile will never assemble an airplane.
  17. i'm not aguing with you; for picking 5 items from a group of 20, you are correct, 15504 is the number. however, i am considering the number of ways you can get a group of 10 items from 20. i think this is a better representation of the problem, as though person A has 15504 choices for selection, person B must choose from the 18476 choices to eleminate as many of person A's choices as possible, and each choice of 10 will eliminate roughly 252 choices. i could obviously be wrong with my "logic" here, it's a gut call. <BR>(to put it a bit more succently, i'm trying to factor in the overlap problem.)
  18. right, a cpu program. basically what i did was randomly select groups of 10 untill i got every group of 5 covered, and then tried to minimize it as much as possible. personally i don't think it should actually require more than 74 groups of 10. 20!/(10!*10!) = 18476 10!/(5!*5!) = 252 18476/252 aprox = 74
  19. using an ugly "brute force" attack, i get the number of nessicary groups of 10 to be at most 2540.
  20. another great site is topcoder.com basically, i would recommend the following. the key in my opinion is not so much how to program a computer, but how to understand problem solving in general. so my suggestion would be this, take some practice problems form the book, write a commented version of what you need to do (high level pseudo-code) and then try coding it for real. if the coded version doesn't work, give it 6-7 more tries, correcting any obvious errors. as an example, many programming books have sorting an array as a practice problem. so your step 1 might look like the following. //go through the array. //if the previous element is greater than the next element, //swap them. //do this until no elements need to be swapped. try step 2 for yourself.
  21. vastor: a picture isn't very useful without the question itself. are you looking for t? then the slope of the line is all you need. (40 -30)/(9-12) = -10/3 40 -10 = 30 9 +3 =12 30 -10 = 20 12 +3 =15 20 -10 = 10 15+3 = 18 10 -10 = 0 18+3 = 21 21 = t or more simply 40/10 = 4, 4*3 +9 = 21. i'm not quite sure what you're trying to do with the area of a triangle aproach. i see your logic in the equation, and you're correct; area of left triangle + area of right triangle = area of whole triangle. i would need to see your teacher's logic as well though to understand what's going on.
  22. bah you guys are too quick. i modified the original question because i quickly realized it was too easy.
  23. out of a set of 12 lights, 3 are burned out. you have a set of 12 light switches in front of you numbered 1-12, with the 12 lights behind a glass wall. each light switch will toggle the state of 2 lights. the 2 lights it toggles will be 2*n %13, and 3*n %13. for example, light switch 7 will toggle light 1, and light 8. is it possible that: no matter what three lights are burned out, you can light up the remaining 9 lights?
  24. hmmm good point about the random function. random 1000 is sufficient or even random 200; random 100 wouldn't be. basically i should see in your submitted code that you are attempting "fair play" and not just always betting 1 point. on each turn your basically trying to under bid your opponent. if you do so, you win the bet. so let's say player 1 wagers 10 points and player 2 wagers 30 points. player 1 wins and gets +30 points, and player 2 gets -30 points (that is he loses that many points from total score).
  25. so here's my challange. the first place contestant will recieve 10 american dollars from me. each player will start off with 10000 points. two players will face off at a time, and wager a certian number of points for each turn. the player with the lower wager will win all the wagered points from the player with the higher. however, the average of all wagers must be 100 points for each player. (that is, if i select any 100 bets, i should come up with an average of 100 or more for those bets your program produces.) once a player drops below 100 points, he loses. the game will be elimination style, once you lose, you're out of the contest. here's your function definition: int myusername(int myPoints, int opPoints, int betNum, int[] myBets, int[] opBets){ int betAmount; //must average 100 or more over a period of 100 bets. /* your program goes here. */ return betAmount; } note that myBets and opBets wil keep track of up to 100 previous bets. you may not keep track of bets yourself. one thing i forgot to note. the most recent bet will be betNum%100; with bets wrapping cylicly. ie on the the 101st bet; the arrays will be... bets = [100th, 101st, 2nd, 3rd, 4th, 5th... 99th]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.