Monkey man algorithm
Monkey man algorithm, who jumps and slip on wall

A monkey man caught inside a jail. He can jumps across the wall. He can jump 'X' meters, but due to slippery walls he falls 'Y' meters after each jump. To escape from jail, he has to cross 'N' number of walls, where height of each wall is given in an array.

Write a program to find total number of jumps, he has to make, to escape

Input Format

Your function will take three arguments, where:

Argument 1: An integer depicting X, which he can jump

Argument 2: An integer depicting Y, which he falls

Argument 3: An array of N integers having the height of each wall.

Constraints

1<=X<=109

1<=Y<=105

Output Format

Your program should return total number of jumps required to escape.


Sample Test Case

Test case 1

Sample Input 10 1 1 10

Sample Output 1

Explanation

Here monkey man can jump 10 meters high, but slides down by 1 meter. He has 1 wall to jump and the height of the wall is 10 meters. Since he jumps 10 meters in the first attempt he cross the wall easily in the first attempt only.

Test case 2

Sample Input 5 1 2 9 10

Sample Output 5

Explanation

Here, the monkey man can jump 5 meters high, but slides down by 1 meters. He has 2 walls to jump and the walls are 9 and 10 meters hight respectively.

While crossing the first wall, he takes 2 attempts, because during the first attempt he jumps 5 meters but slides down by 1 meters since he didn't cross the wall. In the next attempt he jumps 5 more meters from that position and this time he doesn't slide because he crossed the wall in this attempt because 4+5=9 and 9 meters is the actual height of the wall.

Similarly, while crossing the second wall, he takes 3 attempts because during his second attempt on this wall, he silides down by 1 meters since 4+5=9 and the height of the wall is 10 meters. During his third attempt, he was able to escape.

Simply upload file
How to upload file using AJAX and PHP?

Simplest way to upload file is by using FormData. It is used in key/value pairs to send XMLHttpRequest. Initially FormData used to send all form elements data in key/value pair, but it can be used to send keyed data also. Data sent by FormData is in same format as used in form's submit() method. It sends upload data also, if we use multipart/form-data in form's encoding

Tidy number
Tidy Numbers - Display all positive integers in ascending order

Ananya likes to keep things tidy. Her toys are sorted from smallest to largest and pencils are sorted from shortest to longest. One day, when practicing her counting skills, she noticed that some integers, have their digits sorted in non-decreasing order. She calls 8, 123, 555, and 224488 as numbers tidy. Numbers that do not have this property, like 20, 321, 495 and 999990, are not tidy.

She just finished counting all positive integers in ascending order from 1 to N. What was the last tidy number she counted?

Input

The first line of the input gives the number of test cases, T. T lines follow. Each line describes a test case with a single integer N, the last number counted by Ananya.

Output

For each test case, output is the last tidy number counted by Ananya.

1 ≤ T ≤ 100.

Sample Input:

5
132
1000
7
621
489

Sample Output:

129
999
7
599
489

Resolver IP
How to get resolver IP for SSL integration?

Resolver IP is the DNS Server IP of website. It is an optional parameter for OCSP stapling. OCSP stapling itself is an optional parameter but it is highly recommended to use it as it will improve SSL handshake speed of website.

If resolver IP it is not added, it defaults to the server's DNS IP.

You can get Server's DNS IP using following commands in Linux

Command: cat /etc/resolv.conf

Output:

options timeout:2 attempts:5
; generated by /sbin/dhclient-script
search ap-south-1.compute.internal
nameserver x.x.x.x

MVC
Explain MVC (Model View controller) software architecture

Model-view-controller (MVC) is a software architectural pattern for implementing user interfaces and business logic. It divides a software into three layers which manages the request coming from users and separates the internal representation of information.


Components:

The components of MVC are given below

  1. Model, captures the behavior of the application in terms of its problem domain, independent of the user interface. The model directly manages the data, logic and rules of the application. It is mainly used for database interaction.
  2. View can be any output representation of information, such as a chart or a diagram. Multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants. What we see on screen, comes from view. HTML or display is part of view.
  3. Controller, accepts input and converts it to commands for the model or view. When you hit any URL, firstly calls goes to controller. Here we decide, we have to show plain HTML or need to display data from database to HTML. If we have to display from plain HTML, we simply call view from controller otherwise, we calls model for database interaction, fetch relevant data from database and pass it to view.

PHP BASICS
Basics of PHP

PHP (PHP Hypertext Preprocessor) is an open source general HTML embedded purpose scripting language which is specially used for web development. PHP also has support for talking to other services using protocols such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (on Windows) and countless others. You can also open raw network sockets and interact using any other protocol. PHP has support for the WDDX complex data exchange between virtually all Web programming languages.

Add or remove query string
How to add or remove query string in URL without page refresh

You can add/remove query string from URL without reloading page in javascript. Generally URL changes by page reloading. When URL changes page gets refresh and new content appears on page.

e.g. Go

Here when we click 'Go' it goes to new URL with query string.

 

HTML5 gave you facility to change URL using pushState function to change URL and append data using ajax.

e.g. history.pushState({state:1, rand: Math.random()}, '', "?page="+1);

history.pushState function is used to add history state. It takes three parameters: a state object, a title (which is currently ignored), and (optionally) a URL.

sum maximum value in triangle
Find sum of maximum values in each row of a triangle

Input string: "5#9#6#4#6#8#0#7#1#5"

Triangle will be created as

5

9 6

4 6 8

0 7 1 5

 

Sum of highest in each row

5+9+8+7=29

facebook login button
Facebook login in website using javascript SDK

Facebook api gives facility to login on single click. In todays fast life, very less people want to fill credential everytime on any website. So now a days, social login generates maximum market.


Facebook make it very simple to use. To create facebook login in your website, we must have facebook developer account. After it you have to create an app in facebook. In app dashboard you will get an appId, it will be used for facebook login code.

algrorithm super reduced string
Solution for super reduced string algorithm in php
User has n string in english lowercase. In one operation, he can delete any pair of adjacent letters with same value. User wants to reduce string as much as possible. To do this, he will repeat the above operation as many times as it can be performed. Help user to find and print most reducible form of string. If the final string is empty, print Empty String.
Funding

We need your support to operate it properly. We have lots of ideas but less fund, so help us with your funding.

Thoughts for the day

If a country is to be corruption free and become a nation of beautiful minds, I strongly feel there are three key societal members who can make a difference. They are the father, the mother and the teacher.

Dr. A.P.J. Abdul Kalam
Polls
Which device you use most for facebook application?
Laptop/PC
20%

 


Android
53%

 


IOS
13%

 


Blackberry
14%

 


Tutorial On Request
Q. Ask us for any tutorial or any thing which helps to build your career better.
Email:
Query: