<file_sep>/* Sam (Sean) <NAME>
 * Capitalize the first letter of every word in a string of words
 * Java version "1.8.0_201"
 * Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
 * Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
 * February 18th, 2019
 * */
import java.util.Scanner;

public class capitalize {
	
	public static void main(String[] args){
		//variables needed
		String input;
		String[] words;
		String output = "";
		
		//scanner for user input
		Scanner sc = new Scanner(System.in);
		
		//prompt user and store result in words
		System.out.println("Enter a string of words: ");
		input = sc.nextLine();
		
		//split the input and seperate at the spaces, could add other delimiters.
		words = input.split("\\s+");
		
		for(int i = 0; i < words.length; ++i){
			//replace the first character with a capital, keep the rest intact
			words[i] = words[i].substring(0,1).toUpperCase() + words[i].substring(1);
			//
			output += words[i] + " ";
		}
		
		//print output
		System.out.println(output);
	}
}
<file_sep>/*
<NAME>
Prime number generator
Current TODOs:
-write to file
*/

/*standard output*/
#include <stdio.h>
/*string to int conversion*/
#include <stdlib.h>
/*Timing*/
#include <time.h>
/*Check command line flags*/
#include <string.h>
/*Multithreading*/
#include <omp.h>

int bruteforceInt(long int checkNumber);
int fastbruteforceInt(long int checkNumber);

int main(int argc, char **argv){
	
	/*Calculator option variables*/
	long int STARTING_POINT_CALC = 1;
	long int ENDING_POINT_CALC = 5000000;
	long int number;
	
	/*Thread variables*/
	int MULTITHREAD = 0;
	
	/*Clock Variables*/
	int NUM_OF_THREADS = 4;
	clock_t begin, end;
	double time_spent;
	
	/*Flag variables*/
	int temp;
	int flags[3];
	
	/*check flags*/
	for(temp = 0; temp < argc; ++temp){
		/*fast bruteforce*/
		if(strcmp(argv[temp], "-fast") == 0) flags[0] = 1;
		/*enable clock*/
		if(strcmp(argv[temp], "-time") == 0) flags[1] =  1;
		/*write to file TODO*/
		if(strcmp(argv[temp], "-write") == 0) flags[2] = 1;
		/*enable threading*/
		if(strcmp(argv[temp], "-thread") == 0) MULTITHREAD = 1;
		/*change start point*/
		if(strcmp(argv[temp], "-start") == 0){
			STARTING_POINT_CALC = atoi(argv[temp+1]);
			++temp;
		}
		/*change end point*/
		if(strcmp(argv[temp], "-end") == 0){
			ENDING_POINT_CALC = atoi(argv[temp+1]);
			++temp;
		}
	}
	
	/*start clock*/
	if(flags[1]==1){
		 begin = clock();
	}
	/*start multithreading*/
	#pragma omp parallel if(MULTITHREAD)
	
	/*start calculating*/
	if(flags[0]==1){	
		for(number = STARTING_POINT_CALC; number < ENDING_POINT_CALC; ++number){
			fastbruteforceInt(number);
		}
	} else {
		for(number = STARTING_POINT_CALC; number < ENDING_POINT_CALC; ++number){
			bruteforceInt(number);
		}
	}
	/*end clock and calculate time*/
	if(flags[1]==1){
		end = clock();
		time_spent = (double)(end - begin) / (CLOCKS_PER_SEC * NUM_OF_THREADS);
		printf("Time spent: %f seconds\n", time_spent);
	}
	return 0;
}

int bruteforceInt(long int checkNumber){
	long int i;
	int prime = 1;
	/*checks every single possible devision statement to see if it gives a remainder. If it doesn't, checkNumber is prime*/
	for(i = 1; i < checkNumber; ++i){
		if(checkNumber % i == 0 && i != 1){
			prime = 0;
		}
	}
	if(prime == 1 && checkNumber != 1){
		printf("%ld\n", checkNumber);
	}
	return 0;
}

