Skip to content

Instantly share code, notes, and snippets.

View Abiola-Farounbi's full-sized avatar

Abiola Abiola-Farounbi

View GitHub Profile
@Abiola-Farounbi
Abiola-Farounbi / services.json
Last active April 15, 2022 21:07
A data for different bus services
[
{
"name": "Nicosia 1",
"routes":[
{
"name":"YDÜ Kampüs Ana Durak"
},
{
"name":"Near East Bank Durağı"
},
@Abiola-Farounbi
Abiola-Farounbi / Calculator.js
Created November 16, 2021 17:08
Coderbyte Calculator Solution
function Calculator(str) {
var arithmeticOperators = ['+', '-', '/', '*'];
var replacedStr = str.replace(/(.)\(/g, function (match, g1) {
if (arithmeticOperators.indexOf(g1) != -1)
return match;
else
return match.replace(g1, g1 + '*');
});
return eval(replacedStr);
}
@Abiola-Farounbi
Abiola-Farounbi / minMoves.py
Created October 26, 2021 12:52
Grouping Digits - Hackerank Solution
# Given an array of binary digits, 0 and 1, sort the array so that all zeros are at one end and all ones are at the other. Which end does not matter. To sort the array, swap any two adjacent elements. Determine the minimum number of swaps to sort the array.
# Example
# arr = [0, 1, 0, 1]
# With 1 move, switching elements 1 and 2 yields [0, 0, 1, 1], a sorted array
# Function Description
# Complete the function minMoves
# minMoves has the following parameter(s):
@Abiola-Farounbi
Abiola-Farounbi / MeanAndSd.cpp
Created August 27, 2021 10:28
To calculate the Mean and Standard Deviation of five values
#include <iostream>
#include <cmath>
using namespace std;
// Function Prototype
void FillArray(float ArrayValues[]);
void CalculateMeanandStddev(float ArrayValues[], double *Mean_ptr, double *Stddev);
void PrintResult(float ArrayValues[], double Mean, double Stddev);
@Abiola-Farounbi
Abiola-Farounbi / QuadraticEquationCalculator.cpp
Created August 21, 2021 19:53
This program calculates the roots of a quadratic equation in C++
#include <iostream>
#include <cmath>
using namespace std;
//Function call by reference using pointers
void AskForValues(double *a_ptr, double *b_ptr,double *c_ptr)
{
cout << endl << "Enter your values" ;
@Abiola-Farounbi
Abiola-Farounbi / PalindromeNumbers.cpp
Created June 14, 2021 04:02
This problems set determines where a number is palindrome or not in c++
#include <iostream>
using namespace std;
bool isPalindrome(int x) {
//complete the function
int n, num, digit, rev = 0;
bool True = true;
bool False = false;
num = x;
@Abiola-Farounbi
Abiola-Farounbi / SmallestPostiveInteger.py
Created May 29, 2021 01:20
This problem set finds the smallest positive integer that does not exist in an array
---
Write a function:
def solution(A)
that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.
For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5.
Given A = [1, 2, 3], the function should return 4.
@Abiola-Farounbi
Abiola-Farounbi / Decimals.cpp
Created May 28, 2021 19:27
In this problem set, i was able to handle how to output a decimal in c++
// Sololearn problem set for c++
// You are working on a ticketing system. A ticket costs $10.
// The office is running a discount campaign: each group of 5 people is getting a discount, which is determined by the age of the youngest person in the group.
// You need to create a program that takes the ages of all 5 people as input and outputs the total price of the tickets.
// Sample Input: 55 28 15 38 63
// Sample Output: 42.5
// The youngest age is 15, so the group gets a 15% discount from the total price, which is $50 - 15% = $42.5
#include <iostream>
using namespace std;
@Abiola-Farounbi
Abiola-Farounbi / shufflePupils.js
Last active May 21, 2021 07:15
This function returns the shuffled array
// Apex college needs your help in writing a logic to shuffle pupils on an assembly line
// by moving a number of pupils either to the front of the line or to the end of the line.
const shufflePupils = (pupils,val) => {
// Test cases for null and empty array
if (!pupils || pupils.length == 0) return []
// test case for 0 value
if(val == 0) return pupils
@Abiola-Farounbi
Abiola-Farounbi / mergeSortedArray.js
Last active May 12, 2021 13:22
The function returns the merged array of two sorted array
//Problem Set for #AlgorithmFriday Week5
// A school has two classes A and B, Each class has the ages of its students in a sorted list.
// The school decides to join both classes and needs you to help them write a function that merges both lists into one
// such that the students' ages still remains sorted in increasing order.
const mergeSortedArray = (classA,classB) => {
// Test cases for null and empty array
if (!Array.isArray(classA) || !Array.isArray(classB) ) return []