This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class t { | |
public static void main(String[] args) { | |
int current_val = 0, counter = 0; | |
for (int i = 1; i < 10000000; i++) { | |
current_val = i; | |
while (current_val != 1) { | |
current_val = calculateSquares(current_val); | |
if (current_val == 89) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int resualt=GetSquareDigitChains(2,10000000); | |
static int GetSquareDigitChains(int strt, int end) | |
{ | |
int i = 0; | |
for (; strt < end; strt++) | |
{ | |
int nextstrt = 0; | |
int strtTemp = strt; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#Pre-requisite: gem install mail (https://github.com/mikel/mail) | |
require 'mail' | |
mysql_username = 'root' | |
mysql_password = '123456' | |
mysql_database = 'your database' # consider use of ARGV | |
file_suffix = Time.new.strftime('%Y%m%d_%H%M%S') | |
mysql_backup_file = "backup-#{mysql_database}-#{file_suffix}.sql.gz" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def counts_of_files_by_extension(dir) | |
Dir["#{dir}/**/*"].reduce(Hash.new(0)) do |extension_counts, filepath| | |
extension_counts[File.extname(filepath)] += 1 | |
extension_counts | |
end | |
end | |
directory = ARGV.shift || Dir.pwd | |
counts = counts_of_files_by_extension(directory) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'socket' # needed for creating tcp servers | |
require 'base64' # we'll use base64 for encoding images and embedding them in the response | |
require 'cgi' # has a lovely helper method for generating rfc1123 compliant dates for http headers | |
refresh_rate = 1 # in seconds, interval between each screen capture | |
server = TCPServer.open 3005 # start our server at port 3005 | |
# the html page template we'll be sending over to the browser | |
page_tmpl = %Q[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
from math import factorial | |
#from functools import lru_cache | |
MAXN = 100 | |
MAXNCR = 1000000 | |
import time | |
before = time.time() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import heapq | |
from itertools import imap, ifilter | |
import time | |
before = time.time() | |
class Pair(object): | |
def __init__(self, f1, f2): | |
self.f1, self.f2 = f1, f2 | |
self.total = f1 + f2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System; | |
let sw = System.Diagnostics.Stopwatch() | |
sw.Start() | |
let ispalindrom (x):bool = | |
let s = x.ToString().ToCharArray() |> Array.rev | |
(new string(s) = x.ToString()) | |
printfn "%d" (seq { | |
for x in 899..999 do | |
for y in x..999 do | |
if ispalindrom (x*y) then yield (x*y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" | |
#include <time.h> | |
#include <iostream> | |
using namespace std; | |
int reverse(int number); | |
int is_palindromic(int n); | |
int main() | |
{ | |
int biggest = 0; | |
clock_t begin = clock(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_palindrome(int number){ | |
word = Int.to_string(number) | |
word == String.reverse(word) | |
} | |
function pair_with(int elem, it){ | |
Iter.map(function(el){ (elem, el) }, it) | |
} | |
function pairs(seq){ |