code-rag-bench/online-tutorials huggingface dataset:
strpbrk() in C

02 May, 2018
This function finds the first character in the string s1 that matches any character specified in s2 (It excludes terminating null-characters).
Syntax : 
char *strpbrk(const char *s1, const char *s2)

Parameters :
s1 : string to be scanned.
s2 : string containing the characters to match.

Return Value :
It returns a pointer to the character in s1 that 
matches one of the characters in s2, else returns NULL.

// C code to demonstrate the working of// strpbrk#include <stdio.h>#include <string.h>  // Driver functionint main(){    // Declaring three strings    char s1[] = "geeksforgeeks";    char s2[] = "app";    char s3[] = "kite";    char* r, *t;      // Checks for matching character    // no match found    r = strpbrk(s1, s2);     if (r != 0)        printf("First matching character: %c\n", *r);    else        printf("Character not found");      // Checks for matching character    // first match found at "e"    t = strpbrk(s1, s3);    if (t != 0)        printf("\nFirst matching character: %c\n", *t);    else        printf("Character not found");      return (0);}
Output:
Character not found
First matching character: e

Practical ApplicationThis function can be used in game of lottery where the person having string with lettercoming first in victory wins, i.e. this can be used at any place where first person wins.
// C code to demonstrate practical application// of strpbrk#include <stdio.h>#include <string.h>  // Driver functionint main(){    // Initializing victory string    char s1[] = "victory";      // Declaring lottery strings    char s2[] = "a23";    char s3[] = "i22";    char* r, *t;      // Use of strpbrk()    r = strpbrk(s1, s2);    t = strpbrk(s1, s3);      // Checks if player 1 has won lottery    if (r != 0)        printf("Congrats u have won");    else        printf("Better luck next time");      // Checks if player 2 has won lottery    if (t != 0)        printf("\nCongrats u have won");    else        printf("Better luck next time");      return (0);}
Output:
Better luck next time
Congrats u have won

This article is contributed by Shantanu Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@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.
SACHIN KUNTE
C-Library
cpp-string
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Function Pointer in C
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Different Methods to Reverse a String in C++
Vector in C++ STL
Map in C++ Standard Template Library (STL)
Initialize a vector in C++ (7 different ways)
Set in C++ Standard Template Library (STL)
vector erase() and clear() in C++
How to create superuser in Django?

05 Sep, 2020
Django provides us Admin Panel for it’s users. So we need not worry about creating a separate Admin page or providing authentication feature as Django provides us that feature. Before using this feature, you must have migrated your project, otherwise the superuser database will not be created.
How to create superuser in Django?
For creating superuser, first reach the same directory as that of manage.py and run the following command:
python manage.py createsuperuser
Then enter the Username of your choice and press enter.
Username: srishti
Then enter the Email address and press enter.(It can be left blank)
Email address: example@gmail.com
Next, enter the Password in-front of the Password field and press enter.Enter a strong password so as to keep it secure.
Password: ******  
Then again enter the same Password for confirmation.
Password(again): ******
Superuser created successfully if above fields are entered correctly.
Image shown after above steps done 
Now we can login into our Django Admin page by running the command python manage.py runserver . Then, open a Web browser and go to “/admin/” on your local domain – e.g., http://127.0.0.1:8000/admin/ and then enter the same Username and Password.
                                                                                                                                                                                                  
Django admin page
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Tryit Editor v3.7

Tryit: Display a less-than sign
Collapse multiple Columns in Pandas - GeeksforGeeks

08 Mar, 2019
While operating dataframes in Pandas, we might encounter a situation to collapse the columns. Let it becumulated data of multiple columns or collapse based on some other requirement. Let’s see how to collapse multiple columns in Pandas.
Following steps are to be followed to collapse multiple columns in Pandas:
Step #1: Load numpy and Pandas.Step #2: Create random data and use them to create a pandas dataframe.Step #3: Convert multiple lists into a single data frame, by creating a dictionary for each list with a name.Step #4: Then use Pandas dataframe into dict. A data frame with columns of data and column for names is ready.Step #5: Specify which columns are to be collapsed. That can be done by specifying the mapping as a dictionary, where the keys are the names of columns to be combined or collapsed and the values are the names of the resulting column.
Example 1:
# Python program to collapse# multiple Columns using Pandasimport pandas as pd  # sample datan = 3Sample_1 = [57, 51, 6]Sample_2 = [92, 16, 19]Sample_3 = [15, 93, 71]Sample_4 = [28, 73, 31]  sample_id = zip(["S"]*n, list(range(1, n + 1)))  s_names = [''.join([w[0], str(w[1])]) for w in sample_id]  d = {'s_names': s_names, 'Sample_1': Sample_1,      'Sample_2': Sample_2, 'Sample_3': Sample_3,     'Sample_4': Sample_4}  df_1 = pd.DataFrame(d)  mapping = {'Sample_1': 'Result_1',           'Sample_2': 'Result_1',            'Sample_3': 'Result_2',            'Sample_4': 'Result_2'}  df = df_1.set_index('s_names').groupby(mapping, axis = 1).sum()  df.reset_index(level = 0)
Output:
Example 2:
# Python program to collapse# multiple Columns using Pandasimport pandas as pddf = pd.DataFrame({'First': ['Manan ', 'Raghav ', 'Sunny '],                   'Last': ['Goel', 'Sharma', 'Chawla'],                   'Age':[12, 24, 56]})  mapping = {'First': 'Full Name', 'Last': 'Full Name'}  df = df.set_index('Age').groupby(mapping, axis = 1).sum()  df.reset_index(level = 0)
Output:
pandas-dataframe-program
Picked
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python OOPs Concepts
How to Install PIP on Windows ?
Bar Plot in Matplotlib
Defaultdict in Python
Python Classes and Objects
Deque in Python
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python - Ways to remove duplicates from list
Class method vs Static method in Python
Java Regex - Character Class [a-zA-Z] Match

