Latest posts

Introduction to C

The article is written with the view that its readers are able to have a basic knowledge about C programming.
Prior Knowledge:
What is a programming language?
A formal language with some basic structure and can perform following operations is called a programming language.
->Takes input i.e. raw data from the user.
->Stores data i.e. saving data and instructions.
->Processes it i.e. performs logical and arithmetic operations.
->Produces output i.e. useful information which is desired by the user.
->Controls the work i.e. the manner and the technique in which all the above operations execute.

C Language:
-> C Language is a type of structural/procedural programming.
-> C Language works on “top-down” programming approach which means the problem is viewed as a sequence of tasks to be performed.
-> While solving a problem, C Language divides it into segments which behave as subprograms.

Compilation Phases:
The process can be split into four separate stages: Preprocessing, compilation, assembly, and linking.
->Let us have a C program which is saved as “.c” file.
->The first stage of compilation is called preprocessing.
“.c” file goes to preprocessor, which produces “.i” file.
->The second stage of compilation is confusingly enough called compilation.
“.i” file goes to compiler, which produces “.s” file.
->The third stage of compilation is called assembly.
“.s” file goes to assembler, which produces “.o” file, which is in machine language/object type.
->The last stage of compilation is called linking.
“.o” file goes to linker, which produces “.exe” file in windows or “.out” file in Linux.
(The image attached with the article has a diagrammatic representation of this process)

Function of Preprocessor:
->performs “find and replace” operation.
->processes ‘#’ directives.
Function of Compiler:
->checks the grammar of program.
->checks for syntax and errors.
->converts into assembly code.
Function of Assembler:
->converts assembly code to machine language.
Function of Linker:
->links all the files such as printf.o, scanf.o, sio.o, cos.o, etc.
->generates “.exe” file in Windows or “.out” file in Linux.

Let us have a look on the very first code snippet to understand the basic structure of a C code:

include<stdio.h> <—–header file/bin folder

int <—–data type
main() <—–function
{
printf(“Hello, World!”); <—–desired output
return 0; <—–endpoint of the function
}

The article is written with the view that its readers are able to have a basic knowledge about C programming.


Prior Knowledge:
What is a programming language?
A formal language with some basic structure and can perform following operations is called a programming language.
->Takes input i.e. raw data from the user.
->Stores data i.e. saving data and instructions.
->Processes it i.e. performs logical and arithmetic operations.
->Produces output i.e. useful information which is desired by the user.
->Controls the work i.e. the manner and the technique in which all the above operations execute.

C Language:
-> C Language is a type of structural/procedural programming.
-> C Language works on “top-down” programming approach which means the problem is viewed as a sequence of tasks to be performed.
-> While solving a problem, C Language divides it into segments which behave as subprograms.

Compilation Phases:
The process can be split into four separate stages: Preprocessing, compilation, assembly, and linking.
->Let us have a C program which is saved as “.c” file.
->The first stage of compilation is called preprocessing.
“.c” file goes to preprocessor, which produces “.i” file.
->The second stage of compilation is confusingly enough called compilation.
“.i” file goes to compiler, which produces “.s” file.
->The third stage of compilation is called assembly.
“.s” file goes to assembler, which produces “.o” file, which is in machine language/object type.
->The last stage of compilation is called linking.
“.o” file goes to linker, which produces “.exe” file in windows or “.out” file in Linux.

Function of Preprocessor:
->performs “find and replace” operation.
->processes ‘#’ directives.


Function of Compiler:
->checks the grammar of program.
->checks for syntax and errors.
->converts into assembly code.

Function of Assembler:
->converts assembly code to machine language.


Function of Linker:
->links all the files such as printf.o, scanf.o, sio.o, cos.o, etc.
->generates “.exe” file in Windows or “.out” file in Linux.

Let us have a look on the very first code snippet to understand the basic structure of a C code:

include <—–header file/bin folder

int <—–data type
main() <—–function
{
printf(“Hello, World!”); <—–desired output
return 0; <—–endpoint of the function
}

Introduction to C

The article is written with the view that its readers are able to have a basic knowledge about C programming.


