This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python2 solution for codility frog jump question | |
# https://codility.com/programmers/lessons/3-time_complexity/frog_jmp/ | |
import math | |
def solution(X, Y, D): | |
# write your code in Python 2.7 | |
source_and_destination_difference = Y - X | |
fixed_distance_jump = D | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python3 solution to https://www.hackerrank.com/challenges/diagonal-difference/problem | |
# test data | |
first_array = [11, 2, 4] | |
second_array = [4, 5, 6] | |
third_array = [10, 8, -12] | |
sumArray = [] | |
sumArray.append(first_array) | |
sumArray.append(second_array) | |
sumArray.append(third_array) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function factorialize(num) { | |
//check if num == 0 | |
if (num === 0) { | |
return 1; | |
} | |
//else calculate factorial | |
return num * factorialize(num - 1); | |
} | |
//calling the function. this will return 120 | |
factorialize(5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findNonRepeatingChars(string) { | |
const stringArray = string.split('') | |
const nonrecurring = [] | |
const resultObj = {} | |
for(let char of stringArray) { | |
if(!resultObj[char]) { | |
resultObj[char] = 1; | |
} else { | |
resultObj[char] += 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Codility Bbinary Gap Test | |
function solution($N) { | |
// write your code in PHP5.5 | |
$binaryNumber = decbin($N); // binary conversion of number | |
$trimmed = trim($binaryNumber, 0); // trim to remove trailing zeros | |
$binaryGap = explode("1",$trimmed); // explode | |
$binaryCount = array_map('strlen', $binaryGap); | |
return max($binaryCount); // returns the longest binary gap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const AWS = require("aws-sdk") | |
var bodyParser = require('body-parser') | |
const MessageValidator = require('sns-validator') | |
var jsonParser = bodyParser.json() | |
const config = { | |
"SNS_TOPIC_ARN": "", | |
"USER_ARN": "", | |
"USER_ACCESS_KEY_ID": "", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const AWS = require("aws-sdk") | |
var bodyParser = require('body-parser') | |
const MessageValidator = require('sns-validator') | |
const config = { | |
"SNS_TOPIC_ARN": "", | |
"USER_ARN": "", | |
"USER_ACCESS_KEY_ID": "", | |
"USER_SECRET_ACCESS_KEY": "", |
OlderNewer