The character class [a-zA-Z] matches any character from a to z or A to Z.
The following example shows the usage of character class matching.
package com.tutorialspoint;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CharacterClassDemo {
   private static final String REGEX = "[a-zA-Z]";
   private static final String INPUT = "dbcabca124ADCbc";

   public static void main(String[] args) {
      // create a pattern
      Pattern  pattern = Pattern.compile(REGEX);
      
      // get a matcher object
      Matcher matcher = pattern.matcher(INPUT); 

      while(matcher.find()) {
         //Prints the start index of the match.
         System.out.println("Match String start(): "+matcher.start());
      }
   }
}
Let us compile and run the above program, this will produce the following result −
Match String start(): 0
Match String start(): 1
Match String start(): 2
Match String start(): 3
Match String start(): 4
Match String start(): 5
Match String start(): 6
Match String start(): 10
Match String start(): 11
Match String start(): 12
Match String start(): 13
Match String start(): 14

 Print
 Add Notes
 Bookmark this page
How do we use re.finditer() method in Python regular expression?

According to Python docs,
re.finditer(pattern, string, flags=0)
 Return an iterator yielding MatchObject instances over all non-overlapping matches for the RE pattern in string. The string is scanned left-to-right, and matches are returned in the order found. Empty matches are included in the result. 
The following code shows the use of re.finditer() method in Python regex
import re
s1 = 'Blue Berries'
pattern = 'Blue Berries'
for match in re.finditer(pattern, s1):
    s = match.start()
    e = match.end()
    print 'String match "%s" at %d:%d' % (s1[s:e], s, e)
Strings match "Blue Berries" at 0:12
C# | Get the first node of the LinkedList<T> - GeeksforGeeks

01 Feb, 2019
LinkedList<T>.First property is used to get the first node of the LinkedList<T>.
Syntax:
public System.Collections.Generic.LinkedListNode First { get; }

Return Value: The first LinkedListNode<T> of the LinkedList<T>.
Below given are some examples to understand the implementation in a better way:
Example 1:
// C# code to get the first// node of the LinkedListusing System;using System.Collections;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {        // Creating a LinkedList of Strings        LinkedList<String> myList = new LinkedList<String>();          // Adding nodes in LinkedList        myList.AddLast("Geeks");        myList.AddLast("for");        myList.AddLast("Data Structures");        myList.AddLast("Noida");          // To get the first node of the LinkedList        if (myList.Count > 0)            Console.WriteLine(myList.First.Value);        else            Console.WriteLine("LinkedList is empty");    }}
Output:
Geeks

Example 2:
// C# code to get the first// node of the LinkedListusing System;using System.Collections;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {        // Creating a LinkedList of Integers        LinkedList<int> myList = new LinkedList<int>();          // To get the first node of the LinkedList        if (myList.Count > 0)            Console.WriteLine(myList.First.Value);        else            Console.WriteLine("LinkedList is empty");    }}
Output:
LinkedList is empty

Note:
LinkedList accepts null as a valid Value for reference types and allows duplicate values.
If the LinkedList is empty, the First and Last properties contain null.
Retrieving the value of this property is an O(1) operation.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.linkedlist-1.first?view=netframework-4.7.2
CSharp-Generic-Namespace
CSharp-LinkedList
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Delegates
C# | Abstract Classes
Difference between Ref and Out keywords in C#
Extension Method in C#
C# | Replace() Method
C# | Class and Object
C# | Constructors
Introduction to .NET Framework
C# | Data Types
HashSet in C# with Examples
Java Interface

