Some ideas submitted for session 1 in Michaelmas 2019

Make a password, guess a password  
Should you be doing Physics??  
Simple game of Nim  
Naughts and Crosses  
Disney Princess (1st C++ Program)  
Convert decimal into binary  
Generating Pi with Random Numbers  
Random walk in 1D  
A Nightmare In Balls (see below)
Unreliable tetrahedron renderer
My Random Number Quiz  
A program to calculate prime numbers up to a limit  
Caesar Cipher  
Calculating powers of negative and fractional numbers  
EvenOrOdd  
Number Sorter (Mergesort for Floats)  
Powers of Two Test  
A first  simple program in c++  
Computing (Anti)Cheer-leading Chant  
Guess the right number  
Sierpinski Triangle By Random Number Generation  
A game with random numbers  
Days lived  
My simple dot product  
Pascal's triangle and binomial computation using a bottom-up strategy.  
My first foray into C++: Insulting the user via the medium of Gordon Ramsey  
A program to check if an inputted number is prime  
Naismith's Rule  
Sieve of Eratosthenes  
Prime number finder  
Prime Number Checker  
Palindromes  
PrimeNumber  
Tasks in your current lifespan  
Fibonacci sequence  
a code to say your lucky number isnt lucky  
A Function  
Rowing Split-Watts converter  
Simple Calculator (able to work with decimals)  
Over-complicated exercise for the first session(?)  
Hello World Hangman  
Missing a supervision excuse  
Combining normally distributed variables  
numberGuesser  
Pokemon Capture Chance  
BMI Calculator  
N dimensional matricies  
Session 1  
"Exam result calculator for a job applicant"  
First go using C++/Linux  
Supervision Simulator  
Outputting Primes to a Text File  
Monitoring Natsci's life quality   
Calculator  
OddOrEven??  
Orbital Radius Calculator  
Supervision work excuses  
Program to solve quadratic equations with real or complex roots  
My best attempt in insurance industry  
Discriminant and quadratic solver for your function  
Discriminant and quadratic solver  
Simple Polynomial Solver  
Program to find the sum of all the multiples of 3 or 5 below a given number.  
Fibonacci Sequence  
Swallow  
English to Morse Code  
A program to calculate Fibonacci Numbers  
Sine and cosine approximation  
Sieve of Erathosthenes  
A simple program to integrate a function y = ax^2 +bx+c  
Finding the nth Fibonacci Number  
Mr  
Multiple of 7 closest to inserted number  
Find the Puffin  
Mr  
Converter of imperial to metric units  
My first c++ program  
Infix to Reverse Polish Notation  
Prime factors  
Buckling Equation  
Program to add integers  
Multiplication Tables  
Bridgemas tree printer  
First ever successful coding experience (yay!)  
Checking numbers divisible by another number  
Insertion Sort  
Walk  
Quadratic Equation Solver  

Descriptions

I set myself the following additional goal (devised by me): I looked up first c++ projects on the internet because inspiration just wasn't striking and found an idea to create a banking program to keep track of your spending. To modify this, and fit it within a reasonable time limit (I have never seen c++ before in my life so the learning curve has been steep), I decided to create a program that would instead make you create a pin number, and then (ideally some time later), make you enter the correct pin. I'm pretty happy with it, although I admit it is not the most secure system ever, despite what the program may claim... My solution was in a file called pin_guessing.cc

I set myself the following additional goal: I decided to write a program for an interactive quiz to determine whether the user should indeed continue with Physics. Initially, when I wrote the program, the user had to enter 1 or 0 instead of 'yes' and 'no'. However, I modified the code so that the user could instead submit 'yes' and 'no' as answers. Additionally, I had initially stored the answers to each question in separate variables, I looked up how to store the answers more compactly in an array instead and how to loop through the array. To improve my code in the future, I would find out how to make other answers, such as 'YES'. 'y' also acceptable input, and to output an error message if the user inputs an invalid answer. My solution was in a file called sesh1.3.cc

No experience with c++, set what I thought would be a relatively easy task to make a 3 pile version of Nim where you play against the computer, ended up quite messy as the whole thing is within the main function (and I'm sure all of it is far from optimal). Should work fine so long as the player's inputs are valid. Sadly the optimal strategy for this 3 pile case is quite easy to figure out, playing a version with more heaps is more interesting but it would be a huge pain to rejig the thing because it wasn't built for a variable number of heaps.

I set myself the following additional goal (devised by me): I decided to write a program to play naughts and crosses. At first, the program does not recognize if the cell was taken or not. After this was fixed, I encountered serious errors if I tried to enter a number corresponding to a cell not on the grid, or even if I entered alphabets. I have to look up the web to fix the latter problem, but the former is relatively approachable. In the end, I was able to prevent these issues from arising and I was able to play the game smoothly. My solution was in a file called Session1.cc.

I set myself the following additional goal (devised by me): I have never programmed before and hence decided that in order to get used to c++, particularly the syntax I would make a short quiz to determine which Disney princess you are by answering two questions. I used the example from section 3.2 in the handout as a basis and modified it to perform the task I wanted as well as annotating using // to make sure I understood what was happening in each line.

I decided to recreate one of the first programs I did for GCSE computing: converting decimal numbers into binary. I have some programming experience with python (see qualification above), but c++ is completely new to me. This program has allowed me to begin to get used to this language's syntax, including iteration and how to define a function. The program repeatedly asks for an input, until a number is inputted (rounding down if it's a decimal). The program determines the amount of bits required to represnt this number, whilst assigning each bit a 1 or 0. Finally, it prints the bits all on one line.

I have had a bit of previous experience programming however it took me a couple of hours to get to grips with C++, especially float division and random number generation as I kept trying to do it with modulos. I set myself the challenge of creating an estimate of Pi using only random numbers. This is something I've always wanted to try but never really got round to doing. I achieved this by randomly generating coordinates in a square, and then seeing the ratio of how many landed inside a quarter circle of radius 1 vs outside the circle in order to give an area ratio. I used this area ratio to output an estimate of Pi. I used 123456 repeats and generally the value of Pi obtained seems to be just about acceptable, given the limitations of random number generation.

