code-rag-bench/online-tutorials huggingface dataset:
Linear Diophantine Equations | Practice | GeeksforGeeks

A Diophantine equation is a polynomial equation, usually in two or more unknowns, such that only the integral solutions are required. An Integral solution is a solution such that all the unknown variables take only integer values.
Given three integers A, B, C representing a linear equation of the form: Ax + By = C. Determine if the equation has a solution such that x and y are both integral values.
 
Example 1:
Input: 
A = 3
B = 6
C = 9 
Output: 
1 
Explanation:
It is possible to
write A, B, C in the
for 3 + 6 = 9
Example 2:
Input: 
A = 4
B = 2
C = 3
Output: 
0 
Explanation:
It is not possible to
represent A, B, C in 
Diophantine equation form.


Your Task:
You don't need to read input or print anything. Your task is to complete the function isPossible() which takes three integer values A, B, C as input parameters and returns 1 if the solution for x and y exist otherwise return 0.
 
Expected Time Complexity: O(log N)
Expected Space Complexity: O(1)
 
Constraints:
1 <= A,B,C <= 105
0
msbritogabriella3 months ago
solution in C++ with two lines
`
int isPossible(int A, int B, int C){
       // code here
       return C % gcd(A, B) == 0 ? 1 : 0;
   }
   int gcd(int A, int B){
       return B == 0 ? A : gcd(B, A % B);
   }
+1
badgujarsachin835 months ago
int gcd(int a, int b)
{
    // Everything divides 0
    if (a == 0)
       return b;
    if (b == 0)
       return a;
  
    // base case
    if (a == b)
        return a;
  
    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
    int isPossible(int A, int B, int C){
        // code here
        if(C%gcd(A,B)==0){
            return 1;
        }else{
            return 0;
        }
    }
0
Firoz Thakur2 years ago
Firoz Thakur
int isPossible(int A, int B, int C){        // code here    if(C%__gcd(A,B)==0)     return 1;    else     return 0;
    }
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
Hide Bootstrap Modal

The .modal(“hide”) method hides the modal on button click.
Firstly, generate the modal and display it −
$("#newModal").modal("show");
After that, use the modal(“hide”) method on a button to hide the modal on button click −
$("#button1").click(function(){
  $("#newModal").modal("hide");
});
Let us see an example of the modal(‘hide”) method wherein we are hiding a modal which generates on page load −
Live Demo
<!DOCTYPE html>
<html>
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
    #button1 {
      width: 140px;
      padding: 20px;
      bottom: 150px;
      z-index: 9999;
      font-size:15px;
      position: absolute;
      margin: 0 auto;
    }
</style>
</head>

<body>
  <div class="container">
    <h2>Sample</h2>
    <p>This is demo text.</p>
    <p>This is demo text.</p>
    <p>This is demo text.</p>
    <p>This is demo text.</p>
    <p>This is demo text.</p>
    <p>This is demo text.</p>
    <p>This is demo text.</p>
    <p>This is demo text.</p>
    <p>This is demo text.</p>
    <p>This is demo text.</p>
    <p>This is demo text.</p>

    <button type="button" class="btn btn-default btn-lg" id="button1">Click to hide</button>

    <div class="modal fade" id="newModal" role="dialog">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">×</button>
            <h4 class="modal-title">Sample Modal</h4>
          </div>
        <div class="modal-body">
          <p>This is demo text.</p>
        </div>
      </div>
  </div>
 </div>
</div>

<script>
  $(document).ready(function(){
    $("#newModal").modal("show");
    $("#button1").click(function(){
      $("#newModal").modal("hide");
    });
  });
</script>

</body>
</html>
Concatenate columns from different tables in MySQL

You can use CONCAT(). Let us first create a table −
mysql> create table DemoTable1
   -> (
   -> FirstName varchar(20)
   -> );
Query OK, 0 rows affected (0.90 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1 values('Chris');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable1 values('David');
Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable1;
This will produce the following output −
+-----------+
| FirstName |
+-----------+
| Chris     |
| David     |
+-----------+
2 rows in set (0.00 sec)
Here is the query to create the second table −
mysql> create table DemoTable2
   -> (
   -> LastName varchar(20)
   -> );
Query OK, 0 rows affected (0.95 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable2 values('Brown');
Query OK, 1 row affected (0.55 sec)
mysql> insert into DemoTable2 values('Miller');
Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable2;
This will produce the following output −
+----------+
| LastName |
+----------+
| Brown    |
| Miller   |
+----------+
2 rows in set (0.00 sec)
Here is the query to concatenate column from different tables −
mysql> select concat(tbl1.FirstName,' ',tbl2.LastName) from DemoTable tbl1
   -> left join DemoTable2 tbl2
   -> on tbl2.LastName='Brown' or tbl2.LastName='Miller';
This will produce the following output −
+------------------------------------------+
| concat(tbl1.FirstName,' ',tbl2.LastName) |
+------------------------------------------+
| Chris Brown                              |
| David Brown                              |
| Chris Miller                             |
| David Miller                             |
+------------------------------------------+
4 rows in set (0.04 sec)
How to create clickable areas in an image in HTML?

To create clickable areas in an image, create an image map, with clickable areas. For example, on clicking a box, the different website opens and on clicking a triangle in the same image, a different website opens.
The <area> tag defines an area inside an image-and nested inside a <map> tag. The following are the attributes:
You can try to run the following code to create clickable areas in an image in HTML
<!DOCTYPE html>
<html>
   <head>
      <title>HTML area Tag</title>
   </head>

   <body>
      <img src = /images/usemap.gif alt = "usemap" usemap = "#lessons"/>
      <map name = "lessons">
         <area shape = "poly" coords = "74,0,113,29,98,72,52,72,38,27"
            href = "/perl/index.htm" alt = "Perl Tutorial" target = "_blank" />
         <area shape = "rect" coords = "22,83,126,125" alt = "HTML Tutorial"
            href = "/html/index.htm" target = "_blank" />
         <area shape = "circle" coords = "73,168,32" alt = "PHP Tutorial"
            href = "/php/index.htm" target = "_blank" />
      </map>
   </body>
</html>
<mat-menu> in Angular Material - GeeksforGeeks

25 Feb, 2021
Angular Material is a UI component library that is developed by the Angular team to build design components for desktop and mobile web applications. In order to install it, we need to have angular installed in our project, once you have it you can enter the below command and can download it.The <mat-menu> acts as a kind of dropdown or menu section which expands or opens whenever user clicks on any button.
Installation syntax:
ng add @angular/material
Approach:
First, install the angular material using the above-mentioned command.
After completing the installation, Import ‘MatMenuModule’ from ‘@angular/material/menu’ in the app.module.ts file.
In addition to it import ‘MatButtonModule’ from ‘@angular/material/button’ in app.module.ts file.
Then use <mat-menu> tag to group all the items inside this menu tag.
Inside the <mat-menu> tag we need to use <mat-menu-item> tag for every item for displaying in the dropdown.
We have properties like ‘xPosition’ and ‘yPosition’ to customize the opening direction of the dropdown.
Once done with the above steps then serve or start the project.
Code Implementation:
app.module.ts
import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatMenuModule, MatButtonModule } from '@angular/material';     import { AppComponent } from './example.component';     @NgModule({   declarations: [AppComponent],   exports: [AppComponent],   imports: [     CommonModule,     FormsModule,     MatMenuModule,    MatButtonModule    ], }) export class AppModule {}
app.component.html
<h4>    Click on the below button in-order    to activate mat-menu</h4>  <button mat-button [matMenuTriggerFor]="menu">    Web Technologies</button>  <mat-menu #menu="matMenu">  <button mat-menu-item>HTML</button>  <button mat-menu-item>CSS</button>  <button mat-menu-item>JQuery</button>  <button mat-menu-item>Bootstrap</button>  <button mat-menu-item>Angular</button>  <button mat-menu-item>React.js</button></mat-menu>
Output:
Angular-material
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Angular PrimeNG Calendar Component
Angular 10 (blur) Event
Angular PrimeNG Messages Component
How to make a Bootstrap Modal Popup in Angular 9/8 ?
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?
GATE | Gate IT 2005 | Question 50 - GeeksforGeeks

28 Jun, 2021
In a binary tree, for every node the difference between the number of nodes in the left and right subtrees is at most 2. If the height of the tree is h > 0, then the minimum number of nodes in the tree is:(A) 2h – 1(B) 2h – 1 + 1(C) 2h – 1(D) 2hAnswer: (B)Explanation:
Let there be n(h) nodes at height h.

In a perfect tree where every node has exactly 
two children, except leaves, following recurrence holds.

n(h) = 2*n(h-1) + 1

In given case, the numbers of nodes are two less, therefore
n(h) = 2*n(h-1) + 1 - 2
     = 2*n(h-1) - 1

Now if try all options, only option (b) satisfies above recurrence.

Let us see option (B)
n(h) = 2h - 1 + 1

So if we substitute 
n(h-1) = 2h-2 + 1, we should get n(h) = 2h-1 + 1

n(h) =  2*n(h-1) - 1
     =  2*(2h-2 + 1) -1
     =  2h-1 + 1.

Quiz of this Question
Gate IT 2005
GATE-Gate IT 2005
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
How to Solve Java List UnsupportedOperationException? - GeeksforGeeks

09 Mar, 2021
The UnsupportedOperationException is one of the common exceptions that occur when we are working with some API of list implementation. It is thrown to indicate that the requested operation is not supported.
This class is a member of the Java Collections Framework.
All java errors implement the java.lang.Throwable interface or are inherited from another class. The hierarchy of this Exception is-
  java.lang.Object
         java.lang.Throwable
                   java.lang.Exception
                          java.lang.RuntimeException
                                  java.lang.UnsupportedOperationException
Syntax:
public class UnsupportedOperationException
extends RuntimeException
The main reason behind the occurrence of this error is the asList method of java.util.Arrays class returns an object of an ArrayList which is nested inside the class java.util.Arrays. ArrayList extends java.util.AbstractList and it does not implement add or remove method. Thus when this method is called on the list object, it calls to add or remove method of AbstractList class which throws this exception. Moreover, the list returned by the asList method is a fixed-size list therefore it cannot be modified.
The below example will result in UnsupportedOperationException as it is trying to add a new element to a fixed-size list object
Java
import java.util.Arrays;import java.util.List;  public class Example {    public static void main(String[] args)    {        String str[] = { "Apple", "Banana" };        List<String> l = Arrays.asList(str);        System.out.println(l);          // It will throw java.lang.UnsupportedOperationException          l.add("Mango");    }}
Output:
Exception in thread "main" java.lang.UnsupportedOperationException
    at java.base/java.util.AbstractList.add(AbstractList.java:153)
    at java.base/java.util.AbstractList.add(AbstractList.java:111)
    at Example.main(Example.java:14)
We can solve this problem by using a mutable List that can be modified such as an ArrayList. We create a List using Arrays.asList method as we were using earlier and pass that resultant List to create a new ArrayList object. 
Java
import java.util.ArrayList;import java.util.List;import java.util.*;  public class Example {      public static void main(String[] args) {                String str[] = { "Apple", "Banana" };        List<String> list = Arrays.asList(str);                List<String> l = new ArrayList<>(list);                    l.add("Mango"); // modify the list          for(String s: l )          System.out.println(s);      }  }
Apple
Banana
Mango

Java-Exceptions
Picked
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
Internal Working of HashMap in Java
Strings in Java
Internal Structure of Python Dictionary - GeeksforGeeks

22 Nov, 2021
Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only a single value as an element, Dictionary holds key:value pair. Key-value is provided in the dictionary to make it more optimized
The dictionary consists of a number of buckets. Each of these buckets contains the hash code of the object that contains the key-value pair. A pointer to the key object and a pointer to the value object.
The below diagram shows the internal structure of the dictionary:
The dictionary starts with 8 empty buckets. This is then resized by doubling the number of entries whenever its capacity is reached. This sums up to at least 12 bytes on a 32bit machine and 24 bytes on a 64bit machine
Example 1: An empty python dictionary consumes 240 bytes
Python3
# codeimport sys d = {}print(sys.getsizeof(d))
Output:
240
Example 2. The first time we create a dictionary it contains only 8 slots that can be filled with key-value pairs.
Python3
# codeimport sys d = {}d['python'] = 1print(sys.getsizeof(d))
Output:
240
As you can see the size of the dictionary is still the same after adding something to it. The dictionary stores in the bucket which is not full yet.
Example 3: 
The key-values not stored in the dictionary itself the size of the dictionary doesn’t change even if we increase the size of its value
Python3
import sys d = {}d['a'] = 'a' * 100000print("Size of dictionary ->", sys.getsizeof(d))print("Size of a ->", sys.getsizeof('a'))
Size of dictionary -> 240
Size of a -> 50
Output:
Size of dictionary -> 240
Size of a -> 50
Example 4: If we remove the items from a dictionary the size of the dictionary will still be the same.
Python3
# codeimport sys d = {}d['python'] = 1for key in list(d.keys()):  d.pop(key)   print(len(d))print(sys.getsizeof(d))
Output:
0
240
Here, you can see the dictionary hasn’t released the memory it has allocated. It removes the reference from the hash table but the value is in the memory. Since it is not allocated may become part of garbage collection.
Example 5: If we empty the dictionary using the clear method the size of it is 72 bytes less than the initialized empty dictionary i.e. 240 bytes
Python3
import sys d = {}d['python'] = 1for key in list(d.keys()):  d.pop(key)   print(len(d))d.clear()print(sys.getsizeof(d))
Output:
0
72
This is because the method clears up memory. It also clears the initial default space i.e., 8 buckets allocated within the dictionary.
sagar0719kumar
as5853535
python-dict
Python
python-dict
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?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Scala Int toString() method with example - GeeksforGeeks

04 Feb, 2020
The toString() method is utilized to return the string representation of the specified value.
Method Definition: def toString(): String
Return Type: It returns the string representation of the specified value.
Example #1:
// Scala program of Int toString()// method   // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Applying toString method         val result = (65).toString                  // Displays output         println(result)     } } 
65

Example #2:
// Scala program of Int toString()// method   // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Applying toString method         val result = (1515).toString                  // Displays output         println(result)     } } 
1515

Scala
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Type Casting in Scala
Class and Object in Scala
Inheritance in Scala
Scala Tutorial – Learn Scala with Step By Step Guide
Operators in Scala
Scala Constructors
Scala String substring() method with example
Lambda Expression in Scala
How to get the first element of List in Scala
Break statement in Scala
Lodash _.size() Method - GeeksforGeeks

10 Sep, 2020
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, collection, strings, objects, numbers etc.The _.size() method gets the size of collection by returning its length for array such as values or the number of own enumerable string keyed properties for objects.
Syntax:
_.size(collection)
Parameters: This method accepts single parameter as mentioned above and described below:
collection: This parameter holds the collection to inspect.
Return Value: This method returns the collection size.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.
javascript
// Requiring the lodash library const _ = require("lodash");        // Original array and use _.size() methodvar gfg = _.size([12, 14, 36, 29, 10]);  // Printing the output console.log(gfg);
Output:
5

Example 2:
javascript
// Requiring the lodash library const _ = require("lodash");        // Original array and use _.size() methodvar gfg = _.size({ 'p': 1, 'q': 2, 'r': 5});  // Printing the output console.log(gfg);
Output:
3

Example 3:
javascript
// Requiring the lodash library const _ = require("lodash");        // Original array and use _.size() methodvar gfg1 = _.size('geeksforgeeks');var gfg2 = _.size('computer science');  // Printing the output console.log(gfg1, gfg2);
Output:
13, 16

Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.
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
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
UGC-NET | UGC NET CS 2016 Aug – III | Question 24

05 Aug, 2021
Consider the following identities for regular expressions:(a) (r + s)* = (s + r)*(b) (r*)* = r*(c) (r* s*)* = (r + s)*Which of the above identities are true?(A) (a) and (b) only(B) (b) and (c) only(C) (c) and (a) only(D) (a), (b) and (c)Answer: (D)Explanation:
(r + s)* will generate any strings containing r or s or both. We can draw DFA for (r + s)* and it is same as (s + r)*. It is a regular expression.
(r*)* will generate any string containing r and its DFA can be drawn easily and it is same as r*. It is also a regular expression.
(r* s*)* will generate any strings containing r or s or both. We can draw DFA for (r* s*)* and it is same as (r + s)*. It is a regular expression. All option are true.
So, option (D) is correct.Quiz of this Question
as5853535
UGC-NET
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Output of C Program | Set 17

31 Jul, 2018
Predict the output of following C programs.
Question 1
#include<stdio.h>  #define R 10#define C 20  int main(){   int (*p)[R][C];   printf("%d",  sizeof(*p));   getchar();   return 0;}
Output: 10*20*sizeof(int) which is “800” for compilers with integer size as 4 bytes.The pointer p is de-referenced, hence it yields type of the object. In the present case, it is an array of array of integers. So, it prints R*C*sizeof(int).Thanks to Venki for suggesting this solution.
Question 2
#include<stdio.h>#define f(g,g2) g##g2int main(){   int var12 = 100;   printf("%d", f(var,12));   getchar();   return 0;}
Output: 100The operator ## is called “Token-Pasting” or “Merge” Operator. It merges two tokens into one token. So, after preprocessing, the main function becomes as follows, and prints 100.
int main(){   int var12 = 100;   printf("%d", var12);   getchar();   return 0;}
Question 3
#include<stdio.h>int main() {   unsigned int x = -1;   int y = ~0;   if(x == y)      printf("same");   else      printf("not same");   printf("\n x is %u, y is %u", x, y);   getchar();   return 0;}
Output: “same x is MAXUINT, y is MAXUINT” Where MAXUINT is the maximum possible value for an unsigned integer.-1 and ~0 essentially have same bit pattern, hence x and y must be same. In the comparison, y is promoted to unsigned and compared against x. The result is “same”. However, when interpreted as signed and unsigned their numerical values will differ. x is MAXUNIT and y is -1. Since we have %u for y also, the output will be MAXUNIT and MAXUNIT.Thanks to Venki for explanation.
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above
C-Output
Program Output
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Runtime Errors
Different ways to copy a string in C/C++
Output of C++ Program | Set 1
Output of Java Program | Set 3
Output of Java Programs | Set 12
Output of C++ programs | Set 47 (Pointers)
Output of C programs | Set 59 (Loops and Control Statements)
Output of Java Program | Set 7
Output of C programs | Set 35 (Loops)
Output of Java program | Set 15 (Inner Classes)
fmt.Scanf() Function in Golang With Examples

26 Feb, 2021
In Go language, fmt package implements formatted I/O with functions analogous to C’s printf() and scanf() function. The fmt.Scanf() function in Go language scans the input texts which is given in the standard input, reads from there and stores the successive space-separated values into successive arguments as determined by the format. Moreover, this function is defined under the fmt package. Here, you need to import the “fmt” package in order to use these functions.Syntax:  
func Scanf(format string, a ...interface{}) (n int, err error)
Parameters: This function accepts two parameters which are illustrated below:  
format string: This is the different formats which are used for each given elements.
a ...interface{}: These parameters receive each given elements.
Returns: It returns the number of items successfully scanned.Example 1: 
C
// Golang program to illustrate the usage of// fmt.Scanf() function // Including the main packagepackage main // Importing fmtimport (    "fmt") // Calling mainfunc main() {     // Declaring some variables    var name string    var alphabet_count int     // Calling Scanf() function for    // scanning and reading the input    // texts given in standard input    fmt.Scanf("%s", &name)    fmt.Scanf("%d", &alphabet_count)     // Printing the given texts    fmt.Printf("The word %s containing %d number of alphabets.",               name, alphabet_count) }
Input:  
GFG 3
Output:  
The word GFG containing 3 number of alphabets.
Example 2: 
C
// Golang program to illustrate the usage of// fmt.Scanf() function // Including the main packagepackage main // Importing fmtimport (    "fmt") // Calling mainfunc main() {     // Declaring some variables    var name string    var alphabet_count int    var float_value float32    var bool_value bool     // Calling Scanf() function for    // scanning and reading the input    // texts given in standard input    fmt.Scanf("%s", &name)    fmt.Scanf("%d", &alphabet_count)    fmt.Scanf("%g", &float_value)    fmt.Scanf("%t", &bool_value)     // Printing the given texts    fmt.Printf("%s %d %g %t", name,     alphabet_count, float_value, bool_value) }
Input:  
GeeksforGeeks 13 6.789 true
Output:  
GeeksforGeeks 13 6.789 true
 
arorakashish0911
Golang-fmt
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PHP on AWS EC2?

30 Nov, 2021
AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we have the authority to configure, launch or even dissipate this virtual computer To know more about EC2 visit this page.
In this article we will learn how to install PHP on AWS EC2.
AWS account.EC2 Instance.User with privileges to create Instance.
AWS account.
EC2 Instance.
User with privileges to create Instance.
Step 1 – Create an AWS Elastic Cloud Compute Instance, to do so visit How-To-Create-EC2-Instance.
Step 2 – Start the EC2 instance that you have created in Step 1
Step 3 – Connect to your EC2 Instance by clicking on Connect Button 
Step 4 – A prompt will pop up after connecting.
Step 5 – At first check, if PHP is already installed or not.
php --version
Step 6 – If PHP is not installed on your virtual machine then install the PHP using the following command 
sudo apt install php7.4
Step 7 – A prompt will appear asking you  for confirmation , press ‘y’ to confirm.
Step 8 – Wait for the process to end.
Step 9 –We have successfully installed PHP on our EC2  instance, to check if PHP is installed or not, verify using the following command.
php --version
Step 10 – To know the current version of PHP, use the following command.
apt search php7.*
In this way, we can install PHP on our EC2 instance using EC2 Instance Connect. And if you also use a free tier account, make sure you delete all the resources you have used before logging out. 
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Set Git Username and Password in GitBash?
How to Install Jupyter Notebook on MacOS?
How to Install and Use NVM on Windows?
How to Install Python Packages for AWS Lambda Layers?
How to Install Git in VS Code?
Installation of Node.js on Linux
Installation of Node.js on Windows
How to Install Jupyter Notebook on MacOS?
How to Install and Use NVM on Windows?
How to Install Pygame on Windows ?
How do we use checkbox buttons in HTML forms?

Using HTML forms, you can easily take user input. The <form> tag is used to get user input, by adding the form elements. Different types of form elements include text input, radio button input, submit button, etc.
Let’s learn about how to use radio checkbox in HTML forms to get user input. Checkboxes are used when more than one option is required to be selected. They are also created using HTML <input> tag but type attribute is set to a checkbox.
Here are the attributes −
You can try to run the following code to learn how to work with checkbox buttons in HTML  −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <head>
         <title>HTML Checkbox Button</title>
      </head>
      <p>Which languages you work on:</p>
      <form>
         <input type="checkbox" name="language1" value="java">Java
         <br>
         <input type="checkbox" name="language2" value="php">PHP
         <br>
         <input type="checkbox" name="language3" value="cpp">C++
         <br>
      </form>
   </body>
</html>
Differences between SQL and SQLite

13 Aug, 2020
1. Structured Query Language (SQL) :SQL stands for Structured Query Language. SQL can access, created and manage databases. SQL has became standard of American National Standards Institute.
2. SQLite :SQLite is software which provides relational database management system. SQLite lightweight in terms of setup, database administration, and required resources. SQLite has features like self-contained, server-less, zero-configuration, etc.
Differences between SQL and SQLite :
DBMS-SQL
DBMS
Difference Between
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CTE in SQL
Difference between Clustered and Non-clustered index
Introduction of DBMS (Database Management System) | Set 1
SQL Trigger | Student Database
Introduction of B-Tree
Class method vs Static method in Python
Difference between BFS and DFS
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Differences between JDK, JRE and JVM
Python – Filter list elements starting with given Prefix

30 Jun, 2020
Sometimes, we need to filter the list with the first character of each string in the list. This type of task has many applications in day-day programming and even in the competitive programming domain. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using list comprehension + startswith()In this method, we use list comprehension for traversal logic and the startswith method to filter out all the strings that starts with a particular letter. The remaining strings can be used to make a different list.
# Python3 code to demonstrate# Prefix Separation# Using list comprehension + startswith()  # initializing listtest_list = ['sapple', 'orange', 'smango', 'grape']  # initializing start Prefixstart_letter = 's'  # printing original listprint("The original list : " + str(test_list))  # using list comprehension + startswith()# Prefix Separationwith_s = [x for x in test_list if x.startswith(start_letter)]without_s = [x for x in test_list if x not in with_s]  # print resultprint("The list without prefix s : " + str(without_s))print("The list with prefix s : " + str(with_s))
The original list : ['sapple', 'orange', 'smango', 'grape']
The list without prefix s : ['orange', 'grape']
The list with prefix s : ['sapple', 'smango']

 
Method #2 : Using filter() + lambda + startswith()This task can be performed using the filter function with performs the similar task internally as the above function and lambda is helper function to build the logic.
# Python3 code to demonstrate# Prefix Separation# Using filter() + startswith() + lambda  # initializing listtest_list = ['sapple', 'orange', 'smango', 'grape']  # initializing start Prefixstart_letter = 's'  # printing original listprint("The original list : " + str(test_list))  # using filter() + startswith() + lambda# Prefix Separationwith_s = list(filter(lambda x: x.startswith(start_letter), test_list))without_s = list(filter(lambda x: not x.startswith(start_letter), test_list))  # print resultprint("The list without prefix s : " + str(without_s))print("The list with prefix s : " + str(with_s))
The original list : ['sapple', 'orange', 'smango', 'grape']
The list without prefix s : ['orange', 'grape']
The list with prefix s : ['sapple', 'smango']

nidhi_biet
Python list-programs
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iterate over a list in Python
How to iterate through Excel rows in Python?
Enumerate() in Python
Rotate axis tick labels in Seaborn and Matplotlib
Python Dictionary
Deque in Python
Stack in Python
Queue in Python
Read a file line by line in Python
Defaultdict in Python
map::at() in C++ STL - GeeksforGeeks

28 Sep, 2021
Maps are associative containers that store elements in a mapped fashion. Each element has a key value and a mapped value. No two mapped values can have same key values.
at() function is used to reference the element mapped to the key value given as the parameter to the function. For example, if we have a string “hi” mapped to an integer 1, then passing the integer 1 as the parameter of at() function will return the string “hi”.
How is at() function different from operator[] at() function checks the range of the container, and throws an exception when we try to access an element not in the range, while operator[] does not checks the range of the container and shows an undefined behavior when an element not in the range is accessed.
Syntax : 
mapname.at(key)
Parameters :
Key value mapped to the element to be fetched.
Returns :
Direct reference to the element at the given key value.
Examples: 
Input  :  map mymap;
          mymap['a'] = 1;
          mymap.at('a');
Output :  1

Input  :  map mymap;
          mymap["abcd"] = 7;
          mymap.at("abcd");
Output :  7
Errors and Exceptions1. If the key is not present in the map, it throws out_of_range. 2. It has a strong no exception throw guarantee otherwise.
C++
// CPP program to illustrate// Implementation of at() function#include <iostream>#include <map>#include <string>using namespace std; int main(){    // map declaration    map<string, int> mymap;     // mapping strings to integers    mymap["hi"] = 1;    mymap["welcome"] = 2;    mymap["thanks"] = 3;    mymap["bye"] = 4;     // printing the integer mapped    // by string "thanks"    cout << mymap.at("thanks");    return 0;}
Output:
3
Time Complexity: O(logn)
How is at() function different from operator[] at() function checks the range of the container, and throws an exception when we try to access an element not in the range, while operator[] does not checks the range of the container and shows an undefined behavior when an element not in the range is accessed. 
chhabradhanvi
cpp-map
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Sorting a vector in C++
Friend class and function in C++
std::string class in C++
Pair in C++ Standard Template Library (STL)
Queue in C++ Standard Template Library (STL)
Inline Functions in C++
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
How to Create Animated Loader Ring using HTML and CSS? - GeeksforGeeks

11 May, 2020
The Loader Ring can be easily generated using HTML and CSS. The Loader Ring displays when the browsers are loading web pages. To create a loader ring, we will make the use of CSS animations that allows animation of HTML elements.
HTML Code is used to create a basic structure of the animated loader ring and CSS code is used to set the style of Loader Ring. We will use the @keyframes rule that allows the animation to gradually change from current style to the new style at certain times then we will use the transform property to rotate the animation 360 degrees.
Example:
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <title>        How to Create Animated Loader        Ring using HTML and CSS?    </title>      <style>        body {            margin: 0;            padding: 0;            background: #008000;        }          .circle {            position: absolute;            top: 40%;            left: 50%;            transform: translate(-40%, -50%);            animation: effect 1s linear infinite;            width: 100px;            height: 100px;            border-radius: 50%;            border: 6px solid rgba(255, 255, 255, 0.3);            border-top-color: #fff;        }          @keyframes effect {            0% {                transform: rotate(0deg);            }              100% {                transform: rotate(360deg);            }          }    </style></head>  <body>    <div class="circle"></div></body>  </html>
Output:
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
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
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 ?
JavaScript ReferenceError - variable is not defined - GeeksforGeeks

31 Jul, 2020
This JavaScript exception variable is not defined occurs if there is a non-existent variable that is referenced somewhere.
Message:
ReferenceError: "x" is not defined

Error Type:
ReferenceError

Cause of Error:
There is a non-existent variable that is referenced somewhere in the script. That variable has to be declared, or make sure the variable is available in the current script or scope.
Example 1: In this example, the variable(val1) is being accessed from the outside of the function, So the error has not occurred.
HTML
<script>     function sum() {         var val1 = 2;         var val2 = 3;      return val1 + val2;    }    document.write(val1);</script>
Output:
ReferenceError: 'val1' is not defined

Example 2: In this example, the variable(GFG) is not defined, So the error has occurred.
HTML
<script>     GFG.substring(2);                </script>
Output:
ReferenceError: 'GFG' is not defined

JavaScript-Errors
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
How to filter object array based on attributes?
How to remove duplicate elements from JavaScript Array ?
How to get selected value in dropdown list using JavaScript ?
Lodash _.debounce() Method
Angular File Upload
Express.js res.jsonp() Function - GeeksforGeeks

19 Aug, 2021
The res.jsonp() function is used to send a JSON response with JSONP support and this function is similar to the res.json() function except that it opts-in to the support of JSONP callback.
Syntax: 
res.jsonp( [body] )
Parameter: The body parameter describes the body type which can be sent in response.Return Value: It returns an Object.
Installation of express module:  
1. You can visit the link to Install express module. You can install this package by using this command. 
npm install express
2. After installing the express module, you can check your express version in command prompt using the command. 
npm version express
3. After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command. 
node index.js
Example 1: Filename: index.js 
Javascript
var express = require('express');var app = express();var PORT = 3000; // Without middlewareapp.get('/', function(req, res){    res.jsonp({ title: 'GeeksforGeeks' });}); app.listen(PORT, function(err){    if (err) console.log(err);    console.log("Server listening on PORT", PORT);});
Steps to run the program:  
1. The project structure will look like this: 
2. Make sure you have installed express module using the following command: 
npm install express
3. Run index.js file using below command: 
node index.js
Output: 
Server listening on PORT 3000
4. Now open browser and go to http://localhost:3000/, now on your screen you will see the following output: 
{"title":"GeeksforGeeks"}
Example 2: Filename: index.js  
Javascript
var express = require('express');var app = express();var PORT = 3000; // With middlewareapp.use('/', function(req, res, next) {    res.jsonp({ name: 'Legend' });    next();}) app.get('/', function(req, res) {    res.send();}); app.listen(PORT, function(err) {    if (err) console.log(err);    console.log("Server listening on PORT", PORT);});
Run index.js file using below command: 
node index.js
Now open the browser and go to http://localhost:3000/, now check your browser screen and you will see the following output: 
{"name":"Legend"}
Reference: https://expressjs.com/en/5x/api.html#res.jsonp 
kalrap615
Express.js
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between dependencies, devDependencies and peerDependencies
Node.js Export Module
How to connect Node.js with React.js ?
Mongoose find() Function
Mongoose Populate() Method
Remove elements from a JavaScript Array
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?
Difference between var, let and const keywords in JavaScript
Turn a Matrix into a Row Vector in MATLAB - GeeksforGeeks

04 Jul, 2021
Conversion of a Matrix into a Row Vector. This conversion can be done using reshape() function along with the Transpose operation. This reshape() function is used to reshape the specified matrix using the given size vector.
reshape(A, sz)
Parameters: This function accepts two parameters, which are illustrated below:
A: This is the specified matrix of elements.
sz: This is the specified size vector.
Return Value: It returns the row vector of a given matrix.
Example 1 
Matlab
% Conversion of a 2D matrix into its% row vector.A = [1 2; 3 4]; %Initializing a matrix  % Calling the reshape() function% over the above matrix as its transpose% and size vector as 1,[]B = reshape(A.',1,[])
Output:
Example 2
Matlab
%  MATLAB code for Conversion of a 3*3% matrix into its row vector.A = [1 2 3; 4 5 6; 7 8 9]; % Initializing a 3*3 matrix  % Calling the reshape() function% over the above matrix as its transpose% and size vector as 1,[]B = reshape(A.',1,[])
Output:
MATLAB
MATLAB-programs
MATLAB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Forward and Inverse Fourier Transform of an Image in MATLAB
Boundary Extraction of image using MATLAB
How to Remove Noise from Digital Image in Frequency Domain Using MATLAB?
How to Solve Histogram Equalization Numerical Problem in MATLAB?
How to Normalize a Histogram in MATLAB?
How to Remove Salt and Pepper Noise from Image Using MATLAB?
Double Integral in MATLAB
Classes and Object in MATLAB
How to Convert Three Channels of Colored Image into Grayscale Image in MATLAB?
What are different types of denoising filters in MATLAB?
Keep your Notebooks Consistent with JupyterLab Templates | by Luke Gloege, Ph.D. | Towards Data Science

I spend most of my day working in JupyterLab and each notebook I create tends to have a similar structure. Instead of copy and pasting notebooks, the JupyterLab Templates extension is a solution that allows you to create notebooks you can reuse.
This short post will outline how to install and set up this extension.
Install the jupyterlab_templates packages via pip:
pip install jupyterlab_templates
then install
jupyter labextension install jupyterlab_templates
and enable the extension
jupyter serverextension enable --py jupyterlab_templates
Now we just need to set up the template directory
Create a directory where you will store your notebooks. For instance, my templates are stored here:
~/.jupyter/templates
Create the following file (if it does not yet exist)
~/.jupyter/jupyter_notebook_config.py
Add the following line to this file. This tells jupyterLab the full path to your template directory. This must be the full path, do not use the ~ shorthand
template_dirs → List of directories where you will store templates. Each .ipynb file in any subdirectory of these paths will be a template. Files in the parent directory will be ignored
**important** Templates need to be in a subdirectory of template_dirs directory. Files in the parent directory will be ignored
You can have more than one notebook in each subdirectory. As an example, here is my directory tree.
├──.jupyter   └── templates       └── analysis           ├── analysis-template.ipynb           └── test-template.ipynb
Now that everything is set up, you can start making your reusable notebooks. Here is my analysis-template.ipynb notebook
short description 
Change log
date created and any changes go here
import numpy as np
import pandas as pd
import xarray as xr
import matplotlib.pyplot as plt

from dask.distributed import Client
from dask_jobqueue import SLURMCluster

# define worker
cluster = SLURMCluster()

# connect cluster to client
client = Client(cluster)

# add workers to the cluster
cluster.scale(4)

 

 

 

Now when you start jupyterLab you can access your templates like this:
You may have noticed that the package comes with a Sample.ipynb. For those that are curious, the following command will display the location of that file on macOS:
locate Sample.ipynb
On my machine, it is located here:
/Users/luke/miniforge3/lib/python3.9/site-packages/jupyterlab_templates/templates/jupyterlab_templates/Sample.ipynb
I have tried other notebook template solutions in the past, but they were all difficult and confusing to set up. This is the easiest solution I have found.
The only feature missing, in my opinion, is prompting the user to immediately rename the newly created notebook.
I hope this post helps keep your personal notebooks, or those across your team, consistent.
towardsdatascience.com
betterprogramming.pub
betterprogramming.pub
Thank you for reading and supporting Medium writers