code-rag-bench/online-tutorials huggingface dataset:
C program to sort a given list of numbers in ascending order using Bubble sort

In C programming language, bubble sort is the simplest sorting technique and is also called as an exchange sort.
Compare the first element with the remaining elements in the list and exchange(swap) them, if they are not in order.
Compare the first element with the remaining elements in the list and exchange(swap) them, if they are not in order.
Repeat the same for other elements in the list until all the elements gets sorted.
Repeat the same for other elements in the list until all the elements gets sorted.
Given below is an algorithm to sort a given list of numbers in an ascending order by using the bubble sort technique −
Step 1 − Start
Step 2 − Take list(array), num
Step 3 − readlist(list,num)
Step 4 − printlist(list,num)
Step 5 − bub_sort(list,num)
Step 6 − printlist(list,num)
readlist (list, num)
Step 7 − stop
1. for j = 0 to num
2. read list[j].
printlist(list,num)
1. for j =0 to num
2. write list[j].
bub_sort(list,num)
1. for i = 0 to num
2. for j =0 to (num – i)
3. if( list[j] > list[j+1])
4. swapList( address of list[j], address of list[j+1])
swapList( address of list[j], address of list[j+1])
1. temp = value at list[j]
2. value at list[j] = value at list[j+1]
3. value at list[j+1] = temp
Following is the C program to sort a given list of numbers in an ascending order by using the bubble sort technique −
 Live Demo
#include <stdio.h>
#define MAX 10
void swapList(int *m,int *n){
   int temp;
   temp = *m;
   *m = *n;
   *n = temp;
}
/* Function for Bubble Sort */
void bub_sort(int list[], int n){
   int i,j;
   for(i=0;i<(n-1);i++)
      for(j=0;j<(n-(i+1));j++)
         if(list[j] > list[j+1])
            swapList(&list[j],&list[j+1]);
   }
   void readlist(int list[],int n){
   int j;
   printf("\nEnter the elements: \n");
   for(j=0;j<n;j++)
      scanf("%d",&list[j]);
   }
   /* Showing the contents of the list */
   void printlist(int list[],int n){
      int j;
   for(j=0;j<n;j++)
      printf("%d\t",list[j]);
}
void main(){
   int list[MAX], num;
   printf(" Enter the number of elements \n");
   scanf("%d",&num);
   readlist(list,num);
   printf("\n\nElements in the list before sorting are:\n");
   printlist(list,num);
   bub_sort(list,num);
   printf("\n\nElements in the list after sorting are:\n");
   printlist(list,num);
}
When the above program is executed, it produces the following result −
Enter the number of elements
10

Enter the elements:
11
23
45
1
3

6
35
69
10
22


Elements in the list before sorting are:
11 23 45 1 3 6 35 69 10 22

Elements in the list after sorting are:
1 3 6 10 11 22 23 35 45 69
Cancel the Timer Task in Java

In order to cancel the Timer Task in Java, we use the java.util.TimerTask.cancel() method. The cancel() method returns a boolean value, either true or false. The cancel() method is used to cancel the timer task.
Declaration −The java.util.TimerTask.cancel() method is declared as follows −
public boolean cancel()
The cancel() methods returns true when the task is scheduled for one-time execution and has not executed until now and returns false when the task was scheduled for one-time execution and has been executed already.
Let us see a program to illustrate the use of the java.util.TimerTask.cancel() method −
 Live Demo
import java.util.*;
class MyTask extends TimerTask {
   public void run() {
      System.out.println("Task is running");
   }
}
public class Example {
   public static void main(String[] args) {
      Timer timer = new Timer(); // creating timer
      TimerTask task = new MyTask(); // creating timer task
      // scheduling the task at the specified time at fixed-rate
      timer.scheduleAtFixedRate(task,new Date(),2000);
      // cancelling the task and displaying its status
      System.out.println("Task is cancelled:"+task.cancel());
   }
}
Task is running
Task is cancelled:true
Is it possible to calculate a correlation in a MySQL query?

Yes, it is possible to calculate a correlation in a query. To understand the correlation in a query, you need to first create a table. The query to create a table is as follows
mysql> create table correlationDemo
   - > (
   - > value float not null,
   - > value2 float not null
   - > );
Query OK, 0 rows affected (0.62 sec)
Insert some records in the table with the help of insert command. The query is as follows to insert records in the table
mysql> insert into correlationDemo values(1,10);
Query OK, 1 row affected (0.19 sec)
mysql> insert into correlationDemo values(2,4);
Query OK, 1 row affected (0.16 sec)
mysql> insert into correlationDemo values(3,5);
Query OK, 1 row affected (0.14 sec)
mysql> insert into correlationDemo values(6,17);
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from correlationDemo;
The following is the output
+-------+--------+
| value | value2 |
+-------+--------+
|     1 | 10     |
|     2 | 4      |
|     3 | 5      |
|     6 | 17     |
+-------+--------+
4 rows in set (0.03 sec)
Now here is the simple correlation in a query
mysql> select @firstValue:=avg(value),
   - > @secondValue:=avg(value2),
   - > @division:=(stddev_samp(value) * stddev_samp(value2)) from correlationDemo;