I decided to simulate random walk in one dimension. Within each step of total n steps, one can move 1 from or towards origin. After large n, absolute value of distance from origin should behave as n^0.5. Program repeats the walk N times, then calculates average distance from origin with statistical error and compares it to expected value. End goal was to familiarise with c++ environment. Program was is file called random_walk.cpp

For my first adventure into foreign language territory, and with the rudiments I was managed to absorb during the 90 minutes of intense C++ learning, as my self assessment, I bring you a calculator that will tell you how many balls you should buy, should you ever want to transform a friend's bedroom into a cave overflowing with little annoying spheres (or big gym bouncy balls, if that's what you're into). This calculator lets you enter the radius of your balls of choice, and the three dimensions of your . Both will have to be entered in centimetres as I ran out of time to bombard the demonstrators with more questions. How many yellow plastic BB pellets would you need to fill an Approximated-To-The-Nearest-Rectangular-Shape football stadium? Well now you have the program to find out. To reflect one of the uses that could be made of this handy little tool, I named my cc file BallPit.cc, and the subsequent program to be run, ANightmareInBalls.

I set myself the following additional goal (devised by me): Write a program to display simple 3D shapes in a terminal. In its current form, the program draws a regular tetrahedron, which can be looked at from different angles. The result tends to flicker on terminals with slow output speeds; using ncurses would have prevented this. The task was appropriate because it involves reading (characters), writing and arithmetic. Although I have some experience with C, I had none with C++, so I tried to use new language features where I could. The program expects a 24x80 character terminal. It took me more than 150 minutes to write, but I had fun. The solution is in the files: Makefile (an adaptation of an adaptation of one I found online a while ago) main.cc vec_ops.hh vec_ops.cc render.hh render.cc world_setup.hh world_setup.cc input.hh input.cc

I set myself the following goal (devised by me): I wanted to make a program where the user has to guess numbers until they find the one that the computer is thinking of. I chose this so that I could get to grips with using different kinds of loops in C++ as well as researching how to generate random numbers. I eventually did this by using the rand() function from cstdlib. This generates a random number between 1 and 2147483647. Because I only wanted to have numbers between 1 and 10 to give the player a chance I used the modulo command to transfer this into a remainder of 10. The time() function was used to seed the random list so a different number was selected each game. My solution was in a file called RandomNumberGuesser.cc

I'm not very creative so I decided to use the idea in the booklet to test for prime numbers. I then modified the program to print all the prime numbers up to a user-set limit. Basically, I had never touched programming before this summer during which I decided to teach myself some very basic python. So I am familiar with 'For loops', however I have never used C++ before so I thought this was an appropriate challenge for me. This proved to be true since I had to edit the code a lot before getting it to work. My main goal was to get familiar with using C++ syntax, using help from the examples in session 1. I believe to have succeeded here. My program works by having 2 for loops: one for cycling through integers up to the limit and one for cycling through integers up to the 'current number'. By checking the remainder of the division for every integer (from 2) up to the 'current number', it will find and print primes. My solution was in a file called PrimeNumberFinder.cc

I set myself the following additional goal: To write a program to encrypt text with a Caesar cipher. The user should be able to choose the shift. I have programming experience, but have never used C++ before. I believe that while the concept of the task is fairly simple it allowed me to cover a range of C++ statements and syntaxes; and so helped me to gain a basic understanding of the language. My solution was in a file called CaesarCipher.cc

Having never had an experience in coding, and generally disliked the MATLAB course last year, I was apprehensive about beginning this course. However, this has proved to be a generally fun afternoon. I think I definitely prefer Linux to Windows. I began with the goal of combining two numbers, one to the power of another, and this has proved a fun task. The code required me to find an additional preprocessor to accept the notation I eventually used in the code. This took some finding in the index, and the basic computing computing operations in C++ have been fun to 'get my head around'. Moving forward, I would like to introduce complex numbers in the future to the code, as finding powers of those would be an interesting problem to tackle.

I set myself the following additional goal (devised by me): To check whether a number is even or odd as well as a factor an input number. I decided to write a program to practise using loops and if statements as last in Matlab I didn't really understand how they work and how to code them. My solution was in a file called EvenOrOdd.cc

Having learnt about Mergesort in the Algorithms lectures last year as part of the IA NST CST course, I decided to try implementing it in C++ based on its pseudocode to familiarise myself with C++'s syntax and to learn about its deviations from Java which I am more familiar with. The recursive step was straightforward, but translating the pseudocode for the part where the recursively mergesorted halves are merged together was not as trivial. I made an interface that handled inputs and outputs to practice using cin and cout. I also realised that C++ does not allow for arrays to be used as function arguments or outputs, so I had to use pointers to arrays instead. Overall, this has been a fruitful introductory exercise to C++ for me.

Having made a recursive prime number generator for one of the optional exercises, I decided to adapt it to make a prime factor decomposer. Users can provide a positive integer less than or equal to 3991 (as the prime generator can only generate up to 3991) and the output would be the prime factor decomposition. For example, an input of 20 would yield the output: 2^2 5^1. This was good practice for using flow control statements and writing recursive functions.

I set myself the following additional goal (devised by me): I decided to write a program to allow the user to test themselves on calculating the powers of 2. That is, the program repeatedly takes answers which should consist of successive powers of 2 (1, 2, 4 etc.) until the user makes a mistake when it reports how many answers they got and then terminates. This allowed me to fully understand c++'s input and output syntax. MY solution was in a fall called PowerTwoTest.cc

I used the idea of a for loop in combination with user inputs to create a simple integration which tracks how many answers the user got correct. I used the basic if else loops and was also shown the switch command which I used to generate the end reply to user's score. Never programmed before (matlab doesn't count) so am fairly happy with results.