Prior Knowledge:
What is a programming language?
A formal language with some basic structure and can perform following operations is called a programming language.
->Takes input i.e. raw data from the user.
->Stores data i.e. saving data and instructions.
->Processes it i.e. performs logical and arithmetic operations.
->Produces output i.e. useful information which is desired by the user.
->Controls the work i.e. the manner and the technique in which all the above operations execute.

C Language:
-> C Language is a type of structural/procedural programming.
-> C Language works on “top-down” programming approach which means the problem is viewed as a sequence of tasks to be performed.
-> While solving a problem, C Language divides it into segments which behave as subprograms.

Compilation Phases:
The process can be split into four separate stages: Preprocessing, compilation, assembly, and linking.
->Let us have a C program which is saved as “.c” file.
->The first stage of compilation is called preprocessing.
“.c” file goes to preprocessor, which produces “.i” file.
->The second stage of compilation is confusingly enough called compilation.
“.i” file goes to compiler, which produces “.s” file.
->The third stage of compilation is called assembly.
“.s” file goes to assembler, which produces “.o” file, which is in machine language/object type.
->The last stage of compilation is called linking.
“.o” file goes to linker, which produces “.exe” file in windows or “.out” file in Linux.
(The image attached with the article has a diagrammatic representation of this process)

Function of Preprocessor:
->performs “find and replace” operation.
->processes ‘#’ directives.


Function of Compiler:
->checks the grammar of program.
->checks for syntax and errors.
->converts into assembly code.


Function of Assembler:
->converts assembly code to machine language.


Function of Linker:
->links all the files such as printf.o, scanf.o, sio.o, cos.o, etc.
->generates “.exe” file in Windows or “.out” file in Linux.

Let us have a look on the very first code snippet to understand the basic structure of a C code:

include<stdio.h> <—-header file/bin folder
int <—–data type
main() <—–function
{
printf(“Hello, World!”); <—–desired output
return 0; <—–endpoint of the function
}

Sentimental Analysis using SVM

Sentimental analysis is the process of classifying various posts and comments of any social media into negative or positive. Using NLP(Natural Language Programming) or ML(Machine Learning) is the best way to make this process easier.

The project I did for sentimental analysis has the following program flow.

Steps to perform analysis-

The steps for any sentimental analysis is:-

  1. Preparation of Data set– one can take any type of data or can download from net also. More the data more will be accuracy of the prediction.
  2. Data pre processing– In this step we make the words simpler so that the prediction becomes easy. Some common data pre processing methods are- tokenization(dividing into each word),lemmitization,stemming and removing stop words(unwanted words) and characters.lemmitization means getting the original word of the input word that is “beautiful” will become “beauty”
  3. Feature extraction-For all classification algorithms, features are necessary to either plot or make a precise detail so that the predictions are based on that features. here we will use TFIDF algorithm
  4. Classifier algorithms– Here we use svm(support vector machine) but various others like naive bayes , regression,etc. can be used.
  5. Prediction- Once all the above steps are done the model is ready to do the predictions. We will do the predictions on the testing dataset.

Necesary imports:-

Image for post

The data set used is quite simple and is manually entered. The data set is a csv file. You can get a direct comments dataset on google. The data set is nearly of length 308.

Image for post
Dataset

Python Code –

Preparing Dataset-