The following is the output
+-------------------------+---------------------------+-------------------------------------------------------+
| @firstValue:=avg(value) | @secondValue:=avg(value2) | @division:=(stddev_samp(value) *stddev_samp(value2))  |
+-------------------------+---------------------------+-------------------------------------------------------+
| 3                       | 9                         | 12.84090685617215                                     |
+-------------------------+---------------------------+-------------------------------------------------------+
1 row in set (0.00 sec)
Here is the calculation of the above correlation query
mysql> select sum( ( value - @firstValue ) * (value2 - @secondValue) ) / ((count(value) -1) *
@division) from
   - > correlationDemo;
The following is the output
+--------------------------------------------------------------------------------------------+
| sum( ( value - @firstValue ) * (value2 - @secondValue) ) / ((count(value) -1) * @division) |
+--------------------------------------------------------------------------------------------+
| 0.7008850777290727                                                                         |
+--------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
How to change the position of the dialog on Screen android?

This example demonstrates how do I change the position of the dialog on Screen in android.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".MainActivity">
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.java
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setTitle("Alert Dialog");
      builder.setMessage("Have a nice day!");
      builder.setCancelable(false);
      builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
         }
      }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
         }
      });
      final AlertDialog alertDialog = builder.create();
      alertDialog.show();
      alertDialog.getWindow().setGravity(Gravity.BOTTOM);
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen –
Click here to download the project code.
How to set axis limits in ggplot2 in R? - GeeksforGeeks

23 Aug, 2021
In this article, we are going to see how to set the axis limit in ggplot2 in R Programming Language.
This method is most helpful as it displays the plot within the limits of the axis without clipping the actual data. It just zooms in and shows the area under limits. The coord_cartesian() function will be used to reject all outliers that exceed or below a given quartile
Syntax: plot + coord_cartesian(xlim = <lim-vec>, ylim = <lim-vec>)
Example: Set Axis Limits in ggplot2 in R
R
# Create sample dataset.seed(5642)   sample_data <- data.frame(x = rnorm(1000),                            y = rnorm(1000))  # Load ggplot2library("ggplot2")   # create plot with limits setggplot(sample_data, aes(x = x, y = y)) +geom_point() +coord_cartesian(xlim = c(-5, 1), ylim = c(0, 5))
Output:
This method clips the unused data, which means observations out of the set limit will not be sent to any layer and clipped off.
Syntax: plot+ xlim( xmin, xmax ) + ylim( ymin, ymax )
Example:  Set Axis Limits in ggplot2 in R.
R
# Create sample dataset.seed(5642)   sample_data <- data.frame(x = rnorm(1000),                            y = rnorm(1000))# Load ggplot2library("ggplot2")   # create plot with limits setggplot(sample_data, aes(x = x, y = y)) +geom_point() + xlim(-5, 1)+ ylim(0, 5)
Output:
Picked
R-ggplot
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
Replace Specific Characters in String in R
How to filter R dataframe by multiple conditions?
R - if statement
How to import an Excel File into R ?
Time Series Analysis in R
Python requests - POST request with headers and body - GeeksforGeeks