I set myself the additional goal: Trying to learn an interesting computing function in order to convey my mild distress doing computing for the first time (MATLAB doesn't count). I initially used the template of the Hello World because I thought the number listing could be used like a cheer chant, but found the switch function worked better for printing different statements for different integers. My result is the file session1submission.cc and I'm proud of myself because I didn't cry. The chant should be read aloud for maximum effect :)

I set myself the goal of adapting the given code in session 1, such that a random number between 1 and 10 is chosen. Then when the user inputs a number, a suitable message appears depending on whether they guessed the right number.

I have a done a little C++ prior to this course but not much with graphics so I decided to use this time to develop this skill using the SFML library. So I decided to make a program that generates Sierpinski's triangle by random number generation which is something I've wanted investigate for some time. From an initial position a random number is generated which determines which vertex of a triangle to move towards for the next point. The next point is at the midpoint between the initial position and the vertex. This next point is used as the initial position for the next step of the iteration. This process is repeated indefinitely to generate Sierpinski's triangle. My key area of interest was to see what happened if rather than using the vertices of a triangle other regular polygons are used. From this testing, it does appear that for n vertices, if n is odd, then some n fold symmetry structure is observed otherwise no obvious structure appears.

Today's goal was to create a basic two-player game, using if statements, cin, cout that I learned today. This is because currently everyone is stressed, but games are fun! I found rand() through a google search, then again asked our trusty friend google when initial runs of the game had the same answer each time (which was 8). My solution is in a file called RandomNumberGame.cc

I tried to make a program which determines how many days have passed between to given dates. These to dates are namely a birth day and the current date. It uses inputs to know the desired dates, then calculates the days between them with the help of for loops and if statements, taking leap years into account where necessary. My solution was in a filled called Howmany.cc

I set myself the following additional goal (devised by me): I decided to write a program to get the dot product of two size 2 arrays and extended it until it could potentially do this for arrays of any size. The program helped me learn about boolean values, referencing arrays, for loops, and most importantly, function declaration, implementation, and how to invoke them in C++. The program works perfectly, as long as the user is old-fashioned enough to use capitalised "Sure." with a full stop to indicate their confirmation. What's better, the program is so well-thought that there exists possibility of choosing not to compute anything, which saves energy and entropy for our endangered planet. My solution was in a file called dotprod.cc.

I set myself the following additional goal (devised by me): the user inputs a number n and the program outputs the first n lines of Pascal's triangle. Then the user is asked if he wants to compute a binomial, to which he can answer either y (yes) or no (N). If he answers N, the program terminates. If he answers yes, he will then input two numbers i and j to get the binomial of (i,j), with i

I set myself the following additional goal (devised by me): I have never coded before (apart from MATLAB last year) and as such am no stranger to error messages. These messages make me feel sad and angry at the world and particularly at those people who can code. So, because of my primary school jealousy of people that are better than me at things I have to do, I have created a program that will insult the user via the (censored) medium of Gordon Ramsey. I believe that this will firmly put anyone who has the audacity to be able to code in their rightful place. However this made me feel a bit bad and I had some time left so I added a little extension to try and cheer up the user after my insults make them sad. Long live Hell's Kitchen! My solution was in a file called Insults.cc

I set myself the additional task of creating a program to check if an inputted number is prime. This task helped me to understand the syntax of C++ as well as basic things such as for loops, declaration of variables etc. The program used a for loop to divide the input by integers from 2 up to the square root of the inputted number. If the number is prime, "Prime" is outputted and vice versa. One problem I encountered with this program is that for very large numbers the program doesn't work and just outputs that the number is prime whether it is or not. This problem is likely due to the maximum integer value that C++ can hold. My solution was in a file called Submit1.cc

I set myself the additional goal of creating a program to estimate the total time for a walk. This was my first time using c++ and my first time doing any programming other than 1A Matlab. I first modified the HelloFor.cc example to make LuckyNumber.cc. This is a (very!) simple program that tells someone whether their lucky number is the same as my lucky number, using 'if' and 'else'. I then created my main program to estimate the time for a walk using the rule of thumb 'Naismith's Rule'. This states that walkers should allow one hour for every 5km and an additional hour for every 600m of ascent. The user inputs these quantities and the program outputs the estimated total time. The estimated time is an integer number of hours as Naismith's Rule is only a rule of thumb so is only accurate to the nearest hour. The progam then uses 'if' and 'else' to issue appropriate advice to the walker according to the estimated time. My solution was in a file called NaismithsRule.cc

I set myself the following additional goal (devised by me): One of the more interesting and almost certainly the oldest way of calculating prime numbers. I suspected that this would be an interesting programming challenge both in terms of determining an efficient algorithm, as well as getting used to the syntax of a new language. Although not strictly speaking necessary, I decided to separate out the steps for initialising the array, filtering the array to make remove all the non-prime numbers, and actually printing out the array. I suspect C++ will be a powerful language and useful to know due to how widespread it is in embedded systems.

I am new to programming, so I decided to set myself a relatively simple first task so I could get comfortable with the basics of C++. For any given number it will find if it is prime (or else what its factors are), by looping over all integers from 2 to the square root of your number (square root instead of the number itself both to improve efficiency and because otherwise it will print the factor pairs twice). This program uses for and if loops, and the math library

Goal: To make a program that can check if a number entered by the user is a prime or not. Hopefully will remember the programming I did at school and learn the C++ language and how to compile C++. Program has 4 methods, each of which is slightly modified to be more efficient than the last, but all check divisibility from 2 to a number, so are unfortunately rather inefficient in the world of prime number checkers. Solution is in prime.cc, and compiled fine using Cygwin. Wanted to use timers but wasn’t able to figure them out, so might look at these for next weeks project. I did remember most of the programming I did, and am getting more familiar with C++.

I set myself the following additional goal (devised by me): I decided to write a program that would work out if an 8-digit number input by the user was a palindrome or not. Originally I wanted the number to be any length, but I realised this was beyond my scope of knowledge of arrays, etc. for the moment. Also, the number has to be input with spaces between each digit, and it is no so complete as to account for special cases (e.g. input > 8 digits). My solution was in a file called Palindromes.cc

I set myself the following additional goal (devised by me): To get familiarized with the C++ syntax of loop statement, if statement, system IO, and some simple numerical calculation in int. Also, get familiarized with the basic C++ type-casting system. I decided to write a program to check if an input number is prime and extended modified it to accept multiple inputs before reading an invalid input. My solution was in a file called PrimeNumber.cc.

I've done a small amount of Python in the past, but I've never used C++ before. As I'm not able to attend any of the lab sessions I'm planning on working through the handout and online resources. For this session, as well as familiarising myself with a C++ IDE, I wanted to make a program in which you would input your current age and it would output how long it would take do certain tasks in terms of your current lifespan to show how little you can achieve in one lifetime. E.g. If it takes 100 years to accomplish task A and you are 50 years old, it would take 2 of your current lifespans.

I set myself the following additional goal (devised by me): I decided to write a program to calculate the first 10 numbers in the Fibonacci sequence. I extended/modified it so that it asked the user to put in an integer, and then calculated that number of terms of the Fibonacci sequence. My solution was in a file called Fibonacci.cc This helped me to learn how to edit, compile and execute programs in c++ (I have very little experience in programming) and how to use for loops. I also learnt about syntax in c++ and how to define integers and take user input.

Before this session i was of very strong mindset that coding is horrible (mainly from matlab experience) and should be left to the compscis, but having stared today it was suprisingly ok (SHOOK). I've never done anything before so today i just tried to get my head round the language and have a play for the main part. i started by modifying he hello world code to ask a few more questions and got quite interested in the while loops so made that my aim. I wanted it to tell you that your lucky number is wrong and you had to pick a new one before it will let you carry on with the programme. I also wanted it to not let you carry on in the programme if your number was bigger than 10-i used the while loop function to do this. I think i achieved this goal with my code, and i also achieved my goal of not crying in the first coding session. WIN all round!

A class for a function that allows evaluation of the function at a point, taking the derivative and mapping a list. Getting my head round what C++ expects when you are dealing with pointers is hard. This took a bit of time because half of it was googling syntax. The bits at the bottom are just for testing but I thought I'd leave it in as examples. An obvious evolution of this is support for integration, Taylor expansion and maybe even Fourier transformation. Numerical errors are pretty much the only problem, they are even apparent when simply taking a derivative.

I've never done any programming before, apart from the MATLAB in part IA. I am quite a keen rower, so I set myself the additional goal of writing a program to convert your average rowing split (time to row 500 meters) into an average power output per stroke. Concept 2 use the following formula to switch between split and watts on their rowing machines: watts= 2.80/(split/500)^3. The power-split trend follows a cubic fashion because the viscous drag force of the water increases with speed. The file is called RowingSplit.cc

I decided to program a simple calculator capable of adding, subtracting, multiplying and dividing numbers (including decimals) as I have attempted this previously in another programming language. Beginning by including elements from SimpleAdder and HelloFor I expanded the program to be able to combine 2 numbers (integer or decimal) using any of the 4 operations above and also to be easily usable by others. To achieve this I needed to look up using float values, if, else and or statements and structure the program such that it is intuitive at each stage what values to input and that an error message is reported immediately if a suitable input is not submitted at any stage. My end result is in a file called SimpleCalc.cc

I set myself the following additional goal (devised by me): I decided to write a program to allow the user to enter a lucky number and the range of the guess, then prints out the numbers in the range, highlighting the lucky number with "that is lucky!" when it is printed. I then extended modified it to become a multiplication test, which runs on if-else conditions. This program allows the user to input two numbers and its 'solution'. If the product is the same as the 'solution', the user is congratulated. Otherwise, the user is told whether it is greater or lesser than the correct answer. My solution was in a file called Multiplication.cc, and I am proud of it because the if-else loop results in appropriate outputs for whatever the input.

This is my first time coding but I really wanted to challenge myself to create something fun each week. A game of hangman seemed to be a relatively simple place to start (but I was wrong)! So I have created a simple game based on hangman where the player has to guess the letters in "hello world". There are still some flaws in the game but I ran out of time. My solution was in a file called Hello_World_Hangman.cpp

This program takes information about a supervisor, and generates a perfect excuse for if you missed a supervision. I thought it would amuse some of my friends. Whys is this appropriate? : Before this summer I had never programmed, but then I did a 9 week software development internship, coding primarily in C++. I spent a fair amount of time this week fighting with Windows (having used a VM which I ran on Linux at the internship), and then decided to use this mainly as a refresher, but with the added aspect of the time delay (which I've never used), and using cin/cout, which I only used once (when first learning). Note: turns out the screen on VSCode is slightly wider than in this form - have left it incase you are planning to copy and paste, but thats why some of the comments/longer lines look dodgy.

In this session I decided to write a program to (numerically) plot the histogram of a function f = f(x,y,z) where x,y,z are normally distributed measurements. In order to do this, I generated N (=100000 currently) instances of x,y and z, and used them to give N values for f (currently f = z*x*ln(y)). These N values of f were then written out to a file and can then be plotted in eg. gnuplot or Python to give the histogram of the distribution of values of f expected when taking measurements of x,y and z to give f. Overall this was an interesting introduction to C++. It also allowed me to get acquainted with some basic C++ syntax as I have never used C++ before. It also allowed me to explore using more specialised libraries and writing output to file. I also got a basic introduction to gnuplot when plotting the histogram. The added benefit of this project is that I could use it to help me check my answers to the Physics A Experimental Methods questions 7)a) and 7)b)! This was also the inspiration for writing this program.

