GithubHelp home page GithubHelp logo

tests's Introduction

Tests for Jazz Networks - Hamada Fadil Mahdi

I just wanted to give a brief explanation of what I did.

Contents

  1. General Programming Questions

  2. Python Programming Questions

In my first attempt I realised that every third value is even. So I just tried to hard code it at first by finding the even terms of the fibonacci sequence then adding them up.
This obviously isn't the most efficient and wouldn't give me the sum of the first 100 even terms quick enough!

So, I began researching on Maths Stack exchange, I did not want to cheat! I was looking for a theorem that I could code up and then I found this: Closed form for the sum of even fibonacci numbers? More, specifically:

alt text

This allowed me to quickly find the sum without any rigourous computation!!

Another issue that I encountered was that, finding the nth term for the Fibonacci sequence using the recursive function was not effeicient enough. So, I headed to maths Stack exchange again and found this: An nth term for a Fibonacci series? In particular:

alt text

I was now able to quickly work out the nth term of a Fibonacci sequence!

I defined two functions, one that calculated the nth term value for n < 10 and the other for the rest. This is due to the n > 6 condition placed on the theorem.

However, there was an issue. When it came to large numbers. JavaScript began to round them weirdly and I wasn't happy with the result.

Then, after some more brief research I decided to implement big.js which allowed me to manipulate large numbers more accurately.
I also decided to change my approach. Rather than going for a general solution to sum any amount of even Fibonacci sequence terms, I stuck to only finding the sum of the first 100.
However, I still wasn't able to get the full answer as it was 63 digits long:

alt text

With regards to question 2, I have not studies computer science properly except for one module at uni which wasn't extremely thorough. However, I am extremely keen on learning more and solidifying my fundementals God willing!

I really enjoyed this one. I made some assumptions which I hope are reasonable:

  1. The output array must be in Ascending order.
  2. That I did not have to remove duplicated and that the length of the output array must be the same as the sum of the 2 original arrays.

This was my faviourite one!
I had to do some research at first as to how to convert between the base 10 to another base (I started with 5).
I only checked the mathematical method and no code.
So, I followed the method through and coded it up, then when it came to adding the letters I realised that I just needed to swap the 10, 11, 12, 13's etc. with A, B, C, D's etc.
I was contemplating whether I should just go for a for loop with a huge list of if statements but I really really didn't want to do that.
Then by the blessings of God I realised I could use the ASCII conversions!

Sadly, this is the same as Q2 above.

I did not know this off the top off my head. I had to code it out and see what happens. I tried to give a reason for it but I'm not sure if its correct.
However, I'm also very keen on upping my skills in any language and mastering any fundementals needed God willing.

This question was fun, I had to check the syntax for the functions as I had forgotten how to do it from memory. Otherwise, it was pretty straight forward.

tests's People

Contributors

hamadafmahdi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.