Hackerrank | Magic Square

Hackerrank

We define a magic square to be an n*n matrix of distinct positive integers from 1 to n^2 where the sum of any row, column, or diagonal of length n is always equal to the same number: the magic constant. You will be given a 3*3 matrix  of integers in the inclusive range [1,9]. We can convert any digit a to any other digit b in the range [1,9] at cost of [a,b]. Given s, convert it into … Read more

A Python Script to Check IP Address Reachability

Python

Introduction In the world of networking, ensuring that devices are reachable is a fundamental aspect of troubleshooting and monitoring. One common method to test this reachability is by using the ping command. In this blog post, we will explore a simple Python script that prompts the user for an IP address and checks its reachability … Read more

Hackerrank | Birthday Candles Problem

Hackerrank

You are in charge of the cake for a child’s birthday. You have decided the cake will have one candle for each year of their total age. They will only be able to blow out the tallest of the candles. Count how many candles are tallest. Example candles=[4,4,1,3] The maximum height candles are  4 units high. … Read more

Hackerrank | Min Max Sum of N-1 Elements

Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. Example arr=[1,3,5,7,9] The minimum sum is 1+3+5+7=16 and the maximum sum is 3+5+7+9=24 . The function prints Function Description … Read more

HackerRank Problem | Staircase detail

Staircase detail This is a staircase of size n=4: Its base and height are both equal to 4 . It is drawn using # symbols and spaces. The last line is not preceded by any spaces. Write a program that prints a staircase of size n. Function Description Complete the staircase function in the editor below. staircase has the following parameter(s): Print Print … Read more

Hackerrank | Plus Minus Problem

Python

Given an array of integers, calculate the ratios of its elements that are positive,  negative, and zero. Print the decimal value of each fraction on a new line with  places after the decimal. Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute error of up to  10^-4 are acceptable. Example … Read more

Hackerrank Problems | Diagonal Difference

Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix  is shown below: The left-to-right diagonal =1+5+9=15. The right to left diagonal = 3+5+9=17. Their absolute difference is |15-17|=2. Function description Complete the  diagonalDifference function in the editor below. diagonalDifference takes the following parameter: Return Input Format The first line … Read more

Hackerrank Problems | Compare the triplets

Python

Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty. The rating for Alice’s challenge is the triplet a = (a[0], a[1], a[2]), and the rating for Bob’s challenge is the triplet b = (b[0], b[1], b[2]). The task is to find … Read more

Learning Curves | Machine Learning from Scratch

bias-and-variance.

Till now, We have read about Gradient Descent,Min-Batch Gradient Descent,Stochastic Gradient Descent and other type of Gradient Descents and Polynomial Regression. In this post we will learn about Learning Curves in Machine Learning . Introduction Learning curves are graphical representations of how a model’s performance changes over time as it learns from training data. These … Read more

Polynomial Regression | Machine Learning from Scratch

Polynomial regression

Introduction Till now, We have read about Gradient Descent,Min-Batch Gradient Descent,Stochastic Gradient Descent and other type of Gradient Descents. In this post we will learn about Polynomial Regression. What if your data is actually more complex than a simple straight line? Surprisingly,you can actually use a linear model to fit nonlinear data. A simple way … Read more

C Program to get Two Sum and Three Sum

When working with arrays, solving problems like finding two elements that sum up to a target or three elements with a specific sum is quite common. In this blog post, we’ll explore simple implementations in C for both the two-sum and three-sum problems using both iterative and recursive methods. Two Sum Problem Iterative Approach The … Read more

Datasets Importing and exporting in Python.

Python Feature Image

What is Dataset? Datasets are container of data in python. It can work as data storage for the various algorithms in python. and also a primary storage of data in Data Science. Below I will be discussing how to import a datasets as dataframe in python. For this post I’ll be using a public dataset … Read more

CRUD Operation in Mongo-cxx

What is CRUD operation ? 2. In Database we generally perform four operation : C – Create : It will be perform create database by Inserting data . R – Read : It will be perform Read operation of database. U – Update : It will be perform Update Database by using unique key. D … Read more

Installing the Mongodb-C Driver (libmongoc) and BSON library (libbson)

Step 1 : Run the Following Command: wget https://github.com/mongodb/mongo-c-driver/releases/download/1.6.3/mongo-c-driver-1.6.3.tar.gz tar xzf mongo-c-driver-1.6.3.tar.gz cd mongo-c-driver-1.6.3 ./configure –disable-automatic-init-and-cleanup –prefix=/usr/local –libdir=/usr/lib64 –with-libbson=bundled make make install Step 2 : To compile and run the program use following command: gcc -o filename filename.c $(pkg-config –libs –cflags libmongoc-1.0) Issues: 1. $(pkg-config –libs –cflags libmongoc-1.0) , this command in above command is … Read more

Installing the mongo-cxx-driver step by step

Step 1 : Download mongo-c-driver
Step 2 : Updated GCC and G++ compiler after version 5 .current version 7 in system .
Step 3 : Mongo-c-driver Version(1.15.x) version is same version and with mongo-cxx-driver (3.5.x)
Step 4 : Updated CMake 3.2 or later.
Step 5 : Install Mongo-cxx-driver

Install and Secure MongoDB 6.0 on CentOS 7

Step 1: Add the MongoDB Repository First, create a .repo file for MongoDB. This will make sure you can install the latest stable version of MongoDB. Create the repo file: Add the next content to the file: 3. Save and exit: Press Ctrl + O to write out, then press Enter. Press Ctrl + X … Read more

Coalesce in SQL

Coalesce is a SQL function used for handling NULL values. It returns the first non-null expression from the list. Each expression is evaluated for being NULL or not and the first non-null expression will be returned as the output. It takes at least two arguments in the list.