int fastbruteforceInt(long int checkNumber){
	long int i,j;
	int prime = 1;
	/*checks devision statement to see if it gives a remainder. If it doesn't, checkNumber is prime and end condition is set to answer + 1.*/
	for(i = 1, j = checkNumber; i < j; ++i){
		if(checkNumber % i == 0 && i != 1){
			prime = 0;
			break;
		}
		else {
			/*Weird case, doesnt work with 2.*/
			if(checkNumber != 2){
				j = (checkNumber/i) + 1;
			}
		}
	}
	if(prime == 1 && checkNumber != 1){
		printf("%ld\n", checkNumber);
	}
	return 0;
}
<file_sep>#Sam (<NAME>
#Capitalize the first letter of every word in a string of words
#Python 3.6.7
#February 18th, 2019

#prompt user for a string of words
text = input("Enter a string of words: ")

#Split Strings by spaces. Other cases can be added. Example included
#words.replace(',', ' ') #uncomment to add punctuation case for ','. other cases can be added
words = text.split()
newString = ""
#loop through each word that was split
for words in words:
	#capitalize the word
	words = words.capitalize()
	#Add the string to the new string
	newString += words + " "
#print the result
print(newString)
<file_sep>/* <NAME>
 * A simple bubble sort I made
 * While waiting on my friends to finish their other work
 * February 15th, 2019
 */
#include <stdio.h>

int main(){
	int i, j;
	int temp = 0;
	int numArray[15] = {8,10,42,1,96,54,22,88,51,62,42, 88, 100, 3, 29};
	
	/*Print the initial array*/
	printf("initial array: ");
	for(i = 0; i < 15; ++i){
		printf("%d ", numArray[i]);
	}
	printf("\n");
	
	/*Bubble Sort*/
	for(i = 0; i < 15; ++i){
		for(j = i; j < 15; ++j){
			/*Swap spots in array*/
			if(numArray[j] < numArray[i]){
				temp = numArray[i];
				numArray[i] = numArray[j];
				numArray[j] = temp;
			}
		}
	}
	
	/*Print sorted array*/
	printf("sorted array: ");
	for(i = 0; i < 15; ++i){
		printf("%d ", numArray[i]);
	}
	printf("\n");
	
	return 0;
}
<file_sep>all: fibonacci prime permute bubblesort

fibonacci:
	gcc -Wall -ansi -pedantic fibonacci.c -o fibonacci
prime:
	gcc -fopenmp -Wall -ansi -pedantic prime.c -o prime
permute:
	gcc -Wall -ansi -pedantic permute.c -o permute
bubblesort:
	gcc -Wall -ansi -pedantic bubblesort.c -o bubblesort
clean:
	rm prime fibonacci permute bubblesort
<file_sep>/* <NAME>
 * January 13th, 2019
 * prints all possible permutations of the characters in a word
 * Modified version of my school work to work for more words.
 * */

#include <stdio.h>
#include <string.h>

/*function prototypes*/
void permute(char *word);
void recursiveCharacters(char *word, int index);
void swap(char *a, char *b);

/*function definitions*/
int main(int argc, char** argv){
	if(argc == 1){
		printf("Not enough arguments. format is \"./permute <word_to_be_permutated>\".\n");
	} else if(argc >= 3) {
		printf("Too many arguments. format is \"./permute <word_to_be_permutated>\".\n");
	} else {
		permute(argv[1]);
	}
	return 0;
}

/* gets called from main, starts the recursive function
 * could also be called from an external function call in the future*/
void permute(char *word){
	recursiveCharacters(word, 0);
	return;
}

/*get every permutation of the word using recursion*/
void recursiveCharacters(char *word, int index){
	int i;
	int end = strlen(word) - 1;
	/*check if each character has been swapped*/
	if(index != end){
		for(i = index; i <= end; ++i){
			/*swap characters for a new combination*/
			swap(word + index, word + i);
			/*call the recursive function, increment the index*/
			recursiveCharacters(word, index + 1);
			/*swap the characters back so it doesn't mess up later combinations*/
			swap(word + index, word + i);
		}
	} else {
		/*print the word once 6 letters have swapped*/
		/*printWordTest(word);*/
		printf("%s\n", word);
	}
	return;
}

/*Fairly standard swap function for strings*/
void swap(char *a, char *b){
	char temp;
	temp = *a;
	*a = *b;
	*b = temp;
	return;
}

<file_sep>#<NAME>
#A REALLY simple quadratic calculator
#to assist in learning python