#the following line is used so that we run the program again and again the original input values are maintained.
np.random.seed(500)
#now lets read the data set using panda(pd)
data = pd.read_csv(‘training.csv’,encoding=’latin1')
#latin is used as the data set is long so to decode and proper start byte
data.dropna(inplace=True)#removing all empty spaces
# Change all the text to lower case.
#Python interprets ‘car’ and ‘CARS’ differently.I have not used stemming in this program but the process is simple and can be done by using in built functions like “ntlk”.
data[‘Sentence’] = [entry.lower() for entry in data[‘Sentence’]]
data[‘Sentiment’] = np.where(data[‘Sentiment’].str.contains(‘positive’), 1, 0)
#the above step divides the positive as 1 and negative as 0 this could have been done by label encoder but my train_y array is 1 d
Train_X, Test_X, Train_Y, Test_Y = train_test_split(data[‘Sentence’],data[‘Sentiment’],test_size=0.3)
#splitting the data set as training and testing sets in 70:30 ratio
print(Train_X.shape,Train_Y.shape)#this helps to view the number of rows in the data set

OUTPUT-

Image for post

Classifying Sentiment in numeric form and performing TF-IDF

Encoder = LabelEncoder()#this is used so that all the entries of Y is properly divided as 1 and 0
Train_Y = Encoder.fit_transform(Train_Y)
Test_Y = Encoder.fit_transform(Test_Y)
d = pd.read_csv(“stopwords.csv”)
my_stopword=d.values.tolist() #converts the datatype to list
#removing the unwanted words like “are,is you,will,etc…”(stopwords.csv has the list of words)
#tfidf feature extraction using the function
vectorizer = TfidfVectorizer(my_stopword)
vectorizer.fit_transform(data[‘Sentence’])
#feature_names = vectorizer.get_feature_names() by this u can view if the stop words are removed and the only important feature words
#values of tfidf for train data and test data
Train_X_Tfidf = vectorizer.transform(Train_X)
Test_X_Tfidf = vectorizer.transform(Test_X)
print(Train_X_Tfidf)
Image for post


(a,b) c :csr matrix : a- memory index b-unique binary value for each number c- tfidf value.

Perfroming SVM-

#SVM function inbuilt in the library
SVM = svm.SVC(C=1.0, kernel=’linear’, degree=3, gamma=’auto’)
SVM.fit(Train_X_Tfidf,Train_Y)
# predict the labels on validation dataset
predictions_SVM = SVM.predict(Test_X_Tfidf)
# Use accuracy_score function to get the accuracy
print(“SVM Accuracy Score -> “,accuracy_score(predictions_SVM, Test_Y)*100)
#if you want to enter an input sentence and check the classificcation as positive or negative
lst = [ ]
print(“Enter sentences: “)

for i in range(0, 2):
ele = input()
lst.append(ele)

#print(lst)
tes=vectorizer.transform(lst)
#print(tes)
predictions= SVM.predict(tes)
#print(predictions)
for i in predictions:
if predictions[i] == 1 :
print(“ — — positive”)
else:
print(“ — — negative”)

OUTPUT-

Image for post

Hope you all understood it!

Elon Musk Neuralink’s Magic

Do you ever want to download the skills into your brain, operate robots with the brain, stream music, save and replay the favorite memories, play video games with the brain, and many more? No No, it is not about the Science fiction action film which you are thinking about. Elon, founder of many futuristic projects like Tesla, SpaceX, the boring Company, and much more influence by Odyssey clock quote “Sufficiently advanced technology is indistinguishable from magic!” now wants to come into your brain with the most impressive and invasive technology of Merging humans with Machine-Neuralink.

Elon explaining about Neuralink

Chip installation and working

The dread of Artificial Intelligence taking over the human race makes Elon come up with Brain-Machine Interface (BMI). Elon compiles it as Fitbit in your skull with tiny wires. How can one imbed the chip in the brain! The whole process of chip coronation is done by a fully automated neurosurgical robot, with accurate precision of no bleeding within an hour. The robot images the brain and inserts the electrodes with no noticeable damage, and closes things up. A compact inductive charger wirelessly connects to the implant to charge the battery from the outside.

But, how can it perceive our brain activity? Neurons in our body send and receive information from various parts through chemical signals called neurotransmitters. These generate a small electrical field from where the electrodes record the reactions and translate them into an algorithm that a machine can interpret. This way, neuralink makes our brain regulate-machines.

Implantation of chip

Chip demonstration on pigs

Does it work on humans? Recently, Elon made a brain chip demonstration on three pigs named Joyce, Dorothy, and Gertrude, where Joyce didn’t have an implant. Dorothy had an implant, but it was removed, after removing the implant Dorothy is supernormal and safe. Meanwhile, Gertrude currently had the implant used to demonstrate the neural brain activity in real-time for different stimuli. Elon confidently says that the first human implantation will come soon.

Applications of Neuralink

What stuff can we do with this technology? The exertion of neuralink is limitless, but the initial focus of the company is on patients who are with paralysis, neurological disorders, and spinal injuries. If technology flourishes, one can be able to restore the sensory and motor functions, disease prediction, telepathy, save and replay the memories, AI symbiosis, Painless surgeries, control machines, download your brain into a computer, and many more. Anyhow, the Neuralink team has a lot of ethical and technological barriers to cross. What are you thinking about this exciting technology?!

Reverse a Linked List using Python

This blog post will help your to learn, How to reverse Linked List using Python.

Input: Before reverse operation on Linked List 
1->2->3->4->NULL 
Output: After Reverse operation Linked list will look like, 
4->3->2->1->NULL

So to reverse a Linked List, we have to create a three points

  • Prev
  • Current
  • next
Source: Learnersbucket.com

How to create Node in SIngly Linked List using python, You can read out here in few words https://freshlybuilt.com/question/how-to-create-node-for-linked-list-using-python/

Algorithm for Reverse a Linked List

  • Initialize three pointers prev as None, curr as head and next as None
  • Iterate through the linked list.
  • In a Loop follow the bellow steps.
  • Before changing the next of current store next node i.e next = current.next
  • Now change the next of current, This is a point where actual reversing happens i.e current.next = prev
  • Move the prev and current one step forward i.e prev = current, current = next

Reverse a Linked List – Python Code

# Structure for node
class Node: 

	# Constructor to initialize the node object 
	def __init__(self, data): 
		self.data = data 
		self.next = None

class LinkedList: 

	# Function to initialize head 
	def __init__(self): 
		self.head = None

	# Function to reverse the linked list 
	def reverse(self): 
		prev = None
		current = self.head 
		while(current is not None): 
			next = current.next
			current.next = prev 
			prev = current 
			current = next
		self.head = prev 
		
	# Function to insert a new node at the beginning
        # Function to push data at the beginning
	def push(self, new_data): 
		new_node = Node(new_data) 
		new_node.next = self.head 
		self.head = new_node 

	# Function to print the linked LinkedList 
	def printList(self): 
		temp = self.head 
		while(temp): 
			print(temp.data) 
			temp = temp.next


linked_list = LinkedList() 
linked_list.push(1) 
linked_list.push(2) 
linked_list.push(3) 
linked_list.push(4) 

print("Given Linked List will look like ")
linked_list.printList() 
linked_list.reverse() 
print("After reverse function, Reversed Linked List will look like")
linked_list.printList() 

Output

Given Linked List will look like
1 2 3 4
After reverse function, Reversed Linked List will look like
4 3 2 1
  • Time Complexity: O(n)
  • Space Complexity: O(1)

It is one of the simplest method to reverse a linked list. What are your views about the recursive method for reversing a linked list. Do you think it is better than this one, Comment it out in comment section. Let’s have good discussion.

What’s new in Python 3.9

python_3.9_features

Some days back, a stable version of Python 3.9 is officially released with some new features and cool features. Although versions of Python 3.9 were released from time to time, the stable version is released now.

Here are some cool features in this version:

Dictionary Updation

There were many method for merging and updating dictionaries but the syntax was not that good or a bit cryptic.

With new merge (|) and update(|=) operators it becomes easy how we merge dictionaries. The merge and update operators work similarly to the concatenation(+) and in place concatenation(+=) in lists.

>>> a = {'1' : 'apple', '2' : 'mango'}
>>> b = {'3' : 'grapes' ,'4' : 'bananas'}
>>> a|b
{'1' : 'apple', '2' : 'mango', '3': 'grapes', '4': 'bananas'}

One thing to note here is that if there are some conflicts or key errors, then the value from right will be given preference.

Note :- This pipe(or merge) operator should not be used in series as this operator is in-efficient.

Type Hinting

Now, you don’t need to import types from typing library. You can use built-in types too.

For example, we can check type of variables and return type during run time of the code.

>>> def iseven(name: int) -> bool:
. . .      if number%2:
. . .         return False
. . .      else:
. . .         return True 

The above function will throw TypeError is the type defined don’t match.

String Suffix and Prefix

New methods, removeprefix and removesuffix methods are added in built in ‘str’ class to remove unneeded suffix and prefix.

>>> s='python is better'
>>> s.removeprefix('python is ')
'better'
>>> s.removesuffix(' is better')
'python'

Typological Sorting

A new module, graphlib is added to perform topological sorting in graph. It can help in scheduling tasks based on dependencies like installing python libraries that depends on each other.

GCD and LCM

Till now, math module supports HCF of two numbers like this:

>>> from math import gcd
>>> gcd(10,15)
5

As LCM is similar to GCD, there was no method to calculate LCM directly. But with python 3.9, you don’t need to define your own LCM function.

Also, Python below version 3.9 supports gcd of two numbers only and you have to iterate over the list or use reduce to find gcd. With python 3.9, it’s a lot easier.

>>> from math import gcd, lcm
>>> math.gcd(33, 45, 81)
3
>>> math.lcm(33, 45, 81)
4455

NOTE : – These functions can’t calculate based on lists. However, you can unpack it in comma separated values.

Randbytes

Random module has a new function randbytes to generate random bytes.

>>> from random import randbytes
>>> randbytes(6)
b'k\xcf\x07\x0c?\x95'

New HTTP Status Code

In python 3.9, new http status codes EARLY_HINTS(103), IM_A_TEAPOT(418), TOO_EARLY(425) are introduced.

>>> from http import HTTPStatus
>>> HTTPStatus.EARLY_HINTS
<HTTPStatus.EARLY_HINTS: 103>
>>> HTTPStatus.IM_A_TEAPOT.value
418
>>> HTTPStatus.TOO_EARLY.phrase
Too Early

Although there are some more features that are introduces, but only some of them are listed above. For more detailed explanation, visit official documentation here.

List of houseplant best to add the colour red to your decor

Buy Indoor plants

Want to add a pop of red to your place? You can rely on plants for that. I know you must have already shortlisted the wall paints, the art that will go along with it till now. But you don’t need these artificial decor when you can easily rely on nature for that. Speaking about flowers and plants, you will find all the colors under this sky. Infact nature gives us the inspiration of colors, whether it is the red color that you wish to add to your place or any other tint from the color family, all you have to do is order plants online.

Adding red to the decor is a bold choice as red really pops to the eyes and definitely attracts attention instantly. This colour can be added to a place or a room you find dull otherwise. If you want to know which plants will be suitable to bring in your place that will add red to your place, then keep on reading. I have shortlisted a few flowering plants that do well when planted indoors as well outdoors. You can place it wherever you like, and also the care guide is mentioned along with so that you know the type of sun they like, water needs, and everything.

Gerbera daisies plant
First on the list is a really happy flower that we love and will enjoy having at our place- gerbera daisies. This is one happy plant that spreads positivity to any place they are added to. They instantly make anyone smile because the flower this plant gives out is so cheerful. The flower of this plant is available in many different colors, and red out of them is very pretty. It has long rays like petals that are painted beautifully in very subtle red. Also, the golden yellow center of the flower looks great along with the flowers. You can even pluck this flower out of your garden to send it to someone.

Amaryllis plant
Amaryllis plants have been uniquely bred to be grown inside the spaces and are unbelievably simple to grow and maintain. They thrive in winter when there is a maximum of shading, and everything around is dull, with amaryllis. You can add color, and they will remain in blossom for quite a long time. Every year, the flower bulb gets somewhat more strong and sends up extra stalks of blossoms on long, tough stems. In case you need your amaryllis to sprout at Christmas time, you should do a touch of extra care. Yet, on the off chance that you are glad to have it blossom on its own schedule, the main offseason care it needs is to be put outside for the mid-year.

Rose plant
Roses needn’t be introduced separately because when a list with a beautiful red flowering plant is being prepared, roses are a definite pick. Indeed, when you think of red blossoms, it is the automatic response of your brain to put a red rose in the picture. Accessible in various hues like pink, yellow, orange, and speaking of the most beautiful tone, red is the one you should plant in your space. Valentine’s Day, the day of affection, is fragmented without roses. A red rose speaks to the love, energy, and profundity of a relationship. With white rose & red rose, you can communicate the essential parts of a relationship, which are wanted, romance, and love. Buy indoor plants online and have pretty roses bloom in your garden.

Flame of the woods
Since we have all red flowers on the list, we certainly cannot miss this plant. If you are searching for a test, developing Ixora as a houseplant is a remunerative one. These are impulsive plants. If you can locate a radiant spot where there is ample sunlight, then let me say that your plant is happy, leave it there. Any adjustment in exposure can make it wither. However, if you can keep it warm and radiant, you will appreciate many huge blossom bunches of many waxy and shiny, green leaves. Love the look, however, don’t have the sun? You may likewise need to consider dwarf Ixora (Ixora Chinensis), which is impressively smaller in size and easier than its somewhat flashier cousin.

These are the plants that will help you to incorporate the color red to any place.

Truecaller Hiring for Web Development intern 2020

Hello, Truecaller is calling you from Bangalore, India! Ready to pick up?

Truecaller is a Swedish company founded in 2009 in Stockholm, Sweden by Nami Zarringhalam and Alan Mamedi, with the mission to provide more safe and efficient communication to everyone’s daily life. The app began when our co-founders were just students who wanted to create a service that would easily identify incoming calls from unknown numbers.Truecaller is loved by 180 million daily active users around the world,we are the go-to app for Caller ID, spam blocking and payments.We have our strongest presence in South Asia, Middle East, Africa, and HQ in Sweden. We are backed by some of the most prominent investors in the world such as Sequoia Capital, Atomico, and Kleiner Perkins Caufield & Byers.

We at Truecaller for Developer business unit are responsible for building and offering Truecaller connected solutions for external developer and startup ecosystems. The vision of this business unit is to create a trusted and win-win developer platform for startups/ businesses across emerging markets.

What Truecaller expect from you

  • Good Knowledge on HTML and CSS with a good sense of UI elements and design
  • Good understanding of modern JavaScript development including application lifecycle, asynchronous server communication, and UI components.
  •  knowledge on components using frameworks such as Vue or React. should be comfortable writing server-side code in Node.js and have experience using web frameworks such as Express.js
  • Hands on experience on configure build tools and bundlers such as webpack och rollup
  • Should be passionate about writing clean, maintainable and efficient code with proper documentation.
  • Fluent in English, both in speaking and writing
  • Bachelor’s degree in Computer Science or comparable technical experience
  • Ability to learn new technologies quickly

It would be great if you also have

  •  If you have experience writing universal JavaScript applications with frameworks such as Nuxt.js or Next.js, it’s a bonus

What will you work on?

As a Web Development Intern in our Truecaller for Developers Business Unit, you will be responsible for the whole cycle of product development on the web. Everything you release will reach millions of our users, which requires a solid focus on the end-user experience and usability. Your challenge will be to move fast while still applying software knowledge and long term quality thinking to your work. The work will involve everything from the implementation of complex features with a highly usable UI and ongoing improvements based on metrics while ensuring high standards of security and privacy. 

What Truecaller offer:

  • Learning & sharing environment
  • Exciting company parties & team activities – Football Team, Geek lunch, Lab Days!
  • Flexible working hours
  • Competitive stipend
LocationBangalore, India
Employment TypeInternship
BatchAny Batch

ALL THE BEST from Freshlybuilt for your application.

WE DON’T SPAM NOTIFICATION CHANNEL, WE POST ONLY 1-3 FILTERED OPPORTUNITIES PER DAY :), We don’t Like Spamming the GroupJust Aim for providing a good opportunity to better candidate.