Another way to achieve abstraction in Java, is with interfaces.
An interface is a completely "abstract class" 
that is used to group related methods with empty bodies:
// interface
interface Animal {
  public void animalSound(); // interface method (does not have a body)
  public void run(); // interface method (does not have a body)
}
 

To access the interface methods, the interface must be "implemented" 
(kinda like inherited) by another class with the implements 
keyword (instead of extends). The body of the 
interface method is provided by the "implement" class:
// Interface
interface Animal {
  public void animalSound(); // interface method (does not have a body)
  public void sleep(); // interface method (does not have a body)
}

// Pig "implements" the Animal interface
class Pig implements Animal {
  public void animalSound() {
    // The body of animalSound() is provided here
    System.out.println("The pig says: wee wee");
  }
  public void sleep() {
    // The body of sleep() is provided here
    System.out.println("Zzz");
  }
}

class Main {
  public static void main(String[] args) {
    Pig myPig = new Pig();  // Create a Pig object
    myPig.animalSound();
    myPig.sleep();
  }
}
 
 


Try it Yourself »

Like abstract classes, interfaces cannot be used to create objects (in the example above, 
it is not possible to create an "Animal" object in the MyMainClass)
Interface methods do not have a body - the 
body is provided by the "implement" class
On implementation of an interface, you must override all of its methods
Interface methods are by default abstract and 
  public
Interface attributes are by default public, 
  static and final
An interface cannot contain a constructor (as it cannot be used to create objects)
1) To achieve security - hide certain details and only show the important 
details of an object (interface).
2) Java does not support "multiple inheritance" (a class can only inherit from one superclass). However, it can be achieved 
  with interfaces, because the class can implement multiple interfaces.
  Note: To implement multiple interfaces, separate them with a comma (see example below).
To implement multiple interfaces, separate them with a comma:
interface FirstInterface {
  public void myMethod(); // interface method
}

interface SecondInterface {
  public void myOtherMethod(); // interface method
}

class DemoClass implements FirstInterface, SecondInterface {
  public void myMethod() {
    System.out.println("Some text..");
  }
  public void myOtherMethod() {
    System.out.println("Some other text...");
  }
}

class Main {
  public static void main(String[] args) {
    DemoClass myObj = new DemoClass();
    myObj.myMethod();
    myObj.myOtherMethod();
  }
}
 


Try it Yourself »

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Lodash _.isNumber() Function - GeeksforGeeks

25 Nov, 2021
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.isNumber() method is used to find whether the given value parameter is number or not. If the given value is a number then it returns True value otherwise, it returns False.
Syntax:
_.isNumber(value)
Parameters: This method accepts a single parameter as mentioned above and described below:
value: This parameter holds the value to check.
value: This parameter holds the value to check.
Return Value: This method returns true if the value is a number, else false.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library into the file.
Javascript
// Requiring the lodash library  const _ = require("lodash");       // Use of _.isNumber() method   console.log(_.isNumber(10)); console.log(_.isNumber('GeeksforGeeks')); console.log(_.isNumber(15.675));
Output:
true
false
true
Example 2:  
Javascript
// Requiring the lodash library  const _ = require("lodash");       // Use of _.isNumber()  // method   console.log(_.isNumber(true));console.log(_.isNumber(Number.MIN_VALUE)); console.log(_.isNumber(Infinity));console.log(_.isNumber('3'));
Output:
false
true
true
false
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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
Difference Between PUT and PATCH Request
Node.js | fs.writeFileSync() Method
Roadmap to Become a Web Developer in 2022
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?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
MySQL CREATE TABLE Statement

The CREATE TABLE statement is used to create a new table in a database.
The column parameters specify the names of the columns of the table.
The datatype parameter specifies the type of data the column can hold (e.g. varchar, integer, date, etc.).
Tip: For an overview of the available data types, go to our complete Data Types Reference.
The following example creates a table called "Persons" that contains five columns: PersonID, LastName, FirstName, 
Address, and City:
The PersonID column is of type int and will hold an integer.
The LastName, FirstName, Address, and City columns are of type varchar and will hold characters, and the maximum length for these fields 
is 255 characters.
The empty "Persons" table will now look like this:
Tip: The empty "Persons" table can now be filled with data with the 
SQL INSERT INTO statement.
A copy of an existing table can also be created using CREATE TABLE.
The new table gets the same column definitions. All columns or specific columns can be selected.
If you create a new table using an existing table, the new table will be filled with the existing values from the old table.
The following SQL creates a new table called "TestTables" (which is 
a copy of the "Customers" table): 
Write the correct SQL statement to create a new table called Persons.
 (
  PersonID int,
  LastName varchar(255),
  FirstName varchar(255),
  Address varchar(255),
  City varchar(255) 
);

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
SQL Tryit Editor v1.6