I have done a reasonable amount of programming before in python but have never used a compiled language before. For the first week I thought that familiarising myself with some of the more frequently used syntax would be a good start, so I remade on of the first programs I wrote in python many years ago, that guesses a number you have picked between 1 and 100. I made some improvements to my previous version, simply to avoid crashing under certain inputs, and to try and reduce redundant statements. It is however not perfect as I spent quite a lot of time learning syntax this week.

I am entirely new to programming and a large fan of pocket monster based video games, so I decided that a relatively simple starting problem would be computing the capture chance of a pokemon. This file is my solution, taking into account each variable which affects capture chance and spitting out the probability of success. This stretched my programming skills, requiring me to learn the syntax of programming languages and use some (for me) more complex functions like "if" and "do"/"while" commands.

I set myself the goal of producing a BMI calculator to advise the user of their weight category. I decided to write a program that allowed the user to select their preferred units - imperial or metric. They could then enter their weight and height to display their BMI. The BMI was calculated using different formulae , depending on the units selected. The value of the BMI was then used to say whether they were under/over weight or a healthy weight. I also programmed a 'start again' loop. My solution was in a file called BMI.cc

I was going to try to do something more interesting but I’ve never used c++ before so this took me the full two and a half hours and is self-contained enough to submit on its own. I could not find any convenient multidimensional arrays in c++, at least not in stl containers so I made my own. I decided to use an is-a relationship rather than has-a so I could use any built-in functionality for a vector but to privately inherit because I don’t know how overriding works in c++. Currently the methods are Set (set a specified location to a value), Get (get a value), getDimensions (returns a vector of the array sizes in different directions), and fill (fills the entire array with a single value). I have kept all state private. Whilst the array is a set size specified on object instantiation it is a vector so its size is not part of its type, this was done for flexibility. This project was useful if boring first one as it used a variety of syntax/concepts (Generics, inheritance, vectors, classes + constructors, exceptions). And it might be useful for something more interesting later.