APPLY NOW

BNY Mellon Hiring code divas for 2020

Code Divas Diversity Challenge 2020

A stronger digital experience helps us—and our clients—work in a simpler, smarter, safer manner. We are taking a different approach to digitize BNY Mellon. Ours is the only approach that we believe delivers true impactful and sustainable results. 

Digitizing this bank is about changing each process, product, and client interaction so they are digital — in line with best standards and client expectations at BNY Mellon and therefore we’re seeking passionate, talented, 10x engineers who want to make their mark in the financial industry with BNY Mellon Technology, India.

About BNY Mellon

BNY Mellon Alcentra Global Credit Income 2024 Target Term Fund, Inc.  Declares Monthly Distribution | Business Wire

BNY Mellon is an investments company. We provide investment management, investment services and wealth management that help institutions and individuals succeed in market.

Prizes details: 

  • 1st Place: Gift vouchers worth INR 50000 
  • 2nd Place: Gift vouchers worth INR 30000  
  • 3rd Place: Gift vouchers worth INR 20000
  • 10 Consolation Prizes: Gift vouchers INR 5000 each

Eligibility Criteria:

  • Female candidates
  • BE/BTech/ M.E/M.Tech/ MCA/ M.Sc. & MS Maths and Computing
  • CGPA 7 and above
  • No current/active backlogs
  • 2021 graduates for full time and 6-month internship (Jan to Jun 2021) opportunities
  • 2022 graduates for summer internship (May to July 2021)