SELECT * FROM Orders
WHERE OrderDate BETWEEN '1996-07-01' AND '1996-07-31';
​
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, Opera, and Edge(79).
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
atd command in Linux with examples - GeeksforGeeks

04 Apr, 2019
atd is a job scheduler daemon that runs jobs scheduled for later execution. These jobs are one-time task(not recurring) at a specific time scheduled using ‘at’ or ‘batch’ utility.
Syntax:
atd [-l load_avg] [-b batch_interval] [-d] [-f] [-s]
Options:
-l : Specifies a limiting load factor, over which batch jobs should not be run, instead of the compile-time choice of 1.5.
-b : Specify the minimum interval in seconds between the start of two batch jobs (60 default).
-d : Debug; print error messages to standard error instead of using syslog(3). This option also implies -f.
-f : Run atd in the foreground.
-s : Process the at/batch queue only once. This is primarily of use for compatibility with old versions of at; atd -s is equivalent to the old atrun command.
Starting atd:
To start atd in the current session, use below command:$ service atd start 
$ service atd start 
To start atd automatically at boot time, use below command:$ chkconfig atd on 
$ chkconfig atd on 
While using ‘at’ utility, the following issue can be seen:It means that atd is not running and needs to be started.
It means that atd is not running and needs to be started.
Stopping atd:
To stop atd in the current session, use below command:$ service atd stop 
$ service atd stop 
To disable atd from starting at boot time, use below command:$ chkconfig atd off 
$ chkconfig atd off 
Restarting atd: To restart atd, use below command.
$ service atd restart 
Checking atd status: To determine if atd is running or not, use below command:
$ service atd status 
If atd is running, status will be “active”:
If atd is not running, status will be “inactive”:Example:
Example:
linux-command
Linux-misc-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
scp command in Linux with Examples
nohup Command in Linux with Examples
mv command in Linux with examples
Thread functions in C/C++
Docker - COPY Instruction
chown command in Linux with Examples
nslookup command in Linux with Examples
SED command in Linux | Set 2
Named Pipe or FIFO with example C program
uniq Command in LINUX with examples
Adding Drop Shadow to Images using CSS3

To add drop shadow to image in CSS3, use the drop-shadow value for filter property. It has the following values −
h-shadow – To specify a pixel value for the horizontal shadow.
v-shadow – To specify a pixel value for the vertical shadow. Negative values place the shadow above the image.
blur – To add a blur effect to the shadow.
spread - Positive values causes the shadow to expand and negative to shrink.
color – To add color to the shadow
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
img.demo {
   filter: brightness(120%);
   filter: contrast(120%);
   filter: drop-shadow(10px 10px 10px green);
}
</style>
</head>
<body>
<h1>Learn MySQL</h1>
<img src="https://www.tutorialspoint.com/mysql/images/mysql-mini-logo.jpg" alt="MySQL" width="160" height="150">
<h1>Learn MySQL</h1>
<img class="demo" src="https://www.tutorialspoint.com/mysql/images/mysql-mini-logo.jpg" alt="MySQL" width="160" height="150">
</body>
</html>
AWT TextEvent Class

The object of this class represents the text events.The TextEvent is generated when character is entered in the text fields or text area. The TextEvent instance does not include the characters currently in the  text component that generated the event rather we are provided with other methods to retrieve that information.
Following is the declaration for java.awt.event.TextEvent class:
public class TextEvent
   extends AWTEvent
Following are the fields for java.awt.event.TextEvent class:
static int TEXT_FIRST  --The first number in the range of ids used for text events.
static int TEXT_FIRST  --The first number in the range of ids used for text events.
static int TEXT_LAST  --The last number in the range of ids used for text events.
static int TEXT_LAST  --The last number in the range of ids used for text events.
static int TEXT_VALUE_CHANGED  --This event id indicates that object's text changed.
static int TEXT_VALUE_CHANGED  --This event id indicates that object's text changed.
TextEvent(Object source, int id) 
Constructs a TextEvent object.
String	paramString()
 Returns a parameter string identifying this text event.
This class inherits methods from the following classes:
java.awt.AWTEvent
java.awt.AWTEvent
java.util.EventObject
java.util.EventObject
java.lang.Object
java.lang.Object

    13 Lectures 
     2 hours 

 EduOLC
 Print
 Add Notes
 Bookmark this page
Loop through the Vector elements using an Iterator in Java

An Iterator can be used to loop through the Vector elements. The method hasNext( ) returns true if there are more elements in the Vector and false otherwise. The method next( ) returns the next element in the Vector and throws the exception NoSuchElementException if there is no next element.
A program that demonstrates this is given as follows −
 Live Demo
