Found 33676 Articles for Programming

Program to find how many distinct rotation groups are there for a list of words in Python

Arnab Chakraborty
Updated on 05-Oct-2020 06:25:34

298 Views

Suppose we have rotation group for a string that holds all of its unique rotations. If the input is like, "567" then this can be rotated to "675" and "756" and they are all in the same rotation group. Now if we have a list of strings words, we have to group each word by their rotation group, and find the total number of groups.So, if the input is like words = ["xyz", "ab", "ba", "c", "yzx"], then the output will be 3, as There are three rotation groups − ["xyz", "yzx"], ["ab", "ba"], ["c"].To solve this, we will follow ... Read More

Program to check whether every rotation of a number is prime or not in Python

Arnab Chakraborty
Updated on 05-Oct-2020 06:23:26

708 Views

Suppose we have a number n, we have to check whether every rotation of n is prime or not.So, if the input is like n = 13, then the output will be True, as 13 is prime, 31 is also prime.To solve this, we will follow these steps −n := n as stringdo a loop for size of n times, doif n is not a prime number, thenreturn Falsen := n[from index 1 to end] concatenate first character of nreturn TrueLet us see the following implementation to get better understanding −Example Live Democlass Solution:    def solve(self, n):       ... Read More

Malicious QR Code with QRGen

Ajay yadav
Updated on 29-Sep-2020 11:14:21

932 Views

The QR codes are machine-readable data formats used for anything that needs to be scanned automatically. It is possible to exploit the common vulnerabilities using exploits packed into custom QR codes as it is everywhere, from product packaging to airline boarding passes, etc. Hacker used a tool QRGen that create malicious QR codes to target vulnerable devices. QR code attacks are potent because humans can't read or understand the information contained in a QR code without scanning it, potentially exposing any device used to attempt to decipher the code to the exploit contained within. A human can't spot a malicious ... Read More

Build Your Own Botnet

Ajay yadav
Updated on 29-Sep-2020 11:05:23

8K+ Views

BYOB provides a framework for security researchers and developers to build and operate a basic botnet to deepen their understanding of the sophisticated malware that infects millions of devices every year and spawns modern botnets, in order to improve their ability to develop counter-measures against these threats. It is designed to allow developers to easily implement their own code and add cool new features without having to write a RAT or Command & Control server from scratch.FeaturesNothing Written To The Disk − clients never write anything to the disk - not even temporary files because remote imports allow arbitrary code ... Read More

How do you get the file size in C#?

Nizamuddin Siddiqui
Updated on 25-Sep-2020 11:19:43

3K+ Views

The FileInfo class is used to deal with file and its operations in C#.It provides properties and methods that are used to create, delete and read file. It uses StreamWriter class to write data to the file. It is a part of System.IO namespace.The Directory property retrieves an object that represents the parent directory of a file.The DirectoryName property retrieves the full path of the parent directory of a file.The Exists property checks for the presence of a file before operating on it.The IsReadOnly property retrieves or sets a value that specifies whether a file can be modified.The Length retrieves ... Read More

How to write Regex for numbers only in C#?

Nizamuddin Siddiqui
Updated on 25-Sep-2020 11:17:58

3K+ Views

A regular expression is a pattern that could be matched against an input text.The .Net framework provides a regular expression engine that allows such matching.A pattern consists of one or more character literals, operators, or constructs.Here are basic pattern metacharacters used by RegEx −* = zero or more ? = zero or one ^ = not [] = rangeThe ^ symbol is used to specify not condition.the [] brackets if we are to give range values such as 0 - 9 or a-z or A-ZExampleclass Program{    public static void Main(){       string num = "123dh";     ... Read More

How to post data to specific URL using WebClient in C#?

Nizamuddin Siddiqui
Updated on 25-Sep-2020 11:15:49

6K+ Views

We can Get and Post data from a Web API using Web client. Web client provides common methods for sending and receiving data from ServerWeb client is easy to use for consuming the Web API. You can also use httpClient instead of WebClientThe WebClient class uses the WebRequest class to provide access to resources.WebClient instances can access data with any WebRequest descendant registered with the WebRequest.RegisterPrefix method.Namespace:System.Net Assembly:System.Net.WebClient.dllUploadString Sends a String to the resource and returns a String containing any response.Exampleclass Program{    public static void Main(){       User user = new User();       try{   ... Read More

What does LINQ return when the results are empty in C#?

Nizamuddin Siddiqui
Updated on 25-Sep-2020 11:13:10

1K+ Views

Language-Integrated Query (LINQ) is the name for a set of technologies based on the integration of query capabilities directly into the C# language.You can write LINQ queries in C# for SQL Server databases, XML documents, ADO.NET Datasets, and any collection of objects that supports IEnumerable or the generic IEnumerable interface.In Linq-to-SQL if you try to get the first element on a query with no results you will get sequence contains no elements errorToList returns an empty listExampleclass Program{    public static void Main(){       List list = new List { "a" };       IEnumerable ilist = ... Read More

How to read a CSV file and store the values into an array in C#?

Nizamuddin Siddiqui
Updated on 25-Mar-2021 04:45:41

29K+ Views

A CSV file is a comma-separated file, that is used to store data in an organized way. It usually stores data in tabular form. Most of the business organizations store their data in CSV files.In C#, StreamReader class is used to deal with the files. It opens, reads and helps in performing other functions to different types of files. We can also perform different operations on a CSV file while using this class.OpenRead() method is used to open a CSV file and ReadLine() method is used to read its contents.OpenRead() method is used to open a CSV file and ReadLine() ... Read More

How to get the thread ID from a thread in C#?

Nizamuddin Siddiqui
Updated on 25-Sep-2020 11:07:15

3K+ Views

A thread is defined as the execution path of a program. Each thread defines a unique flow of control. If your application involves complicated and time-consuming operations, then it is often helpful to set different execution paths or threads, with each thread performing a particular job.Threads are lightweight processes. One common example of use of thread is implementation of concurrent programming by modern operating systems. Use of threads saves wastage of CPU cycle and increase efficiency of an application.In C#, the System.Threading.Thread class is used for working with threads. It allows creating and accessing individual threads in a multithreaded application. ... Read More

Advertisements