http://projecteuler.net/problem=63
Powerful digit counts
The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power.
How many n-digit positive integers exist which are also an nth power?
http://projecteuler.net/problem=63
Powerful digit counts
The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power.
How many n-digit positive integers exist which are also an nth power?
http://projecteuler.net/problem=53
Combinatoric selections
There are exactly ten ways of selecting three from five, 12345:
123, 124, 125, 134, 135, 145, 234, 235, 245, and 345
In combinatorics, we use the notation, 5C3 = 10.
where r n, n! = n(n1)…321, and 0! = 1.How many, not necessarily distinct, values of nCr, for 1
n
100, are greater than one-million?
http://projecteuler.net/problem=56
Powerful digit sum
A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1.
Considering natural numbers of the form, ab, where a, b
100, what is the maximum digital sum?
http://projecteuler.net/problem=28
Number spiral diagonals
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:
2122 23 2425
2078910
19 612 11
1854312
1716 15 1413
It can be verified that the sum of the numbers on the diagonals is 101.
What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed in the same way?
http://projecteuler.net/problem=40
Champernowne’s constant
An irrational decimal fraction is created by concatenating the positive integers:
0.123456789101112131415161718192021…
If dn represents the nth digit of the fractional part, find the value of the following expression.
d1
d10
d100
d1000
d10000
d100000
d1000000
http://projecteuler.net/problem=48
Self Powers
The series, 11 + 22 + 33 + … + 1010 = 10405071317.
Find the last ten digits of the series, 11 + 22 + 33 + … + 10001000.
Recently, I’ve been typing more Ruby then usual. In Ruby you can have a fairly big number.
http://projecteuler.net/problem=25
1000-digit Fibonacci number
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn
1 + Fn
2, where F1 = 1 and F2 = 1.
The 12th term, F12, is the first term to contain three digits.
What is the first term in the Fibonacci sequence to contain 1000 digits?
Recently, I had received an email from someone asking me how to obtain all sentences containing a specific word. So, I made this quick post. The code below shows how to use regular expressions to parse all sentences from text, then check to see if the sentence contains a specific word.
//Look for sentences containing the word "bank" string word = "bank"; //Text String string fulltext = @"Starting in the early 1960s federal banking regulators interpreted provisions of the Glass–Steagall Act to permit commercial banks and especially commercial bank affiliates to engage in an expanding list and volume of securities activities. By the time the affiliation restrictions in the Glass–Steagall Act were repealed through the Gramm–Leach–Bliley Act of 1999 (GLBA), many commentators argued Glass–Steagall was already “dead.” Most notably, Citibank’s 1998 affiliation with Salomon Smith Barney, one of the largest US securities firms, was permitted under the Federal Reserve Board’s then existing interpretation of the Glass–Steagall Act. President Bill Clinton publicly declared ""the Glass–Steagall law is no longer appropriate."" Many commentators have stated that the GLBA’s repeal of the affiliation restrictions of the Glass–Steagall Act was an important cause of the late-2000s financial crisis. Some critics of that repeal argue it permitted Wall Street investment banking firms to gamble with their depositors' money that was held in affiliated commercial banks. Others have argued that the activities linked to the financial crisis were not prohibited (or, in most cases, even regulated) by the Glass–Steagall Act. Commentators, including former President Clinton in 2008 and the American Bankers Association in January 2010, have also argued that the ability of commercial banking firms to acquire securities firms (and of securities firms to convert into bank holding companies) helped mitigate the financial crisis."; //Match Collection for every sentence MatchCollection matchSentences = Regex.Matches(fulltext, @"([A-Z][^\.!?]*[\.!?])"); //Alternative pattern : @"(\S.+?[.!?])(?=\s+|$)" //counter for sentences. int foundSentenceWithWord = 0; foreach (Match sFound in matchSentences) { foreach (Capture capture in sFound.Captures) { string current_sentence = capture.Value; //if you don't want to match for words like 'bank'er or 'bank'ing //use the word boundary "\b" //change this pattern to @"\b"+word+@"\b" Match matchWordInSentence = Regex.Match(capture.Value, word, RegexOptions.IgnoreCase); if (matchWordInSentence.Success) { Console.WriteLine("Sentence Found Containing '" + word+"' :"); Console.WriteLine(current_sentence); Console.WriteLine(); foundSentenceWithWord++; } } } Console.WriteLine(); Console.WriteLine("Found " + foundSentenceWithWord + " Sentences Containing the word '" + word + "'"); Console.WriteLine(); |
How to split apart a GIF image frame by frame, and save each frame as PNG into a sub-folder.
To achieve this I will be using ImageMagick
http://www.imagemagick.org/
Download, Install and locate an executable named convert.exe
I created a folder on my C: Drive called
/ImageConversion/
Place your GIFs into the ImageConversion Folder, also copy convert.exe into there as well. So the folder should look like this:

Execute this code:
//get all files in folder string[] files = Directory.GetFiles(@"c:\ImageConversion\"); //loop through each file foreach (string file in files) { //check if .GIF string ext = Path.GetExtension(file); if (ext == ".gif") { Console.WriteLine("Splitting : "+file); //Get the name of the file without extension string filenameNoExt = Path.GetFileNameWithoutExtension(file); //Get the file name with extention string filenameExt = Path.GetFileName(file); Console.WriteLine(); //Create a Sub Directory with the same as the GIF's filename Directory.CreateDirectory(@"c:\ImageConversion\"+filenameNoExt); Process imProcess = new Process(); //Arguments string im_command = @"c:\ImageConversion\" + filenameExt + @" -scene 1 +adjoin -coalesce c:\ImageConversion\" + filenameNoExt + @"\" + filenameNoExt + ".png"; imProcess.StartInfo.UseShellExecute = false; imProcess.StartInfo.RedirectStandardOutput = true; imProcess.StartInfo.FileName = @"c:\ImageConversion\convert"; imProcess.StartInfo.Arguments = im_command; imProcess.Start(); imProcess.WaitForExit(); } } |
That’s it, you’re done.
Now the ImageConversion folder should be populated with a folder for every gif containing every frame as an individual png.
For this example, I will be downloading all the .gifs from a specific page on imgur. Then, I will save them into a folder called _Images.
This is the url to the specific page I will be downloading images from http://imgur.com/a/GPlx4
Below is C# code that will:
-use a WebClient.DownloadString() to download the html into a string
-parse out specific image links from the returned html string using regular expressions
-use another WebClient.DownloadFile() to download each image link parsed
WebClient wchtml = new WebClient(); string htmlString = wchtml.DownloadString("http://imgur.com/a/GPlx4"); int mastercount = 0; Regex regPattern = new Regex(@"http://i.imgur.com/(.*?)alt=""", RegexOptions.Singleline); MatchCollection matchImageLinks = regPattern.Matches(htmlString ); foreach (Match img_match in matchImageLinks) { string imgurl = img_match.Groups[1].Value.ToString(); Regex regx = new Regex("http://([\\w+?\\.\\w+])+([a-zA-Z0-9\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)_\\-\\=\\+\\\\\\/\\?\\.\\:\\;\\'\\,]*)?", RegexOptions.IgnoreCase); MatchCollection ms = regx.Matches(imgurl); foreach (Match m in ms) { Console.WriteLine("Downloading.. " + m.Value); mastercount++; try { WebClient wc = new WebClient(); wc.DownloadFile(m.Value, @"C:\_Images\bg_" + mastercount + ".gif"); Thread.Sleep(1000); } catch (Exception x) { Console.WriteLine("Failed to download image."); } break; } } |
Output: C:\_Images