# Search Results

• ### Project Euler 4: (Iron)Python

##### - by Ben Griswold
In my attempt to learn (Iron)Python out in the open, here’s my solution for Project Euler Problem 4.  As always, any feedback is welcome. # Euler 4 # http://projecteuler.net/index.php?section=problems&id=4 # Find the largest palindrome made from the product of # two 3-digit numbers. A palindromic number reads the # same both ways. The largest palindrome made from the # product of two 2-digit numbers is 9009 = 91 x 99. # Find the largest palindrome made from the product of # two 3-digit numbers. import time start = time.time() def isPalindrome(s): return s == s[::-1] max = 0 for i in xrange(100, 999): for j in xrange(i, 999): n = i * j; if (isPalindrome(str(n))): if (n > max): max = n print max print "Elapsed Time:", (time.time() - start) * 1000, "millisecs" a=raw_input('Press return to continue')

• ### Project Euler 6: (Iron)Python

##### - by Ben Griswold
In my attempt to learn (Iron)Python out in the open, here’s my solution for Project Euler Problem 6.  As always, any feedback is welcome. # Euler 6 # http://projecteuler.net/index.php?section=problems&id=6 # Find the difference between the sum of the squares of # the first one hundred natural numbers and the square # of the sum. import time start = time.time() square_of_sums = sum(range(1,101)) ** 2 sum_of_squares = reduce(lambda agg, i: agg+i**2, range(1,101)) print square_of_sums - sum_of_squares print "Elapsed Time:", (time.time() - start) * 1000, "millisecs" a=raw_input('Press return to continue')

• ### Project Euler 13: (Iron)Python