Most of the time I tried to get used to Linux and how to save and again alter scripts. After that, I set myself the following goal: I decided to write a program that return all numbers a user input can be divided by without rest. My solution is in a file called Divider.cc

I set myself the additional goal of making an average exam results calculator that aimed to take three test scores and compute an average. I then developed it so that it used the if else functions to further comment on whether the user had a test score that enabled them to be qualified for a job or not. I used three if else statements and also used the 'greater than and less than' when evaluating the average test marks. I am very pleased with the result as this is my first time programming! :) My solution was in a file called Examresults.cc

I set myself the goal of getting (more) comfortable with both the c++ language and the linux OS, as I haven’t used either before. I used the script from p12/13 of the handout (SimpleAdder.cc) and attempted to compile various versions of it, with deliberate mistakes. I changed almost every piece of syntax I could think of in the editor (using jEdit) and also ran the functioning program and looked at the results when giving, for example, non-integer inputs (including letters). Some findings are presented in the comments of the file, which has the original script, named BadAdder.cc. The comments are fairly extensive! But I feel I at least understand the basics of the programming and some simple commands recognised in the standard namespace and some simple unix commands.

I set myself the following additional goal: I decided to write a program to asses how well one's supervisions are going. The progress was evaluated in points. Then I extended modified it to contain an Easter egg question about this session if one's supervisions go very well. My solution was in a file called SupervisionSimulator.cc

I have done a reasonable amount of coding before, but never in C++. As such I set myself a relatively simple goal of calculating the primes to N (chosen by the user) and output them into a file (with filename chosen by the user). This was mainly an exercise in learning the syntax of C++: using conditionals and for and while loops and outputting to files and the console. The work was done in Visiual Studio 2019.

I set myself the following additional goal (devised by me): I decided to write a program to monitor students' life quality by considering the work/rest balance. By asking users to input their time spent on lecture, labs, sleep and work, I have decided that if the ratio of work to sleep is more than 1.5 or lower than 0.5, it is not a good balance. This is my first C++ program. My solution was in a file called LifeQuality.cc

I set myself the following additional goal (devised by me): I set myself the challenge of making a simple calculator, where an operation can be selected and then that operation can be performed using two numbers as inputs. I have programmed before, but never in C++, so I wanted to get used to the language before trying something more ambitious.

I have very little programming experience and certainly zero experience in C++ - so I decided to try a relatively simple program where the user inputs two integers, the computer calculates the product of the two numbers, and then determines whether the product is even or odd. The user then receives a message saying whether it's even or not. This was intended just to get used to the syntax and structure of C++, and I was quite proud of how, after lots of fiddling around, I got this to work out. My solution was in a file called Session1.cc.

I wanted to do a bit more than a basic number cruncher for my first week exercise as I have some coding experience, just not in compiled languages, so I thought I would try to use more complex mathematical functions than just basic operators. So my goal was to learn to use math libraries and get used to a compiled language. I like space, so I decided to make a program that, given an input of star mass and orbital period, would compute how far away the planet would have to be to have a given orbital period. For this I needed to be able to raise numbers to powers, both integer and fractional. My solution is in a file called orbit.cc

I set myself the following additional goal (devised by me): Since I have never used C++ before, I decided to write a simple program that would produce excuses for late supervision work, that would allow me to get a feel for the basic syntax of the language. Initially, the program took inputs from the user in order to produce a standard response regarding the unfortunate demise of a goldfish. I then extended the program so that it could randomly select a response from a list of five possible excuses, by means of a random number generator and a set of simple if statements. For the amusement of the examiner, I made these excuses outlandishly far fetched, which prompted the addition of an additional function to gauge the user's response to the excuse. This provided the opportunity to incorporate some rudimentary validation, which relied on indefinite iteration to ensure that an input was an integer between 1 and 10. At this point, I had spent about 2.5 hours on the session, and since I felt I had gained a sufficient feel for the basic syntax of c++, I decided that the task was complete. My solution was in a file called Session1.cc

I set myself the task of writing a simple program to solve quadratic equations with real or complex roots (quadratic.cc). Considering that I have never coded using C++ or any other programming language outside of Matlab, I think that this was a suitable project as it allowed me to practice basic commands including if and else statements yet was basic enough that I could write it myself and fully understand every line of code. Principally this process helped me learn how to navigate terminal to both write and run basic programs from it which as a beginner I found to be very useful. My program allows the coefficients of a quadratic (or linear if a=0) equation to be input and will then return with either the real or complex solutions. Two if statements were used to distinguish between the three cases of linear, quadratic with determinent less than zero, quadratic with determinent greater than or equal to zero, all of which leading to a valid output.