import java.util.Iterator;
import java.util.Vector;
public class Demo {
   public static void main(String args[]) {
      Vector vec = new Vector();
      vec.add(4);
      vec.add(1);
      vec.add(3);
      vec.add(9);
      vec.add(6);
      vec.add(8);
      System.out.println("The Vector elements are: ");
      Iterator i = vec.iterator();
      while (i.hasNext()) {
         System.out.println(i.next());
      }
   }
}
The output of the above program is as follows −
The Vector elements are:
4
1
3
9
6
8
Now let us understand the above program.
The Vector is created and Vector.add() is used to add the elements to the Vector. Then the vector elements are displayed using an iterator which makes use of the Iterator interface. A code snippet which demonstrates this is as follows −
Vector vec = new Vector();
vec.add(4);
vec.add(1);
vec.add(3);
vec.add(9);
vec.add(6);
vec.add(8);
System.out.println("The Vector elements are: ");
Iterator i = vec.iterator();
while (i.hasNext()) {
   System.out.println(i.next());
}
bin() in Python - GeeksforGeeks

17 Sep, 2021
Python bin() function returns the binary string of a given integer.
Syntax:  bin(a)
Parameters : a : an integer to convert
Return Value : A binary string of an integer or int object.
Exceptions : Raises TypeError when a float value is sent in arguments.
Python3
# Python code to demonstrate working of# bin() # declare variablenum = 100 # print binary numberprint(bin(num))
Output:
0b1100100
Python3
# Python code to demonstrate working of# bin() # function returning binary stringdef Binary(n):    s = bin(n)     # removing "0b" prefix    s1 = s[2:]    return s1 print("The binary representation of 100 (using bin()) is : ", end="")print(Binary(100))
Output: 
The binary representation of 100 (using bin()) is : 1100100
Here we send the object of the class to the bin methods, and we are using python special methods __index()__ method which always returns positive integer, and it can not be a rising error if the value is not an integer. 
Python3
# Python code to demonstrate working of# bin()class number:    num = 100     def __index__(self):        return(self.num) print(bin(number()))
Output:
0b1100100
This article is contributed by Manjeet Singh. 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. 
kumar_satyam
base-conversion
Python-Built-in-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Python program to convert a list to string
Reading and Writing to text files in Python
Minimize Rounding Error to Meet Target in C++

Suppose we have an array of prices P [p1,p2...,pn] and a target value, we have to round each price Pi to Roundi(Pi) so that the rounded array [Round1(P1),Round2(P2)...,Roundn(Pn)] sums to the given target value. Here each operation Roundi(pi) could be either Floor(Pi) or Ceil(Pi).
We have to return the string "-1" if the rounded array is impossible to sum to target. Otherwise, return the smallest rounding error, which will be (as a string with three places after the decimal) defined as −
∑i−1n|Roundi(????)−????
So if the input is like [“0.700”, “2.800”, “4.900”], and the target is 8. Use floor or ceil operations to get (0.7 - 0) + (3 - 2.8) + (5 - 4.9) = 0.7 + 0.2 + 0.1 = 1.0
To solve this, we will follow these steps −
ret := 0
ret := 0
make one priority queue pq for (double and array) type complex data
make one priority queue pq for (double and array) type complex data
for i in range 0 to size of pricesx := double value of prices[i]low := floor of xhigh := ceiling of xif low is not highdiff := (high - x) – (x - low)insert diff into pqtarget := target – lowret := ret + (x - low)
for i in range 0 to size of prices
x := double value of prices[i]
x := double value of prices[i]
low := floor of x
low := floor of x
high := ceiling of x
high := ceiling of x
if low is not highdiff := (high - x) – (x - low)insert diff into pq
if low is not high
diff := (high - x) – (x - low)
diff := (high - x) – (x - low)
insert diff into pq
insert diff into pq
target := target – low
target := target – low
ret := ret + (x - low)
ret := ret + (x - low)
if target > size of pq or target < 0, then return “-1”
if target > size of pq or target < 0, then return “-1”
while target is not 0ret := ret + top of pq, delete from pqddecrease target by 1
while target is not 0
ret := ret + top of pq, delete from pq
ret := ret + top of pq, delete from pq
d
decrease target by 1
decrease target by 1
s := ret as string
s := ret as string
return substring s by taking number up to three decimal places
return substring s by taking number up to three decimal places
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
struct Comparator{
   bool operator()(double a, double b) {
      return !(a < b);
   }
};
class Solution {
   public:
   string minimizeError(vector<string>& prices, int target) {
      double ret = 0;
      priority_queue < double, vector < double >, Comparator > pq;
      for(int i = 0; i < prices.size(); i++){
         double x = stod(prices[i]);
         double low = floor(x);
         double high = ceil(x);
         if(low != high){
            double diff = ((high - x) - (x - low));
            pq.push(diff);
         }
         target -= low;
         ret += (x - low);
      }
      if(target > pq.size() || target < 0) return "-1";
      while(target--){
         ret += pq.top();
         pq.pop();
      }
      string s = to_string (ret);
      return s.substr (0, s.find_first_of ('.', 0) + 4);
   }
};
main(){
   vector<string> v = {"0.700","2.800","4.900"};
   Solution ob;
   cout << (ob.minimizeError(v, 8));
}
["0.700","2.800","4.900"]
8
"1.000"
Node.js shift() function - GeeksforGeeks