##### - by Ben Griswold
In my attempt to learn (Iron)Python out in the open, here’s my solution for Project Euler Problem 13.  As always, any feedback is welcome. # Euler 13 # http://projecteuler.net/index.php?section=problems&id=13 # Work out the first ten digits of the sum of the # following one-hundred 50-digit numbers. import time start = time.time() number_string = '\ 37107287533902102798797998220837590246510135740250\ 46376937677490009712648124896970078050417018260538\ 74324986199524741059474233309513058123726617309629\ 91942213363574161572522430563301811072406154908250\ 23067588207539346171171980310421047513778063246676\ 89261670696623633820136378418383684178734361726757\ 28112879812849979408065481931592621691275889832738\ 44274228917432520321923589422876796487670272189318\ 47451445736001306439091167216856844588711603153276\ 70386486105843025439939619828917593665686757934951\ 62176457141856560629502157223196586755079324193331\ 64906352462741904929101432445813822663347944758178\ 92575867718337217661963751590579239728245598838407\ 58203565325359399008402633568948830189458628227828\ 80181199384826282014278194139940567587151170094390\ 35398664372827112653829987240784473053190104293586\ 86515506006295864861532075273371959191420517255829\ 71693888707715466499115593487603532921714970056938\ 54370070576826684624621495650076471787294438377604\ 53282654108756828443191190634694037855217779295145\ 36123272525000296071075082563815656710885258350721\ 45876576172410976447339110607218265236877223636045\ 17423706905851860660448207621209813287860733969412\ 81142660418086830619328460811191061556940512689692\ 51934325451728388641918047049293215058642563049483\ 62467221648435076201727918039944693004732956340691\ 15732444386908125794514089057706229429197107928209\ 55037687525678773091862540744969844508330393682126\ 18336384825330154686196124348767681297534375946515\ 80386287592878490201521685554828717201219257766954\ 78182833757993103614740356856449095527097864797581\ 16726320100436897842553539920931837441497806860984\ 48403098129077791799088218795327364475675590848030\ 87086987551392711854517078544161852424320693150332\ 59959406895756536782107074926966537676326235447210\ 69793950679652694742597709739166693763042633987085\ 41052684708299085211399427365734116182760315001271\ 65378607361501080857009149939512557028198746004375\ 35829035317434717326932123578154982629742552737307\ 94953759765105305946966067683156574377167401875275\ 88902802571733229619176668713819931811048770190271\ 25267680276078003013678680992525463401061632866526\ 36270218540497705585629946580636237993140746255962\ 24074486908231174977792365466257246923322810917141\ 91430288197103288597806669760892938638285025333403\ 34413065578016127815921815005561868836468420090470\ 23053081172816430487623791969842487255036638784583\ 11487696932154902810424020138335124462181441773470\ 63783299490636259666498587618221225225512486764533\ 67720186971698544312419572409913959008952310058822\ 95548255300263520781532296796249481641953868218774\ 76085327132285723110424803456124867697064507995236\ 37774242535411291684276865538926205024910326572967\ 23701913275725675285653248258265463092207058596522\ 29798860272258331913126375147341994889534765745501\ 18495701454879288984856827726077713721403798879715\ 38298203783031473527721580348144513491373226651381\ 34829543829199918180278916522431027392251122869539\ 40957953066405232632538044100059654939159879593635\ 29746152185502371307642255121183693803580388584903\ 41698116222072977186158236678424689157993532961922\ 62467957194401269043877107275048102390895523597457\ 23189706772547915061505504953922979530901129967519\ 86188088225875314529584099251203829009407770775672\ 11306739708304724483816533873502340845647058077308\ 82959174767140363198008187129011875491310547126581\ 97623331044818386269515456334926366572897563400500\ 42846280183517070527831839425882145521227251250327\ 55121603546981200581762165212827652751691296897789\ 32238195734329339946437501907836945765883352399886\ 75506164965184775180738168837861091527357929701337\ 62177842752192623401942399639168044983993173312731\ 32924185707147349566916674687634660915035914677504\ 99518671430235219628894890102423325116913619626622\ 73267460800591547471830798392868535206946944540724\ 76841822524674417161514036427982273348055556214818\ 97142617910342598647204516893989422179826088076852\ 87783646182799346313767754307809363333018982642090\ 10848802521674670883215120185883543223812876952786\ 71329612474782464538636993009049310363619763878039\ 62184073572399794223406235393808339651327408011116\ 66627891981488087797941876876144230030984490851411\ 60661826293682836764744779239180335110989069790714\ 85786944089552990653640447425576083659976645795096\ 66024396409905389607120198219976047599490197230297\ 64913982680032973156037120041377903785566085089252\ 16730939319872750275468906903707539413042652315011\ 94809377245048795150954100921645863754710598436791\ 78639167021187492431995700641917969777599028300699\ 15368713711936614952811305876380278410754449733078\ 40789923115535562561142322423255033685442488917353\ 44889911501440648020369068063960672322193204149535\ 41503128880339536053299340368006977710650566631954\ 81234880673210146739058568557934581403627822703280\ 82616570773948327592232845941706525094512325230608\ 22918802058777319719839450180888072429661980811197\ 77158542502016545090413245809786882778948721859617\ 72107838435069186155435662884062257473692284509516\ 20849603980134001723930671666823555245252804609722\ 53503534226472524250874054075591789781264330331690' total = 0 for i in xrange(0, 100 * 50 - 1, 50): total += int(number_string[i:i+49]) print str(total)[:10] print "Elapsed Time:", (time.time() - start) * 1000, "millisecs" a=raw_input('Press return to continue')

• ### Project Euler 7: (Iron)Python

##### - by Ben Griswold
In my attempt to learn (Iron)Python out in the open, here’s my solution for Project Euler Problem 7.  As always, any feedback is welcome. # Euler 7 # http://projecteuler.net/index.php?section=problems&id=7 # By listing the first six prime numbers: 2, 3, 5, 7, # 11, and 13, we can see that the 6th prime is 13. What # is the 10001st prime number? import time start = time.time() def nthPrime(nth): primes = [2] number = 3 while len(primes) < nth: isPrime = True for prime in primes: if number % prime == 0: isPrime = False break if (prime * prime > number): break if isPrime: primes.append(number) number += 2 return primes[nth - 1] print nthPrime(10001) print "Elapsed Time:", (time.time() - start) * 1000, "millisecs" a=raw_input('Press return to continue')

• ### Project Euler 3: (Iron)Python

