Instantly share code, notes, and snippets.

View second-index.js
/*
You are given two strings and you have to find an index of the second occurrence of the second string in the first one.
Let's go through the first example where you need to find the second occurrence of "s" in a word "sims". It’s easy to find its first occurrence with a function indexOf which will point out that "s" is the first symbol in a word "sims" and therefore the index of the first occurrence is 0. But we have to find the second "s" which is 4th in a row and that means that the index of the second occurrence (and the answer to a question) is 3.
Input: Two strings.
Output: Int or undefined
*/
View first-word.js
/*
You are given a string where you have to find its first word.
When solving a task pay attention to the following points:
There can be dots and commas in a string.
A string can start with a letter or, for example, a dot or space.
A word can contain an apostrophe and it's a part of a word.
The whole text can be represented with one word and that's it.
Input: A string.
View plugin.php
<?php
/* Plugin Name: Damn Vulnerable WordPress Plugin
* Description: Intentionally vulnerable plugin for plugin author education
* Version: 0.1
* Plugin URI: http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
* Author: Jon Cave
* Author URI: http://joncave.co.uk
* License: GPLv2+
*
* DO NOT RUN THIS PLUGIN ON AN INTERNET ACCESSIBLE SITE
View you-are-old.js
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
View array-elements-sum.js
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
View conditional-statement.js
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
View left-rotation.js
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
View total-meal-cost.js
var tip = mealCost * tipPercent/100;
var tax = mealCost * taxPercent/100;
var totalCost = Math.round(mealCost + tip + tax);
console.log("The total meal cost is " + totalCost + " dollars.");
View stdin-stream.js
// Declare second integer, double, and String variables.
var i2;
var d2;
var s2;
// Read and save an integer, double, and String to your variables.
/* The parseInt() function parses a string argument and returns an integer of the specified radix
(the base in mathematical numeral systems).*/
i2 = parseInt(readLine());
View hourglass-sum.js
// i - row
// j - column
function main() {
var arr = [];
var sum = 0;
var maxSum = -63;
for(arr_i = 0; arr_i < 6; arr_i++){
arr[arr_i] = readLine().split(' ');
arr[arr_i] = arr[arr_i].map(Number);