Challenge Format:

  • 4 programming questions

Participants can attempt as many questions as they can within the test duration. The more the number of questions they attempt and get correct, the better their chances of getting shortlisted for interviews.

Interns and full time campus grads hired will be placed in one of the several teams of BNY Mellon Technology. The job role will revolve around Software Development. The final decision of the compensation, role and department selection rests with BNY Mellon and will be decided after the interview process post the challenge.

Ideal Candidate

We are looking for rock star 10X developers who are passionate about developing world class software. We love candidates with strong analytical abilities, are quick learners, are strong customer advocates, self-starters and team players with a strong degree of ownership.

Responsibilities

  • Work with business analysts to design and develop new features on our platforms
  • Design and develop small to medium sized micro-services to support business automation
  • Work with a global scrum team of 6-8 team members focused on service delivery
  • Enhance and maintain applications identifying and debugging complex problems, finding root cause and fixing the problems
  • Participate in design discussions and other agile development activities

Requirements

  • Knowledge of one or more high-level programming languages such as Java, C/C++, Python, Ruby, GoLang, Javascript amongst others
  • Knowledge of frameworks such as Spring, Gin, RoR (Backend) and/or Angular, React.js (Front End) is a plus
  • Knowledge of popular public cloud platforms and concepts such as AWS, Azure, and other is a plus
  • Strong understanding of data structures and algorithms
  • Excellent analytical and problem-solving abilities
  • Solid computer science fundamentals