##### - by Ben Griswold
In my attempt to learn (Iron)Python out in the open, here’s my solution for Project Euler Problem 3.  As always, any feedback is welcome. # Euler 3 # http://projecteuler.net/index.php?section=problems&id=3 # The prime factors of 13195 are 5, 7, 13 and 29. # What is the largest prime factor of the number # 600851475143? import time start = time.time() def largest_prime_factor(n): max = n divisor = 2 while (n >= divisor ** 2): if n % divisor == 0: max, n = n, n / divisor else: divisor += 1 return max print largest_prime_factor(600851475143) print "Elapsed Time:", (time.time() - start) * 1000, "millisecs" a=raw_input('Press return to continue')

• ### Project Euler 1: (Iron)Python

##### - by Ben Griswold
In my attempt to learn (Iron)Python out in the open, here’s my solution for Project Euler Problem 1.  As always, any feedback is welcome. # Euler 1 # http://projecteuler.net/index.php?section=problems&amp;id=1 # If we list all the natural numbers below 10 that are # multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of # these multiples is 23. Find the sum of all the multiples # of 3 or 5 below 1000. import time start = time.time() print sum([x for x in range(1000) if x % 3== 0 or x % 5== 0]) print "Elapsed Time:", (time.time() - start) * 1000, "millisecs" a=raw_input('Press return to continue') # Also cool def constraint(x): return x % 3 == 0 or x % 5 == 0 print sum(filter(constraint, range(1000)))

• ### Project Euler 20: (Iron)Python

##### - by Ben Griswold
In my attempt to learn (Iron)Python out in the open, here’s my solution for Project Euler Problem 20.  As always, any feedback is welcome. # Euler 20 # http://projecteuler.net/index.php?section=problems&id=20 # n! means n x (n - 1) x ... x 3 x 2 x 1 # Find the sum of digits in 100! import time start = time.time() def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) print sum([int(i) for i in str(factorial(100))]) print "Elapsed Time:", (time.time() - start) * 1000, "millisecs" a=raw_input('Press return to continue')

• ### What's the best Open Php newsletter manager ?

##### - by Bilel
Hi :) I'm looking for a nice newsletter management solution. I tried CCmail a good script but whaere I can't imort usernames !!! I would like to find a system that is able to import Opt-in lists in the following format : John Smith;[email protected];other paramaeters...;[like] ;Male;Age... I will develop my own module if I could find another emailing manager Are you already satisfied with a similar application with a trusted (spam-prevention) emailer ? Thank you :)

• ### select the first and the last two elements

##### - by Luca Romagnoli
hi i have a table with this elements id name 1 luke 2 johnny 3 perry 4 jenny 5 mark I have to do a query that take the first element and the lasts 2 i this example 1 luke 4 jenny 5 mark how can i do? thanks

• ### Algorithm to compare people names to detect identicalness

##### - by Pentium10
I am working on address book synchronization algorithm. I would like to reuse some code if there exists, but couldn't find one yet. Does someone know about an algorithm that will tell me in numbers/float/procent how much two names are identical. Levenstein distance is not good in this approach, as names and our adddress books are matching the begining of each of the name sections. John Smith should match Smith Jon, Jonathan Smith, Johnny Smith

• ### SQL & Linq To SQL Help

##### - by cre-johnny07
I have a table which is some thing like below.. Date ID 2009-07-01 1 2009-07-01 2 2009-07-01 3 2009-08-01 4 2009-08-01 5 2009-08-01 6 2009-09-01 7 2009-09-01 8 2009-10-01 9 2009-10-01 10 2009-11-01 11 .... Now I need to write a query which will show a output like below. Date Start End 2009-07 1 3 2009-08 4 6 2009-09 7 8 ... How can I do this.. Any help would be highly appreciated Thanking In Advance Johnny

• ### Efficient way to store tuples in the datastore

##### - by Drew Sears
If I have a pair of floats, is it any more efficient (computationally or storage-wise) to store them as a GeoPtProperty than it would be pickle the tuple and store it as a BlobProperty? If GeoPt is doing something more clever to keep multiple values in a single property, can it be leveraged for arbitrary data? Can I store the tuple ("Johnny", 5) in a single entity property in a similarly efficient manner?

• ### Alice In Wonderland: Good, but not Great