23 Nov, 2021
HTTP headers let the client and the server pass additional information with an HTTP request or response. All the headers are case-insensitive, headers fields are separated by colon, key-value pairs in clear-text string format.
Requests do not change its behavior at all based on which headers are specified. The headers are simply passed on into the final request. All header values must be a string, bytestring, or Unicode. While permitted, it’s advised to avoid passing Unicode header values. We can make requests with the headers we specify and by using the headers attribute we can tell the server with additional information about the request.
Headers can be Python Dictionaries like,  { “Name of Header”: “Value of the Header” }
The Authentication Header tells the server who you are.  Typically, we can send the authentication credentials through the Authorization header to make an authenticated request.
Example:
Headers = { “Authorization” : ”our_unique_secret_token” }
response = request.post(“https://example.com/get-my-account-detail”, headers=Headers)
Request Object Structure
POST requests pass their data through the message body, The Payload will be set to the data parameter. data parameter takes a dictionary, a list of tuples, bytes, or a file-like object. You’ll want to adapt the data you send in the body of your request to the specified URL.
Syntax:
requests.post(url, data={key: value}, json={key: value}, headers={key:value}, args) *(data, json, headers parameters are optional.)
Given below are few implementations to help understand the concept better.
Example 1: Sending requests with data as a payload
Python3
import requests url = "https://httpbin.org/post" data = {    "id": 1001,    "name": "geek",    "passion": "coding",} response = requests.post(url, json=data) print("Status Code", response.status_code)print("JSON Response ", response.json())
Output:
Example 2: Sending requests with JSON data and headers
Python
import requestsimport json url = "https://httpbin.org/post" headers = {"Content-Type": "application/json; charset=utf-8"} data = {    "id": 1001,    "name": "geek",    "passion": "coding",} response = requests.post(url, headers=headers, json=data) print("Status Code", response.status_code)print("JSON Response ", response.json())
Output:
varshagumber28
gssenyonjo
Picked
Python-requests
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python Classes and Objects
Python - Intersection of two String

In this article, we are going to learn how to intersect two strings in different ways.
Follow the below the steps to solve the problem.
Initialize two strings and an empty string.
Iterate over the first string and add the current character to the new string if it presents in the second string as well and not present in new string already.
Print the result.
 Live Demo
# initializing the string
string_1 = 'tutorialspoint'
string_2 = 'tut'

result = ''

# finding the common chars from both strings
for char in string_1:
   if char in string_2 and not char in result:
      result += char

# printing the result
print(result)
If you run the above code, then you will get the following result.
tu

We'll use the set to intersect two strings. Follow the below steps.
Convert two strings into sets.
Intersect two sets using intersection method.
Convert the result to string using join method.
Print the result.
 Live Demo
# initializing the string
string_1 = 'tutorialspoint'
string_2 = 'tut'

# intersection
result = set(string_1).intersection(string_2)

# converting to string
result_str = ''.join(result)

# printing the result
print(result_str)
If you run the above code, then you will get the following result.
ut

If you have any queries in the article, mention them in the comment section.
Determining the current client in SAP using code

You can find the current client in sy-mandt.
Here is the code you can write for same.
IF sy-mandt = ‘001’.
*do A.
ELSE.
*Do B.
ENDIF.
How to avoid the pop-up window in chrome browser with Selenium?

We can avoid the pop-up window in Chrome browser with Selenium webdriver using the ChromeOptions class. We have to create an object of this class and apply the setExperimentalOption method to it. We shall create a Map and insert the below Chrome browser preference to it −
profile.default_content_setting_values.notifications, and set its value to 2.
The above browser preference shall be passed as a parameter to the method setExperimentalOption and finally added to the webdriver object.
Map<String, Object> pf = new HashMap<String, Object>();
pf.put("profile.default_content_setting_values.notifications", 2);
ChromeOptions p = new ChromeOptions();
p.setExperimentalOption("prefs", pf);
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.util.HashMap;
import java.util.Map;
import org.openqa.selenium.WebDriver;
public class PopupDisable {
   public static void main(String[] args) throws IOException {
      System.setProperty("webdriver.chrome.driver",
         "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      //Map creation
      Map<String, Object> pf = new HashMap<String, Object>();
      // disable pop up browser preference added to Map
      pf.put("profile.default_content_setting_values.notifications", 2);
      //object of ChromeOptions
      ChromeOptions p = new ChromeOptions();
      p.setExperimentalOption("prefs", pf);
      // pass browser option to webdriver
      WebDriver driver = new ChromeDriver(p);
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL launch
      driver.get("https://www.tutorialspoint.com/index.htm");
      System.out.println("Pop-up blocked");
      //browser quit
      driver.quit();
   }
}
Generating a range of numbers in MySQL?

To generate a range of numbers in MySQL, you can use stored procedure. Firstly, we need to create a table. After that, we will create a stored procedure that generates a range of number from 10 to 1.
The following is the query to create a table −
mysql> create table GeneratingNumbersDemo
   −> (
      −> Number int
   −> );
Query OK, 0 rows affected (0.55 sec)
Now you can create a stored procedure that stores a range of numbers in the table. The following is the query to create a stored procedure −
mysql> delimiter //
mysql> CREATE PROCEDURE Stored_ProceduretoGenerateNumbersDemo()
   −> BEGIN
   −> DECLARE start INT DEFAULT 10;
   −> WHILE start > 0 DO
   −> INSERT GeneratingNumbersDemo VALUES (start);
   −> SET start = start - 1;
   −> END WHILE;
   −> END //
Query OK, 0 rows affected (0.12 sec)
After that we need to call the stored procedure that fills a range of numbers in the table.
You can call the stored procedure with the help of call command. The syntax is as follows −
call yourStoredProcedureName();
Now you can call above stored procedure like this −
Calling the stored procedure −
mysql> call Stored_ProceduretoGenerateNumbersDemo();
Query OK, 1 row affected (0.85 sec)
Check whether the range of numbers are present in the table or not. The query is as follows −
mysql> select *from GeneratingNumbersDemo;
The following is the output −
+--------+
| Number |
+--------+
|     10 |
|      9 |
|      8 |
|      7 |
|      6 |
|      5 |
|      4 |
|      3 |
|      2 |
|      1 |
+--------+
10 rows in set (0.00 sec)
How to group footer content in form of table using HTML ? - GeeksforGeeks

15 Oct, 2020
In this article, we define the group of footer content in a table by using the <tfoot> tag in HTML. It  is used in HTML table with header and body which is known as “thead” and “tbody”. <tfoot> tag is child tag of table and parent tag of <tr> and <td>. 
Syntax:  
<tfoot> // Table footer contents... </tfoot>  
Example:   
HTML
<!DOCTYPE html><html>  <head>      <style>        h1 {            color: green;        }          tfoot {            color: blue;        }          table,        tbody,        td {            border: 1px solid black;            border-collapse: collapse;        }    </style></head>  <body>    <center>        <h1>GeeksforGeeks</h1>          <h2>            How to group the footer content             in a table using HTML ?        </h2>                  <table>            <thead>                <tr>                    <th>Name</th>                    <th> Id</th>                </tr>            </thead>            <tbody>                <tr>                    <td>Mukesh</td>                    <td>Shivam_b</td>                </tr>                <tr>                    <td>Shashank</td>                    <td>@shashankla</td>                </tr>                <tr>                    <td>Rahman</td>                    <td>@rahamD</td>                </tr>            </tbody>              <!-- tfoot tag starts from here -->            <tfoot>                <tr>                    <td>Total user</td>                    <td>4</td>                </tr>            </tfoot>            <!-- tfoot tag ends here -->          </table>    </center></body>  </html>
Output 
Supported Browsers:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to apply style to parent if it has child with CSS?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
Design a web page using HTML and CSS
How to set space between the flexbox ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Sorting Array Elements By Frequency | Set 3 (Using STL) - GeeksforGeeks

29 May, 2018
Given an array of integers, sort the array according to frequency of elements. If frequencies of two elements are same, print them in increasing order.
Examples:
Input : arr[] = {2, 3, 2, 4, 5, 12, 2, 3, 3, 3, 12}
Output : 3 3 3 3 2 2 2 12 12 4 5
Explanation :
No. Freq
2  : 3
3  : 4
4  : 1
5  : 1
12 : 2

We have discussed different approaches in below posts :Sort elements by frequency | Set 1Sort elements by frequency | Set 2
We can solve this problem using map and pairs. Initially we create a map such that map[element] = freq. Once we are done building the map, we create an array of pairs. A pair which stores elements and their corresponding frequency will be used for the purpose of sorting. We write a custom compare function which compares two pairs firstly on the basis of freq and if there is a tie on the basis of values.Below is its c++ implementation :
// C++ program to sort elements by frequency using// STL#include <bits/stdc++.h>using namespace std;  // function to compare two pairs for inbuilt sortbool compare(pair<int,int> &p1,             pair<int, int> &p2){    // If frequencies are same, compare    // values    if (p1.second == p2.second)        return p1.first < p2.first;    return p1.second > p2.second;}  // function to print elements sorted by freqvoid printSorted(int arr[], int n){    // Store items and their frequencies    map<int, int> m;    for (int i = 0; i < n; i++)        m[arr[i]]++;      // no of distinct values in the array    // is equal to size of map.    int s = m.size();      // an array of pairs    pair<int, int> p[s];      // Fill (val, freq) pairs in an array    // of pairs.    int i = 0;    for (auto it = m.begin(); it != m.end(); ++it)        p[i++] = make_pair(it->first, it->second);      // sort the array of pairs using above    // compare function.    sort(p, p + s, compare);      cout << "Elements sorted by frequency are: ";    for (int i = 0; i < s; i++)    {        int freq = p[i].second;        while (freq--)            cout << p[i].first << " ";    }}  // driver programint main(){    int arr[] = {2, 3, 2, 4, 5, 12, 2, 3,                 3, 3, 12};    int n = sizeof(arr)/ sizeof(arr[0]);    printSorted(arr, n);    return 0;}
Output:
Elements sorted by frequency are:
 3 3 3 3 2 2 2 12 12 4 5

Time Complexity : O(n Log n)
This article is contributed by Aditi Sharma. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
cpp-pair
Oracle
STL
Zycus
Arrays
Sorting
Oracle
Zycus
Arrays
Sorting
STL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to Arrays
Multidimensional Arrays in Java
Linked List vs Array
Python | Using 2D arrays/lists the right way
Search an element in a sorted and rotated array
Check if any permutation of a number is divisible by 3 and is Palindromic in Python

Suppose, we are provided with a large positive integer number N. We have to check if we can find out a number from its digit-permutations; such that the permutation is equal to its reverse form, i.e. its palindrome, and is also divisible by 3.
For example, suppose we have the number 132213. If we check the permutations from the digits of the number, we get 123321 which is a palindrome and is also divisible by 3. We have to check whether any of the permutations possible from the input number satisfy the above conditions.
So, if the input is like: input_num = 132213, then the output will be "One or more permutation is a palindrome and is divisible by three".
To solve this, we will follow these steps −
digit_array := a new list of size 10 initialized with 0s
input_sum := 0
while input_num is not zero, doinput_sum := input_sum + (input_num mod 10)digit_array[input_num mod 10] := digit_array[input_num mod 10] + 1input_num := floor value of (input_num / 10)
input_sum := input_sum + (input_num mod 10)
digit_array[input_num mod 10] := digit_array[input_num mod 10] + 1
input_num := floor value of (input_num / 10)
if input_sum mod 3 is not same as 0, thenreturn False
return False
index_odd := 0
for i in range 0 to 9, doif digit_array[i] mod 2 is not same as 0, thenindex_odd := index_odd + 1
if digit_array[i] mod 2 is not same as 0, thenindex_odd := index_odd + 1
index_odd := index_odd + 1
if index_odd > 1, thenreturn "No permutation is a palindrome and is divisible by three"
return "No permutation is a palindrome and is divisible by three"
otherwise,return "One or more permutation is a palindrome and is divisible by three"
return "One or more permutation is a palindrome and is divisible by three"
Let us see the following implementation to get better understanding −
 Live Demo
def solve(input_num):
   digit_array = [0] * 10
   input_sum = 0
   while (input_num) :
      input_sum += input_num % 10 digit_array[input_num % 10] += 1
      input_num //= 10
   if (input_sum % 3 != 0):
      return False
   index_odd = 0
   for i in range(10) :
      if (digit_array[i] % 2 != 0):
         index_odd += 1
   if (index_odd > 1):
      return "No permutation is a palindrome and is divisible by three"
   else:
      return "One or more permutation is a palindrome and is divisible by three"
input_num = 132213
print(solve(input_num))
132213
One or more permutation is a palindrome and is divisible by three
How to kill process in windows using port number - onlinetutorialspoint

PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
JAVAEXCEPTIONSCOLLECTIONSSWINGJDBC
EXCEPTIONS
COLLECTIONS
SWING
JDBC
JAVA 8
SPRING
SPRING BOOT
HIBERNATE
PYTHON
PHP
JQUERY
PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
We can kill the process by using a port in below two steps.
Step 1:
Get the process id using port number by firing below command.
C:\> netstat -ano | findstr :YourPortNumber
Step 2 :
Kill the process using PID by firing below command.
C:\> taskkill /PID enterPID /F
Happy Learning 🙂

Install Docker Desktop on Windows 10
How to install SOAPUI on Windows 10
How to Install Git windows 10 Operating System
Install Mysql on Windows 10 Step by Step
How to install Elasticsearch on Windows 10
How to install AWS CLI on Windows 10
Install Apache Solr on Windows 10
How to install Android Studio on Windows 10
How to install Android SDK Windows 10 Manual Process
How to use Spring Boot Random Port
How to change Spring Boot Tomcat Port Number
Error response from daemon: Cannot kill container: XXX: Container XXX is not running
How to install PuTTY on windows 10
How to install RabbitMQ on Windows 10
How to clear PuTTY Sessions on Windows

Install Docker Desktop on Windows 10
How to install SOAPUI on Windows 10
How to Install Git windows 10 Operating System
Install Mysql on Windows 10 Step by Step
How to install Elasticsearch on Windows 10
How to install AWS CLI on Windows 10
Install Apache Solr on Windows 10
How to install Android Studio on Windows 10
How to install Android SDK Windows 10 Manual Process
How to use Spring Boot Random Port
How to change Spring Boot Tomcat Port Number
Error response from daemon: Cannot kill container: XXX: Container XXX is not running
How to install PuTTY on windows 10
How to install RabbitMQ on Windows 10
How to clear PuTTY Sessions on Windows
 


Δ
 Install Java on Mac OS
 Install AWS CLI on Windows
 Install Minikube on Windows
 Install Docker Toolbox on Windows
 Install SOAPUI on Windows
 Install Gradle on Windows
 Install RabbitMQ on Windows
 Install PuTTY on windows
 Install Mysql on Windows
 Install Hibernate Tools in Eclipse
 Install Elasticsearch on Windows
 Install Maven on Windows
 Install Maven on Ubuntu
 Install Maven on Windows Command
 Add OJDBC jar to Maven Repository
 Install Ant on Windows
 Install RabbitMQ on Windows
 Install Apache Kafka on Ubuntu
 Install Apache Kafka on Windows
How to set focus for Tkinter widget?

Tkinter has many inbuilt functions or methods that can be used to extend the functionality of any widget in the application. Sometimes, we need to change or modify the focus of any widget in the application which can be achieved by using the focus_set() method.This method sets the default focus for any widget and makes it active till the execution of the program.
In this example, we will set the focus on first Entry widget where we are required to Enter the name of the User.
#Import the required Libraries
from tkinter import *
from tkinter import ttk

#Create an instance of Tkinter frame
win = Tk()

#Set the geometry of Tkinter frame
win.geometry("750x350")

#Define a function to submit the validate the value of Entry widget
def submit_name():
   Label(frame, text="Hello "+ entry1.get(), font=('Helvetica',12, 'bold')).pack(pady=20)
   Label(frame, text= "Your Email is : "+ entry2.get(), font=('Helvetica',12, 'bold')).pack(pady=12)

#Creates a Frame
frame = LabelFrame(win, width= 400, height= 180, bd=3)
frame.pack()

#Create an Entry widget in the Frame for Accepting the Username
entry1 = ttk.Entry(frame, width= 40)
entry1.insert(INSERT, "Enter Your Name")
entry1.pack(ipadx= 30, ipady=30)

#Set the focus on Entry1
entry1.focus_set()

#Create an Entry Widget to accept the email Address of the User
entry2 = ttk.Entry(frame, width= 40)
entry2.insert(INSERT, "Enter Your Email")
entry2.pack(pady=10)

#Create a submit button
submit= ttk.Button(win, text= "submit",command=submit_name)
submit.pack(pady=10)
win.mainloop()
Run the above code to display two entry widget which has default focus set during the execution of the program.
In the given output, enter the name and Email Address to display the message on the screen.
MySQL | DES_DECRYPT ( ) Function

13 Nov, 2019
The MySQL DES_DECRYPT function is used for decrypting an encrypted string using DES(Data Encryption Standard) algorithm. The MySQL DES_DECRYPT function uses a key to decrypt a string.
The value returned by the DES_DECRYPT function is a decrypted string or NULL. The DES_DECRYPT function accepts two parameters which are the encrypted string and a key string to decrypt the string.
Syntax:
DES_DECRYPT(encrypted_string, key_string);
Parameters Used:
encrypted_string – It is used to specify an encrypted string which is to be decrypted.
key_string – It is used to specify a key which is used to decrypt the encrypted string.
Return Value:The DES_DECRYPT function in MySQL returns a decrypted string.
Supported Versions of MySQL:
MySQL 5.7
MySQL 5.6
MySQL 5.5
MySQL 5.1
MySQL 5.0
MySQL 4.1
Example-1: Implementing DES_DECRYPT function on a string.
SELECT  
AES_DECRYPT(AES_ENCRYPT('ABC', 'key_string'), 'key_string'); 
Output:
ABC 
Example-2: Implementing AES_DECRYPT function on a string with a combination of characters and integer values.
SELECT  
AES_DECRYPT(AES_ENCRYPT('ABC123', 'key_string'), 'key_string'); 
Output:
ABC123 
Example-3: Implementing AES_DECRYPT function on a bigger string.
SELECT  
AES_DECRYPT(AES_ENCRYPT('Geeksforgeeks', 'key_string'), 'key_string'); 
Output:
Geeksforgeeks 
Example-4: Implementing AES_DECRYPT function on a NULL string.
SELECT  
AES_DECRYPT(AES_ENCRYPT(NULL, 'key_string'), 'key_string'); 
Output:
NULL 
mysql
SQLmysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between DELETE, DROP and TRUNCATE
SQL | Sub queries in From Clause
Difference between SQL and NoSQL
SQL Correlated Subqueries
MySQL | Group_CONCAT() Function
Window functions in SQL
Difference between DELETE and TRUNCATE
MySQL | Regular expressions (Regexp)
Algorithms | Graph Minimum Spanning Tree | Question 8

28 Jun, 2021
Consider a weighted complete graph G on the vertex set {v1,v2 ,v} such that the weight of the edge (v,,v) is 2|i-j|. The weight of a minimum spanning tree of G is: (GATE CS 2006)
(A) n — 1(B) 2n — 2(C) nC2(D) 2Answer: (B)Explanation: Minimum spanning tree of such a graph is
v1
  \
    v2
      \
       v3
         \
          v4
            .
              .
                .
                 vn
 
Weight of the minimum spanning tree= 2|2 – 1| + 2|3 – 2| + 2|4 – 3| + 2|5 – 4| .... + 2| n – (n-1) |= 2n – 2Quiz of this Question
Algorithms-Graph Minimum Spanning Tree
Graph Minimum Spanning Tree
Algorithms Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Image Pyramid using OpenCV | Python

20 May, 2019
Image Pyramids are one of the most beautiful concept of image processing.Normally, we work with images with default resolution but many times we need to change the resolution (lower it) or resize the original image in that case image pyramids comes handy.
The pyrUp() function increases the size to double of its original size and pyrDown() function decreases the size to half. If we keep the original image as a base image and go on applying pyrDown function on it and keep the images in a vertical stack, it will look like a pyramid. The same is true for upscaling the original image by pyrUp function.
Once we scale down and if we rescale it to the original size, we lose some information and the resolution of the new image is much lower than the original one.
Below is an example of Image Pyramiding –
import cv2import matplotlib.pyplot as plt  img = cv2.imread("images/input.jpg")  layer = img.copy()  for i in range(4):    plt.subplot(2, 2, i + 1)      # using pyrDown() function    layer = cv2.pyrDown(layer)      plt.imshow(layer)    cv2.imshow("str(i)", layer)    cv2.waitKey(0)        cv2.destroyAllWindows()
Output:
Advantages of Image pyramids:
Lowering of resolution
Getting various sizes of image
Image Blending
Edge detection
Image-Processing
OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Display Network Image in Flutter

09 Jul, 2021
Flutter has an Image widget to display different types of images. To display images from the internet, the Image.network() function is used.
Syntax: Image.network (source_URL)
Properties Of Image Widget:
height: This property takes in an integer value as the object. It decides the height of the image vertically.
width: This property also takes in an Int value as the object to determine the width in pixels to be allocated to the image.
Follow the below steps to display the images from the internet in your Flutter application:
Step 1: Create a new flutter application in the required directory using the below command:
flutter create <app_name>
Step 2: Now, delete the code from main.dart file to add your own code.
Step 3: Now, use the below code in the main.dart file and change the parameter of Image.network function as per you need.
Dart
import 'package:flutter/material.dart'; void main() {  runApp(MyApp());} class MyApp extends StatelessWidget {  @override  Widget build(BuildContext context) {    return MaterialApp(      title: 'Network Image',      theme: ThemeData(        primarySwatch: Colors.blue,      ),      home: MyHomePage(),      debugShowCheckedModeBanner: false,    );  }} // setup a stateful widgetclass MyHomePage extends StatefulWidget {  @override  _MyHomePageState createState() => _MyHomePageState();}class _MyHomePageState extends State<MyHomePage> {  @override  Widget build(BuildContext context) {    return Scaffold(             // Design of the application      appBar: AppBar(        title:Text("GeeksforGeeks"),        backgroundColor:Colors.green      ),      body: Padding(        padding: const EdgeInsets.all(8.0),        child: ListView(          children:<Widget>[            Padding(              padding: const EdgeInsets.all(8.0),                             // Image.network(src)                           child: Image.network("https://images.pexels.com/photos/213780/pexels-photo-213780.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"),              ),            Padding(              padding: const EdgeInsets.all(8.0),              child: Image.network("https://images.pexels.com/photos/2899097/pexels-photo-2899097.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"),            ),            Padding(              padding: const EdgeInsets.all(8.0),              child: Image.network("https://images.pexels.com/photos/2820884/pexels-photo-2820884.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"),            )          ]        ),      ),    );  }}
 
Output:
Here we used the ListView to display images on the screen.
In Image.network(src), we have given the network image path (src is image path).
Finally, we used the width and height to resize the image.
ankit_kumar_
kalrap615
Flutter
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Display sum in last row of table using MySQL?

To display sum in last row of a table, you can use UNION. To understand how, let us create a table
mysql> create table showSumInLastRowDemo
   -> (
   -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> StudentName varchar(20),
   -> StudentMarks int
   -> );
Query OK, 0 rows affected (0.69 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into showSumInLastRowDemo(StudentName,StudentMarks) values('John',56);
Query OK, 1 row affected (0.14 sec)
mysql> insert into showSumInLastRowDemo(StudentName,StudentMarks) values('John',87);
Query OK, 1 row affected (0.10 sec)
mysql> insert into showSumInLastRowDemo(StudentName,StudentMarks) values('John',52);
Query OK, 1 row affected (0.17 sec)
mysql> insert into showSumInLastRowDemo(StudentName,StudentMarks) values('Carol',97);
Query OK, 1 row affected (0.12 sec)
mysql> insert into showSumInLastRowDemo(StudentName,StudentMarks) values('Larry',75);
Query OK, 1 row affected (0.14 sec)
mysql> insert into showSumInLastRowDemo(StudentName,StudentMarks) values('Larry',98);
Query OK, 1 row affected (0.10 sec)
mysql> insert into showSumInLastRowDemo(StudentName,StudentMarks) values('Carol',73);
Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from showSumInLastRowDemo;
The following is the output
+-----------+-------------+--------------+
| StudentId | StudentName | StudentMarks |
+-----------+-------------+--------------+
|         1 | John        |           56 |
|         2 | John        |           87 |
|         3 | John        |           52 |
|         4 | Carol       |           97 |
|         5 | Larry       |           75 |
|         6 | Larry       |           98 |
|         7 | Carol       |           73 |
+-----------+-------------+--------------+
7 rows in set (0.00 sec)
Here is the query to display sum in last row of table using MySQL
mysql> (select StudentName,StudentMarks from showSumInLastRowDemo)
   -> UNION
   -> (select 'TotalMarksOfAllStudent' as StudentName,sum(StudentMarks) StudentMarks from showSumInLastRowDemo);
The following is the output
+------------------------+--------------+
| StudentName            | StudentMarks |
+------------------------+--------------+
| John                   |           56 |
| John                   |           87 |
| John                   |           52 |
| Carol                  |           97 |
| Larry                  |           75 |
| Larry                  |           98 |
| Carol                  |           73 |
| TotalMarksOfAllStudent |          538 |
+------------------------+--------------+
8 rows in set (0.00 sec)
How to Resolve Stale Element Reference Exception in Selenium WebDriver?

We can resolve StaleElementReferenceException in Selenium webdriver. The term stale means something which is not fresh and decayed. Thus a stale element points to an element which is not present any more.
There may be a case, when an element was in DOM initially but after modifications in Document Object Model (DOM), the element becomes stale and the StaleElementReferenceException is thrown if we make an attempt to access this element.
This exception is caused whenever an element is not present in the DOM, or deleted. We can handle this exception by the following ways −
Refreshing the page and verifying again.
Refreshing the page and verifying again.
Implement retry method.
Implement retry method.
Code Implementation to illustrate StaleElementException.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class StaleElmnt{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
      // identify element
      WebElement l = driver.findElement(By.id("gsc−i−id1"));
      l.sendKeys("Selenium");
      //refresh page
      driver.navigate().refresh();
      l.sendKeys("Selenium");
      driver.quit();
   }
}
Code Implementation to fix the StaleElementException.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.StaleElementReferenceException;
public class StaleElmntFix{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
      // identify element
      WebElement l = driver.findElement(By.id("gsc−i−id1"));
      l.sendKeys("Selenium");
      //refresh page
      driver.navigate().refresh();
      //fix exception with try−catch block
      try{
         l.sendKeys("Selenium");
      }
      catch(StaleElementReferenceException e){
         l = driver.findElement(By.id("gsc−i−id1"));
         l.sendKeys("Selenium");
         //obtain value entered
         String s= l.getAttribute("value");
         System.out.println("Value entered is: " +s);
      }
      driver.quit();
   }
}
MySQL query to convert timestamp to month?

To convert timestamp to month, use the FROM_UNIXTIME() method as in the below syntax −
select month(from_unixtime(yourColumnName)) from yourTableName;
Let us first create a table −
mysql> create table DemoTable1457
   -> (
   -> Value bigint
   -> );
Query OK, 0 rows affected (0.85 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1457 values(1570207117);
Query OK, 1 row affected (0.07 sec)
mysql> insert into DemoTable1457 values(1548947534);
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable1457 values(1575213134);
Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1457;
This will produce the following output −
+------------+
| Value      |
+------------+
| 1570207117 |
| 1548947534 |
| 1575213134 |
+------------+
3 rows in set (0.00 sec)
Following is the query to convert timestamp to month −
mysql> select month(from_unixtime(Value)) from DemoTable1457;
This will produce the following output −
+-----------------------------+
| month(from_unixtime(Value)) |
+-----------------------------+
|                          10 |
|                           1 |
|                          12 |
+-----------------------------+
3 rows in set (0.00 sec)
Lodash _.first() Method - GeeksforGeeks

01 Mar, 2021
The _.first() method is used to get the first element of the specified array.
Syntax:
_.first(array)
Parameters: This method accepts a single parameter as mentioned above and described below:
array: This parameter holds an array to query.
Return Value: This method returns the first element of the array.
Example 1:
Javascript
// Defining Lodash variableconst _ = require('lodash'); // Calling _.first() functionsconsole.log(_.first([5]));console.log(_.first([2, 4, 6]));console.log(_.first(["gfg", "GFG"]));
 
 
Output:
 
5
2
gfg
 
Example 2:
 
Javascript
// Defining Lodash variableconst _ = require('lodash'); // Calling _.first() functionsconsole.log(_.first([]));
 
 
Output:
 
undefined
 
Note: This will not work in normal JavaScript because it requires the Lodash library to be installed.
 
arorakashish0911
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Python Script to check PC last reboot time - GeeksforGeeks

28 Jul, 2021
psutil is a cross-platform library for retrieving information on running processes and system utilization(CPU, memory, disks, networks, sensors) in Python. The Python script below can be run in both Windows and Linux. psutil library can be installed using the terminal by:
In Windows:
pip install psutil
In Linux:
sudo apt-get install gcc python3-dev
sudo pip3 install psutil
Code:
Python3
import psutilimport datetime # returns the time in seconds since the epochlast_reboot = psutil.boot_time() # converting the date and time in readable formatprint(datetime.datetime.fromtimestamp(last_reboot))
Output:
2020-08-20 16:46:48
Explanation: 
psutil.boot_time() returns the system boot time expressed in seconds since the epoch. It is the number of seconds that have elapsed since the Unix epoch, minus leap seconds; the Unix epoch is 00:00:00 UTC on 1 January 1970. To convert this time to DateTime we use fromtimestamp(), which returns the local date and time.
ruhelaa48
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()