14 Oct, 2021
shift() is an array function from Node.js that is used to delete element from the front of an array.
Syntax:
array_name.shift()
Parameter: This function does not takes any parameter.
Return type: The function returns the array after deleting the element.
The program below demonstrates the working of the function:
Program 1:
function shiftDemo(){  arr.shift();  console.log(arr);}var arr=[17, 55, 87, 49, 78];shiftDemo();
Output:
[ 55, 87, 49, 78 ]
Program 2:
function shiftDemo(){  arr.shift();  console.log(arr);}var arr=['a', 'b'];shiftDemo();
Output:
[ 'b' ]
Program 3:
let Lang = ["Python", "C", "Java", "JavaScript"];while ((i = Lang.shift()) !== undefined) {    Lang.shift();}console.log(Lang);
Output:
[]
NodeJS-function
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to build a basic CRUD app with Node.js and ReactJS ?
How to connect Node.js with React.js ?
Mongoose Populate() Method
Express.js req.params Property
Mongoose find() Function
Top 10 Front End Developer Skills That You Need in 2022
Top 10 Projects For Beginners To Practice HTML and CSS Skills
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
Operator Precedence and Associativity in C

Operator precedence determines the grouping of terms in an expression and decides how an expression is evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has a higher precedence than the addition operator.
For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has a higher precedence than +, so it first gets multiplied with 3*2 and then adds into 7.
Here, operators with the highest precedence appear at the top of the table, those with the lowest appear at the bottom. Within an expression, higher precedence operators will be evaluated first.
#include <stdio.h>
main() {
   int a = 20;
   int b = 10;
   int c = 15;
   int d = 5;
   int e;
   e = (a + b) * c / d; // ( 30 * 15 ) / 5
   printf("Value of (a + b) * c / d is : %d\n", e );
   e = ((a + b) * c) / d; // (30 * 15 ) / 5
   printf("Value of ((a + b) * c) / d is : %d\n" , e );
   e = (a + b) * (c / d); // (30) * (15/5)
   printf("Value of (a + b) * (c / d) is : %d\n", e );
   e = a + (b * c) / d; // 20 + (150/5)
   printf("Value of a + (b * c) / d is : %d\n" , e );
   return 0;
}
Value of (a + b) * c / d is : 90
Value of ((a + b) * c) / d is : 90
Value of (a + b) * (c / d) is : 90
Value of a + (b * c) / d is : 50
C# Program to Get the Machine Name or Host Name Using Environment Class - GeeksforGeeks

30 Nov, 2021
Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information and time since last system boot in milliseconds information. By just using the predefined MachineName Property we can get the machine name or the hostname using the Environment class. This property is used to find the NetBIOS name of the computer. It also throws InvalidOperationException when this property does not get the name of the computer.
Syntax:
Environment.MachineName
Return: This method returns a string that contains the machine name.
Example:
C#
// C# program to find the name of the machine// Using Environment classusing System; class GFG{ static public void Main(){         // Here we get the machine name    // Using the MachineName property    // of the Environment class    Console.WriteLine("Machine Name is" + Environment.MachineName);}}
Output:
Machine Name is Check
avtarkumar719
CSharp-programs
Picked
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Partial Classes in C#
C# | Inheritance
C# | List Class
Difference between Hashtable and Dictionary in C#
Lambda Expressions in C#
Appending to list in Python dictionary - GeeksforGeeks