##### - by Theo Moore
We went to see Alice In Wonderland today. We both like Tim Burton a lot (the stranger the better) and like Johnny Depp very well also. After seeing all the previews and such, we were fired up to see this film. Honestly, I thought it was good but not great. I was prepared to be wow-ed, but I wasn't. Perhaps I expected too much. I did like it, but I'll not own it nor would I expect to see it again...unless someone I know decides they want to see it. I was about to say something to reassure you that I wasn't going to provide any spoilers but two things occurred to me: one, I never give spoilers and two, why worry about spoilers for a film that so closely follows a book? My comments about the film are hard to describe, but the basic gist is that it doesn't really feel like it..."works" to me. I can't get any more specific than that, much as I'd like to do so. Something about it seems sort of disjointed and not in that Alice way you'd expect. My only specific comment is that I didn't like the actor who plays Alice very well. She was very flat and just didn't sell he character to me. She seemed a bit, well, plastic. Depp was as good as you'd expect him to be, I am happy to say. Obviously Lewis Carroll couldn't have imagined this made into film, but I can't help thinking that he'd see this and say that Depp was the perfect Mad Hatter. So, I'd definitely recommend seeing it (we saw it in 3D which was cool, but not really necessary) at least once, but don't be surprised if you're kinda meh afterwards.

• ### JavaOne 2012 Day 1

##### - by Geertjan
Day 1, Sunday, started the night before for those attending the NetBeans Party at Johnny Foley's: Invitations had been sent out prior to the party to all speakers for NetBeans Day, as well as speakers in JavaOne sessions where NetBeans is going to be used. That turns out to be around 40 people, who hung out until quite late, with snacks and drinks. Next day, NetBeans Day had most sessions with completely packed rooms, which means there were around 300 people! Panel discussions around central themes in the NetBeans ecosystem (Java EE, JavaFX, and NetBeans Platform) were held, which resulted in a whole bunch of people up on stage throughout the day, such as this group of speakers in the Java EE session: From left to right above you see Sean Comerford from ESPN.com, John Yeary the Java EE panel moderator and JUG lead from Greenville, Cagatay Civici the PrimeFaces lead developer, Glenn Holmer long time NetBeans enthusiast (more on him below) from the Weyco Group, and NetBeans/Java EE book author David Heffelfinger. There were panels just like the above for JavaFX and the NetBeans Platform too, with very interesting and dynamic talks, such as one by JavaFX book authors Gail and Paul Anderson, who showed off this brilliant JavaFX/NetBeans Platform mashup: NetBeans Day ended with a good discussion about how to get involved in the NetBeans community, wrapping up with an award ceremony with two very special NetBeans community awards: Then everyone caught buses to the Masonic Auditorium, where 4 hours of keynotes took place. This is what the room looked like: The 4 hours ended with a very well received HTML5/NetBeans demo, showing of NetBeans IDE 7.3 features, by NetBeans director John Ceccarelli. And I liked this slide during an earlier keynote session by Oracle VP Hasan Rizvi: There was really a lot of love for NetBeans during the JavaOne keynote sessions and I don't remember hearing any other IDE being mentioned, in any way at all. Next there was the Duke's Choice Award ceremony, outside the Hilton in a cool lounge area, where, among others, Timon and Angelo from the NetBeans Platform community received their awards for AgroSense and MICE. In between all of the above, I met very many friends from previous conferences, as well as several new ones. It was clearly a great start to the conference. Looking forward to what the rest of the week will bring!

• ### New Feature! Automatic Categories for Geekswithblogs.net

##### - by Jeff Julian
One of the features we have been working on is a way to categorize posts without the need of all our bloggers getting on the same page with what categories we have and making them select the categories.  Johnny Kauffman, one of our team members at AJI Software, developed what we call the Sherlock Project over the past few months.  Sherlock is a category suggestion engine based on the content within the posts.  Now, after a post is published, Sherlock will investigate the content and come up with the suggested categories that content fits in.  This will now allow you to go to the specific topics you are interested in and see all the related posts. This is just the beginning, so many more opportunities will arise now that we have our content organized.  One of the first features I will be adding is RSS feeds for each category and sub category.  If you are into ALM, we will have a feed for that! I hope you enjoy these and the engine will continue to get better as we start testing the data.  I hope you are as excited about this as I am :D.  Technorati Tags: Geekswithblogs.net,Categories,Sherlock

• ### Track button click within a iframe

