Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Julia Amosova juliaamosova

Block or report user

Report or block juliaamosova

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@juliaamosova
juliaamosova / second-index.js
Last active May 3, 2018
Checkio: Return the second index of a symbol in a given text.
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
*/
@juliaamosova
juliaamosova / first-word.js
Last active May 3, 2018
Checkio: Find the first word in a given string.
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.
@juliaamosova
juliaamosova / plugin.php
Last active Apr 1, 2018 — forked from joncave/plugin.php
An intentionally vulnerable plugin developed for WordPress plugin author education.http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
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
@juliaamosova
juliaamosova / you-are-old.js
Created Sep 29, 2017
Class vs. Instance Challenge
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;
});
@juliaamosova
juliaamosova / array-elements-sum.js
Created Sep 28, 2017
Given an array of integers N, find the sum of its elements.
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;
});
@juliaamosova
juliaamosova / conditional-statement.js
Created Sep 28, 2017
Given an integer n, perform several conditional actions.
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;
});
@juliaamosova
juliaamosova / left-rotation.js
Created Sep 27, 2017
Given an array of n integers and a number , d, perform d left rotations on the array. Then print the updated array as a single line of space-separated integers.
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;
});
@juliaamosova
juliaamosova / total-meal-cost.js
Created Sep 26, 2017
Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal's total cost.
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.");
@juliaamosova
juliaamosova / stdin-stream.js
Created Sep 26, 2017
Hackerrank: Using readLine() to read a stream from STDIN
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());
@juliaamosova
juliaamosova / hourglass-sum.js
Created Sep 25, 2017
Calculate the hourglass sum for every hourglass in array
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);
You can’t perform that action at this time.