CTC11 – 21 lacs per annum CTC
Job LocationPune and Chennai
Openings100
Intern Stipend60,000 per month
Open atOct 17, 4:00 PM IST
Closes atOct 17, 10:00 IST
Batch AllowedOnly 2021 and 2022 Batch
Duration3H

ALL THE BEST from Freshlybuilt for your application.

WE DON’T SPAM NOTIFICATION CHANNEL, WE POST ONLY 1-3 FILTERED OPPORTUNITIES PER DAY :), We don’t Like Spamming the GroupJust Aim for providing a good opportunity to better candidate.

APPLY NOW

Number of Triangles in an N-sided Polygon by white vertices only

Maths is considered as one of the most important skills for a computer science student. It helps you to understand and analyze the problem to come up with an optimal solution.

In this article, one can learn one of the important topic of mathematics, i.e., combinatorics using a sample problem.

Problem Statement

You are given a polygon of N sides with vertices numbered from 1, 2, …, N. Now, exactly 2 vertices of the polygons are coloured black and remaining are coloured white. You are required to find the number of triangles denoted by A such that:

  1. The triangle is formed by joining only the white-coloured vertices of the polygon.
  2. The triangle shares at least one side with the polygon.

Approach

This problem can be solved in O(1) if you have a strong foundation of mathematics. For this law of combinatorics are required.