##### - by philgo20
Hi, Is it possible to track a button click within an iFrame if i don't have control over the external website or it's contents? (very fictionnal example)if i had an iframe like this: <iframe src="http://www.johnny.com/plugins/like.php?href=http%253A%252F%252Fexample.com%252Fpage%252Fto%252Flike&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

• ### How to get the position of a record in a table (SQL Server)

##### - by Peter Siegmann
Following problem: I need to get the position of a record in the table. Let's say I have five record in the table: Name: john doe, ID: 1 Name: jane doe, ID: 2 Name: Frankie Boy, ID: 4 Name: Johnny, ID: 9 Now, "Frankie Boy" is in the third position in the table. But How to get this information from the SQL server? I could count IDs, but they are not reliable, Frankie has the ID 4, but is in the third position because the record with the ID '3' was deleted. Is there a way? I am aware of ROW_RANK but it would be costly, because I need to select basically the whole set first before I can rank row_rank them. I am using MS SQL Server 2008 R2.

• ### C++ Sentinel/Count Controlled Loop beginning programming

##### - by Bryan Hendricks
Hello all this is my first post. I'm working on a homework assignment with the following parameters. Piecework Workers are paid by the piece. Often worker who produce a greater quantity of output are paid at a higher rate. 1 - 199 pieces completed \$0.50 each 200 - 399 \$0.55 each (for all pieces) 400 - 599 \$0.60 each 600 or more \$0.65 each Input: For each worker, input the name and number of pieces completed. Name Pieces Johnny Begood 265 Sally Great 650 Sam Klutz 177 Pete Precise 400 Fannie Fantastic 399 Morrie Mellow 200 Output: Print an appropriate title and column headings. There should be one detail line for each worker, which shows the name, number of pieces, and the amount earned. Compute and print totals of the number of pieces and the dollar amount earned. Processing: For each person, compute the pay earned by multiplying the number of pieces by the appropriate price. Accumulate the total number of pieces and the total dollar amount paid. Sample Program Output: Piecework Weekly Report Name Pieces Pay Johnny Begood 265 145.75 Sally Great 650 422.50 Sam Klutz 177 88.5 Pete Precise 400 240.00 Fannie Fantastic 399 219.45 Morrie Mellow 200 110.00 Totals 2091 1226.20 You are required to code, compile, link, and run a sentinel-controlled loop program that transforms the input to the output specifications as shown in the above attachment. The input items should be entered into a text file named piecework1.dat and the ouput file stored in piecework1.out . The program filename is piecework1.cpp. Copies of these three files should be e-mailed to me in their original form. Read the name using a single variable as opposed to two different variables. To accomplish this, you must use the getline(stream, variable) function as discussed in class, except that you will replace the cin with your textfile stream variable name. Do not forget to code the compiler directive #include < string at the top of your program to acknowledge the utilization of the string variable, name . Your nested if-else statement, accumulators, count-controlled loop, should be properly designed to process the data correctly. The code below will run, but does not produce any output. I think it needs something around line 57 like a count control to stop the loop. something like (and this is just an example....which is why it is not in the code.) count = 1; while (count <=4) Can someone review the code and tell me what kind of count I need to introduce, and if there are any other changes that need to be made. Thanks. [code] //COS 502-90 //November 2, 2012 //This program uses a sentinel-controlled loop that transforms input to output. #include <iostream> #include <fstream> #include <iomanip> //output formatting #include <string> //string variables using namespace std; int main() { double pieces; //number of pieces made double rate; //amout paid per amount produced double pay; //amount earned string name; //name of worker ifstream inFile; ofstream outFile; //***********input statements**************************** inFile.open("Piecework1.txt"); //opens the input text file outFile.open("piecework1.out"); //opens the output text file outFile << setprecision(2) << showpoint; outFile << name << setw(6) << "Pieces" << setw(12) << "Pay" << endl; outFile << "_____" << setw(6) << "_____" << setw(12) << "_____" << endl; getline(inFile, name, '*'); //priming read inFile >> pieces >> pay >> rate; // ,, while (name != "End of File") //while condition test { //begining of loop pay = pieces * rate; getline(inFile, name, '*'); //get next name inFile >> pieces; //get next pieces } //end of loop inFile.close(); outFile.close(); return 0; }[/code]