17 Oct, 2021
In this article, we are going to see how to append to a list in a Python dictionary.
In this method, we will use the += operator to append a list into the dictionary, for this we will take a dictionary and then add elements as a list into the dictionary.
Python3
Details = {"Destination": "China",            "Nstionality": "Italian", "Age": []}Details["Age"] += [20, "Twenty"]print(Details)
Output:
{'Destination': 'China', 'Nstionality': 'Italian', 'Age': [20, 'Twenty']}
You can as well append one item.
In this method, we will use conditions for checking the key and then append the list into the dictionary.
Python3
Details = {}Details["Age"] = [20]print(Details)  if "Age" in Details:    Details["Age"].append("Twenty")    print(Details)
Output:
{'Age': [20]}
{'Age': [20, 'Twenty']}
In this method, we are using defaultdict() function, It is a part of the collections module. You have to import the function from the collections module to use it in your program. and then use to append the list into the dictionary.
Python3
from collections import defaultdict  Details = defaultdict(list)Details["Country"].append("India")print(Details)
Output:
defaultdict(<class 'list'>, {'Country': ['India']})
Since append takes only one parameter, to insert another parameter, repeat the append method.
Python3
from collections import defaultdict  Details = defaultdict(list)Details["Country"].append("India")Details["Country"].append("Pakistan")print(Details)
Output:
defaultdict(<class 'list'>, {'Country': ['India', 'Pakistan']})
We will use the update function to add a new list into the dictionary. You can use the update() function to embed a dictionary inside another dictionary. 
Python3
Details = {}Details["Age"] = []Details.update({"Age": [18, 20, 25, 29, 30]})print(Details)
Output:
{'Age': [18, 20, 25, 29, 30]}
You can convert a list into a value for a key in a python dictionary using dict() function.
Python3
Values = [18, 20, 25, 29, 30]Details = dict({"Age": Values})print(Details)
Output:
{'Age': [18, 20, 25, 29, 30]}
Picked
Python dictionary-programs
python-dict
Python
Python Programs
python-dict
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Top 5 Easter Eggs in Python - GeeksforGeeks

22 Jul, 2021
Python is really an interesting language with very good documentation. In this article, we will go through some fun stuff that isn’t documented and so considered as Easter eggs of Python.
Most of the programmers should have started your programming journey from printing “Hello World!”. Would you believe that Python has a secret module to print “Hello World” and the name of the module is __hello__
Python3
import __hello__ 
Output:
Hello world!
If you feel bored typing code all day, then check the antigravity module in Python which redirects you to
https://xkcd.com/353/ a web-comic.
Python3
# redirects you to https://xkcd.com/353/import antigravity
“Zen of python”  is a guide to Python design principles.  It consists of 19 design principles and it is written by an American software developer Tim Peters. This is also by far the only ‘official’ Easter egg that is stated as an ‘Easter egg’ in Python Developer’s Guide. You can see them by importing the module “this”.
Python3
import this
Output:
Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren’t special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one– and preferably only one –obvious way to do it.Although that way may not be obvious at first unless you’re Dutch.Now is better than never.Although never is often better than *right* now.If the implementation is hard to explain, it’s a bad idea.If the implementation is easy to explain, it may be a good idea.Namespaces are one honking great idea — let’s do more of those!
Recognized that the != inequality operator in Python 3.0 was a horrible, finger pain-inducing mistake, the FLUFL reinstates the <> diamond operator as the sole spelling.
Python3
from __future__ import barry_as_FLUFL  1 <> 21 != 2
Output:
True
SyntaxError: with Barry as BDFL, use '<>' instead of '!='
Unlike most of the language, Python uses indentation instead of curly braces “{ }”. While making a transition from languages like C++ or JAVA to Python it is a bit difficult to adapt to indentation. Thus if we try to use braces using __future__ module, Python gives a funny reply “not a chance”.
Python3
from __future__ import braces
 Output:
File "<stdin>", line 1
SyntaxError: not a chance
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()
AngularJS | ng-disabled Directive - GeeksforGeeks

31 Aug, 2021
The ng-disabled Directive in AngularJS is used to enable or disable HTML elements. If the expression inside the ng-disabled attribute returns true then the form field will be disabled or vice versa. It is usually applied on form field (input, select, button, etc). 
Syntax:  
<element ng-disabled="expression"> Contents... </element>
Example 1: This example uses ng-disabled Directive to disable the button.  
html
<!DOCTYPE html><html>     <head>    <title>ng-disabled Directive</title>     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">    </script></head> <body ng-app="app" style="text-align:center">         <h1 style="color:green">GeeksforGeeks</h1>         <h2>ng-disabled Directive</h2>         <div ng-controller="app" ng-init="disable=false">        <button ng-click="geek(disable)" ng-disabled="disable">            Click to Disable        </button>                 <button ng-click="geek(disable)" ng-show="disable">            Click to Enable        </button>    </div>         <script>        var app = angular.module("app", []);        app.controller('app', ['$scope', function ($app) {            $app.geek = function (disable) {                $app.disable = !disable;            }        }]);    </script></body> </html>
Output: Before clicking the button:  
After clicking the button:  
 