We can divide our problem in three parts as follows:-

  1. Polygon in which black vertices are adjacent to each other.
  2. Polygon in which there is a white vertex between black vertices.
  3. All other cases

Case 1: – Polygon in which black vertices are adjacent to each other

polygon with black vertices adjacent to each other

Here in the above image vertex 1 and vertex 2 are black and all other vertices are white.

Now, in this question, it is mentioned that the triangle should share at least one side with the polygon.

By the law of combinators,
No. of triangles formed = no. of ways to choose one side * no. of ways to choose another vertex – no. of triangles counted more than once.
Here, as triangles should have only white vertices side formed by vertex 1 or vertex 2 can’t be chosen.
No. of ways to choose one side= n-3C1 (as sides formed by (1,2),(1,6) and (2,3) can’t be chosen.

Let us assume that the side formed by vertex pairs (3,4) is chosen.

No. of ways to choose another vertex = n-4C1 (as vertices 1,2,3 and 4 can’t be chosen). We have 4 fewer choices when choosing another vertex.

Now, some triangles have been counted twice. For eg: -△ 345 is counted twice. Therefore, triangles formed by two sides common should be removed.

Generally, n triangles with two sides common can be formed with an n-sided polygon. But as black vertices can’t be included, we have 4 fewer pairs of two consecutive sides. (Pairs ((5,6),(6,1)), ((6,1),(1,2)), ((1,2),(2,3)), ((2,3),(3,4)) ) can’t be chosen). Therefore, n-4 triangles are counted twice.

