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? …

Horner’s Rule Polynomials

This program generates 25 polynomials of increasing degree randomly using a Mersenne twister, solves them via Horner’s rule and records runtime. /////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <vector> #include <random> #include <iomanip> #include <chrono> /////////////////////////////////////////////////////////////////////////////// std::vector<int> randIntGen(int count); float randRealGen(void); void polyPrint(float x, std::vector<int> polyVals); void hornersRuleTime(float x, int n, std::vector<int> polyVals); …

Python IRC Bot

The bot doesn’t do much but tell fortunes, give a pong response to a ping, and log the chatroom. Will probably add to is as I get bored. The fortunes text file can be found here if interested. import socket import random from config import * def processChat(sock, buff): buff = buff.strip() …

Project Euler #29: Distinct Powers

Consider all integer combinations of a^b for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: 22=4, 23=8, 24=16, 25=32 32=9, 33=27, 34=81, 35=243 42=16, 43=64, 44=256, 45=1024 52=25, 53=125, 54=625, 55=3125 If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct terms: 4, …

RSA Decryption

/////////////////////////////////////////////////////////////////////////////// // This program takes a RSA encrypted message in a text file, // by given parameters, and decrypts it. After which it outputs to console. /////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <fstream> #include <sstream> #include <vector> #include <math.h> /////////////////////////////////////////////////////////////////////////////// void fileRead(std::ifstream &inFile, std::vector &fileBuff); void decrypt(std::vector<int> cipherText, std::vector<char> &plaintText, int pq, …

Kruskal’s and Prim’s algorithm on weighted adjacency matrice

This program takes an input WAM, and applies Kruskal’s and Prim’s algorithms to it. /////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <vector> #include <sstream> /////////////////////////////////////////////////////////////////////////////// struct Edge { int vertOne, vertTwo, weight; Edge(int one, int two, int passedWeight) { this->vertOne = one; this->vertTwo = two; this->weight = passedWeight; } }; class Vertex { …