import math
#using python 2
print "Quadratic Root Calculator"
print "Enter the coefficients (format AX^2 + BX + C)"
#get user input
A = raw_input('AX^2:')
A = int(A)
B  = raw_input('BX:')
B = int(B)
C = raw_input('C:')
C = int(C)
#only calculate stuff under the root once
D = (B * B) - (4 * A * C)
if  ( D < 0 ):
	#negative root, not able to get with math.sqrt
	print "Sorry mate, negative root. The math library is not a fan."
else:
	#positive root(s)
	x1 = (-B + math.sqrt(D) )/ (2 * A)
	x2 = (-B - math.sqrt(D) )/ (2 * A)
	print "root 1: ", x1
	#check for repeated root
	if(x1 != x2):
		print "root 2: ", x2
<file_sep>/*
<NAME>
Fibonacci sequence generator
*/

#include <stdio.h>	/*For output to console*/
#include <string.h>	/*For checking flags*/
#include <stdlib.h> /*convert number to strings*/
#include <time.h>	/*For measuring time*/

/*
TODO: writing to a file
Flags:
	'-w' flag for writing to a file
	'-t" flag for showing time taken to calculate
	'-n #'flag for number limit, where # is the number
Current limit: unsigned long limit on laptop (64-bit) is around 9,700,000,000,000,000,000 in ANSI standard
Status: Works, no file write
*/

int main(int argc, char **argv){
	
	/*Clock variables*/
	clock_t start_t, end_t, total_t;
	double totalTime;
	
	/*Calculator variables*/
	unsigned long a = 0;
	unsigned long b = 1;
	unsigned long c;
	int i = 0;
	unsigned long numberLimit = 9000000000000000000;
	
	/*Flag variables*/
	int temp;
	int flags[2];
	
	/*Checks flags*/
	for(temp = 0; temp < argc; temp++){
		/*write to file*/
		if(strcmp(argv[temp],"-w")==0) flags[0] = 1;
		/*Time the calculation*/
		if(strcmp(argv[temp],"-t")==0) flags[1] = 1;
		/*change number limit*/
		if(strcmp(argv[temp],"-n")==0){
			numberLimit = atoi(argv[temp+1]);
		}
	}
	
	printf("Fibonacci Sequence generator\n");
	
	if(flags[1]==1)start_t = clock();
	
	/*Fibonacci  Sequence Calculator*/
	while(c < numberLimit || i < 101){
		printf("%lu\n", c);
		c = a + b;
		a = b;
		b = c;
		++i;
	}
	
	if(flags[1]==1)end_t = clock();
	
	/*Clock printouts*/
	if(flags[1]==1){
		total_t = (end_t - start_t);
		printf("Total clocks to calculate: %li\n", total_t);
		printf("clocks per second: %li\n", CLOCKS_PER_SEC);
		totalTime = ((double) total_t / (double) CLOCKS_PER_SEC);
		printf("Total time to calculate: %f seconds\n", totalTime);
	}
	return 0;
}
<file_sep>/* Sam (Sean) <NAME>
 * Capitalize the first letter of every word in a sentence
 * C (ansi / std=c90)
 * Compiler: gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
 * February 18th, 2019
 * */
 
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
	/*allocate space for 1024 characters. Dynamic memory allocation requires a lot more work.*/
	char input[1024];
	char *words;
	char output[1024] = "";
	
	/*prompt user imput*/
	printf("Enter a string of words: ");
	scanf("%[^\n]", input);
	
	/*split string using space as a delimiter. other delimiters can be added if needed.*/
	words = strtok(input, " ");
	
	/*loop through each word*/
	while(words != NULL){
		/*turn the first letter into its uppercase form*/
		words[0]  = toupper(words[0]);
		
		/* put resulting word into the ouput string*/
		strcat(output, words);
		strcat(output, " ");
		words = strtok(NULL, " ");
	}
	
	/*print the resulting output*/
	printf("%s\n", output);
	return 0;
}
<file_sep># Small Projects

These are small projects I made in my (limited) free time.
C programming files can be compiled with the included makefile.

**C programming language:**
- bubblesort.c - A simple bubblesort algorithm
- fibonacci.c - A simple Fibonacci sequence generator
- prime.c - A simple prime number generator
- permute.c - A command line based word permutator

**Python 2 & 3 programming language:**
- quadraticPY2.py - Python 2 - A Simple quadratic root calculator

**Multiple (Multi) Languages**

Things written in multiple languages
- capitalize - Python, Java, C