I set myself a goal to write code that would calculate for how long a person has been alive since his birth. I am not new to programming, but have never used C++ before. I considered that such a program would be of appropriate difficulty for the start, focusing on conditionals and user input. It also uses simple arithmetics and converting between datatypes. This code takes 1) date of birth and 2) present date and calculates the corresponding julian day numbers (which it substracts). Based on current average UK lifespan of 80.96 years, it also estimates the remaining time for the user.

My initial goal of the 1st session was to ultimately get a working program. This was my first real go at c++ and computer programming in general, so I decided to set a task suited my ability. Obviously not the most exciting program, but I had fun seeing my program work and trying to conquer my initial errors. Initially I set up the discriminant calculator, but realised I could produce a quadratic solver as well which other people had done in the past.The program incorporates an if function where if the roots are real, the program is able to automatically calculate the roots. In doing so, I incorporated cmath language as well as isostream to enable powers by non integer values. My solution was in a file Disciminantquadraticsolver.cc. I look forward to more programming...

My initial goal of the 1st session was to ultimately get a working program. This was my first real go at c++ and computer programming in general, so I decided to set a task suited my ability. Obviously not the most exciting program, but I had fun seeing my program work and trying to conquer my initial errors. Initially I set up the discriminant calculator, but realised I could produce a quadratic solver as well which other people had done in the past.The program incorporates an if function where if the roots are real, the program is able to automatically calculate the roots. In doing so, I incorporated cmath functions as well as isostream to enable powers by non integer values. My solution was in a file Disciminantquadraticsolver.cc. I look forward to more programming...

I set myself the following additional goal (devised by me): The task I set myself was to build a simple calculator, which would return the solutions for first and second order polynomials which have been entered by the user. I then modified it to produce error messages in the cases of either a negative discriminant, or when the program attempted to divide by zero.

I set myself the following additional goal (inspired by an exercise on ProjectEuler.net, as suggested by the demonstrators): "Find the sum of all the multiples of 3 or 5 below 1000." I modified this exercise to allow the user to input any number (not limited to 1000), and then output the sum of the multiples of 3 or 5 below that number. If any number x is a multiple of y, then x mod y = 0, and this is the condition I check against in my if-statement to determine whether each number i is a multiple of either 3 or 5. If it is, then the code within the if-statement is executed: that number i is added to the variable 'total'. This happens for each iteration of the for-loop. I have never coded in C++ before, so I thought this exercise was a good way to familiarise myself with the outline of a basic program and the syntax for some basic instructions such as: declaring and defining integer variables, outputting text to the terminal, getting input from the user, constructing for loops, simple if-statements, OR expressions and the modulo function.

I have some exposure to programming, though more at a higher level, principally in Python, so the shift to C++ is a bit of a change which is taking some getting used to. Today was principally about familiarising myself with some of the basic commands in C++, as well as learning how to use compile and run it on a Mac PC. It took some time, but in the end managed to make it run on a Mac which was fun. Project Euler was suggested as a possible source of problems, and a variant of one of the challenges on there made me think about the fibonacci numbers. I learnt about the cout and cin commands, as well as the use of the for, while and if commands, and their syntax in C++ as well. Combining this all together in the following code.

I set myself the goal of coming up with a quiz that would help determine the velocity of a swallow, be it unladen or carrying a coconut and European or African. This was to ensure there could be no more confusion when you are trying to recruit people for the court of Camelot and the quest for the Holy Grail, hence speeding up the process, ensuring for time to be spent at spamalot afterwards (what a silly place). Aside from the Monty Python references, I have never coded in C++ and never had to navigate and use a terminal before to compile and run code. I have dabbled in python but that was always in a program that compiled and ran the code for me. Hence, I used this exercise to get to grips with the basics of C++ and a terminal and I made it enjoyable for myself whilst I did by choosing the silly topic of the quiz.

I set myself the following additional goal (devised by me): I decided to write a program to convert phrases from the English alphabet into Morse code (including numbers to Morse). I chose this task as it allowed for me to acquaint myself with a useful data-structure and how it is represented in c++ - the map. I was familiar with the concept of a map from Java and have often found myself using it in previous programs. It was also useful to get used to the, in my opinion, odd syntax of the input and output - to terminal - commands that cout and cin use, whilst intuitive that the greater and less thans point in the direction the data is going I was still a little baffled by the omission of just using brackets so it was useful to get used to it. I also found it useful to learn how to iterate through items in a string within a for loop as it will likely come in useful in the future, and also it was useful to learn how to manipulate string to change cases using the transform function on an entire string or just by using the ::tolower function to convert characters to lower case, iterating through the characters in the string. I believe this is a reasonable self assessment as the last time I wrote code was quite the while ago and in a different, albeit similar in syntax, language. It allowed for me to write something that was quite engaging and very fun to see working, it provides a good spring board for future tasks and demonstrates my understanding of the first sessions content. My solution was in a file called selfAssess1.cc

I set myself the goal to compute the first n Fibonacci Numbers dynamically because I have never coded in c++ before. I have coded a similar function in java and ML so wanted learn the c++ syntax with a simple program and remind myself of dynamic programming that I studied last year. I decided to write a program that took an integer input, n, from the user. If n was 0 or less the program printed out an error message. This is because Fibonacci numbers are only defined for n greater than 0. My program also printed out an error message if n was greater than 40. This is because the Fibonacci numbers are stored as integers which are only 8 bits, so with values of Fibonacci numbers above 2^7-1 you get negative (incorrect) values due to the two's complement representation of integers. Otherwise my program prints out the first n Fibonacci numbers. My solution is in a file called Fibonacci.cc.