Example 2: This example uses ng-disabled Directive to enable and disable button using checkbox.  
html
<!DOCTYPE html><html>     <head>    <title>ng-disabled Directive</title>     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">    </script></head> <body ng-app="app" style="text-align:center">         <h1 style="color:green">GeeksforGeeks</h1>         <h2>ng-disabled Directive</h2>         <div ng-controller="geek">        <h4>            Check it            <input type="checkbox" ng-model="check" />        </h4>                 <button type="button" ng-disabled="!(check)">            Click to submit        </button>    </div>         <script>        var app = angular.module("app", []);        app.controller('geek', ['$scope', function ($scope) {            $scope.disableClick = function (isDisabled) {            $scope.isDisabled = !isDisabled;            }        }]);    </script></body> </html>
Output: Before clicking the button:  
After clicking the button:  
Supported Browser:
Google Chrome
Microsoft Edge
Firefox
Opera
Safari
ysachin2314
AngularJS-Directives
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Auth Guards in Angular 9/10/11
Angular PrimeNG Calendar Component
What is AOT and JIT Compiler in Angular ?
How to bundle an Angular app for production?
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?
Program to convert Java list of Strings to Seq in Scala - GeeksforGeeks

14 Jan, 2020
A java list of Strings can be converted to sequence in Scala by utilizing toSeq method of Java in Scala. Here, we need to import Scala’s JavaConversions object in order to make this conversions work else an error will occur.Now, lets see some examples and then discuss how it works in details.Example:1#
// Scala program to convert Java list // to Sequence in Scala  // Importing Scala's JavaConversions objectimport scala.collection.JavaConversions._    // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Creating list of Strings in Java        val list = new java.util.ArrayList[String]()                  // Adding Strings to the list        list.add("geeks")        list.add("cs")        list.add("portal")                  // Converting list to Sequence         val seq= list.toSeq                  // Displays seq        println(seq)          }}
Buffer(geeks, cs, portal)

Example:2#
// Scala program to convert Java list // to Sequence in Scala  // Importing Scala's JavaConversions objectimport scala.collection.JavaConversions._    // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Creating list of Strings in Java        val list = new java.util.ArrayList[String]()                  // Adding Strings to the list        list.add("i")        list.add("am an")        list.add("author")                  // Converting list to Sequence         val seq= list.toSeq                  // Displays seq        println(seq)              }}
Buffer(i, am an, author)

Scala
scala-collection
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in Scala
Scala | Traits
Scala ListBuffer
Scala | Case Class and Case Object
Hello World in Scala
Scala | Functions - Basics
Scala | Decision Making (if, if-else, Nested if-else, if-else if)
Scala List map() method with example
Comments In Scala
Scala | Try-Catch Exceptions
Python 3 - String rstrip() Method

The rstrip() method returns a copy of the string in which all chars have been stripped from the end of the string (default whitespace characters).
Following is the syntax for rstrip() method −
str.rstrip([chars])

chars − You can supply what chars have to be trimmed.
This method returns a copy of the string in which all chars have been stripped from the end of the string (default whitespace characters).
The following example shows the usage of rstrip() method.
#!/usr/bin/python3

str = "     this is string example....wow!!!     "
print (str.rstrip())

str = "*****this is string example....wow!!!*****"
print (str.rstrip('*'))
When we run above program, it produces the following result −
     this is string example....wow!!!
*****this is string example....wow!!!


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
MongoDB query to search date records using only Month and Day

To search using month and day only, use $where. Let us create a collection with documents −
> db.demo181.insertOne({"ShippingDate":new ISODate("2020-01-10")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e398a699e4f06af551997fe")
}
> db.demo181.insertOne({"ShippingDate":new ISODate("2019-12-11")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e398a729e4f06af551997ff")
}
> db.demo181.insertOne({"ShippingDate":new ISODate("2018-01-10")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e398a7d9e4f06af55199800")
}
> db.demo181.insertOne({"ShippingDate":new ISODate("2020-10-12")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e398a879e4f06af55199801")
}
Display all documents from a collection with the help of find() method −
> db.demo181.find();
This will produce the following output −
{ "_id" : ObjectId("5e398a699e4f06af551997fe"), "ShippingDate" : ISODate("2020-01-10T00:00:00Z") }
{ "_id" : ObjectId("5e398a729e4f06af551997ff"), "ShippingDate" : ISODate("2019-12-11T00:00:00Z") }
{ "_id" : ObjectId("5e398a7d9e4f06af55199800"), "ShippingDate" : ISODate("2018-01-10T00:00:00Z") }
{ "_id" : ObjectId("5e398a879e4f06af55199801"), "ShippingDate" : ISODate("2020-10-12T00:00:00Z") }
Following is the query to search with Month and Day −
> db.demo181.find({$where : function() { return this.ShippingDate.getMonth() == 1 || this.ShippingDate.getDate() == 10} })
This will produce the following output −
{ "_id" : ObjectId("5e398a699e4f06af551997fe"), "ShippingDate" : ISODate("2020-01-10T00:00:00Z") }
{ "_id" : ObjectId("5e398a7d9e4f06af55199800"), "ShippingDate" : ISODate("2018-01-10T00:00:00Z") }