Found 33676 Articles for Programming

Golang program to take in a slice of integers and compute their sum using concurrency

Akhil Sharma
Updated on 04-Aug-2023 16:44:49

1K+ Views

In this Go language article, we will write programs to take in a slice of integers and compute their sum using concurrency. Concurrency helps multiple tasks or operations to be performed simultaneously. It helps make efficient use of system resources. It is achieved using Go routines which are light-weight threads and channels which helps in the communication between the go routines. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its size and capacity as arguments. func range(variable) The ... Read More

Golang program to sort a slice of integers using merge sort with concurrency

Akhil Sharma
Updated on 04-Aug-2023 16:43:48

307 Views

In this article, we will write Go language programs to sort a slice of integers using merge sort with concurrency. It is a process which makes the parts of a program run independently and parallelly enhancing the efficiency of the program. Go routines and channels are used to execute concurrency. Merge sort is a divide and conquer algorithm used to sort the unsorted array or slice by dividing the input slice into smaller sub-slices, individually sort them recursively and then merge them into a single slice which is sorted. Syntax func make ([] type, size, capacity) The make function ... Read More

Golang program to compute the factorial of a number using concurrency

Akhil Sharma
Updated on 04-Aug-2023 16:38:00

528 Views

In this article, we will write Go language programs to compute the factorial of a number using concurrency. It is a task of implementing multiple operations simultaneously and can be implemented using Go routines and channels. Go routines are the lightweight threads and channels help in non-conflicting communications between the routines. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its size and capacity as arguments. Algorithm This program imports the necessary packages main and fmt. In this ... Read More

Golang program to compute all prime numbers up to a given number using concurrency

Akhil Sharma
Updated on 04-Aug-2023 16:22:28

556 Views

In this Go language article, we will write programs to compute all prime numbers up to a given number using concurrent execution. Concurrent execution is the process of executing multiple tasks simultaneously. In Golang, go routines and channels are used to create concurrent programs. Go routines are lightweight threads which are managed by the Go runtime and channels help in the communication between Go routines without any conflicts. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its size ... Read More

Golang program to return the nth number in fibonacci sequence using dynamic programming

Akhil Sharma
Updated on 04-Aug-2023 14:57:49

1K+ Views

In this article, we will write Go language programs to return the nth number in Fibonacci sequence using dynamic programming. It is a technique used to solve complex problems by breaking them into smaller sub problems. Memoization is the process of storing the output of the function calls in some data structure by which the next time call is made it need not calculate the output again, it can use that value to make the computation which in return lessens the execution time. Syntax func make ([] type, size, capacity) The make function in go language is used to ... Read More

How to simulate mouse movements using Python?

S Vijay Balaji
Updated on 24-Aug-2023 12:21:04

8K+ Views

When it comes to automation, be it to setup your computer on start-up or to farm coins on a clicker game, it becomes essential to simulate mouse movements and clicks. And what better way to do this than use Python! For performing this particular task of automating or simulating your mouse movement, we will be using Python’s mouse library that has various methods and functionalities to help simulate your mouse on your computer. Now that you know what we will be working with, let us get started! Getting Started Firstly, we need to install the mouse library. Since this library ... Read More

How to schedule simple alarms in Python?

S Vijay Balaji
Updated on 24-Aug-2023 12:20:22

392 Views

Creating a simple alarm clock is one of the basic projects that can help you understand the basics of time manipulation, running system commands, playing audio files and other such essential topics. And, in this tutorial, we will be learning how to build one. For this, we will be working with the PyGame module to play the audio file and the datetime module to get the current system time. Alright, let us get started then! Getting Started For playing the audio file, we will be using the PyGame module. This module does not come pre-packaged with Python. So, we’ll be ... Read More

Creating Snow Effect using the Arcade Module in Python

S Vijay Balaji
Updated on 04-Aug-2023 13:11:24

283 Views

We’ve all wanted to add additional effects to our presentation or to a video. These effects help us in better present our product or helps increase user experience. And in this tutorial, you will learn how to implement the snow effect using the arcade module. You can use this in your games to create a snow drizzle or a rain drop effect. You can even go ahead and set it up as a screen timeout effect. That being said, let us get started! Getting Started Throughout this tutorial, we will be using the arcade module that helps users create game ... Read More

3-coloring is NP Complete

Aayush Shukla
Updated on 04-Aug-2023 12:55:57

709 Views

3-shading is an exemplary NP-complete issue in chart hypothesis where the goal is to decide whether a given diagram can be hued utilizing three tones, to such an extent that no two neighboring vertices share a similar variety. The issue is delegated NP-complete, importance there is no known effective calculation to tackle it for all occasions, and checking a potential arrangement should be possible in polynomial time. Numerous other NP-complete issues can be decreased to 3-shading, showing its computational intricacy and its importance in understanding the more extensive class of NP-complete issues. Subsequently, 3-shading assumes a major part in the ... Read More

Automate GUI Interactions in Python using the PyAutoGUI Library

S Vijay Balaji
Updated on 04-Aug-2023 12:50:02

1K+ Views

PyAutoGUI is a fantastic module for automating graphical user interface interactions in Python applications. It enables developers to imitate user input and automate repetitive operations, making it a good choice for testing, data entry, and other jobs that require interacting with GUIs. PyAutoGUI is a cross-platform library that supports all major operating systems such as Windows, Linux, and macOS. In this tutorial, we'll understand how to use Python's PyAutoGUI package to automate GUI interactions. We'll start by installing PyAutoGUI and learning how to use it. Then, we'll delve further into the library's features, such as keyboard and mouse control and ... Read More

Advertisements