I set myself the task to calculate sine and cosine and compare these values with the small angle approximation. The program makes use of input and output functions and is able to call other executables. 1_approx calls 1_sine_approx or 1_cosine_approx depending on which was selected by the user. The code also implements two new libraries and makes use of them. I am quite satisfied with the result :)

I set myself the task to calculate different sequences according to the wishes of the user. I started by calculating the first N terms of the Fibonacci sequence where N was entered by the user. To test out the casting operator I decided to estimate the golden ratio by using the ratio between the last two terms. After this I also added the option to calculate the first N terms of the Hofstadter-Conway $10,000 Sequence just because I liked the name. For the Hofstadter-Conway sequence I needed a slightly more complicated but at the same time more intuitive approach. I used an array to keep track of all the numbers in the sequence. Thus, I also modified my calculation of the Fibonacci numbers to work with an array :)

I wrote a program estimating ln2 by a Monte Carlo method. I didn't receive any help on this and wrote it on my own. However, parts of the code are copied from the example given in the handout. The estimate is achieved by calculating the number of random points under the curve y=1/x on the interval [1,2) which should tend to the integral of 1/x between 1 and 2, i.e. ln2. To achieve the desired accuracy, it is necessary to generate around 2127 points assuming that the standard deviation of the mean is given by sqrt(p*(1-p)/N) where p is the probability to land inside the integral. Thus p = ln(2). Even though the standard deviation has a maximum when p = 1-p = 1/2, the number of tries needed seems to go down when this is the case, i.e. when y is multiplied by approximately 2ln(2). What would you suggest for a more efficient Monte Carlo? Is my formula for the standard deviation wrong? I modified the program so that it only prints out every n^2 result.

I set myself the goal (devised by me) of writing a program to list all prime numbers smaller than a given integer using the Sieve of Eratosthenes. I extended it to allow the user to input the upper bound. This allowed me to learn about loops and user input in C++ My solution was in a file called session1.cc

I set myself the following additional goal: Developing a fuller understanding of the basic c++ structure, in particular of: - a for loop - the cout and cin commands - floating point numbers I decided to write a program able to compute the integral under a curve of the type y = ax^2 + bx +c. In doing so, I decided to use the method of rectangles. As a C++ beginner, I preferred concentrating on learning the syntax rather than on the Maths involved. My solution was in a file called Simple_integral.cc

I wrote a program which finds the nth Fibonacci number. This works by using the two previous values to find the next. I have used the convention that the 0th Fibonacci number is zero and the 1st is 1. I have used two booleans to catch when n is negative, or n is too large meaning that the nth Fibonacci number is too large to be stored in a long integer: the largest that can be stored is approximately 9 quintillion, while for n=92 the corresponding Fibonacci number is approximately 7.5 quintillion. My solution was in a file Fibonacci.cc

I set myself the following additional goal: calculating products of matrices that are smaller than 5 by 5. I have coded in Java before, and thus explored a bit about writing functions and using variables in C++. The program asks about dimensions of the input matrix and then its elements, and will output a warning message if the dimensions do not fit for multiplication. It then outputs the product of the matrices. It turns out that the array in C++ is a bit harder to manipulate than in java, and passing an array to a function requires either using a pointer or specifying the dimensions, so the printMatrix function is not very generalized. However, the program helped me learn a lot about C++. The file name is main.cpp

I set myself the goal of building the program that detects if a number inserted from the keyboard is a multiple of 7. After I succedeed in doing that, I extended the program such that it displays the biggest multiple of 7 which is smaller than my number, if my number is not a multiple of 7. My solution was in a file called sess_1.cc

I've written a simple game based around the idea of what if a puffin can't swim. You have 10 moves to save the puffin from drowning by getting to it in time. It uses the while loop and random number generating function.

Having learned a small amount of a few languages in the past (MATLAB, Python, VBA, Batch) I picked up the C++ syntax relatively easily, and was already fairly confodent in the basics of variable types, control statements, loops, etc. I modified an example script I was using to set up C++ in VS Code on my PC that just printed some strings from a vector. I modified it to ask for a name and then compare that with the current username of the user, and then prints out responses accordingly. I wanted to use references instead of duplicating the vectors into another which is then printed, but couldn't work out the proper syntax - something for next week. Note that for non-Windows getenv variable names should be changed to HOSTNAME and USER respectively (I think!).

I set myself the following goal: I decided to write a program that performs conversions of 6 basic imperial units to their metric equivalents. This will allow me to understand the fundamentals of the C++ programming language, the use of simple arithmetic operations (+,-,/,*) and the input/output functions that allow the user to interact with any programme. The programme initially ask the user to input 6 quantities to be converted, computes the conversions and outputs the results in a legible manner. My solution was in a file called Units.cc

I set myself the following goal: I decided to write a program that performs conversions of 6 basic imperial units to their metric equivalents. This will allow me to understand the fundamentals of the C++ programming language, the use of simple arithmetic operations (+,-,/,*) and the input/output functions that allow the user to interact with any programme. The programme initially ask the user to input 6 quantities to be converted, computes the conversions and outputs the results in a legible manner. My solution was in a file called Units.cc

I set myself the following additional goal I decided to write a program to calculate the mean of three values, modified it untill it could give the mean. My solution was in a file called Calculatiingmeanofthreenumbers.cc

Over the course of this course, I plan to play around with symbolic manipulation. I'm new to C++, but not to programming, so I can write relatively complex algorithms, but it takes ages to look up the syntax. This week, I have made a program that parses an input string into postfix 'Reverse Polish' notation. Apparently this is an adaptation of the shunting yard algorithm, although it was entirely homebrew. It took way longer than hoped so there may be bugs (I haven't tested much) and I probably will produce less in coming weeks. The output is also semi-encoded, e.g.'h' representing 'sin()', as I plan to do a little more with this task.

I set myself the following additional goal (devised by me): Originally I decided to write a program that decides if the input number is a prime or not. Then I modified it so that it gives the prime factors of the input integer. The main aim was to get familiar with the basic elements of the programming language. My solution was in a file called SESSION1.cc

