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 image = [ | |
[0, 1, 1, 1, 1, 1, 1], | |
[1, 1, 1, 1, 1, 1, 1], | |
[0, 1, 1, 0, 0, 0, 1], | |
[1, 0, 1, 0, 0, 0, 1], | |
[1, 0, 1, 1, 1, 1, 1], | |
[1, 0, 1, 0, 0, 1, 1], | |
[1, 1, 1, 0, 0, 1, 1], | |
[1, 1, 1, 1, 1, 1, 0], | |
]; |
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 PalindromeCreator(str) { | |
const isStringPalindrome = isPalindrome(str); | |
if (isStringPalindrome) return 'palindrome'; | |
const palindrome = findPalindrome([{ | |
str, | |
chars: [], | |
}], 2, 0); | |
return palindrome && palindrome.str.length > 2 ? getRemovedCharsForPalindrome(palindrome) : 'not possible'; | |
} |
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 WordSplit(strArr) { | |
const word = strArr[0]; | |
const substrings = generateSubstrings(word); | |
const words = substrings.filter(substring => strArr[1].includes(substring)); | |
const pairs = generatePairs(words); | |
const pair = pairs.find(pair => pair.join('') === word); | |
return pair ? pair.join(',') : 'no pair'; | |
} | |
function generateSubstrings(str) { |
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
<?php | |
// Your goal is to count how many items exist that have an age equal to or greater than 50, and print this final value. | |
$ch = curl_init('https://coderbyte.com/api/challenges/json/age-counting'); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
$data = curl_exec($ch); | |
curl_close($ch); |
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
#!/bin/python3 | |
# | |
# Complete the 'maxPoints' function below. | |
# | |
# The function is expected to return a LONG_INTEGER. | |
# The function accepts INTEGER_ARRAY elements as parameter. | |
# | |
def maxPoints(elements): |
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
#!/bin/python3 | |
# | |
# Complete the 'countSubarrays' function below. | |
# | |
# The function is expected to return a LONG_INTEGER. | |
# The function accepts following parameters: | |
# 1. INTEGER_ARRAY numbers | |
# 2. INTEGER k | |
# |
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
#!/bin/python3 | |
# | |
# Complete the 'getShiftedString' function below. | |
# | |
# The function is expected to return a STRING. | |
# The function accepts following parameters: | |
# 1. STRING s | |
# 2. INTEGER leftShifts | |
# 3. INTEGER rightShifts |
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 data = require('./data.json'); | |
// jq '[ .transactions[].amount ]' data.json | |
function shouldSaveForUserToday(data) { | |
const balanceThreshold = .2; | |
const accountBalance = data.accounts[0].balance.available; | |
const transactionAmounts = data.transactions.map(transaction => transaction.amount); | |
const transactionAverage = transactionAmounts.reduce((sum, amount) => sum + amount, 0) / transactionAmounts.length; | |
return transactionAverage < 0 && Math.abs(transactionAverage) < (accountBalance * balanceThreshold); |
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 digits = [3, 7, 0, 2, 8, 3, 7, 6]; | |
const digits_empty = []; | |
function canFindZero(values, startIndex, checkedIndexes) { | |
checkedIndexes.push(startIndex); | |
if (values[startIndex] === 0) { | |
return true; | |
} | |
const leftIndex = startIndex - values[startIndex]; | |
const leftIndexValue = values[leftIndex]; |
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 sample = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ligula massa, pretium nec sagittis posuere, ornare in augue. Integer porta sapien quis diam tempor, id commodo lorem tempor. Vestibulum ac semper erat, eget venenatis risus. Pellentesque enim nisl, dignissim quis ullamcorper sed, pretium ac ligula. Etiam in dui ipsum. Mauris nisi lorem, facilisis at feugiat non, tristique pretium eros. Donec ultricies nibh urna, egestas iaculis nulla aliquet eget. Phasellus vitae tellus sagittis, viverra elit vel, porta neque. Pellentesque enim augue, malesuada ut risus nec, eleifend fringilla purus. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Curabitur luctus, leo vitae interdum varius, lacus sapien imperdiet erat, eget aliquam orci mauris sit amet risus. Pellentesque maximus nibh id diam elementum aliquam eget vitae nisl. Morbi maximus eu sem sed posuere. Nullam aliquam ut dui nec tempus. Phasellus eget justo facilisis, lacinia quam at, sagittis tortor. Ma |