Project Euler #22: Names scores

Using names.txt (right click and ‘Save Link/Target As…’), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score. For example, …

Project Euler #15: Lattice Paths

Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. How many such routes are there through a 20×20 grid? This problem is solvable via combinatorics; since you are …

Linked List Exercise in C++

#include #include using namespace std; struct Node { char _data; Node *_next; Node() { this->_next = 0; this->_data = 0; } Node(char ch) { this->_data = ch; this->_next = 0; } ~Node() { } }; class LinkedList { private: Node *_header; int listCount; public: LinkedList(); ~LinkedList(); Node *getHeader(); void setHeader(Node …

Linked List Exercise in C++

#ifndef _LINKED_LIST_ #define _LINKED_LIST_ #include struct Node{ // Data Link void *data; // Pointers to previous and next Node *next; }; class LinkedList { private: // Keeps count of the number of list elements int listCount; // Keeps track of the head of the list for traversal Node *head; public: …

Malloc, Realloc, and Free Implementation In C

/* Sources: Computer Systems a Programmers Perspective The C Programming Language http://danluu.com/malloc-tutorial/ http://g.oswego.edu/dl/html/malloc.html https://www.cs.cmu.edu/~fp/courses/15213-s05/code/18-malloc/malloc.c */ #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <unistd.h> #include <string.h> #include “mm.h” #include “memlib.h” /* malloc, realloc, and free implementation in C. The list is searched in a first fit manner, where the first fit …