I set myself the following additional goal (devised by me): I decided to write a programme that allows me to calculate the fold wavelength from several physical parameters (layer thickness, viscosity of layer and surrounding matrix) described by a simple mathematical equation. This allows me to use things I have learnt in my lectures for which I am extremely proud of. I am using Xcode so the file extension may be a bit weird. My solution was in a file called buckling.cpp.

I decided to write program that adds integers. User can specify how many to add. I liked the fact that I implemented the "for" loop. During this session I became familiar with the structure of the program and this way of thinking. I also tried to add something that checks whether a thing typed by the user is an integer (not a word for example) but it turned to be more complicated than I expected, learning how to do it might be my goal for a future.

I set myself this additional goal: I decided to write a program to print out the multiplication tables for an integer chosen by the user, up to a multiple chosen by the user. I modified this to identify the square and cube of the number chosen, and also to check whether or not the user's lucky number was a multiple of the chosen number. My solution was in a file called timestables.cc

I set myself the following additional goal (devised by me): I decided to write a program to print out a Christmas tree made of "*". The program requests a number and prints a Christmas tree of a size specified by this number. This program might be used by the physics supervisors to ask Santa for making their students getting the first class. My solution was in a file BridgeMas.cc, however I used a compiler for .cpp when writing the code. My experience in C++ is rather limited, however I learned a bit before this course.

I set myself the following additional goal (devised by me): I decided to write a program to print out a Christmas tree made of "*". The program requests a number and prints a Christmas tree of a size specified by this number. This program might be used by the physics supervisors to ask Santa for making their students getting the first class. My solution was in a file BridgeMas.cc, however I used a compiler for .cpp when writing the code. My experience in C++ is rather limited, however I learned a little bit before this course. I send this for the second time (this time corrected), because I found a bug in the code later, when I wanted to present my program to the friend of mine.

I set myself the following additional goal (devised by me): I decided to write a program to estimate the Euler-Mascheroni constant using harmonic series computed with a loop. The program requests a number n and calculates the Euler-Mascheroni constant using approximation with the harmonic series (up to n terms). Sufficiently large n give a decent approximation of the constant. I decided to play with this constant, because I find it exceptionally adorable, since IA NST Maths lecture when it was introduced. Harmonic series diverges, thus I did not see this constant coming then and I found it amazing. My solution was in a file Euler_Mascheroni.cc, however I used a compiler for .cpp when writing the code.

I have chosen the following goal: I decided to compute the value of ln(2) according to the last exercise of 10.2 section of the handout. I confirm that I solved this exercise by myself. The solution is based on calculating the area under the curve of 1/x on the interval [1,2). This area corresponds to the definite integral of this function, equal to ln(2). This approach was similar to the case of circle inside the unit square from previous exercise. For [1,2) interval - 1/x takes values [0.5,1). Therefore, taking the square formed from the intervals [0,1) for x and [1,2) for y, which has unit area, was a very convenient choice. If for random (x,y) from this square y<1/x, then the point is under the curve, so corresponds to the area under the curve, which we want to compute. The Monte Carlo probability of landing below 1/x curve is equal to the area under the square divided by the unit area corresponding to all possible outcomes (which are all in the defined unit square). The value of N=1000000 (sqrt(N) = 1000) was used to decrease the error in computed ln(2) value below 0.01. The particular steps are also described and explained in the comments included in the code. My solution was in a file Monte.cc, however I used a compiler for .cpp when writing the code.

I set myself the following additional goal (devised by me): I decided to write a program to compute the determinant of any 3 x 3 matrix (having real entries) using a function assigning the value of the Levi-Civita tensor entry to the corresponding permutation The program requests the entries of the 3 x 3 matrix row by row. The Levi Civita tensor has been included in the separate function, which can also be used for aims other than calculating the determinant. I chose such a function because I wanted to determine something and I find determining the determinant quite enjoyable. However, I don't like writing down all the permutations and prefer suffix notation. Hence, I decided to make life easier by making the lovely Levi-Civita tensor an approachable function. My solution was in a file Determinant_Determinator.cc, however I used an online compiler for .cpp when writing the code.

I set myself the following goal (devised by me): Following the instructions given in the lecture notes, I wrote a program to allow the user to pick a lucky number and a range. If the lucky number was within the chosen range, the user was congratulated but if not, the user would be told to have better luck next time. I then modified the code so the user could key in their birthday and today’s date, after which an appropriate greeting would appear. My solution is in a file called Birthday.cc, of which I am reasonably pleased as this is my first ever successful (and enjoyable) coding experience.

I set myself the following additional goal (devised by me): I decided to write a program to enumerate a list of numbers, from 1 to `nloop' (decided by the user). Instead of deciding a lucky number and then highlighting which number was lucky, I extended and modified it to highlight all numbers that are divisible by a certain number, denote as `factor', (decided by the user, as well). My solution was in a file called SESS1SUB.cc

I wrote a program that sorts an arbitrary length input array into ascending order via insertion sort. My solution is included in a file called 'Session1.cc'

I set myself the following additional goal: I designed a game (I really do not think it is, but still...) called Walk. You can input L, F, B and F to move left, right, forward and back. If you can reach the destination without falling off the edge, you win the game. My solution was in a file called Walk.cc.

I have some previous experience with Java, but I am new to C++ so I am interested to know more about the syntax of it. It turns out that input and output in C++ are a lot more convenient and intelligent than Java (convenient syntax, and number strings are automatically converted to numbers if the variable is supposed to be a number). Besides that, I also intend to explore the syntax for control flow and library call for C++. Many math functions seem to be conveniently overloaded to allow input of both float and double. Good.

Since there is already the exercise of finding primes smaller than a set value, it is natural to think about finding all prime factors of some given number. To solve the problem, nested control loops are used, and to clean up the code, function calls are used (which might be understood as the intention of the exercise). In particular, this program always gives the prime factors in increasing order, so it is more useful. In hindsight, the np() i.e. next-prime function might not be strictly necessary.