No. of triangles formed: - n-3C1×n-4C1 - (n-4)
= (n-3) × (n-4) -(n-4)
= n2 - 7n + 12 -n +4 = n2-8n+16
= (n-4)2

No. of triangles formed in hexagon = (6-4)×(6-4) = 2×2=4
triangles formed in hexagon with black vertices adjacent to each other
Triangles formed are:- △356, △346, △345 & △456.

Case 2: – Polygon in which white vertex is between black vertices

polygon with a vertex between black vertices adjacent

Here, all vertices are white except vertex 1 and vertex 3.

By the law of combinators,
No. of triangles formed = no. of ways to choose one side * no. of ways to choose another vertex – no. of triangles counted more than once.
Here, as triangles should have only white vertices side formed by vertex 1 or vertex 2 can’t be chosen.
No. of ways to choose one side= n-4C1 (as sides formed by (1,2),(1,6),(2,3) and (3,4) can’t be chosen.

Similar to previous case, there are n-4C1 ways to choose another vertex.

No. of triangles counted twice = No. of triangles formed by two consecutive sides.
Here, We have 5 less consecutive pairs as black vertices are excluded. (Pairs ((5,6),(6,1)), ((6,1),(1,2)), ((1,2),(2,3)), ((2,3),(3,4)) & ((3,4),(4,5)) ) can’t be chosen).

No. of triangles formed: - n-4C1×n-4C1 - (n-5)
= (n-4) × (n-4) -(n-5)
= n2 - 8n + 16 -n +5
= n2-9n+21

No. of triangles formed in hexagon = 6×6 – 9×6 +21 = 36 – 54 + 21 = 3
triangles formed in hexagon with more than one white vertex between black vertices
Triangles formed are:- △245, △256 & △456.

Case 3: – Polygon in which there are more than two or more vertices between black vertices

no of triangle in a polygon
Hexagon with two white vertices between black vertices

Here all vertices are white except 1 vertex 1 and vertex 4.

Similar to previous case, the no. of ways to choose a side and another vertex are same, i.e, n-4C1

There are no consecutive pairs in the above hexagon. By visualizing some more polygons with more sides we can deduce that there are 6 fewer pairs.

No. of triangles formed: - n-4C1×n-4C1 - (n-6)
= (n-4) × (n-4) -(n-6)
= n2 - 8n + 16 -n +6
= n2-9n+22

No. of triangles formed in hexagon = 6×6 – 9×6 +22 = 36 – 54 + 22 = 4
triangles formed in hexagon with white vertex between black vertices
Triangles formed are:- △235, △236, △256 & △356.

Code in Python

for _ in range(int(input())):
    n,b1,b2=map(int,input().split())
    if abs(b1-b2)==1 or abs(b1-b2)==n-1:
        print((n-4)**2)
    elif abs(b1-b2)==2 or abs(b1-b2)==n-2:
        print(n*n-9*n+21)
    else:
        print(n*n-9*n+22)

If you found any error, feel free to post in the comments section.

Reference Link:- https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/number-of-triangles-6ac88eb2/description/