• ### How to get a list of names + a count of occurrences relating to the name from another table

##### - by Jacob Degeling
Hi, Hope my subject line was descriptive enough. Basically, I have a table called Students, and one called Absences. The Students table contains student information (Name, DOB, StudentID etc.), the Absences table contains any absences (Date, Reason, related by StudentID). I want to get a full list of the students, plus a count of their absences. Sample results would be: StudentName Absences ------------- ----------- Johnny 3 Mark 2 James 1 Anthony 0 Sharon 0 Can someone suggest a way I should tackle this problem? I would prefer to have a single SQL statement, possibly incorporating some views etc. Thanks, Jacob.

• ### Rails rabl json format

##### - by brabertaser1992
I'm displaying data from my db in json format using rabl to parse it for android... My json looks like so: [ { "bank":{ "central_office_address":"ololo", "license":"12312312", "location_id":3, "name":"Pbank", "tax_number":"12312312", "year_of_foundation":1987 } }, { "bank":{ "central_office_address":"sdfsdf sdf", "license":"321312", "location_id":3, "name":"Bbank", "tax_number":"321321", "year_of_foundation":1999 } } ] I need my json in a format like: { "contacts": [ { "id": "c200", "name": "Ravi Tamada", "email": "[email protected]", "address": "xx-xx-xxxx,x - street, x - country", "gender" : "male", "phone": { "mobile": "+91 0000000000", "home": "00 000000", "office": "00 000000" } }, { "id": "c201", "name": "Johnny Depp", "email": "[email protected]", "address": "xx-xx-xxxx,x - street, x - country", "gender" : "male", "phone": { "mobile": "+91 0000000000", "home": "00 000000", "office": "00 000000" } } ] } Such data is normally parsed in java.... My rabl view: object @banks attributes :central_office_address, :license, :location_id, :name, :tax_number, :year_of_foundation How do I change its output to match the second example?

• ### How do I change folder timestamps recursively?

##### - by MonkeyWrench32
I was wondering if anyone knows how to change the timestamps of folders recursively based on the latest timestamp found of the files in that folder. So for example: [email protected]:/media/media/MP3s/Foo Fighters/(1997-05-20) The Colour and The Shape\$ ls -alF total 55220 drwxr-xr-x 2 jon jon 4096 2010-08-30 12:34 ./ drwxr-xr-x 11 jon jon 4096 2010-08-30 12:34 ../ -rw-r--r-- 1 jon jon 1694044 2010-04-18 00:51 Foo Fighters - Doll.mp3 -rw-r--r-- 1 jon jon 3151170 2010-04-18 00:51 Foo Fighters - Enough Space.mp3 -rw-r--r-- 1 jon jon 5004289 2010-04-18 00:52 Foo Fighters - Everlong.mp3 -rw-r--r-- 1 jon jon 5803125 2010-04-18 00:51 Foo Fighters - February Stars.mp3 -rw-r--r-- 1 jon jon 4994903 2010-04-18 00:51 Foo Fighters - Hey, Johnny Park!.mp3 -rw-r--r-- 1 jon jon 4649556 2010-04-18 00:52 Foo Fighters - Monkey Wrench.mp3 -rw-r--r-- 1 jon jon 5216923 2010-04-18 00:51 Foo Fighters - My Hero.mp3 -rw-r--r-- 1 jon jon 4294291 2010-04-18 00:52 Foo Fighters - My Poor Brain.mp3 -rw-r--r-- 1 jon jon 6778011 2010-04-18 00:52 Foo Fighters - New Way Home.mp3 -rw-r--r-- 1 jon jon 2956287 2010-04-18 00:51 Foo Fighters - See You.mp3 -rw-r--r-- 1 jon jon 2730072 2010-04-18 00:51 Foo Fighters - Up in Arms.mp3 -rw-r--r-- 1 jon jon 6086821 2010-04-18 00:51 Foo Fighters - Walking After You.mp3 -rw-r--r-- 1 jon jon 3033660 2010-04-18 00:52 Foo Fighters - Wind Up.mp3 The folder "(1997-05-20) The Colour and The Shape" would have its timestamp set to 2010-04-18 00:52. Thanks in advance!