C Program for Egg Dropping Puzzle (DP 11)

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

402 Views

This is a famous puzzle problem. Suppose there is a building with n floors, if we have m eggs, then how can we find the minimum number of drops needed to find a floor from which it is safe to drop an egg without breaking it.There some important points to remember −When an egg does not break from a given floor, then it will not break for any lower floor also.If an egg breaks from a given floor, then it will break for all upper floors.When an egg breaks, it must be discarded, otherwise we can use it again.Input - The ... Read More

What Are Smart Contracts?

Prasanna Kotamraju
Updated on 30-Jul-2019 22:30:26

538 Views

Cryptocurrency is entirely dependent on Block Chains to maintain their transactions. A block is like a page of a ledger book where some transactions are written in ink, permanent which cannot be altered. A block typically consists of transactions of bitcoin or any other cryptocurrency and the details of transactions - who has sent, who has received, timestamp and previous blocks information to link it to the Block chain. This information is passed through a hashing algorithm like SHA 256 and creates a 32-bit hash value. This hash value is irreversible.Thus a block is a permanent store of records, which ... Read More

Send Notification When Android App is Closed

Smita Kapse
Updated on 30-Jul-2019 22:30:26

4K+ Views

This example demonstrate about How to Send a notification when the Android app is closedStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivitypackage app.tutorialspoint.com.notifyme ; import android.content.Intent ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;       setContentView(R.layout. activity_main ... Read More

Find and Replace NumberLong Type Field in MongoDB

Smita Kapse
Updated on 30-Jul-2019 22:30:26

534 Views

Use $set operator along with update() for this. Let us first create a collection with documents. Here we have set one field as NumberLong −> db.findAndReplaceDemo.insertOne({"UserId":NumberLong(101)}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2c960b64f4b851c3a13b6") } > db.findAndReplaceDemo.insertOne({"UserId":NumberLong(110)}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2c966b64f4b851c3a13b7") } > db.findAndReplaceDemo.insertOne({"UserId":NumberLong(101)}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2c969b64f4b851c3a13b8") } > db.findAndReplaceDemo.insertOne({"UserId":NumberLong(120)}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2c96cb64f4b851c3a13b9") } > db.findAndReplaceDemo.insertOne({"UserId":NumberLong(130)}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2c96eb64f4b851c3a13ba") }Following is the query to display all documents from a collection with the help of find() method ... Read More

Create a Border with a Raised Beveled Edge in Java

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

299 Views

Use the createRaisedBevelBorder() method to create a border with a raised beveled edge. We will set it on the label component −JLabel label; label = new JLabel("This has a border with a raised bevel edge!"); label.setBorder(BorderFactory.createRaisedBevelBorder());The following is an example to create a border with a raised beveled edge −Examplepackage my; import javax.swing.BorderFactory; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame("Demo");       JLabel label;       label = new JLabel("This has a border with a raised bevel edge!"); ... Read More

MongoDB Query to Replace Value in an Array

Anvi Jain
Updated on 30-Jul-2019 22:30:26

1K+ Views

Use $set to replace value in an array. Let us first create a collection with documents −> db.replaceValueInArrayDemo.insertOne({"StudentScores":[45, 56, 78]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7f0421a844af18acdffb7") } > db.replaceValueInArrayDemo.insertOne({"StudentScores":[33, 90, 67]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7f0521a844af18acdffb8") }Following is the query to display all documents from a collection with the help of find() method −> db.replaceValueInArrayDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cd7f0421a844af18acdffb7"),    "StudentScores" : [       45,       56,       78    ] } {    "_id" : ObjectId("5cd7f0521a844af18acdffb8"),    "StudentScores" : [ ... Read More

HTML DOM Input Checkbox Value Property

Rama Giri
Updated on 30-Jul-2019 22:30:26

606 Views

The Input Checkbox value property returns a string with the value attribute of input checkbox. User can also set it to a new string.SyntaxFollowing is the syntax −Returning string valueinputCheckboxObject.valueSetting value attribute to a string valueinputCheckboxObject.value = ‘String’ExampleLet us see an example of Input Checkbox value property − Live Demo Value Attribute of Checkbox Color-Red: Change value of input checkbox    var valueOfInput = document.getElementById("formCheckbox");    var displayDiv = document.getElementById("displayDiv");    displayDiv.textContent = 'Value: ' + valueOfInput.value;    function changeType(){       if(valueOfInput.value == 'Green' && valueOfInput.checked == true){   ... Read More

HTML DOM Input Text Type Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

272 Views

The HTML DOM Input Text type property returns/sets type of Input Text.SyntaxFollowing is the syntax −Returning string valueinputTextObject.typeSetting type to string valueinputTextObject.type = stringValueString ValuesHere, “stringValue” can be the following −stringValueDetailsemailIt defines that input type is emailtextIt defines that input type is textradioIt defines that input type is radiotelIt defines that input type is tel and a number keypad is shown for inputExampleLet us see an example of Input Text type property − Live Demo Input Text type    form {       width:70%;       margin: 0 auto;       text-align: center;    } ... Read More

Differences Between Python 2.x and Python 3.x

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

2K+ Views

There is always a debate in the coding community on which python version was the best one to learn: Python 2.x or Python 3.x.Below are key differences between pyton 2.x and python 3.x1. The print functionIn python 2.x, “print” is treated as a statement and python 3.x explicitly treats “print” as a function. This means we need to pass the items inside your print to the function parentheses in the standard way otherwise you will get a syntax error.#Python 2.7 print 'Python', python_version() print 'Hello, World!' print('Hello, World!') print "text", ; print 'some more text here'OutputPython 2.7.6 Hello, World! ... Read More

What is Ethereum?

Prasanna Kotamraju
Updated on 30-Jul-2019 22:30:26

307 Views

Before we talk about Ethereum let us first understand the concept of Decentralized network of Bitcoin which laid the foundation for the following Decentralized networks. Bitcoin digital currency was invented by Satoshi Nakamoto in 2009 as using a decentralized and transparent network.Bitcoin uses Cryptography + Proof of work + Decentralized network architecture together. The algorithm of Bitcoins is written in “Turing Incomplete” language, which understands only a limited set of orders like, who has sent the money, how much and who received it.While Bitcoin aims to remove a centralized authority to create the currency, Ethereum uses the Block Chain to ... Read More

Advertisements