master 60ae0ebf09c7 cached
607 files
858.5 KB
302.5k tokens
539 symbols
1 requests
Download .txt
Showing preview only (983K chars total). Download the full file or copy to clipboard to get everything.
Repository: Automedon/CodeWars-6-kyu-Soluitions
Branch: master
Commit: 60ae0ebf09c7
Files: 607
Total size: 858.5 KB

Directory structure:
gitextract_eg3a47vk/

├── "this" is an other problem.js
├── "this" is an other solution.js
├── (L33T + Grεεκ) Case.js
├── +1 Array.js
├── 1 n- Cycle.js
├── 1RM Calculator.js
├── 80's Kids #7: She's a Small Wonder.js
├── A Rule of Divisibility by 13.js
├── A String of Sorts.js
├── A Taste of Curry.js
├── A disguised sequence (I).js
├── A tetrahedron of cannonballs.js
├── ASCII hex converter.js
├── Ackermann Function.js
├── Adding Binary Numbers.js
├── Adding ordinal indicator suffixes to numbers.js
├── Adjacent pairs in a string.js
├── Almost Even.js
├── Alphabet war - airstrike - letters massacre.js
├── Alphabetized.js
├── Alternating Loops.js
├── Anagram difference.js
├── Anything to integer.js
├── Arabian String.js
├── Are they the "same"?
├── Are we alternate?.js
├── Array Deep Count.js
├── Array Helpers.js
├── Array#reduce.js
├── Array.diff
├── Arrays Similar.js
├── Arrh, grabscrab!.js
├── Atbash Cipher Helper.js
├── Autocomplete! Yay!.js
├── Baby Magpies.js
├── Backspaces in string.js
├── Backwards Read Primes.js
├── Balance the arrays.js
├── Ball Upwards.js
├── Banker's Plan.js
├── Base Conversion.js
├── Basic Encryption.js
├── Binary string.js
├── Binary to Text (ASCII) Conversion.js
├── Binding within the List Monad.js
├── Bingo Card.js
├── Bit Counting
├── Bleatrix Trotter (The Counting Sheep).js
├── Body mass index calculation.js
├── Bouncing Balls
├── Bowling Pins.js
├── Braces status.js
├── Bracket Duplicates.js
├── Braking well.js
├── Break camelCase.js
├── Breaking search bad.js
├── Build Tower
├── Build Tower Advanced.js
├── Build a pile of Cubes
├── Buying a car
├── ByState.js
├── Calculate Hypotenuse of Right-angled Triangle.js
├── Calculate String Rotation.js
├── Calculate number of inversions in array.js
├── Calculate the area of a regular n sides polygon inside a circle of radius r.js
├── Calculate the function f(x) for a simple linear sequence (Easy).js
├── Calculate the function f(x) for a simple linear sequence (Medium).js
├── Cambridge Word Scramble.js
├── CamelCase Method.js
├── CamelCase to underscore.js
├── Can you keep a secret?.js
├── Case Reversal of Consecutive Duplicates.js
├── Cat Kata, Part 1.js
├── Cat and Mouse - Harder Version.js
├── Catalog.js
├── Chain Evaluation.js
├── Character frequency.js
├── Character limits: How long is your piece of string?.js
├── Character with longest consecutive repetition.js
├── Check if two words are isomorphic to each other.js
├── Checkerboard Generation.js
├── Checkered Board.js
├── Checking Groups
├── Chess Fun #1: Chess Board Cell Color.js
├── Chess Fun #2: Bishop And Pawn.js
├── Christmas Day.js
├── Christmas tree.js
├── Circularly Sorted Array.js
├── Clay Pigeon Shooting.js
├── Clock in Mirror.js
├── Clocky Mc Clock-Face.js
├── Closures and Scopes.js
├── Coding Meetup #10 - Higher-Order Functions Series - Create usernames.js
├── Coding Meetup #13 - Higher-Order Functions Series - Is the meetup language-diverse?.js
├── Coding Meetup #15 - Higher-Order Functions Series - Find the odd names.js
├── Coding Meetup #16 - Higher-Order Functions Series - Ask for missing details.js
├── Coding Meetup #7 - Higher-Order Functions Series - Find the most senior developer.js
├── Coding Meetup #8 - Higher-Order Functions Series - Will all continents be represented?.js
├── Coding Meetup #9 - Higher-Order Functions Series - Is the meetup age-diverse?.js
├── Collatz.js
├── Color Choice.js
├── Combinator Flip.js
├── Compare Versions.js
├── Compare powers.js
├── Compare section numbers.js
├── Complete Fibonacci Series.js
├── Complete The Pattern #12.js
├── Complete The Pattern #16.js
├── Complete The Pattern #8 - Number Pyramid.js
├── Complete The Pattern #9 - Diamond.js
├── Complete the table pattern.js
├── Consecutive strings
├── Consonant value,js
├── Convert integer to Whitespace format.js
├── Convert string to camel case
├── Coordinates Validator
├── Count Repeats.js
├── Count characters in your string
├── Count letters in string.js
├── Count the days!.js
├── Count the divisible numbers.js
├── Count the smiley faces!
├── Countdown - Longest Word.js
├── Counting DNA Nucleotides.js
├── Counting Duplicates
├── Create Four Letter Birding Codes from Bird Names.js
├── Create Parse HTML CSS Colors.js
├── Create a frame!.js
├── Creating a string for an array of objects from a set of words.js
├── Cryptography #1 - Viva Cesare.js
├── Cumulative Triangle.js
├── Custom Array Filters.js
├── Custom Setters and Getters.js
├── Custom each() Array method.js
├── Custom sort function.js
├── Cycle Detection: greedy algorithm.js
├── Cycle a list of values.js
├── Cylon Evolution.js
├── Dashatize it.js
├── Data Reverse.js
├── Data compression using run-length encoding.js
├── Dead Ants.js
├── Decipher this!.js
├── Decode Morse.js
├── Decode the Morse code
├── Decompose a number.js
├── Deep Freeze.js
├── Delete occurrences of an element if it occurs more than n times
├── Descriptive selections of data.js
├── Design a Simple Automaton (Finite State Machine).js
├── Detect Pangram
├── Difference of 2.js
├── Digital cypher vol 3 - missing key.js
├── Disease Spread.js
├── Disgruntled Employee.js
├── Disguised sequences (II).js
├── Divisible Ints.js
├── Does my number look big in this?
├── Don't rely on luck.
├── Doors in the school.js
├── Dragon's Curve.js
├── Drunk friend.js
├── Dubstep
├── Duplicate Arguments
├── Duplicate Encoder
├── Ease the StockBroker.js
├── Easter egg list in ReactJS.js
├── Easy Balance Checking.js
├── Easy Diagonal.js
├── Emotional Sort ( ︶︿︶).js
├── Encrypt this!.js
├── English beggars.js
├── Enigeliisohe too Eniigeeliiisoohee Toroanisoliatooro.js
├── Equal Sides Of An Array
├── Errors : histogram.js
├── Escape HTML Markup.js
├── Esolang Interpreters #1 - Introduction to Esolangs and My First Interpreter (MiniStringFuck).js
├── Esolang: MiniBitMove.js
├── Esolang: Tick.js
├── Even Fibonacci Sum.js
├── Evil Autocorrect Prank.js
├── Exclamation marks series #17: Put the exclamation marks and question marks to the balance, Are they balanced?.js
├── Exercise in Summing.js
├── Extract Nested Object Reference.js
├── Extract last names of people named Michael.js
├── Extract the IDs from the data set.js
├── FIXME: Hello.js
├── Factorial length.js
├── Faro Shuffle Count.js
├── Fat Fingers.js
├── Feynman's square question.js
├── Fibonacci Reloaded.js
├── Fibonacci, Tribonacci and friends.js
├── File Path Operations.js
├── Financing Plan on Planet XY140Z-n.js
├── Financing a purchase.js
├── Find The Duplicated Number in a Consecutive Unsorted List - Tougher Version.js
├── Find The Parity Outlier
├── Find X.js
├── Find heavy ball - level: conqueror.js
├── Find the Mine!.js
├── Find the Nexus of the Codewars Universe.js
├── Find the Nth longest string in an Array.js
├── Find the missing letter
├── Find the missing term in an Arithmetic Progression
├── Find the odd int
├── Find the unique number
├── Find the unique number.js
├── Find within array.js
├── FizzBuzz Array! (Custom).js
├── Flexible Card Game.js
├── Floating-point Approximation (I).js
├── Fold an array.js
├── Follow that Spy.js
├── Football - Yellow and Red Cards.js
├── Format Text.js
├── Format a string of names like 'Bart, Lisa & Maggie'.
├── Format words into a sentence.js
├── Framed Reflection.js
├── Free pizza.js
├── Friday the 13ths.js
├── Frog jumping.js
├── Fruit Machine.js
├── Fun with lists: countIf.js
├── Fun with lists: filter.js
├── Fun with lists: map.js
├── Fun with lists: reduce.js
├── Fun with trees: max sum.js
├── Function Composition
├── Function composition.js
├── Function iteration.js
├── Functional Lists.js
├── GA-DE-RY-PO-LU-KI cypher vol 2.js
├── Genetic Algorithm Series - #5 Roulette wheel selection.js
├── Get All Possible Anagrams from a Hash.js
├── Get all array elements except those with specified indexes.js
├── Give me a Diamond
├── Good vs Evil
├── Greatest Position Distance Between Matching Array Values.js
├── Grill it!.js
├── Grouped by commas.js
├── Guess the number!.js
├── HTML dynamic color string generation.js
├── Hamming Distance.js
├── Handshake problem
├── Hanoi record.js
├── Happy numbers.js
├── Hard Time Bomb.js
├── Harshad or Niven numbers.js
├── Help Mrs Jefferson.js
├── Help the bookseller !.js
├── Hidden "Cubic" numbers.js
├── Highest Rank Number in an Array.js
├── Highest Scoring Word
├── Ho Ho Ho with Functions!.js
├── Holiday Shopping Priority Queue.js
├── Holy cats.js
├── House of cards.js
├── How Many Reindeers?.js
├── How Much?.js
├── How many feelings?.js
├── How much hex is the fish.js
├── How new Works.js
├── I need more speed!.js
├── IP Address to Number.js
├── IP Validation
├── IPv4 to int32
├── IQ Test
├── Ideal electron distribution.js
├── If you can read this....js
├── Image host filename generator.js
├── Implementing Array.prototype.groupBy method.js
├── Inserting multiple strings into another string.js
├── Inside Out Strings.js
├── Integer depth.js
├── Integers: Recreation Two.js
├── Irreducible Sum of Rationals.js
├── Is Integer Array ?.js
├── Is a number prime?
├── Javascript filter - 2.js
├── Javascript filter - 3.js
├── JoJo's Bizarre Kata.js
├── Ka Ka Ka cypher - words only vol 1.js
├── Kebabize.js
├── Killer Garage Door.js
├── LICENSE.md
├── LOTTO 6 aus 49 - 6 of 49.js
├── Length of missing array
├── Letter Changes.js
├── Levenshtein Distance.js
├── Linear Regression of Y on X.js
├── Linked Lists - Insert Nth Node.js
├── Linked Lists - Insert Sort.js
├── Linked Lists - Recursive Reverse.js
├── Linked Lists - Remove Duplicates.js
├── Linked Lists - Shuffle Merge.js
├── Linked Lists - Sorted Insert.js
├── Linked Lists-Length & Count.js
├── Look and say numbers.js
├── Loose Change.js
├── Lottery Ticket
├── Lowest product of 4 consecutive numbers.js
├── Lucas numbers.js
├── MTV Cribs.js
├── Make the Deadfish swim..js
├── Making Change.js
├── Manhattan Distance.js
├── Master of Files.js
├── Matrix Addition.js
├── Matrix Transpose.js
├── Max Accessor Function.js
├── Maze Runner.js
├── Meeting.js
├── Mexican Wave.js
├── Midpoint Sum.js
├── Minutes to Midnight.js
├── Mirror object - tcejbo rorriM.js
├── Mirror, Mirror.js
├── Missing Alphabet.js
├── Mix Fruit Juice.js
├── Moduli number system.js
├── Most Frequent Weekdays.js
├── Moves in squared strings (II).js
├── Moves in squared strings (III).js
├── Moves in squared strings (IV).js
├── Mr. Safety's treasures.js
├── Multi-tap Keypad Text Entry on an Old Mobile Phone
├── Multiples of 3 and 5 redux.js
├── Multiples of 3 or 5
├── Multiplication Tables.js
├── Multiplication table.js
├── Mutual Recursion.js
├── Mysterious function.js
├── N smallest elements in original order.js
├── N-th Fibonacci.js
├── Name That Integer.js
├── Name to Matrix.js
├── New Cashier Does Not Know About Space or Shift.js
├── Next Version.js
├── Non-even substrings.js
├── None shall pass.js
├── Not prime numbers.js
├── Nuclear Missile Manager.js
├── Number Format.js
├── Number Shortening Filter.js
├── Number Zoo Patrol.js
├── Number of anagrams in an array of words.js
├── Number of measurements to spot the counterfeit coin.js
├── Number of permutations without repetitions.js
├── Number pattern.js
├── Numerical Palindrome #1.5.js
├── Numericals of a String.js
├── Numerology.js
├── Odd Even number of divisors.js
├── Odd-heavy Array.js
├── Once.js
├── Only Duplicates.js
├── Ordinal Numbers.js
├── Ore Numbers.js
├── Organise duplicate numbers in list.js
├── PI approximation.js
├── Pad Left and Right.js
├── Padovan numbers.js
├── Pair of gloves.js
├── Palindrome for your Dome.js
├── Palindromes Below.js
├── Palindromic Numbers.js
├── Palindromization.js
├── Parabolic Arc Length.js
├── Parity bit - Error detecting code.js
├── Parse a linked list from a string.js
├── Pascal's Triangle #2.js
├── Pascal's Triangle.js
├── Password generator.js
├── Paths in the Grid.js
├── PatternCraft - Decorator.js
├── PatternCraft - State.js
├── PatternCraft - Strategy.js
├── Pentabonacci.js
├── Permutations and Dot Products.js
├── Persistent Bugger.
├── Pete, the baker (part 2).js
├── Piano Kata, Part 1.js
├── Piano Kata, Part 2.js
├── Ping-Pong service problem.js
├── Pizza pieces.js
├── Playing on a chessboard.js
├── Playing with digits
├── Playing with passphrases.js
├── Plenty of Fish in the Pond.js
├── Point in Polygon.js
├── Points On A Line.js
├── Points in the circle.js
├── Pokemon Damage Calculator.js
├── Polybius square cipher - encode.js
├── Pong! [Basics].js
├── Positions Average.js
├── Prefill an Array.js
├── Prime Factors.js
├── Prime factorization.js
├── Primorial Of a Number.js
├── Prize Draw.js
├── Proof Read.js
├── Pyramid Array.js
├── Quick (n choose k) calculator.js
├── README.md
├── RNA to Protein Sequence Translation.js
├── Rainfall.js
├── Range function.js
├── Rank Vector.js
├── Ranking System.js
├── Reach Me and Sum my Digits.js
├── Rectangle into Squares
├── Reducing by rules to get the result.js
├── Reducing by steps.js
├── Regex Tic Tac Toe Win Checker.js
├── Regexp Basics - is it IPv4 address?.js
├── Regexp basics - parsing time.js
├── Remember.js
├── Repeated Substring.js
├── Replace With Alphabet Position
├── Return 1, 2, 3 randomly.js
├── Reverse every other word in the string.js
├── Reverse or rotate?.js
├── Reverse polish notation calculator
├── RoboScript #1 - Implement Syntax Highlighting.js
├── Roman Numerals Decoder
├── Roman Numerals Encoder
├── Rotate Array (JS).js
├── Rotation Cipher Cracker.js
├── Round by 0.5 steps.js
├── Routes in a square grid.js
├── Run-length encoding.js
├── Running Average.js
├── Salesman's Travel.js
├── Same Array?.js
├── Santa's Master Plan.js
├── Scheduling (Shortest Job First or SJF).js
├── Schrödinger's Boolean.js
├── Scrabble best word.js
├── Secret Message.js
├── Separate The Wheat From The Chaff.js
├── Sequence generator.js
├── Sequences and Series.js
├── Shortest steps to a number.js
├── Simple Encryption #1 - Alternating Split
├── Simple Fun #116: Prime String.js
├── Simple Fun #135: Missing Alphabets.js
├── Simple Fun #165: Withdraw.js
├── Simple Fun #170: Sum Groups.js
├── Simple Fun #23: Square Digits Sequence.js
├── Simple Fun #258: Is Divisible By 6.js
├── Simple Fun #303: Prime Product.js
├── Simple Fun #319: Number And IP Address.js
├── Simple Fun #79: Delete a Digit.js
├── Simple Sentences.js
├── Simple Simple Simple String Expansion.js
├── Simple Substitution Cipher Helper.js
├── Simple Web Framework #1: Create a basic router.js
├── Simple card game.js
├── Simple frequency sort.js
├── Simple prime streaming.js
├── Simple string indices.js
├── Simple sum of pairs.js
├── Simple transposition.js
├── Simpson's Rule - Approximate Integration.js
├── Single Word Pig Latin.js
├── Single character palindromes.js
├── Sometimes.js
├── Sort Arrays (Ignoring Case).js
├── Sort My Animals.js
├── Sort odd and even numbers in different order.js
├── Sort sentence pseudo-alphabetically.js
├── Sort the odd
├── Sorting by bits.js
├── Special Multiples.js
├── Spelling Bee.js
├── Split Strings
├── Sqrt approximation.js
├── Squares in a Rectangle.js
├── Srot the inner ctonnet in dsnnieedcg oredr.js
├── Statistics for an Athletic Association.js
├── Steps in Primes.js
├── Stop gninnipS My sdroW!
├── Street Fighter 2 - Character Selection.js
├── String Breakers.js
├── String Integer Greater-than.js
├── String Shortener (shrink).js
├── String Suffixes.js
├── String array revisal.js
├── String average.js
├── String character frequency.js
├── String reduction.js
├── String searching with wildcard.js
├── String tops.js
├── String transformer.js
├── Stringing me along.js
├── Strip Url Params.js
├── Sum The Tree.js
├── Sum consecutives.js
├── Sum of Digits Digital Root
├── Sum of Two Integers.js
├── Sum of a Sequence [Hard-Core Version].js
├── Sum of many ints.js
├── Sum of nested numbers.js
├── Summarize ranges.js
├── Sums of Parts.js
├── Surrounding Primes for a value.js
├── T.T.T.17: Split odd and even.js
├── Take a Number And Sum Its Digits Raised To The Consecutive Powers And ....¡Eureka!!
├── Take a Ten Minute Walk
├── Tank Truck.js
├── Temperature converter.js
├── The Book of Mormon.js
├── The Deaf Rats of Hamelin.js
├── The Desperate Rocket Scientist.js
├── The Enigma Machine - Part 1: The Plugboard.js
├── The Freeway Game.js
├── The Modulo-3 Sequence.js
├── The Most Sacred of Days.js
├── The Non-Discriminate Factorial.js
├── The Office V - Find a Chair.js
├── The Shell Game.js
├── The Spider and the Fly (Jumping Spider).js
├── The Supermarket Queue.js
├── The Vowel Code.js
├── The elegance of the code.js
├── The maximum and minimum difference -- Simple version
├── The maximum sum value of ranges -- Simple version.js
├── The nth smallest integer.js
├── The range() function.js
├── The takeWhile Function.js
├── Think how isArray function can be implemented.js
├── Thinkful - Logic Drills: Red and bumpy.js
├── Three added Characters.js
├── Throwing Darts.js
├── Tick Toward.js
├── Time-like string format.js
├── Title Case
├── Tortoise racing
├── Transform To Prime.js
├── Tree Depth.js
├── Triangle number check.js
├── Triangle type
├── Tribonacci Sequence
├── Trim a String.js
├── Triple trouble
├── Tug-o'-War.js
├── Turkish National Identity Number.js
├── Two Joggers
├── Two Sum.js
├── Two cube sums.js
├── Typer.js
├── Unary function chainer.js
├── Unique In Order
├── Unwanted dollars.js
├── Update inventory in your smartphone store.js
├── Upside down numbers.js
├── Upside-Down Pyramid Addition...REVERSED!.js
├── Urban Dictionary.js
├── Valid Braces
├── Valid Phone Number
├── Valid string.js
├── Validate Credit Card Number.js
├── Vasya - Clerk.js
├── Vasya and Stairs.js
├── Vasya and System of Equations.js
├── Vowel Recognition.js
├── Vowel Shifting.js
├── Walter's miraculous FizzBuzz factory.js
├── WeIrD StRiNg CaSe
├── What century is it?.js
├── What's in a name?.js
├── Wheel of Fortune.js
├── Where is my parent!?(cry).js
├── Which are in?
├── Which filetypes are you using the most?.js
├── Who likes it?
├── Who won the election?.js
├── Wind component calculation.js
├── Word Mesh.js
├── Word Patterns.js
├── Word Segmentation: MaxMatch.js
├── Word a10n (abbreviation)
├── Wordify an integer.js
├── World Bits War.js
├── Write JavaScript's 'call' function using apply..js
├── Write Number in Expanded Form
├── Write Number in Expanded Form - Part 2.js
├── X marks the spot!.js
├── Your Ride Is Here.js
├── Your order, please
├── Zero fill... for the Queen!.js
├── Ziiiiip!.js
├── bit "Wise" #1: XOR-cism.js
├── bit "Wise" #2: SHIFT-iness.js
├── compute cube as sums.js
├── extract file name.js
├── first character that repeats.js
├── longest_palindrome.js
├── mkdir -p.js
├── new with apply.js
├── replaceAll(input, find, replace).js
├── search in multidimensional array.js
├── uniq (UNIX style).js
├── up AND down.js
└── zipWith.js

================================================
FILE CONTENTS
================================================

================================================
FILE: "this" is an other problem.js
================================================
/*
Description:
After you've solved @priyankaherur's problem ( http://www.codewars.com/kata/this-is-a-problem/javascript ) you may try to solve this other one.

The problem:
Having created a function NamedOne which takes first & last names as parameters and returns an object with firstName, lastName and fullName ( = firstName + a space + lastName ) properties which should be all accessibles, we discovered that "accessible" also means "mutable".

If, for example, we've got a "NamedOne" like this :

var namedOne = new NamedOne("Naomi","Wang")
namedOne.firstName // -> "Naomi"
namedOne.lastName  // -> "Wang"
namedOne.fullName  // -> "Naomi Wang"
...properties may be changed :

namedOne.firstName = "John"
namedOne.firstName // -> "John"
namedOne.lastName = "Doe"
namedOne.lastName  // -> "Doe"
...but all properties are not updated !

namedOne.fullName  // -> "Naomi Wang" 
//-- Oh no ! we want fullName == "John Doe" now !
Your mission:
So the purpose of this kata is to create an object with accessible and "updatable" (can i say that?) properties.

If .firstName or .lastName are changed, then .fullName should also be changed
If .fullName is changed, then .firstName and .lastName should also be changed.
Note : "input format" to .fullName will be firstName + space+ lastName. If given fullName isn't valid then no property is changed.

Examples:
var namedOne = new NamedOne("Naomi","Wang")

namedOne.firstName = "John"
namedOne.lastName = "Doe"
// ...then...
namedOne.fullName // -> "John Doe"

// -- And :
namedOne.fullName = "Bill Smith"
// ...then...
namedOne.firstName // -> "Bill"
namedOne.lastName  // -> "Smith"

// -- But :
namedOne.fullName = "Tom" // -> no : lastName missing
namedOne.fullName = "TomDonnovan" // -> no : no space between first & last names
namedOne.fullName // -> "Bill Smith" (unchanged)
Can you change our function to create such a NamedOne object ?

( Hint: in this kata you'll try to define properties of an object )
*/
class NamedOne {
  constructor(f, l) { this.firstName = f; this.lastName = l }
  get fullName() { return this.firstName + ' ' + this.lastName }
  set fullName(v) { if (/ /.test(v)) [this.firstName, this.lastName] = v.split(' ') }
}


================================================
FILE: "this" is an other solution.js
================================================
/*
Description:
In a previous kata ( http://www.codewars.com/kata/547f1a8d4a437abdf800055c ) we try to create an object with mutable properties.

The function NamedOne taken first & last names as parameters, returned an object with firstName, lastName and fullName ( = firstName + a space + lastName ) properties. These properties were mutable.

For example, with a "NamedOne" like this :

var namedOne = new NamedOne("Naomi","Wang")
namedOne.fullName  // -> "Naomi Wang"
...we were able to change its properties:

namedOne.firstName = "John" 
namedOne.lastName = "Doe"
namedOne.fullName  // -> "John Doe" 
//..or..
namedOne.fullName = "Bill Smith"
namedOne.firstName // -> "Bill" 
namedOne.lastName // -> "Smith"
##Your mission

On the contrary, the purpose of this kata is to create an OnceNamedOne object with immutable properties.

That means .firstName, .lastName and .fullName are defined into the Constructor and can't be no more changed.

The properties are still readable using the dot or bracket notation but there're not writable.

##Examples:

var onceNamed = new OnceNamedOne("Naomi","Wang")

// ...then...
onceNamed.firstName // -> "Naomi"
onceNamed.lastName  // -> "Wang"
onceNamed.fullName // -> "Naomi Wang"

// ...if you try : ...
onceNamed.firstName = "Bill"
// ...or...
onceNamed['lastName'] = "Smith"

// ...then...
onceNamed['firstName'] // -> "Naomi"
onceNamed['lastName']  // -> "Wang"
onceNamed['fullName'] // -> "Naomi Wang"

// ..but you can still create other instances..
var otherOne = new OnceNamedOne("Don","Jones")
otherOne.fullName // -> "Don Jones"
Can you change our function to create such a OnceNamedOne object ?

( Hint: in this kata you'll try to define properties of an object )
*/
function OnceNamedOne(first, last) {
    this.firstName = first;
    this.lastName = last;
    this.fullName = this.firstName + ' ' + this.lastName;
    Object.freeze(this)
}


================================================
FILE: (L33T + Grεεκ) Case.js
================================================
/*
Description:
Getting Familiar: LEET: (sometimes written as "1337" or "l33t"), also known as eleet or leetspeak, is another alphabet for the English language that is used mostly on the internet. It uses various combinations of ASCII characters to replace Latinate letters. For example, leet spellings of the word leet include 1337 and l33t; eleet may be spelled 31337 or 3l33t.

GREEK: The Greek alphabet has been used to write the Greek language since the 8th century BC. It was derived from the earlier Phoenician alphabet, and was the first alphabetic script to have distinct letters for vowels as well as consonants. It is the ancestor of the Latin and Cyrillic scripts.Apart from its use in writing the Greek language, both in its ancient and its modern forms, the Greek alphabet today also serves as a source of technical symbols and labels in many domains of mathematics, science and other fields.

Your Task :

You have to create a function **GrεεκL33t** which    
takes a string as input and returns it in the form of 
(L33T+Grεεκ)Case.
Note: The letters which are not being converted in 
(L33T+Grεεκ)Case should be returned in the lowercase.
(L33T+Grεεκ)Case:

A=α (Alpha)      B=β (Beta)      D=δ (Delta)
E=ε (Epsilon)    I=ι (Iota)      K=κ (Kappa)
N=η (Eta)        O=θ (Theta)     P=ρ (Rho)
R=π (Pi)         T=τ (Tau)       U=μ (Mu)      
V=υ (Upsilon)    W=ω (Omega)     X=χ (Chi)
Y=γ (Gamma)
Examples:

GrεεκL33t("CodeWars") = "cθδεωαπs"
GrεεκL33t("Kata") = "κατα"
*/
function GrεεκL33t(str){
  let dict = {a:'α',b:'β',d:'δ',e:'ε',i:'ι',k:'κ',n:'η',o:'θ',p:'ρ',r:'π',t:'τ',u:'μ',
  v:'υ',w:'ω',x:'χ',y:'γ'}
  return str.replace(/./g,v=>{
    if (dict[v.toLowerCase()]){
      return v===v.toUpperCase()?dict[v.toLowerCase()]:dict[v]
    }
    return v.toLowerCase()
  })
}


================================================
FILE: +1 Array.js
================================================
/*
Description:
Given an array of integers of any length, return an array that has 1 added to the value represented by the array.

the array can't be empty
only non-negative, single digit integers are allowed
Return nil (or your language's equivalent) for invalid inputs.

Examples
For example the array [2, 3, 9] equals 239, adding one would return the array [2, 4, 0].

[4, 3, 2, 5] would return [4, 3, 2, 6]
*/
function upArray(arr){
  if (!arr.every(v=>v>=0)||arr.length===0) return null
  if (arr.some(v=>v.toString().length>1)) return null
  let arr1 =[];
  for (let i=0;i<arr.length;i+=15){
  arr1.push(arr.slice(i,i+15))
  }
  arr1[arr1.length-1]= arr1[arr1.length-1].join('')*1+1
  arr1=arr1.map(v=>Array.isArray(v)?v.join('')*1:v)
  return (arr1.join('')).split('').map(v=>v*1)
}


================================================
FILE: 1 n- Cycle.js
================================================
/*
Description:
Let be n an integer prime with 10 e.g. 7.

1/7 = 0.142857 142857 142857 ....

We see that the decimal part has a cycle: 142857. The length of this cycle is 6. In the same way:

1/11 = 0.09 09 09 .... Cycle length is 2.

Task
Given an integer n (n > 1), the function cycle(n) returns the length of the cycle if n and 10 are coprimes, otherwise returns -1.

Exemples:
cycle(5) = -1
cycle(13) = 6 -> 0.076923 076923 0769
cycle(21) = 6 -> 0.047619 047619 0476
cycle(27) = 3 -> 0.037 037 037 037 0370
cycle(33) = 2 -> 0.03 03 03 03 03 03 03 03
cycle(37) = 3 -> 0.027 027 027 027 027 0
cycle(94) = -1 

cycle(22) = -1 since 1/22 ~ 0.0 45 45 45 45 ...
*/
function cycle(n) {
 if (n%2 == 0 || n%5 == 0) {
    return -1
  } else {
    let res = 10 % n, c = 1;
    while (res != 1) 
    {
        res = res * 10 % n; 
        c++;
    }
    return c;
    }
}


================================================
FILE: 1RM Calculator.js
================================================
/*
Description:
You just got done with your set at the gym, and you are wondering how much weight you could lift if you did a single repetition. Thankfully, a few scholars have devised formulas for this purpose (from Wikipedia) :

Epley

McGlothin

Lombardi

Your function will receive a weight w and a number of repetitions r and must return your projected one repetition maximum. Since you are not sure which formula to use and you are feeling confident, your function will return the largest value from the three formulas shown above, rounded to the nearest integer. However, if the number of repetitions passed in is 1 (i.e., it is already a one rep max), your function must return w. Also, if the number of repetitions passed in is 0 (i.e., no repetitions were completed), your function must return 0.
*/
function calculate1RM(w, r){
  let a= w *(1+r/30);
  let b= (100*w)/(101.3-2.67123*r);
  let c=w*(r**0.1);
  if (r===0||w===0) return 0;
  if (r===1) return w;
  return Math.round(Math.max(a,b,c))
}


================================================
FILE: 80's Kids #7: She's a Small Wonder.js
================================================
/*
Description:
Vicky is quite the small wonder. Most people don't even realize she's not a real girl, but a robot living amongst us. Sure, if you stick around her home for a while you might see her creator open up her back and make a few tweaks and even see her recharge in the closet instead of sleeping in a bed.

In this kata, we're going to help Vicky keep track of the words she's learning.

Write a function, learnWord(word) which is a method of the Robot object. The function should report back whether the word is now stored, or if she already knew the word.

Example:

var vicky = new Robot();
vicky.learnWord('hello') -> 'Thank you for teaching me hello'
vicky.learnWord('abc') -> 'Thank you for teaching me abc'
vicky.learnWord('hello') -> 'I already know the word hello'
vicky.learnWord('wow!') -> 'I do not understand the input'
Robot vicky = new Robot();
vicky.learnWord("hello") -> "Thank you for teaching me hello"
vicky.learnWord("abc") -> "Thank you for teaching me abc"
vicky.learnWord("hello") -> "I already know the word hello"
vicky.learnWord("wow!") -> "I do not understand the input"
Case shouldn't matter. Only alpha characters are valid. There's also a little trick here. Enjoy!
*/
function Robot() {
  this.arr =['i', 'already', 'know', 'the', 'word','thank', 'you', 'for','me','teaching','understand']
}

Robot.prototype.learnWord = function(word) {
  if (/\W|\d|\s/i.test(word)||!word) return "I do not understand the input"
  if (!this.arr.includes(word.toLowerCase())){
  this.arr.push(word.toLowerCase())
  return `Thank you for teaching me ${word}`
  }else
  return `I already know the word ${word}`
}


================================================
FILE: A Rule of Divisibility by 13.js
================================================
/*
Description:
When you divide the successive powers of 10 by 13 you get the following remainders of the integer divisions:

1, 10, 9, 12, 3, 4.

Then the whole pattern repeats.

Hence the following method: Multiply the right most digit of the number with the left most number in the sequence shown above, the second right most digit to the second left most digit of the number in the sequence. The cycle goes on and you sum all these products. Repeat this process until the sequence of sums is stationary.

...........................................................................

Example: What is the remainder when 1234567 is divided by 13?

7×1 + 6×10 + 5×9 + 4×12 + 3×3 + 2×4 + 1×1 = 178

We repeat the process with 178:

8x1 + 7x10 + 1x9 = 87

and again with 87:

7x1 + 8x10 = 87

...........................................................................

From now on the sequence is stationary and the remainder of 1234567 by 13 is the same as the remainder of 87 by 13: 9

Call thirt the function which processes this sequence of operations on an integer n (>=0). thirt will return the stationary number.

thirt(1234567) calculates 178, then 87, then 87 and returns 87.

thirt(321) calculates 48, 48 and returns 48
*/
function thirt(n) {
   const dict=[1, 10, 9, 12, 3, 4]
   let sum=n;
   while(1){
       let temp=sum
       sum=sum.toString().split``.reverse().join``.split``.map((v,i)=>{
         v=v*dict[i%6]
         return v
       }).reduce((a,b)=>a+b,0)
       if (sum===temp){break}
     }
   return sum
}


================================================
FILE: A String of Sorts.js
================================================
/*
Description:
Define a method that accepts 2 strings as parameters. The method returns the first string sorted by the second.

sortString("foos", "of")       => "oofs"

sortString("string", "gnirts") => "gnirts"

sortString("banana", "abn")    => "aaabnn"
To elaborate, the second string defines the ordering. It is possible that in the second string characters repeat, so you should remove repeating characters, leaving only the first occurrence.

Any character in the first string that does not appear in the second string should be sorted to the end of the result in original order.
*/
function sortString(string,ordering) {
  ordering=ordering.split``
  let arr1 = string.split``.filter(v=>ordering.includes(v)).sort((a,b)=>ordering.indexOf(a)-ordering.indexOf(b))
  let arr2 = string.split``.filter(v=>!ordering.includes(v))
  return arr1.join``+arr2.join``
}


================================================
FILE: A Taste of Curry.js
================================================
/*
Description:
Your relative have decided to open a small Indian restaurant, and so she bought an automatic cooker. It publishes an API function

function cook(
    /*String*/ dish,
    /*Number*/ nServings
    /* , other params, specific to the dish - represented by strings */
) {
    ...
}```

 which takes an amount of servings, dish name and several other parameters which can vary per dish (yes, this is a very advanced cooking machine).

The restaurant instantly became very popular, and your relative noticed that most people order some curry with additional ingredients - because she was already tired to repeatedly type the word _'curry'_  when making a request to cooker. So she decided to ask for your help.

She cannot lend you her cooker, because it is in constant use - so she needs you to write a function

```javascript
function curry(fun, /*args*/) { 
    ...
}
which takes another function fun and an arbitrary number of other arguments - and returns a function, which works like fun with the first arguments replaced by the remaining arguments of curry.

For example

function add(a, b, c) { return a+b+c; }
var addOne = curry(add , 1);

add(1, 2, 3) === addOne(2, 3);
And one more thing - some code warrior who was having a snack at your relative's restaurant told her that there is such thing as execution context, and that the cook function might rely on it somehow - it is designed to work exclusively with cooking machine after all.

So another request for curry function is that if the resulting function is invoked with context ctx the original function inside it should also be invoked with context ctx

For example,

var obj = {
  a: 'foo',
  b: function (a) { return this.a + a; }
}

obj.foobar = curry(obj.b, 'bar');
obj.foobar() //should return foobar
*/
function curry(fun,...args) {
    return function(...arg2) {
    return fun.call(this,...args,...arg2);
  }
}


================================================
FILE: A disguised sequence (I).js
================================================
/*
Description:
Given u0 = 1, u1 = 2 and the relation 6unun+1-5unun+2+un+1un+2 = 0 calculate un for any integer n >= 0.

#Examples

fcn(n) returns un: fcn(17) -> 131072, fcn(21) -> 2097152

Remark: You can take two points of view to do this kata:

the first one purely algorithmic from the definition of un

the second one - not at all mandatory, but as a complement - is to get a bit your head around and find which sequence is hidden behind un.
*/
function fcn (n) {
    return 2**n
}


================================================
FILE: A tetrahedron of cannonballs.js
================================================
/*
Description:
Previously on Codewars...

"Triangular numbers are so called because of the equilateral triangular shape that they occupy when laid out as dots. i.e.

1st (1)   2nd (3)    3rd (6)
*          **        ***
           *         **
                     *
In the Triangular Treasure kata you need to return the nth triangular number."

(If you haven't solved Triangular Treasure go solve it, cause you are going to need the solution here)

Now, in this kata...

The triangular number you just calculated is going to be the base of our "brand new" tetrahedral stack.

You need to calculate the number of cannonballs that can be stacked to form a regular tetrahedron with the given edge's length.

A regular tetrahedron is a platonic solid composed of triangular faces with all the edges having the same length. *** Please note, this is not a square pyramid, but a triangular one

For our problem, we are going to consider that the length of the edge is the number of cannonballs that can be lined up along one edge. *** Please note, we are not talking about volume here, we are talking about stacking spheres.

So. Given an edge with length = 1, the number of cannonballs contained in the base triangle (the triangular number) will be 1, and the number of cannonballs you would be able to stack in a regular tetrahedron will be 1.

The table for the series is this:

(edge's length -> triangular number -> "cannonball number")

 1 ->   1 ->    1
 2 ->   3 ->    4
 3 ->   6 ->   10
 4 ->  10 ->   20
 5 ->  15 ->   35
 6 ->  21 ->   56
 7 ->  28 ->   84
 8 ->  36 ->  120
 9 ->  45 ->  165
10 ->  55 ->  220
11 ->  66 ->  286
12 ->  78 ->  364
13 ->  91 ->  455
14 -> 105 ->  560
15 -> 120 ->  680
16 -> 136 ->  816
17 -> 153 ->  969
18 -> 171 -> 1140
19 -> 190 -> 1330
20 -> 210 -> 1540 
You can see some properties here:

The nth triangular number is: t(n) = n + t(n-1)
The nth cannonball number is: c(n) = t(n) + c(n-1)
Hint: Remember that, even though, we are talking about tetrahedrons the key number here is not 4 but 3.

*** Please, don't worry about the parameters. You will only receive positive integers.
*/
function tetrahedron(size) {
  return size*(size + 1)*(size + 2)/6
}


================================================
FILE: ASCII hex converter.js
================================================
/*
Write a module Converter that can take ASCII text and convert it to hexadecimal. The class should also be able to take hexadecimal and convert it to ASCII text.

Example
Converter.toHex("Look mom, no hands")
=> "4c6f6f6b206d6f6d2c206e6f2068616e6473"

Converter.toAscii("4c6f6f6b206d6f6d2c206e6f2068616e6473")
=> "Look mom, no hands"
*/
var Converter = {
  toAscii: function (hex) {
    let arr=[];
    for (let i=0;i<hex.length;i+=2){
        arr.push(hex.slice(i,i+2))
      }
    return arr.map(v=>String.fromCharCode(parseInt(v,16))).join('')
  },
  toHex: function (ascii) {
     return ascii.split('').map(v=>v.charCodeAt().toString(16)).join('')
  }
}


================================================
FILE: Ackermann Function.js
================================================
/*
Description:
The Ackermann function is a famous function that played a big role in computability theory as the first exemple of a total computable function that is not primitive recursive.

Since then the function has been a bit simplified but is still of good use. Due to its definition in terms of extremely deep recursion it can be used as a benchmark of a compiler's ability to optimize recursion.

The goal of this kata is to code a function wich will be given two input, m and n, and will return the Ackermann number A(m,n) defined by:

A(m,n) = n+1                          if m=0  
A(m,n) = A(m-1,1)                     if m>0 , n=0
A(m,n) = A(m-1,A(m,n-1))              if m,n > 0
m,n should be non-negative integers, the function should return null (Javascript), None (Python), or nil (Ruby) for other type, non-integer and negative numbers. In C, input is restricted to integer type.
*/
Ackermann=function(m,n) {
    if (m<0||n<0){
        return null
    }
    if (m == 0) {
        return n + 1;
    }
    if (m>0&&n == 0) {
        return Ackermann(m - 1, 1)
    }
    if (m>0&&n>0){
        return Ackermann(m-1,Ackermann(m,n-1))
    }
}


================================================
FILE: Adding Binary Numbers.js
================================================
/*
Description:
##Task: You have to write a function add which takes two binary numbers as strings and returns their sum as a string.

##Note:

You are not allowed to convert binary to decimal & vice versa.
The sum should contain No leading zeroes.
##Examples:

add('111','10'); => '1001'
add('1101','101'); => '10010'
add('1101','10111') => '100100'
*/
function add(a,b){
  a = a.split('').reverse();
  b = b.split('').reverse();
  var result = '', temp = 0;
  while (a.length || b.length || temp) {
    temp += (~~a.shift()) + (~~b.shift());
    let mod = temp % 2;
    result = mod + result;
    temp = temp > 1;
  }
  return (+result) ? result.replace(/^0+/, '') : '0';
};


================================================
FILE: Adding ordinal indicator suffixes to numbers.js
================================================
/*
Description:
Finish the function numberToOrdinal, which should take a number and return it as a string with the correct ordinal indicator suffix (in English). That is:

numberToOrdinal(1) ==> '1st'
numberToOrdinal(2) ==> '2nd'
numberToOrdinal(3) ==> '3rd'
numberToOrdinal(4) ==> '4th'
... and so on
For the purposes of this kata, you may assume that the function will always be passed a non-negative integer. If the function is given 0 as an argument, it should return '0' (as a string).

To help you get started, here is an excerpt from Wikipedia's page on Ordinal Indicators:

st is used with numbers ending in 1 (e.g. 1st, pronounced first)
nd is used with numbers ending in 2 (e.g. 92nd, pronounced ninety-second)
rd is used with numbers ending in 3 (e.g. 33rd, pronounced thirty-third)
As an exception to the above rules, all the "teen" numbers ending with 11, 12 or 13 use -th (e.g. 11th, pronounced eleventh, 112th, pronounced one hundred [and] twelfth)
th is used for all other numbers (e.g. 9th, pronounced ninth).
*/
function numberToOrdinal(n) {
  var suffix = "th";
  if (n == 0) suffix = "";
  if (n % 10 == 1 && n % 100 != 11) suffix = "st";
  if (n % 10 == 2 && n % 100 != 12) suffix = "nd";
  if (n % 10 == 3 && n % 100 != 13) suffix = "rd";
  return n + suffix;
}


================================================
FILE: Adjacent pairs in a string.js
================================================
/*
Description:
You know how sometimes you write the the same word twice in a sentence, but then don't notice that it happened? For example, you've been distracted for a second. Did you notice that *"the"* is doubled in the first sentence of this description?

As as aS you can see, it's not easy to spot those errors, especially if words differ in case, like *"as"* at the beginning of the sentence.

Write a function countAdjacentPairs that counts the number of adjacent pairs in a string. It should be case-insenstive. A word in this kata is a sequence of non-whitespace characters enclosed by whitespace, so the string "dog dog." contains the two words "dog" and "dog.", which differ. The occurence of two or more equal words next after each other count as one.

Example:

countAdjacentPairs "dog cat"       == 0
countAdjacentPairs "dog dog cat"   == 1
countAdjacentPairs "apple dog cat" == 0
countAdjacentPairs "pineapple apple dog cat" == 0
countAdjacentPairs "apple     apple dog cat" == 1
countAdjacentPairs "apple dog apple dog cat" == 0
countAdjacentPairs "dog dog dog dog dog dog" == 1
countAdjacentPairs "dog dog dog dog cat cat" == 2
countAdjacentPairs "cat cat dog dog cat cat" == 3
//returns 0
countAdjacentPairs('')

// returns 1
countAdjacentPairs('cat dog dog')

// returns 1 (The first pair has been matched, and will be ignored from then on).
countAdjacentPairs('dog dog dog')

// returns 2
countAdjacentPairs('cat cat dog dog cat')
*/
function countAdjacentPairs(searchString) {
  let obj={};
  searchString.toLowerCase().split(' ').map(v=>obj[v]=obj[v]?obj[v]+1:1);
  return Object.values(obj).filter(v=>v>1).length
}


================================================
FILE: Almost Even.js
================================================
/*
Description:
We need the ability to divide an unknown integer into a given number of even parts — or at least as even as they can be. The sum of the parts should be the original value, but each part should be an integer, and they should be as close as possible.

Example code:

splitInteger(20, 6)  //  returns [3, 3, 3, 3, 4, 4]
Complete the function so that it returns an array of integer representing the parts. Ignoring the order of the parts, there is only one valid solution for each input to your function!

(Also, there is no reason to test for edge cases: the input to your function will always be valid for this kata.)
*/
var splitInteger = function(num, parts) {
  let n =Math.floor(num/parts)
  const arr  = [];
  for (let i=0;i<parts;i++){
    arr.push(n)
  }
  if (arr.reduce((a,b)=>a+b,0)===num) return arr
  for (let i=0;i<parts;i++){
    arr[i]++
    if (arr.reduce((a,b)=>a+b,0)===num) return arr
  }
}


================================================
FILE: Alphabet war - airstrike - letters massacre.js
================================================
/*
Description:
Introduction
There is a war and nobody knows - the alphabet war!
There are two groups of hostile letters. The tension between left side letters and right side letters was too high and the war began. The letters called airstrike to help them in war - dashes and dots are spreaded everywhere on the battlefield.

Task
Write a function that accepts fight string consists of only small letters and * which means a bomb drop place. Return who wins the fight after bombs are exploded. When the left side wins return Left side wins!, when the right side wins return Right side wins!, in other case return Let's fight again!.

The left side letters and their power:

 w - 4
 p - 3 
 b - 2
 s - 1
The right side letters and their power:

 m - 4
 q - 3 
 d - 2
 z - 1
The other letters don't have power and are only victims.
The * bombs kills the adjacent letters ( i.e. aa*aa => a___a, **aa** => ______ );

Example
alphabetWar("s*zz");           //=> Right side wins!
alphabetWar("*zd*qm*wp*bs*"); //=> Let's fight again!
alphabetWar("zzzz*s*");       //=> Right side wins!
alphabetWar("www*www****z");  //=> Left side wins!
*/

function alphabetWar(fight)
{ let dict={'w':4,'p':3,'b':2,'s':1,'m':-4,'q':-3,'d':-2,'z':-1};
  
  const arr=[];
  const arr1=fight.split('')
  for (let i=0;i<fight.length;i++){
  if(arr1[i-1]!=='*'&&arr1[i]!=='*'&&arr1[i+1]!=='*'){arr.push(arr1[i])}
  }
  let sum=arr.reduce((a,b)=>a+(dict[b]?dict[b]:0),0)
  return sum<0?'Right side wins!':sum>0?'Left side wins!':'Let\'s fight again!';
}


================================================
FILE: Alphabetized.js
================================================
/*
Description:
The alphabetized kata
Re-order the characters of a string, so that they are concatenated into a new string in "case-insensitively-alphabetical-order-of-appearance" order. Whitespace and punctuation shall simply be removed!

The input is restricted to contain no numerals and only words containing the english alphabet letters.

Example:

alphabetized("The Holy Bible") // "BbeehHilloTy"
Inspired by Tauba Auerbach
*/
function alphabetized(s) {
 var ans="";
 for (var i=97; i<123; ++i)
   for (var j=0; j<s.length; j++)
     if (s[j].toLowerCase().charCodeAt()==i)
     ans+=s[j]
 return ans
}


================================================
FILE: Alternating Loops.js
================================================
/*
Description:
Write

function combine()
that combines arrays by alternatingly taking elements passed to it.

E.g

combine(['a', 'b', 'c'], [1, 2, 3]) == ['a', 1, 'b', 2, 'c', 3]
combine(['a', 'b', 'c'], [1, 2, 3, 4, 5]) == ['a', 1, 'b', 2, 'c', 3, 4, 5]
combine(['a', 'b', 'c'], [1, 2, 3, 4, 5], [6, 7], [8]) == ['a', 1, 6, 8, 'b', 2, 7, 'c', 3, 4, 5]
Arrays can have different lengths.
*/
function combine(...arr) {
  let newArr=[]
  let max=Math.max(...arr.map(v=>v.length))
  for(let i=0;i<max;i++){
    for (let j=0;j<arr.length;j++){
      arr[j][i]?newArr.push(arr[j][i]):1
      }
  }
   return newArr
}


================================================
FILE: Anagram difference.js
================================================
/*
Description:
Given two words, how many letters do you have to remove from them to make them anagrams?
Example
First word : c od e w ar s (4 letters removed)
Second word : ha c k er r a nk (6 letters removed)
Result : 10
Hints
A word is an anagram of another word if they have the same letters (usually in a different order).
Do not worry about case. All inputs will be lowercase.
When you're done with this kata, check out its big brother/sister : https://www.codewars.com/kata/hardcore-anagram-difference
*/
function anagramDifference(str1,str2){
    let count1 = Array(26).fill(0) 
    let count2 = Array(26).fill(0) 
    let i = 0
    while (i < str1.length){
        count1[str1[i].charCodeAt()-97] += 1
        i += 1
        }
    i =0
    while (i < str2.length){
        count2[str2[i].charCodeAt()-97] += 1
        i += 1
        }
   let result = 0
    for (let i = 0; i<26;i++){
        result += Math.abs(count1[i] - count2[i]) 
    }
    return result 
}


================================================
FILE: Anything to integer.js
================================================
/*
Description:
Your task is to program a function which converts any input to an integer.

Do not perform rounding, the fractional part should simply be discarded.

If converting the input to an integer does not make sense (with an object, for instance), the function should return 0 (zero).

Also, Math.floor(), parseInt() and parseFloat() are disabled for your unconvenience.

Onegaishimasu!
*/
function toInteger(n) {
  if (isNaN(n)) return 0
  n=Math.trunc(n)
  if (!Number.isFinite(n)) return 0
  return n  
}


================================================
FILE: Arabian String.js
================================================
/*
Description:
You must create a method that can convert a string from any format into CamelCase. This must support symbols too.

Don't presume the separators too much or you could be surprised.

Tests
camelize("example name")   // => ExampleName
camelize("your-NaMe-here") // => YourNameHere
camelize("testing ABC")    // => TestingAbc
*/
function camelize(str){
  return str.replace(/[^a-z0-9]/gi,' ').split` `.map(v=>v.slice(0,1).toUpperCase()+v.slice(1).toLowerCase()).join``
}


================================================
FILE: Are they the "same"?
================================================
/*
Description:
Given two arrays a and b write a function comp(a, b) (compSame(a, b) in Clojure) that checks whether the two arrays have the "same" elements, with the same multiplicities. "Same" means, here, that the elements in b are the elements in a squared, regardless of the order.

Examples
Valid arrays
a = [121, 144, 19, 161, 19, 144, 19, 11]  
b = [121, 14641, 20736, 361, 25921, 361, 20736, 361]
comp(a, b) returns true because in b 121 is the square of 11, 14641 is the square of 121, 20736 the square of 144, 361 the square of 19, 25921 the square of 161, and so on. It gets obvious if we write b's elements in terms of squares:

a = [121, 144, 19, 161, 19, 144, 19, 11] 
b = [11*11, 121*121, 144*144, 19*19, 161*161, 19*19, 144*144, 19*19]
Invalid arrays
If we change the first number to something else, comp may not return true anymore:

a = [121, 144, 19, 161, 19, 144, 19, 11]  
b = [132, 14641, 20736, 361, 25921, 361, 20736, 361]
comp(a,b) returns false because in b 132 is not the square of any number of a.

a = [121, 144, 19, 161, 19, 144, 19, 11]  
b = [121, 14641, 20736, 36100, 25921, 361, 20736, 361]
comp(a,b) returns false because in b 36100 is not the square of any number of a.

Remarks
a or b might be [] (all languages except R, Shell). a or b might be nil or null or None or nothing (except in Haskell, Elixir, C++, Rust, R, Shell).

If a or b are nil (or null or None), the problem doesn't make sense so return false.

If a or b are empty the result is evident by itself.
*/

function comp(array1, array2){
  array1=array1.map(v=>v*v)
return array2?array1.reduce((a,b)=>a+b,0)===array2.reduce((a,b)=>a+b,0):false
}


================================================
FILE: Are we alternate?.js
================================================
/*
Description:
Create a function isAlt() that accepts a string as an argument and validates whether the vowels (a, e, i, o, u) and consonants are in alternate order.

isAlt("amazon")
// true
isAlt("apple")
// false
isAlt("banana")
// true
Arguments consist of only lowercase letters.
*/
function isAlt(word) {
 
  return word.split('').every((v,i)=>{
  if (/[aeiou]/.test(word[0])){
    if (i%2===0&&/[aeiou]/.test(v)){
      return true
      } else if (i%2!==0&&!/[aeiou]/.test(v)){ return true
      } else {return false}
    }
  if (!/[aeiou]/.test(word[0])){
    if (i%2==0&&!/[aeiou]/.test(v)){
      return true
      } else if (i%2!==0&&/[aeiou]/.test(v)){ return true
      } else {return false}
    }
  })
}


================================================
FILE: Array Deep Count.js
================================================
/*
Description:
Array.prototype.length will give you the number of top-level elements in an array.

Your task is to create a function deepCount that returns the number of ALL elements within an array, including any within inner-level arrays.

For example:

deepCount([1, 2, 3]);  
//>>>>> 3
deepCount(["x", "y", ["z"]]);  
//>>>>> 4
deepCount([1, 2, [3, 4, [5]]]);  
//>>>>> 7
The input will always be an array.
*/
function deepCount(a){
  return a.reduce((s,e)=>s+(Array.isArray(e)?deepCount(e):0),a.length);
}


================================================
FILE: Array Helpers.js
================================================
/*
Description:
This kata is designed to test your ability to extend the functionality of built-in classes. In this case, we want you to extend the built-in Array class with the following methods: square(), cube(), average(), sum(), even() and odd().

Explanation:

square() must return a copy of the array, containing all values squared
cube() must return a copy of the array, containing all values cubed
average() must return the average of all array values; on an empty array must return NaN (note: the empty array is not tested in Ruby!)
sum() must return the sum of all array values
even() must return an array of all even numbers
odd() must return an array of all odd numbers
Note: the original array must not be changed in any case!

Example
var numbers = [1, 2, 3, 4, 5];

numbers.square();  // must return [1, 4, 9, 16, 25]
numbers.cube();    // must return [1, 8, 27, 64, 125]
numbers.average(); // must return 3
numbers.sum();     // must return 15
numbers.even();    // must return [2, 4]
numbers.odd();     // must return [1, 3, 5]
*/

Array.prototype.square=function(){
return this.map(v=>v*v)
}
Array.prototype.cube=function(){
return this.map(v=>v*v*v)
}
Array.prototype.sum=function(){
return this.reduce((a,b)=>a+b,0)
}
Array.prototype.average=function(){
return this.reduce((a,b)=>a+b,0)/this.length
}
Array.prototype.even=function(){
return this.filter(v=>v%2==0)
}
Array.prototype.odd=function(){
return this.filter(v=>v%2!==0)
}


================================================
FILE: Array#reduce.js
================================================
/*
Description:
In this kata, you must define the Array.reduce method.

I have disabled the pre-existing reduce methods.

Here's how it works:

[1,2,3].reduce( function(sum, next){return sum+next}, 0) 
// => 6

['a','b','a'].reduce( function(obj, elem){if(!obj[elem]) obj[elem] = 0; obj[elem] += 1; return obj}, {})
// => {'a':2, 'b':1}
Summary: The reduce method goes through each element of an array, applies the function to whatever the function returned last, and returns the last outcome. On the first iteration, it should pass the initial value to the function, as well as the first element of the array. If no initial value is passed, skip to the first element of the array.

Ruby methods should expect a lambda.
*/
Array.prototype.reduce = function(process, initial) {
  for (let i = 0; i < this.length; i++) {
    if (!initial){i++;initial=this[0]}
    initial =  process(initial, this[i]);
 }
 return initial
}


================================================
FILE: Array.diff
================================================
/*
Description:
Your goal in this kata is to implement a difference function, which subtracts one list from another and returns the result.

It should remove all values from list a, which are present in list b.

array_diff([1,2],[1]) == [2]
If a value is present in b, all of its occurrences must be removed from the other:

array_diff([1,2,2,2,3],[2]) == [1,3]
*/

function array_diff(a, b) {
  return a.filter(e => !b.includes(e));
}


================================================
FILE: Arrays Similar.js
================================================
/*
Description:
Write a function that determines whether the passed in arrays are similar. Similar means they contain the same elements, and the same number of occurrences of elements.

var arr1 = [1, 2, 2, 3, 4],
    arr2 = [2, 1, 2, 4, 3],
    arr3 = [1, 2, 3, 4],
    arr4 = [1, 2, 3, "4"]

arraysSimilar(arr1, arr2); // Should equal true
arraysSimilar(arr2, arr3); // Should equal false
arraysSimilar(arr3, arr4); // Should equal false
*/
function arraysSimilar(arr1, arr2) {
  arr1=arr1.sort((a,b)=>a-b) 
  arr2=arr2.sort((a,b)=>a-b) 
  return arr1.length>arr2.length?arr1.every((v,i)=>v===arr2[i]):arr2.every((v,i)=>v===arr1[i])
}


================================================
FILE: Arrh, grabscrab!.js
================================================
/*
Description:
Pirates have notorious difficulty with enunciating. They tend to blur all the letters together and scream at people.

At long last, we need a way to unscramble what these pirates are saying.

Write a function that will accept a jumble of letters as well as a dictionary, and output a list of words that the pirate might have meant.

For example:

grabscrab( "ortsp", ["sport", "parrot", "ports", "matey"] )
Should return ["sport", "ports"].

Return matches in the same order as in the dictionary. Return an empty array if there are no matches.

Good luck!
*/
function grabscrab(anagram, dictionary) {
  anagram=anagram.split('').sort().join()
  let arr = dictionary.slice().map(v=>v.split('').sort().join()===anagram)
  return dictionary.filter((v,i)=>arr[i]===true)
}


================================================
FILE: Atbash Cipher Helper.js
================================================
/*
Description:
The Atbash cipher is a simple substitution cipher originally known to be implemented using the Hebrew alphabet (אתבש, aleph-tav-beth-shin). The Atbash cipher is particularly well-known for its use in the Bible. It was in use as early as 500BC by scribes writing the Book of Jeremiah.

In the Atbash cipher, the first letter of the alphabet is substituted with the last letter, the second letter with the second to last letter, and so on.

For the Latin alphabet, this could be mapped as:

A|B|C|D|E|F|G|H|I|J|K|L|M
Z|Y|X|W|V|U|T|S|R|Q|P|O|N
For the Hebrew alphabet:

א|ב|ג|ד|ה|ו|ז|ח|ט|י|כ
ת|ש|ר|ק|צ|פ|ע|ס|נ|מ|ל
When viewing Hebrew text:

This is about viewing the text and should have no impact on your code. It may, however, help you with debugging text.
I assume that your computer will display the characters properly.
Hebrew is written right-to-left, such that: "א|ב".charAt(0) == "א".
There are alternate forms of some letters in Hebrew (e.g. final forms) that aren't listed here. You won't need to worry about them for this Kata.
Your solution should support any alphabet provided to the constructor, and should leave characters that are not in the specified alphabet in situ (e.g. uppercase letters should be left as-is if provided an alphabet of only lowercase letters).
*/
function AtbashCipher(abc) {
  this.decode = this.encode = function(str) {
    return str.replace(/./g, function(c) {
      return abc[abc.length - 1 - abc.indexOf(c)] || c;
    });
  };
}


================================================
FILE: Autocomplete! Yay!.js
================================================
/*
Description:
It's time to create an autocomplete function! Yay!

The autocomplete function will take in an input string and a dictionary array and return the values from the dictionary that start with the input string. If there are more than 5 matches, restrict your output to the first 5 results. If there are no matches, return an empty array.

Example:

autocomplete('ai', ['airplane','airport','apple','ball']) = ['airplane','airport']
For this kata, the dictionary will always be a valid array of strings. Please return all results in the order given in the dictionary, even if they're not always alphabetical. The search should NOT be case sensitive, but the case of the word should be preserved when it's returned.

For example, "Apple" and "airport" would both return for an input of 'a'. However, they should return as "Apple" and "airport" in their original cases.

Important note:

Any input that is NOT a letter should be treated as if it is not there. For example, an input of "$%^" should be treated as "" and an input of "ab*&1cd" should be treated as "abcd".

(Thanks to wthit56 for the suggestion!)
*/
function autocomplete(input, d){
  input=input.replace(/[^a-zA-Z]/gi,'')
  const arr=[];
  for (let i=0;i<d.length;i++){
    if (d[i].slice(0,input.length).toLowerCase()===input.toLowerCase()){ arr.push(d[i]) }
  }
  return arr.slice(0,5)
}


================================================
FILE: Baby Magpies.js
================================================
/*
Magpies are my favourite birds
Baby ones even more so...


It is a little known fact^ that the black & white colours of baby magpies differ by at least one place and at most two places from the colours of the mother magpie.

So now you can work out if any two magpies may be related.

...and Quardle oodle ardle wardle doodle the magpies said

Kata Task
Given the colours of two magpies, determine if one is a possible child or grand-child of the other.

Notes
Each pair of birds being compared will have same number of colour areas
B = Black
W = White
Example
Given these three magpies

Magpie 1  BWBWBW
Magpie 2  BWBWBB
Magpie 3  WWWWBB
You can see:

Magpie 2 may be a child of Magpie 1 because there is only one difference
Magpie 3 may be child of Magpie 2 because there are two differences
So Magpie 3 may be a grand-child of Magpie 1
On the other hand, Magpie 3 cannot be a child of Magpie 1 because there are three differences
DM :-)

^ This fact is little known because I just made it up
*/
var child = function(bird1, bird2) {
  if (bird1===bird2) return false
  return ( getDifference(bird1, bird2) < 3 ? true : false );
}
var grandchild = function(bird1, bird2) {
  if (bird1.length===1&&bird2.length===1&&bird2!==bird1) return false
  return ( getDifference(bird1, bird2) <=4 ? true : false );
}

function getDifference(bird1,bird2) {
        let dif = 0;
        for(let i=0; i<bird1.length; i++) {
          if(bird1.slice(i,i+1)!==bird2.slice(i,i+1)) dif++;
         }
        return dif;
}


================================================
FILE: Backspaces in string.js
================================================
/*
Description:
Assume "#" is like a backspace in string. This means that string "a#bc#d" actually is "bd"

Your task is to process a string with "#" symbols.

Examples
"abc#d##c"      ==>  "ac"
"abc##d######"  ==>  ""
"#######"       ==>  ""
""              ==>  ""
*/
function clean_string(s) {
  s=s.split``
	for (let i=0;i<s.length;i++){
    if (s[i]==='#'){
      s[i]=''
      s[i-1]=''
      s=s.filter(v=>v!=='')
      i-=2
    }
  }
  return s.join``
};


================================================
FILE: Backwards Read Primes.js
================================================
/*
Description:
Backwards Read Primes are primes that when read backwards in base 10 (from right to left) are a different prime. (This rules out primes which are palindromes.)

Examples:
13 17 31 37 71 73 are Backwards Read Primes
13 is such because it's prime and read from right to left writes 31 which is prime too. Same for the others.

Task
Find all Backwards Read Primes between two positive given numbers (both inclusive), the second one always being greater than or equal to the first one. The resulting array or the resulting string will be ordered following the natural order of the prime numbers.

Example
backwardsPrime(2, 100) => [13, 17, 31, 37, 71, 73, 79, 97] backwardsPrime(9900, 10000) => [9923, 9931, 9941, 9967] backwardsPrime(501, 599) => []

backwardsPrime(2, 100) => [13, 17, 31, 37, 71, 73, 79, 97] 
backwardsPrime(9900, 10000) => [9923, 9931, 9941, 9967]
*/

function backwardsPrime(start, stop){
    var arr = [];
    for(var x = start; x <= stop; x++) {
        if(isPrime(x)) {
            if(arr.includes(x)) {
                continue;
            }
            let temp = parseInt(x.toString().split('').reverse().join(''))
            if (temp != x && isPrime(temp)) {
                arr.push(x);
                arr.push(temp);
            }
        }    
    }
    return arr.filter(a=> a >= start && a <= stop).sort((b,c)=>b-c);
}

function isPrime(n) {
    if(n == 2 || n == 3) {
        return true;
    }
    if(n % 2 == 0 || n % 3 == 0 || n < 2) {
        return false;
    }
    var x = 5;
    var N = Math.sqrt(n);
    while (x <= N) {
        if (n % x == 0) {
            return false;
        }
        x++;
    }
    return true;
}


================================================
FILE: Balance the arrays.js
================================================
/*
Description:
Check that the two provided arrays both contain the same number of different unique items, regardless of order. For example in the following:

[a,a,a,a,b,b] and [c,c,c,d,c,d]
Both arrays have four of one item and two of another, so balance should return true.

#Have fun!
*/
function balance (arr1, arr2){
  if (arr1.length!==arr2.length) return false
  let f = arr1.reduce((a,b)=>(a[b]=a[b]+1|0+1,a),{})
  let s = arr2.reduce((a,b)=>(a[b]=a[b]+1|0+1,a),{})
  return Object.values(f).sort().toString()===Object.values(s).sort().toString()
}


================================================
FILE: Ball Upwards.js
================================================
/*
You throw a ball vertically upwards with an initial speed v (in km per hour). The height h of the ball at each time t is given by h = v*t - 0.5*g*t*t where g is Earth's gravity (g ~ 9.81 m/s**2). A device is recording at every tenth of second the height of the ball. For example with v = 15 km/h the device gets something of the following form: (0, 0.0), (1, 0.367...), (2, 0.637...), (3, 0.808...), (4, 0.881..) ... where the first number is the time in tenth of second and the second number the height in meter.

Task
Write a function max_ball with parameter v (in km per hour) that returns the time in tenth of second of the maximum height recorded by the device.

Examples:
max_ball(15) should return 4

max_ball(25) should return 7

Notes
Remember to convert the velocity from km/h to m/s or from m/s in km/h when necessary.
The maximum height recorded by the device is not necessarily the maximum height reached by the ball.
*/
function maxBall(v0) {
  const v = v0 * 1000 * 10 / 3600;
  return Math.round(v / 9.81); 
}


================================================
FILE: Banker's Plan.js
================================================
/*
Description:
John has some amount of money of which he wants to deposit a part f0 to the bank at the beginning of year 1. He wants to withdraw each year for his living an amount c0.

Here is his banker plan:

deposit f0 at beginning of year 1
his bank account has an interest rate of p percent per year, constant over the years
John can withdraw each year c0, taking it whenever he wants in the year; he must take account of an inflation of i percent per year in order to keep his quality of living. i is supposed to stay constant over the years.
all amounts f0..fn-1, c0..cn-1 are truncated by the bank to their integral part
Given f0, p, c0, i the banker guarantees that John will be able to go on that way until the nth year.
Example:
f0 = 100000, p = 1 percent, c0 = 2000, n = 15, i = 1 percent
beginning of year 2 -> f1 = 100000 + 0.01*100000 - 2000 = 99000;  c1 = c0 + c0*0.01 = 2020 (with inflation of previous year)
beginning of year 3 -> f2 =  99000 + 0.01*99000 - 2020  = 97970;  c2 = c1 + c1*0.01 = 2040.20 
(with inflation of previous year, truncated to 2040)
beginning of year 4 -> f3 =  97970 + 0.01*97970 - 2040  = 96909.7 (truncated to 96909); 
c3 = c2 + c2*0.01 = 2060.4 (with inflation of previous year, truncated to 2060)
and so on...

John wants to know if the bankers'plan is right or wrong. Given parameters f0, p, c0, n, i build a function fortune which returns true if John can make a living until the nth year and false if it is not possible.

Some cases:
fortune(100000, 1, 2000, 15, 1) -> True
fortune(100000, 1, 10000, 10, 1) -> True
fortune(100000, 1, 9185, 12, 1) -> False

For the last case you can find below the amounts of his account at the beginning of each year:
100000, 91815, 83457, 74923, 66211, 57318, 48241, 38977, 29523, 19877, 10035, -5
f11 = -5 so he has no way to withdraw something for his living in year 12.
Note: Don't forget to convert the percent parameters as percentages in the body of your function: if a parameter percent is 2 you have to convert it to 0.02.
*/
const fortune = (f0, p, c0, n, i) => {
    let c = c0;
    let sum = f0;

    for (let j = 1; j < n; j++) {
        sum = Math.ceil(sum * (1 + p / 100) - c);
        c = Math.ceil(c * (1 + i / 100))
    }

    return sum >= 0;
};


================================================
FILE: Base Conversion.js
================================================
/*
Description:
In this kata you have to implement a base converter, which converts positive integers between arbitrary bases / alphabets. Here are some pre-defined alphabets:

var Alphabet = {
  BINARY:        '01',
  OCTAL:         '01234567',
  DECIMAL:       '0123456789',
  HEXA_DECIMAL:  '0123456789abcdef',
  ALPHA_LOWER:   'abcdefghijklmnopqrstuvwxyz',
  ALPHA_UPPER:   'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
  ALPHA:         'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
  ALPHA_NUMERIC: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
};
The function convert() should take an input (string), the source alphabet (string) and the target alphabet (string). You can assume that the input value always consists of characters from the source alphabet. You don't need to validate it.

Examples
// convert between numeral systems
convert("15", Alphabet.DECIMAL, Alphabet.BINARY); // should return "1111"
convert("15", Alphabet.DECIMAL, Alphabet.OCTAL); // should return "17"
convert("1010", Alphabet.BINARY, Alphabet.DECIMAL); // should return "10"
convert("1010", Alphabet.BINARY, Alphabet.HEXA_DECIMAL); // should return "a"

// other bases
convert("0", Alphabet.DECIMAL, Alphabet.ALPHA); // should return "a"
convert("27", Alphabet.DECIMAL, Alphabet.ALPHA_LOWER); // should return "bb"
convert("hello", Alphabet.ALPHA_LOWER, Alphabet.HEXA_DECIMAL); // should return "320048"
convert("SAME", Alphabet.ALPHA_UPPER, Alphabet.ALPHA_UPPER); // should return "SAME"
Additional Notes:

The maximum input value can always be encoded in a number without loss of precision in JavaScript. In Haskell, intermediate results will probably be too large for Int.
The function must work for any arbitrary alphabets, not only the pre-defined ones
You don't have to consider negative numbers
*/

function convert(input, source, target) {
  let s=0;  let str='';
  for (let i=0; i<input.length; i++) {
    s=s*source.length+source.indexOf(input[i]);
  }
  while (s>0) {
    str=target[s%target.length]+str;
    s=Math.floor(s/target.length);
  }  
  return str ? str : target[0];
}


================================================
FILE: Basic Encryption.js
================================================
/*
Description:
The most basic encryption method is to map a char to another char by a certain math rule. Because every char has an ASCII value, we can manipulate this value with a simple math expression. For example 'a' + 1 would give us 'b', because 'a' value is 97 and 'b' value is 98.

You will need to write a method which does exactly that -

get a string as text and an int as the rule of manipulation, and should return encrypted text. for example:

encrypt("a",1) = "b"

Full ascii table is used on our question (256 chars) - so 0-255 are the valid values.

Good luck.
*/
function encrypt(text, rule) {
  return text.split('').map(v=>String.fromCharCode((v.charCodeAt()+rule)%256)).join(``)
};


================================================
FILE: Binary string.js
================================================
/*
Description:
Given a positive (or 0) number, return a string of 1's and 0's representing it's binary value: toBinaryString(6) should return "110" (no leading 0).

Use of the native method
number.toString(2);
is disallowed.
*/
function toBinaryString(num){
   let out = "", bit = 1;
    while( num >= bit ) {
        out = ( num & bit ? 1 : 0 ) + out;
        bit <<= 1;
    }
    return out || "0";
}


================================================
FILE: Binary to Text (ASCII) Conversion.js
================================================
/*
Description:
Write a function that takes in a binary string and returns the equivalent decoded text (the text is ASCII encoded).

Each 8 bits on the binary string represent 1 character on the ASCII table.

The input string will always be a valid binary string.

Characters can be in the range from "00000000" to "11111111" (inclusive)

Note: In the case of an empty binary string your function should return an empty string.
*/
function binaryToString(binary) {
  let arr=[];
  for (let i=0;i<binary.length;i+=8){
  arr.push(binary.slice(i,i+8))
  }
  return arr.map(v=>String.fromCharCode(parseInt(v,2))).join('')
}


================================================
FILE: Binding within the List Monad.js
================================================
/*
Description:
In Haskell, Monads are simple containers, or even 'box-like' datastructures, of which lists are included, which can respond to certain functions, which are defined in the Monad typeclass. (To put it simply!)

In this kata, you must implement the Bind function for lists, or arrays. In haskell, the function is represented by >>=, but we'll just call it bind.

Essentially, bind should map the array with the function given, and then flatten it one time. Don't manipulate the original array; make you function pure: without side-effects, so that no variables are edited whilst the function is carried out.

Here's how it should work:

bind( [1,2,3], function(a){ return [a+1] } )
=> [2,3,4]

bind( [1,2,3], function(a){ return [[a]] } )
=> [[1],[2],[3]]

bind( [1,2,3], function(a){ return a } )
=> # ERROR! The returned value is not a list!
As per usual, the ruby function will be passed a Proc or Lambda. Remember that the function still takes two arguments!
*/
bind = function(list, func) {
  if (typeof func(list[0]) !== "object") {throw Error()}
  return list.reduce((a,b)=>a.concat(func(b)),[])
}


================================================
FILE: Bingo Card.js
================================================
/*
Description:
After yet another dispute on their game the Bingo Association decides to change course and automize the game.

Can you help the association by writing a method to create a random Bingo card?

Task:

Finish method:
getCard()
A Bingo card contains 24 unique and random numbers according to this scheme:
5 numbers from the B column in the range 1 to 15
5 numbers from the I column in the range 16 to 30
4 numbers from the N column in the range 31 to 45
5 numbers from the G column in the range 46 to 60
5 numbers from the O column in the range 61 to 75

The card must be returned as an array of Bingo style numbers:
{ 'B14', 'B12', 'B5', 'B6', 'B3', 'I28', 'I27', ... }
The numbers must be in the order of their column: B, I, N, G, O. Within the columns the order of the numbers is random.
*/
function getCard() {
    let arr=[];
    for (let i=0;i<5;i++){
    let r=`B${getRandomIntInclusive(1,15)}`
    if (!arr.includes(r)){
     arr.push(r)} else {i--}
    }
    for (let i=0;i<5;i++){
    let r=`I${getRandomIntInclusive(16,30)}`
    if (!arr.includes(r)){
     arr.push(r)} else {i--}
    }
    for (let i=0;i<5;i++){
    let r=`N${getRandomIntInclusive(31,45)}`
    if (i===2){}  
    else if (!arr.includes(r)){
    arr.push(r)} else {i--}
    }
    for (let i=0;i<5;i++){
      let r=`G${getRandomIntInclusive(46,60)}`
    if (!arr.includes(r)){
     arr.push(r)} else {i--}
    }
    for (let i=0;i<5;i++){
     let r=`O${getRandomIntInclusive(61,75)}`
      if (!arr.includes(r)){
     arr.push(r)} else {i--}
    }
    return arr
}
function getRandomIntInclusive(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min + 1)) + min;
  }


================================================
FILE: Bit Counting
================================================
/*
Description:
Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative.

Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
*/

var countBits = function(n) {
  return n.toString(2).replace(/0/g,'').length;
};


================================================
FILE: Bleatrix Trotter (The Counting Sheep).js
================================================
/*
Description:
Bleatrix Trotter the sheep has devised a strategy that helps her fall asleep faster. First, she picks a number N. Then she starts naming N, 2 × N, 3 × N, and so on.

Whenever she names a number, she thinks about all of the digits in that number. She keeps track of which digits (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) she has seen at least once so far as part of any number she has named. Once she has seen each of the ten digits at least once, she will fall asleep.

Bleatrix must start with N and must always name (i + 1) × N directly after i × N.

For example, suppose that Bleatrix picks N = 1692. She would count as follows:

N = 1692. Now she has seen the digits 1, 2, 6, and 9.
2N = 3384. Now she has seen the digits 1, 2, 3, 4, 6, 8, and 9.
3N = 5076. Now she has seen all ten digits, and falls asleep.
The purpose of this kata is to return the last number Bleatrix Trotter sees before falling asleep.

Input
Will always be positive integer or zero
Output
The last number Bleatrix Trotter sees or "INSOMNIA" (-1 in Rust and C++) if she will count forever
Please note, this challenge is not my idea. It's from Google Code Jam 2016
*/
function trotter(n){
  let check = n
  let arr = n.toString().split``
  for (let i=1;i<1000;i++){
    n=check*i
    arr=arr.concat(n.toString().split``)
    arr=[...new Set(arr)]
    if (arr.length===10) return n
  }
  return "INSOMNIA"
}


================================================
FILE: Body mass index calculation.js
================================================
/*
Description:
For long period JavaScript warriors trained a lot in coding kata. But to find way warrior also need physical kata. Some of warriors forgot about this fact and enemies can use this weakness, your clan is under threat. You are chosen to fix this situation. Write a function to calculate Body mass index for each warrior.

bmi = weght(kg)/(height(m)*height(m))

Warriors know only their height in centimetres and weight (in kilogrames). Your task is to return an object with fields

value - calculated Body mass index, rounded with one number after decimal point.

category - from https://en.wikipedia.org/wiki/Body_mass_index

Ex :

calculateBmi(65,175)
Returns :

{value: "21.2", category: "Normal (healthy weight)"}
*/

function calculateBmi(weight, height) {
  const bmi = (weight/((height/100)*(height/100))).toFixed(1)
  let  z=''
  const obj={};
  if (bmi<15) z='Very severely underweight';
  if (bmi<16&&bmi>15) z= 'Severely underweight';
  if (bmi<18.5&&bmi>16) z= 'Underweight';
  if (bmi<25&&bmi>18.5) z= "Normal (healthy weight)";
  if (bmi<30&&bmi>25) z= 'Overweight';
  if (bmi<35&&bmi>30) z= 'Obese Class I (Moderately obese)';
  if (bmi<40&&bmi>35) z= 'Obese Class II (Severely obese)';
  if (bmi<45&&bmi>40) z= 'Obese Class III (Very severely obese)';
  if (bmi<50&&bmi>45) z= 'Obese Class IV (Morbidly Obese)';
  if (bmi<60&&bmi>50) z= 'Obese Class V (Super Obese)';
  if (bmi>60) z= 'Obese Class VI (Hyper Obese)';
  obj.value=bmi
  obj.category=z
return obj
}


================================================
FILE: Bouncing Balls
================================================
/*Description:
A child is playing with a ball on the nth floor of a tall building. The height of this floor, h, is known.

He drops the ball out of the window. The ball bounces (for example), to two-thirds of its height (a bounce of 0.66).

His mother looks out of a window 1.5 meters from the ground.

How many times will the mother see the ball pass in front of her window (including when it's falling and bouncing?

Three conditions must be met for a valid experiment:
Float parameter "h" in meters must be greater than 0
Float parameter "bounce" must be greater than 0 and less than 1
Float parameter "window" must be less than h.
If all three conditions above are fulfilled, return a positive integer, otherwise return -1.

Note: The ball can only be seen if the height of the rebounding ball is stricty greater than the window parameter.

Example:

h = 3, bounce = 0.66, window = 1.5, result is 3

h = 3, bounce = 1, window = 1.5, result is -1 (Condition 2) not fulfilled).
*/

function bouncingBall(h,  bounce,  window) {
  var rebounds = -1;
  if (bounce > 0 && bounce < 1) while (h > window) rebounds+=2, h *= bounce;
  return rebounds;
}


================================================
FILE: Bowling Pins.js
================================================
/*
Description:
Mount the Bowling Pins!
Task:
Did you ever play Bowling? Short: You have to throw a bowl into 10 Pins arranged like this:


I I I I  # each Pin has a Number:    7 8 9 10
 I I I                                4 5 6
  I I                                  2 3
   I                                    1

You will get an Array with Numbers, e.g.: [3,5,9] and remove them from the field like this:


I I   I
 I   I
  I   
   I   

Return a string with the current field.

Note that:
String.prototype.replace() is not allowed!

You begin a new line with \n
Each Line must be 7 chars long
Fill the missing pins with a whitespace
Have fun!
*/
function bowlingPins(arr){
  return "7 8 9 10\n 4 5 6 \n  2 3  \n   1   ".split`\n`.map(
  v=>v.split` `.map(v=>arr.includes(v*1)?' ':v===''?'':'I').join` `).join`\n`
}


================================================
FILE: Braces status.js
================================================
/*
Description:
Write a function that checks the braces status in a string, and return True if all braces are properly closed, or False otherwise. Available types of brackets: (), [], {}.

Please note, you need to write this function without using regex!

Examples
"([[some](){text}here]...)"  =>  true
"{([])}"                     =>  true
"()[]{}()"                   =>  true
"(...[]...{(..())}[abc]())"  =>  true
"1239(df){"                  =>  false
"[()])"                      =>  false
")12[x]34("                  =>  false
Don't forget to rate this kata! Thanks :)
*/
const bracesStatus = s => {
  s = s.replace(/[^\(\)\[\]\{\}]/g, '');
  while (/\(\)|\[\]|\{\}/.test(s)) s = s.replace(/\(\)|\[\]|\{\}/g, '');
  return s.length < 1;
}


================================================
FILE: Bracket Duplicates.js
================================================
/*
Description:
Create a program that will take in a string as input and, if there are duplicates of more than two alphabetical characters in the string, returns the string with all the extra characters in a bracket.

For example, the input "aaaabbcdefffffffg" should return "aa[aa]bbcdeff[fffff]g"

Please also ensure that the input is a string, and return "Please enter a valid string" if it is not.
*/
function stringParse(string){
  if (typeof string !== 'string') return "Please enter a valid string"
  let arr = []
  let str = ''
  for (let i=0;i<string.length;i++){
    if (string[i-1]===string[i]){
      str+=string[i]
    }else {
      arr.push(str)
      str=string[i]
    }
    if (i===string.length-1){arr.push(str)}
  }
  return arr.map(v=>v.length>2?v.slice(0,2)+'['+v.slice(2)+']':v).join``
}


================================================
FILE: Braking well.js
================================================
/*
Description:
Braking distance d1 is the distance a vehicle will go from the point when it brakes to when it comes to a complete stop. It depends on the original speed v and on the coefficient of friction mu between the tires and the road surface.

The braking distance is one of two principal components of the total stopping distance. The other component is the reaction distance, which is the product of the speed and the perception-reaction time of the driver.

The kinetic energy E is 0.5*m*v**2, the work W given by braking is mu*m*g*d1. Equalling E and W gives the braking distance: d1 = v*v / 2*mu*g where g is the gravity of Earth and m the vehicle's mass.

We have v in km per hour, g as 9.81 m/s/s and in the following we suppose that the reaction time is constant and equal to 1 s. The coefficient mu is dimensionless.

There are two tasks.

The first one is to calculate the total stopping distance in meters given v, mu (and the reaction time t = 1).

dist(v, mu) -> d = total stopping distance

The second task is to calculate v in km per hour knowing d in meters and mu with the supposition that the reaction time is still t = 1.

speed(d, mu) -> v such that dist(v, mu) = d.

#Examples:

dist(100, 0.7) -> 83.9598760937531

speed(83.9598760937531, 0.7) -> 100.0

#Notes:

Remember to convert the velocity from km/h to m/s or from m/s in km/h when necessary.
Don't forget the reaction time t: t = 1
Don't truncate or round your results. See in "RUN EXAMPLES" the function assertFuzzyEquals.
Shell: only dist is tested.
*/
const G = 9.81
function dist(v, mu) {								
   let u = v*5/18;
		return (u*u)/(2 * mu * G) + u;	
}

function speed(d, mu) {							
      let b = -2 * mu * G;
	    return (3.6 * (b + Math.sqrt(b*b - 4*b*d) ) / 2);
}


================================================
FILE: Break camelCase.js
================================================
/*
Complete the solution so that the function will break up camel casing, using a space between words.

Example
solution('camelCasing') // => should return 'camel Casing'
*/

function solution(string) {
  return(string.replace(/([A-Z])/g, ' $1'));

}


================================================
FILE: Breaking search bad.js
================================================
/*
Description:
We have a search function who return an array of titles that match the String passed as an argument.

var titles = ['Rocky 1', 'Rocky 2', 'My Little Poney'];
search('ock')  // ==> should return ['Rocky 1', 'Rocky 2']
But the function return some weird result and skip some of the matching results.

Does the function have special movie taste ?

Let's figure out !
*/
function search(searchTerm) {
  return TITLES.filter(v=>new RegExp(searchTerm, 'i').test(v))
} 


================================================
FILE: Build Tower
================================================
/*
Description:
Build Tower
Build Tower by the following given argument:
number of floors (integer and always greater than 0).

Tower block is represented as *

Python: return a list;
JavaScript: returns an Array;
C#: returns a string[];
PHP: returns an array;
C++: returns a vector<string>;
Haskell: returns a [String];
Ruby: returns an Array;
Have fun!

for example, a tower of 3 floors looks like below

[
  '  *  ', 
  ' *** ', 
  '*****'
]
and a tower of 6 floors looks like below

[
  '     *     ', 
  '    ***    ', 
  '   *****   ', 
  '  *******  ', 
  ' ********* ', 
  '***********'
]
Go challenge Build Tower Advanced once you have finished this :)
*/


function towerBuilder(n) {
  return [...Array(n)].map((_,i)=>" ".repeat(n-1-i)+"*".repeat(i*2+1)+" ".repeat(n-1-i))
}


================================================
FILE: Build Tower Advanced.js
================================================
/*
Description:
Build Tower Advanced
Build Tower by the following given arguments:
number of floors (integer and always greater than 0)
block size (width, height) (integer pair and always greater than (0, 0))

Tower block unit is represented as *

Python: return a list;
JavaScript: returns an Array;
Have fun!

for example, a tower of 3 floors with block size = (2, 3) looks like below

[
  '    **    ',
  '    **    ',
  '    **    ',
  '  ******  ',
  '  ******  ',
  '  ******  ',
  '**********',
  '**********',
  '**********'
]
and a tower of 6 floors with block size = (2, 1) looks like below

[
  '          **          ', 
  '        ******        ', 
  '      **********      ', 
  '    **************    ', 
  '  ******************  ', 
  '**********************'
]
Go take a look at Build Tower which is a more basic version :)
*/
function towerBuilder(nFloors, nBlockSz) {
  const tower = []
  for (let i=0;i<nFloors;i++){
    for (let j=0;j<nBlockSz[1];j++){
      tower.push(' '.repeat((nFloors-i)*nBlockSz[0]-nBlockSz[0])+'*'.repeat(nBlockSz[0]+(i*(nBlockSz[0]*2)))+' '.repeat((nFloors-i)*nBlockSz[0]-nBlockSz[0]))
    }
  }
  return tower
}


================================================
FILE: Build a pile of Cubes
================================================
/*
Description:
Your task is to construct a building which will be a pile of n cubes. The cube at the bottom will have a volume of n^3, the cube above will have volume of (n-1)^3 and so on until the top which will have a volume of 1^3.

You are given the total volume m of the building. Being given m can you find the number n of cubes you will have to build?

The parameter of the function findNb (find_nb, find-nb, findNb) will be an integer m and you have to return the integer n such as n^3 + (n-1)^3 + ... + 1^3 = m if such a n exists or -1 if there is no such n.

Examples:
findNb(1071225) --> 45
findNb(91716553919377) --> -1
mov rdi, 1071225
call find_nb            ; rax <-- 45

mov rdi, 91716553919377
call find_nb            ; rax <-- -1
*/


function findNb(m) {
let i=1;
let count=0;
while (m>0){
    m-=Math.pow(i,3)
    i++
    count++
    }
    
    
    return (m === 0) ? count : -1;
}


================================================
FILE: Buying a car
================================================
/*
Description:
Let us begin with an example:

A man has a rather old car being worth $2000. He saw a secondhand car being worth $8000. He wants to keep his old car until he can buy the secondhand one.

He thinks he can save $1000 each month but the prices of his old car and of the new one decrease of 1.5 percent per month. Furthermore this percent of loss increases by 0.5 percent at the end of every two months. Our man finds it difficult to make all these calculations.

Can you help him?

How many months will it take him to save up enough money to buy the car he wants, and how much money will he have left over?

Parameters and return of function:

parameter (positive int, guaranteed) startPriceOld (Old car price)
parameter (positive int, guaranteed) startPriceNew (New car price)
parameter (positive int, guaranteed) savingperMonth 
parameter (positive float or int, guaranteed) percentLossByMonth

nbMonths(2000, 8000, 1000, 1.5) should return [6, 766] or (6, 766)
where 6 is the number of months at the end of which he can buy the new car and 766 is the nearest integer to 766.158 (rounding 766.158 gives 766).

Note:

Selling, buying and saving are normally done at end of month. Calculations are processed at the end of each considered month but if, by chance from the start, the value of the old car is bigger than the value of the new one or equal there is no saving to be made, no need to wait so he can at the beginning of the month buy the new car:

nbMonths(12000, 8000, 1000, 1.5) should return [0, 4000]
nbMonths(8000, 8000, 1000, 1.5) should return [0, 0]
We don't take care of a deposit of savings in a bank:-)
*/

function nbMonths(startPriceOld, startPriceNew, savingperMonth, percentLossByMonth){
  if (startPriceOld>=startPriceNew) return [0,startPriceOld-startPriceNew] 
  var count=0;
  var money=startPriceOld;
  for (let i=1;money<=startPriceNew;i++){
  if (i%2==0){percentLossByMonth+=0.5}
    count++;
    startPriceOld = startPriceOld - (startPriceOld*(percentLossByMonth/100));
		startPriceNew = startPriceNew - ((startPriceNew*percentLossByMonth)/100);
		money = startPriceOld + (savingperMonth*count);
    };
   return [count,Math.round(money-startPriceNew)];
  
}


================================================
FILE: ByState.js
================================================
/*
Description:
Given a string with friends to visit in different states:

ad3="John Daggett, 341 King Road, Plymouth MA
Alice Ford, 22 East Broadway, Richmond VA
Sal Carpenter, 73 6th Street, Boston MA"
we want to produce a result that sorts the names by state and lists the name of the state followed by the name of each person residing in that state (people's names sorted). When the result is printed we get:

Massachusetts
.....^John Daggett 341 King Road Plymouth Massachusetts
.....^Sal Carpenter 73 6th Street Boston Massachusetts
^Virginia
.....^Alice Ford 22 East Broadway Richmond Virginia
Spaces not being always well seen, in the above result ^ means a white space.

Not printed, the resulting string will be:

"Massachusetts\n..... John Daggett 341 King Road Plymouth Massachusetts\n..... Sal Carpenter 73 6th Street Boston Massachusetts\n Virginia\n..... Alice Ford 22 East Broadway Richmond Virginia"
Notes
There can be a blank last line in the given string of adresses.
The tests only contains CA, MA, OK, PA, VA, AZ, ID, IN for states.
You can see another example in the "Sample tests".
States
For the lazy ones:

'AZ': 'Arizona',
'CA': 'California',
'ID': 'Idaho',
'IN': 'Indiana',
'MA': 'Massachusetts',
'OK': 'Oklahoma',
'PA': 'Pennsylvania',
'VA': 'Virginia'
*/
function byState(str) {
  let arr = str.replace(/,/g,"").split`\n`;
  let states = [["AZ","Arizona"],
                ["CA","California"],
                ["ID","Idaho"],
                ["IN","Indiana"],
                ["MA","Massachusetts"],
                ["OK","Oklahoma"],
                ["PA","Pennsylvania"],
                ["VA","Virginia"]];
  let res = "";
  states.forEach(([s,n]) => {
    let temp = arr.filter(x => x.slice(-2) === s).sort();
    if(temp.length){
      res += "\r\n " + n + "\r\n";
      res += temp.map(x => `..... ${x.slice(0,-3)} ${n}`).join`\r\n`;
    }
  });
  return res.slice(3);
}


================================================
FILE: Calculate Hypotenuse of Right-angled Triangle.js
================================================
/*
Description:
To solve this Kata, complete the function, calculateHypotenuse(a,b), which will return the length of the hyptenuse for a right angled triangle with the other two sides having a length equal to the inputs. More details:

The returned value should be a number rounded to three decimal places
An error (ArgumentException in C#) should be thrown if an invalid input is provided (inputs should both be numbers that are above zero)
calculateHypotenuse(1,1); // returns 1.414
calculateHypotenuse(3,4); // returns 5
calculateHypotenuse(-2,1); // throws error
calculateHypotenuse("one", "two"); // throws error
For more information on the hypotenuse, visit: http://en.wikipedia.org/wiki/Hypotenuse
*/

function calculateHypotenuse(a,b){
  if (typeof a !== 'number'||typeof b !== 'number') throw new Error('Not a Number')
  if (isNaN(a)||isNaN(b)) throw new Error('Not a Number')
  if (a<0||b<0) throw new Error('Less than 0')
  return Math.hypot(a,b).toFixed(3)
}


================================================
FILE: Calculate String Rotation.js
================================================
/*
Description:
Write a function that receives two strings and returns n, where n is equal to the number of characters we should shift the first string forward to match the second.

For instance, take the strings "fatigue" and "tiguefa". In this case, the first string has been rotated 5 characters forward to produce the second string, so 5 would be returned.

If the second string isn't a valid rotation of the first string, the method returns -1.
Examples:
``` "coffee", "eecoff" => 2 "eecoff", "coffee" => 4 "moose", "Moose" => -1 "isn't", "'tisn" => 2 "Esham", "Esham" => 0 "dog", "god" => -1 ```
For Swift, your function should return an Int?. So rather than returning -1 when the second string isn't a valid rotation of the first, return nil.

shiftedDiff("coffee", "eecoff") => 2
shiftedDiff("eecoff", "coffee") => 4
shiftedDiff("moose", "Moose") => nil
shiftedDiff("isn't", "'tisn") => 2
shiftedDiff("Esham", "Esham") => 0
shiftedDiff("dog", "god") => nil

*/
function shiftedDiff(first,second){
  for (let i=0;i<first.length;i++){
    if (first===second) return i;
    first=rotLeft(first, first.length-1)
  }
  return -1
}
function rotLeft(arr, n) {
     let arrTemp = arr.split(``)
     for (let i = 0; i < n; i++) {
         let temp = arrTemp.shift()
        arrTemp.push(temp)
     }
    return arrTemp.join(``)
}


================================================
FILE: Calculate number of inversions in array.js
================================================
/*
Description:
Array inversion indicates how far the array is from being sorted.

Inversions are pairs of elements in array, that are out of order.

Examples
countInversions([1,2,3,4]) // 0 inversions

countInversions([1,3,2,4]) // 1 inversion: 2 and 3

countInversions([4,1,2,3]) // 3 inversions: 4 and 1, 4 and 2, 4 and 3

countInversions([4,3,2,1]) // 6 inversions: 4 and 3, 4 and 2, 4 and 1, 3 and 2, 3 and 1, 2 and 1
Goal
The goal is to come up with a function that can calculate inversions for any arbitrary array
*/
function countInversions( array ){
  let sorted = array.slice().sort((a,b)=>a-b).join``
  let count = 0;
  for (let i=1;array.join``!==sorted;i++){
    for (let j=0;j<array.length;j++){
      if (array[j]<array[j-1]){
      let temp = array[j]
      array[j]=array[j-1]
      array[j-1]=temp
      count++
      }
    }
  }
  return count
}


================================================
FILE: Calculate the area of a regular n sides polygon inside a circle of radius r.js
================================================
/*
Description:
Write the following function:

function areaOfPolygonInsideCircle(circleRadius, numberOfSides)
It should calculate the area of a regular polygon of numberOfSides or number_of_sides sides inside a circle of radius circleRadius or circle_radius which passes through all the vertices of the polygon (such circle is called circumscribed circle or circumcircle). The answer should be a number rounded to 3 decimal places.

Input :: Output Examples

areaOfPolygonInsideCircle(3, 3) // returns 11.691

areaOfPolygonInsideCircle(5.8, 7) // returns 92.053

areaOfPolygonInsideCircle(4, 5) // returns 38.042
*/
function areaOfPolygonInsideCircle(r, s) {
    let angle = Math.PI / s
    let area = r * r * s * Math.sin(angle * 2) / 2
    return +area.toFixed(3)
}


================================================
FILE: Calculate the function f(x) for a simple linear sequence (Easy).js
================================================
/*
For any given linear sequence, calculate the function [f(x)] and return it as a string.

For example:

getFunction([0, 1, 2, 3, 4]) => "f(x) = x"
getFunction([0, 3, 6, 9, 12]) => "f(x) = 3x"
getFunction([1, 4, 7, 10, 13]) => "f(x) = 3x + 1"
Assumptions for this kata are:

the sequence argument will always contain 5 values equal to f(0) - f(4).
the function will always be in the format "nx +/- m", 'x +/- m', 'nx', 'x' or 'm'
if a non-linear sequence simply return 'Non-linear sequence' or Nothing in Haskell.
*/
function getFunction(seq) {
  let add = seq[0], mul = seq[1]-add, linear=seq.every(function(v,i){return v==i*mul+add});
  return linear ? "f(x) = "+ ( mul? (mul==1? '':mul==-1? "-":mul) +"x"+ (!add? "" : (add>0? " + ":" - ") +Math.abs(add)) : add ) : "Non-linear sequence"
}


================================================
FILE: Calculate the function f(x) for a simple linear sequence (Medium).js
================================================
/*
Description:
This is a follow-up from my previous Kata which can be found here: http://www.codewars.com/kata/5476f4ca03810c0fc0000098

This time, for any given linear sequence, calculate the function [f(x)] and return it as a function in Javascript or Lambda/Block in Ruby.

For example:

getFunction([0, 1, 2, 3, 4])(5) => 5
getFunction([0, 3, 6, 9, 12])(10) => 30
getFunction([1, 4, 7, 10, 13])(20) => 61
Assumptions for this kata are:

The sequence argument will always contain 5 values equal to f(0) - f(4).
The function will always be in the format "nx +/- m", 'x +/- m', 'nx', 'x' or 'm'
If a non-linear sequence simply return 'Non-linear sequence' for javascript, ruby, and python. For C#, throw an ArgumentException.
*/
function getFunction(sequence) {
  const n = sequence[1]-sequence[0]
  const check = sequence[1]-sequence[0]===sequence[2]-sequence[1]
  if (!check) return'Non-linear sequence'
  return (x)=>x*n+sequence[0]
}


================================================
FILE: Cambridge Word Scramble.js
================================================
/*
Description:
One of the first chain emails I ever received was about a supposed Cambridge University study that suggests your brain can read words no matter what order the letters are in, as long as the first and last letters of each word are correct.

Your task is to create a function that can take any string and randomly jumble the letters within each word while leaving the first and last letters of the word in place.

For example,

mixwords('Winter is coming') // returns 'Wntier is cminog' or 'Wtiner is conimg'
mixwords('Hey, friends!') // returns 'Hey, fierdns!' or 'Hey, fernids!'
All punctuation should remain in place
Words smaller than 3 letters should not change
Letters must be randomly moved (and so calling the function multiple times with the same string should return different values
Parameters that are not strings should return undefined
The tests do the following things to ensure a valid string is returned:

Check that the string returned is not equal to the string passed (you may have to revalidate the solution if your function randomly returns the same string)
Check that first and last letters of words remain in place
Check that punctuation remains in place
Checks string length remains the same
Checks the function returns undefined for non-strings
Checks that word interiors (the letters between the first and last) maintain the same letters, albeit in a different order
Checks that letters are randomly assigned.
*/
function mixwords(str){
   if (typeof str ==='string'){
     return str.replace(/[a-z]+/gi,v=>{
     if (v.length>2) return v.slice(0,1)+v.slice(1,-1).split``.sort((a,b)=>Math.random()-0.5).join``+v.slice(-1)
     return v
     })
   }
};


================================================
FILE: CamelCase Method.js
================================================
/*
Description:
Write simple .camelCase method (camel_case function in PHP, CamelCase in C# or camelCase in Java) for strings. All words must have their first letter capitalized without spaces.

For instance:

"hello case".camelCase() => HelloCase
"camel case word".camelCase() => CamelCaseWord
Don't forget to rate this kata! Thanks :)
*/

String.prototype.camelCase=function(){
  let arg = this.toString().trim().split(' ');
  let arr = arg.map((v,i,arr)=>v?v.slice(0,1).toUpperCase()+v.slice(1):v);
  return arr.join('');
}


================================================
FILE: CamelCase to underscore.js
================================================
/*
Description:
You wrote all your unit test names in camelCase. But some of your colleagues have troubles reading these long test names. So you make a compromise to switch to underscore separation.

To make these changes fast you wrote a class to translate a camelCase name into an underscore separated name.

Implement the ToUnderscore() method.

Example:

"ThisIsAUnitTest" => "This_Is_A_Unit_Test"

But of course there are always special cases...

You also have some calculation tests. Make sure the results don't get splitted by underscores. So only add an underscore in front of the first number.

Also Some people already used underscore names in their tests. You don't want to change them. But if they are not splitted correct you should adjust them.

Some of your colleagues mark their tests with a leading and trailing underscore. Don't remove this.

And of course you should handle empty strings to avoid unnecessary errors. Just return an empty string then.

Example:

"Calculate15Plus5Equals20" => "Calculate_15_Plus_5_Equals_20"

"This_Is_Already_Splitted_Correct" => "This_Is_Already_Splitted_Correct"

"ThisIs_Not_SplittedCorrect" => "This_Is_Not_Splitted_Correct"

"_UnderscoreMarked_Test_Name_" => _Underscore_Marked_Test_Name_"
*/
const toUnderScore = name => {
  return name.replace(/([A-Z]|\d+)/g,'_$1').replace(/^_/,'').replace(/__/g,'_')
}


================================================
FILE: Can you keep a secret?.js
================================================
/*
There's no such thing as private properties on a coffeescript object! But, maybe there are?

Implement a function createSecretHolder(secret) which accepts any value as secret and returns an object with ONLY two methods

getSecret() which returns the secret
setSecret() which sets the secret
obj = createSecretHolder(5)
obj.getSecret() # returns 5
obj.setSecret(2)
obj.getSecret() # returns 2
*/
function createSecretHolder(secret) {
  return {
  getSecret:function(){
    return secret
    },
  setSecret:function(v){
    secret=v}
  }
}


================================================
FILE: Case Reversal of Consecutive Duplicates.js
================================================
/*
Description:
The aim of this Kata is to write a function which will reverse the case of all consecutive duplicate letters in a string. That is, any letters that occur one after the other and are identical.

If the duplicate letters are lowercase then they must be set to uppercase, and if they are uppercase then they need to be changed to lowercase.

Examples:

reverseCase("puzzles")    Expected Result: "puZZles"
reverseCase("massive")    Expected Result: "maSSive"
reverseCase("LITTLE")     Expected Result: "LIttLE"
reverseCase("shhh")       Expected Result: "sHHH"
Arguments passed will include only alphabetical letters A–Z or a–z.
*/
function reverseCase(string) {
  return string.replace(/(\w)(\1)+/g,(v)=>v[0]===v[0].toLowerCase()?v.toUpperCase():v.toLowerCase())
}


================================================
FILE: Cat Kata, Part 1.js
================================================
/*
Description:
The story you are about to hear is true
Our cat, Balor, sadly died of cancer in 2015.

While he was alive, the three neighborhood cats Lou, Mustache Cat, and Raoul all recognized our house and yard as Balor's territory, and would behave respectfully towards him and each other when they would visit.

But after Balor died, gradually each of these three neighborhood cats began trying to claim his territory as their own, trying to drive the others away by growling, yowling, snarling, chasing, and even fighting, when one came too close to another, and no human was right there to distract or extract one of them before the situation could escalate.

It is sad that these otherwise-affectionate animals, who had spent many afternoons peacefully sitting and/or lying near Balor and each other on our deck or around our yard, would turn on each other like that. However, sometimes, if they are far enough away from each other, especially on a warm day when all they really want to do is pick a spot in the sun and lie in it, they will ignore each other, and once again there will be a Peaceable Kingdom.

Your Mission
In this, the first and simplest of a planned trilogy of cat katas :-), all you have to do is determine whether the distances between any visiting cats are large enough to make for a peaceful afternoon, or whether there is about to be an altercation someone will need to deal with by carrying one of them into the house or squirting them with water or what have you.

As input your function will receive a list of strings representing the yard as a grid, and an integer representing the minimum distance needed to prevent problems (considering the cats' current states of sleepiness). A point with no cat in it will be represented by a "-" dash. Lou, Mustache Cat, and Raoul will be represented by an upper case L, M, and R respectively. At any particular time all three cats may be in the yard, or maybe two, one, or even none.

If the number of cats in the yard is one or none, or if the distances between all cats are at least the minimum distance, your function should return True/true/TRUE (depending on what language you're using), but if there are two or three cats, and the distance between at least two of them is smaller than the minimum distance, your function should return False/false/FALSE.

Some examples
(The yard will be larger in the random test cases, but a smaller yard is easier to see and fit into the instructions here.)

In this first example, there is only one cat, so your function should return True.

["------------",
 "------------",
 "-L----------",
 "------------",
 "------------",
 "------------"], 10
In this second example, Mustache Cat is at the point yard[1][3] and Raoul is at the point yard[4][7] -- a distance of 5, so because the distance between these two points is smaller than the specified minimum distance of 6, there will be trouble, and your function should return False.

["------------",
 "---M--------",
 "------------",
 "------------",
 "-------R----",
 "------------"], 6
In this third example, Lou is at yard[0][11], Raoul is at yard[1][2], and Mustache Cat at yard[5][2]. The distance between Lou and Raoul is 9.05538513814, the distance between Raoul and Mustache Cat is 4, and the distance between Mustache Cat and Lou is 10.295630141 -- all greater than or equal to the specified minimum distance of 4, so the three cats will nap peacefully, and your function should return True.

["-----------L",
 "--R---------",
 "------------",
 "------------",
 "------------",
 "--M---------"], 4
Have fun!
*/
function peacefulYard(yd, d) {
  for(var pos=[],i=0;i<yd.length;i++)for(var j=0;j<yd[0].length;j++) if(yd[i][j]!="-") pos.push([i,j])
  return pos.every(x=>Math.min(...pos.map(y=>(Math.pow(x[0]-y[0],2)+Math.pow(x[1]-y[1],2))||d*d))>=d*d)
}


================================================
FILE: Cat and Mouse - Harder Version.js
================================================
/*
Description:
You will be given a string (x) featuring a cat 'C', a dog 'D' and a mouse 'm'. The rest of the string will be made up of '.'.

You need to find out if the cat can catch the mouse from it's current position. The cat can jump (j) characters.

Also, the cat cannot jump over the dog.

So:

if j = 5:

..C.....m. returns 'Caught!' <-- not more than j characters between

.....C............m...... returns 'Escaped!' <-- as there are more than j characters between the two, the cat can't jump far enough

if j = 10:

...m.........C...D returns 'Caught!' <--Cat can jump far enough and jump is not over dog

...m....D....C....... returns 'Protected!' <-- Cat can jump far enough, but dog is in the way, protecting the mouse

Finally, if all three animals are not present, return 'boring without all three'
*/
function catMouse(x, j){
  if (!x.includes('D')||!x.includes('C')||!x.includes('m')) return "boring without all three"
  if (Math.abs(x.indexOf('C')-x.indexOf('m'))>j) return "Escaped!"
  if (x.replace(/\./g,'')==='CDm'||x.replace(/\./g,'')==='mDC') return 'Protected!'
  return "Caught!"
}


================================================
FILE: Catalog.js
================================================
/*
Description:
You are given a small extract of a catalog:

s = "<prod><name>drill</name><prx>99</prx><qty>5</qty></prod>

<prod><name>hammer</name><prx>10</prx><qty>50</qty></prod>

<prod><name>screwdriver</name><prx>5</prx><qty>51</qty></prod>

<prod><name>table saw</name><prx>1099.99</prx><qty>5</qty></prod>

<prod><name>saw</name><prx>9</prx><qty>10</qty></prod>

...
(prx stands for price, qty for quantity) and an article i.e "saw".

The function catalog(s, "saw") returns the line(s) corresponding to the article with $ before the prices:

"table saw > prx: $1099.99 qty: 5\nsaw > prx: $9 qty: 10\n..."
If the article is not in the catalog return "Nothing".

Notes
There is a blank line between two lines of the catalog.
The same article may appear more than once. If that happens return all the lines concerned by the article (in the same order as in the catalog).
The line separator of results may depend on the language \nor \r\n. You can see examples in the "Sample tests".
*/
function catalog(s, article) {
  return s.match(new RegExp(`name.+${article}.+\/qty`,'g'))?s.match(new RegExp(`name.+${article}.+\/qty`,'g'))
  .map(v=>v.replace(/<\/name><prx>/,' > prx: $'))
  .map(v=>v.replace(/name>/,''))
  .map(v=>v.replace(/<\/prx><qty>/,' qty: '))
  .map(v=>v.replace(/<\/qty/,'')).join`\r\n`
  :'Nothing'
}


================================================
FILE: Chain Evaluation.js
================================================
/*
Description:
Method chaining is a very interesting way to keep your program clean.

As a part of this Kata, you need to create functions such that one could evaluate the following expression:

(3).add(5).multiply(2)
The above expression evaluates to be 16.

You need to implement the following methods:

add
subtract
multiply
divide
square
After you're done, one could chain these five methods to create chains of almost any length.
*/
Number.prototype.add=function(x){ return this+x};
Number.prototype.subtract=function(x){ return this-x;}
Number.prototype.multiply=function(x){ return this*x;}
Number.prototype.divide=function(x){ return this/x;}
Number.prototype.square=function(){ return this*this;}


================================================
FILE: Character frequency.js
================================================
/*
Description:
Write a function that takes a piece of text in the form of a string and returns the letter frequency count for the text. This count excludes numbers, spaces and all punctuation marks. Upper and lower case versions of a character are equivalent and the result should all be in lowercase.

The function should return a list of tuples (in Python) or arrays (in other languages) sorted by the most frequent letters first. The Rust implementation should return an ordered BTreeMap. Letters with the same frequency are ordered alphabetically. For example:

  letterFrequency('aaAabb dddDD hhcc')
will return

  [['d',5], ['a',4], ['b',2], ['c',2], ['h',2]]
Letter frequency analysis is often used to analyse simple substitution cipher texts like those created by the Caesar cipher.
*/
function letterFrequency(text){
  let str=text.toLowerCase().replace(/[^a-z]\s*/gi,'').split(``).sort();
  if (str.length===0) return []
  let arr=[];
  let obj={};
  str.map(v=>obj[v]=obj[v]?obj[v]+1:1)
  obj=JSON.stringify(obj).slice(1,-1).replace(/"/g,'').split(',')
  .map(v=>arr.push([v.split(':')[0],v.split(':')[1]*1]))
  return arr.sort((a,b)=>b[1]-a[1]||a[0].localeCompare(b[0]))
}


================================================
FILE: Character limits: How long is your piece of string?.js
================================================
/*
Description:
Cara is applying for several different jobs. The online application forms ask her to respond within a specific character count. Cara needs to check that her answers fit into the character limit.

Annoyingly, some application forms count spaces as a character, and some don't.

Your challenge:

Write Cara a function charCheck() with the arguments:

"text": a string containing Cara's answer for the question
"max": a number equal to the maximum number of characters allowed in the answer
"spaces": a boolean which is True if spaces are included in the character count and False if they are not
The function charCheck() should return an array: [True, "Answer"] , where "Answer" is equal to the original text, if Cara's answer is short enough.

If her answer "text" is too long, return an array: [False, "Answer"]. The second element should be the original "text" string truncated to the length of the limit.

When the "spaces" argument is False, you should remove the spaces from the "Answer".

For example:

charCheck("Cara Hertz", 10, True) should return [ True, "Cara Hertz" ]
charCheck("Cara Hertz", 9, False) should return [ True, "CaraHertz" ]
charCheck("Cara Hertz", 5, True) should return [ False, "Cara " ]
charCheck("Cara Hertz", 5, False) should return [ False, "CaraH" ]
*/
function charCheck(text, max, spaces){
  if (!spaces){
    text=text.replace(/\s+/g,'')
  }
  return [text.length<=max,text.slice(0,max)]
};


================================================
FILE: Character with longest consecutive repetition.js
================================================
/*
Description:
For a given string s find the character c with longest consecutive repetition and return a tuple (c, l) (in Haskell Just (Char, Int), in C# Tuple<char?, int>, in Shell a String of comma-separated values c,l, in JavaScript [c,l], in Ruby [c, l], in Groovy [c, l]) where l is the length of the repetition. If there are two or more characters with the same l return the first.

For empty string return ('', 0) (in Haskell Nothing, in C# Tuple<char, int>(null, 0), in Shell ,0, in JavaScript ["",0], in Ruby ["", 0], in Groovy ["", 0]).

Happy coding! :)
*/
function longestRepetition(s) {
  let str='';
  let count=1;
  let arr = []
  for (let i=0;i<s.length;i++){
    if (s[i]===s[i+1]){
      count++
    } else {
      if (arr.every(v=>v<count)){
      str=s[i]+count
      }
      arr.push(count)
      count=1
    }
  }
  return !str?['',0]:[str.slice(0,1),str.slice(1)*1];
}


================================================
FILE: Check if two words are isomorphic to each other.js
================================================
/*
Description:
Two strings a and b are called isomorphic if there is a one to one mapping possible for every character of a to every character of b. And all occurrences of every character in a map to same character in b.

Task
In this kata you will create a function that return True if two given strings are isomorphic to each other, and False otherwise. Remember that order is important.

Your solution must be able to handle words with more than 10 characters.

Example
True:

CBAABC DEFFED
XXX YYY
RAMBUNCTIOUSLY THERMODYNAMICS
False:

AB CC
XXY XYY
ABAB CD
*/
function isomorph(a, b) {
  const dict = {};
  const dict2 = {};
  let f1 = true
  let f2 = true
  a.split``.map((v,i)=>{
    if (!dict[v]){
      dict[v]=b[i]
    } else {
      if (dict[v]!=b[i]) f1=false
    }
  })
  b.split``.map((v,i)=>{
    if (!dict2[v]){
      dict2[v]=a[i]
    } else {
      if (dict2[v]!=a[i]) f2=false
    }
  })
  return f1&&f2
}


================================================
FILE: Checkerboard Generation.js
================================================
/*
Description:
Checkerboard
Write a method checkerboard/Checkerboard which takes an integer size and returns a checkerboard of dimensions size x size. There are two colored squares on the checkerboard. Red squares are represented by the string [r] and black squares are represented by the string [b]. You MUST use the newline character \n to insert a newline at the end of each row.

The top left corner should be a red square.
Each row should have alternating squares in the row.
The starting square on each row should also alternate.
Assumptions
You can assume you are given an integer size.
You cannot assume positive values.
Thus you should return an empty string for negative sizes and a size of 0. (An empty string does not have a newline ending).
You should assume the newline character used is \n.
You MUST leave a newline character at the end of the full checkerboard thus allowing the board to be on its own if you were to run in a terminal.
Examples
checkerboard(8);
"[r][b][r][b][r][b][r][b]
[b][r][b][r][b][r][b][r]
[r][b][r][b][r][b][r][b]
[b][r][b][r][b][r][b][r]
[r][b][r][b][r][b][r][b]
[b][r][b][r][b][r][b][r]
[r][b][r][b][r][b][r][b]
[b][r][b][r][b][r][b][r]"
What We're Testing
We're testing loops and conditionals and aiming at beginners. There are many ways of achieving the solution so the correct solution will present a fairly basic version that should be more advanced than typical loop examples and has some extra challenge to the problem with the alternating on columns and rows.
*/
function checkerboard (size) {
    "use strict";
    if (size<=0) return '';
    let str='';
    for (let i=0;i<size;i++){
    if (i%2==0) str+='[r]'
    else str+='[b]'
    }
    let str1=''
    for (let i=0;i<size;i++){
    if (i%2==0) str1+='[b]'
    else str1+='[r]'
    }
    let answ=''
    for (let i=0;i<size;i++){
    if (i%2==0) answ+=str+'\n'
    else answ+=str1+'\n'
    }
    return answ
};


================================================
FILE: Checkered Board.js
================================================
/*
Description:
Write a function which takes one parameter representing the dimensions of a checkered board. The board will always be square, so 5 means you will need a 5x5 board.

The dark squares will be represented by a unicode white square, while the light squares will be represented by a unicode black square (the opposite colours ensure the board doesn't look reversed on code wars' dark background). It should return a string of the board with a space in between each square and taking into account new lines.

An even number should return a board that begins with a dark square. An odd number should return a board that begins with a light square.

The input is expected to be a whole number that's at least two, and returns false otherwise (Nothing in Haskell).

Examples:

checkeredBoard(5)
returns the string

■ □ ■ □ ■
□ ■ □ ■ □
■ □ ■ □ ■
□ ■ □ ■ □
■ □ ■ □ ■
There should be no trailing white space at the end of each line, or new line characters at the end of the string.

Note
Do not use HTML entities for the squares (e.g. □ for white square) as the code doesn't consider it a valid square. A good way to check is if your solution prints a correct checker board on your local terminal.

Ruby note: CodeWars has encoding issues with rendered unicode in Ruby. You'll need to use unicode source code (e.g. "\u25A0") instead of rendered unicode (e.g "■").
*/
function checkeredBoard(dimension) {
  if (dimension!==parseInt(dimension)||dimension<2) return false
  let light=true
  let arr=[]
  if (dimension%2===0){light=false}
  for (let i=0;i<dimension;i++){
      let temp=''
      for (let j=0;j<dimension;j++){
        if (!light){
          if (j%2==0){
            temp+='□ '
          }else {
            temp+='■ '
          }
        }else {
          if (j%2!=0){
            temp+='□ '
          }else {
            temp+='■ '
          }
        }
    }
      temp=temp.trim()
      arr.push(temp)
      light=!light
  }
  return arr.join`\n`
}


================================================
FILE: Checking Groups
================================================
/*
Description:
In English and programming, groups can be made using symbols such as () and {} that change meaning. However, these groups must be closed in the correct order to maintain correct syntax.

Your job in this kata will be to make a program that checks a string for correct grouping. For instance, the following groups are done correctly:

({})
[[]()]
[{()}]
The next are done incorrectly:

{(})
([]
[])
A correct string cannot close groups in the wrong order, open a group but fail to close it, or close a group before it is opened.

Your function will take an input string that may contain any of the symbols (), {} or [] to create groups.

It should return True if the string is empty or otherwise grouped correctly, or False if it is grouped incorrectly.
*/

function groupCheck(braces){
   while(/\(\)|\[\]|\{\}/g.test(braces)){braces = braces.replace(/\(\)|\[\]|\{\}/g,"")}
 return !braces.length;
 }


================================================
FILE: Chess Fun #1: Chess Board Cell Color.js
================================================
/*
Description:
Task
Given two cells on the standard chess board, determine whether they have the same color or not.

Example
For cell1 = "A1" and cell2 = "C3", the output should be true.



For cell1 = "A1" and cell2 = "H3", the output should be false.



Input/Output
[input] string cell1

[input] string cell2

[output] a boolean value

true if both cells have the same color, false otherwise.
*/
function chessBoardCellColor(cell1, cell2) {
 let obj={};
 
 for (let i=1;i<9;i++){
   if (i%2===0){
   obj[`A${i}`]=1
   obj[`B${i}`]=0
   obj[`C${i}`]=1
   obj[`D${i}`]=0
   obj[`E${i}`]=1
   obj[`F${i}`]=0
   obj[`G${i}`]=1
   obj[`H${i}`]=0
   } else {
   obj[`A${i}`]=0
   obj[`B${i}`]=1
   obj[`C${i}`]=0
   obj[`D${i}`]=1
   obj[`E${i}`]=0
   obj[`F${i}`]=1
   obj[`G${i}`]=0
   obj[`H${i}`]=1
   }
 }
 return obj[`${cell1}`]===obj[`${cell2}`] 
}


================================================
FILE: Chess Fun #2: Bishop And Pawn.js
================================================
/*
Description:
Task
Given the positions of a white bishop and a black pawn on the standard chess board, determine whether the bishop can capture the pawn in one move.

The bishop has no restrictions in distance for each move, but is limited to diagonal movement. Check out the example below to see how it can move:



Example
For bishop = "a1" and pawn = "c3", the output should be true.



For bishop = "h1" and pawn = "h3", the output should be false.



Input/Output
[input] string bishop

Coordinates of the white bishop in the chess notation.

[input] string pawn

Coordinates of the black pawn in the same notation.

[output] a boolean value

true if the bishop can capture the pawn, false otherwise.
*/
function bishopAndPawn(bishop, pawn) {
  let desk = []
  for (let i=0;i<8;i++){
    let temp = []
    for (let j=0;j<8;j++){
      temp.push(0)
    }
    desk.push(temp)
  }
  let mapL = {a:0,b:1,c:2,d:3,e:4,f:5,g:6,h:7}
  let mapN = {1:7,2:6,3:5,4:4,5:3,6:2,7:1,8:0}
  let b = bishop.split``
  let x = mapL[b[0]]
  let y = mapN[b[1]]
    for (let i=y,j=x;j>=0&&i>=0;j--,i--){
      desk[i][j]=1
    }
    for (let i=y,j=x;j<8&&i<8;j++,i++){
      desk[i][j]=1
    }
    for (let i=y,j=x;j<8&&i>=0;j++,i--){
      desk[i][j]=1
    }
    for (let i=y,j=x;j>=0&&i<8;j--,i++){
      desk[i][j]=1
    }
  let p = pawn.split``
  let xP = mapL[p[0]]
  let yP = mapN[p[1]]
  return desk[yP][xP]===1
}


================================================
FILE: Christmas Day.js
================================================
/*
Description:
Sometimes it's useful to know on which day of the week Christmas, the holly holiday, will occur.
Write a function which takes the date of Christmas, and outputs the day of the week it falls on. Just don't limit yourself to this year. 

Example:

findOutChristmasWeekday('2013 12 25') // returns 'Wednesday'
Only valid Christmas dates will be passed to the function.

Date parameter could be a string or a Date object. If it's a string here are possible date parameter formats:

'2013 12 25'
'12 25 2013'
'25 December 2013'
Note: calendar used in the kata is Gregorian.
*/

function findOutChristmasWeekday(date) {
  if (typeof date == "string") date = date.replace(/ /g, '-');
  return ['Sun', 'Mon','Tues','Wednes','Thurs','Fri','Satur'][new Date(date).getDay()] + "day";
}


================================================
FILE: Christmas tree.js
================================================
/*
Description:
Create a function christmasTree(height) that returns a christmas tree of the correct height

christmasTree(5) should return:

    *    
   ***   
  *****  
 ******* 
*********
Height passed is always an integer between 0 and 100.

Use \n for newlines between each line.

Pad with spaces so each line is the same length. The last line having only stars, no spaces.
*/
function christmasTree(height) {
  let str=[];
  for (let i=1;i<=height;i++){
  str.push(' '.repeat(height-i)+'*'.repeat((i - 1) * 2 + 1)+' '.repeat(height-i))
  }
  return str.join('\n')
}


================================================
FILE: Circularly Sorted Array.js
================================================
/*
Description:
Write a method, isCircleSorted(int[] A) (Java, JavaScript), or Array#circularly_sorted? (Ruby) that determines if A is circularly sorted. An Array is circularly sorted if the elements are sorted in ascending order, but displaced, or rotated, by any number of steps.

For Example:

// True:
isCircleSorted([2,3,4,5,0,1]);
isCircleSorted([4,5,6,9,1]);
isCircleSorted([10,11,6,7,9]);
isCircleSorted([1,2,3,4,5]);
isCircleSorted([5,7,43,987,-9,0]);


// False:
isCircleSorted([4,1,2,5]);
isCircleSorted([8,7,6,5,4,3]);
isCircleSorted([6,7,4,8]);
isCircleSorted([7,6,5,4,3,2,1]);
*/
function isCircleSorted( arr ){
    let cnt = 0;
    for (let i = 0; i < arr.length; i++) {
        if (arr[i] > arr[(i + 1) % arr.length]) {
            cnt++;
        }
    }
    return cnt === 1;
}


================================================
FILE: Clay Pigeon Shooting.js
================================================
/*
Description:
Pete and his mate Phil are out in the countryside shooting clay pigeons with a shotgun - amazing fun.

They decide to have a competition. 3 rounds, 2 shots each. Winner is the one with the most hits.

Some of the clays have something attached to create lots of smoke when hit, guarenteed by the packaging to generate 'real excitement!' (genuinely this happened). None of the explosive things actually worked, but for this kata lets say they did.

For each round you will receive the following format:

[{P1:'XX', P2:'XO'}, true]

That is an array containing an object and a boolean. Pl represents Pete, P2 represents Phil. X represents a hit and O represents a miss. If the boolean is true, any hit is worth 2. If it is false, any hit is worth 1.

Find out who won. If it's Pete, return 'Pete Wins!'. If it is Phil, return 'Phil Wins!'. If the scores are equal, return 'Draw!'.

Note that as there are three rounds, the actual input (x) will look something like this:

[[{P1:'XX', P2:'XO'}, true], [{P1:'OX', P2:'OO'}, false], [{P1:'XX', P2:'OX'}, true]]
*/
function shoot(x){
  let pete=0
  let phil=0
  for (let i=0;i<x.length;i++){
    x[i][0].P1.replace(/X/g,v=>x[i][1]?pete+=2:pete++)
    x[i][0].P2.replace(/X/g,v=>x[i][1]?phil+=2:phil++)
  }
  return pete>phil?'Pete Wins!':pete<phil?'Phil Wins!':'Draw!'
}


================================================
FILE: Clock in Mirror.js
================================================
/*
Description:
Peter can see a clock in the mirror from the place he sits in the office. When he saw the clock shows 12:22

alt text

He knows that the time is 11:38

alt text

in the same manner:

05:25 --> 06:35

01:50 --> 10:10

11:58 --> 12:02

12:01 --> 11:59

Please complete the function WhatIsTheTime(timeInMirror), where timeInMirror is the mirrored time (what Peter sees) as string.

Return the real time as a string.

Consider hours to be between 1 <= hour < 13.

So there is no 00:20, instead it is 12:20.

There is no 13:20, instead it is 01:20.
*/
function WhatIsTheTime(timeInMirror){
    let time = timeInMirror.split(':')
    let time2 = 60 - (parseInt(time[1]))
    let time1 = time2 == 60 ? 12 - parseInt(time[0]) : 12 - (parseInt(time[0]) +1 )
    let hour = time1 == 0 ? '12' : time1 == -1 ? '11' : time1 > 9 ? time1 : '0' + time1
    let minute = time2 < 10 ? '0' + time2 : time2 == 60 ? '00' : time2
    return `${hour}:${minute}`
}


================================================
FILE: Clocky Mc Clock-Face.js
================================================
/*
Description:
Story
Due to lack of maintenance the minute-hand has fallen off Town Hall clock face.

And because the local council has lost most of our tax money to a Nigerian email scam there are no funds to fix the clock properly.

Instead, they are asking for volunteer programmers to write some code that tell the time by only looking at the remaining hour-hand!

What a bunch of cheapskates!

Can you do it?

Kata
Given the angle (in degrees) of the hour-hand, return the time in HH:MM format. Round down to the nearest minute.

Examples
12:00 = 0 degrees
03:00 = 90 degrees
06:00 = 180 degrees
09:00 = 270 degrees
12:00 = 360 degrees
Notes
0 <= angle <= 360
*/
var whatTimeIsIt = function(angle) {
  let hour=Math.floor(angle/30)
  if (hour===0) hour=12
  let min=Math.floor(angle%30*2)
  return `${('0'+String(hour)).slice(-2)}:${('0'+String(min)).slice(-2)}`;
}


================================================
FILE: Closures and Scopes.js
================================================
/*
Description:
We want to create a function, which returns an array of functions, which return their index in the array. For better understanding, here an example:

var callbacks = createFunctions(5); // create an array, containing 5 functions

callbacks[0](); // must return 0
callbacks[3](); // must return 3
We already implemented that function, but when we actually run the code, the result doesn't look like what we expected. Can you spot, what's wrong with it? A test fixture is also available
*/
function createFunctions(n) {
  var callbacks = [];

  for (let i=0; i<n; i++) {
    callbacks.push(function() {
      return i;
    });
  }
  
  return callbacks;
}


================================================
FILE: Coding Meetup #10 - Higher-Order Functions Series - Create usernames.js
================================================
/*
Description:
Given the following input array:

var list1 = [
  { firstName: 'Emily', lastName: 'N.', country: 'Ireland', continent: 'Europe', age: 30, language: 'Ruby' },
  { firstName: 'Nor', lastName: 'E.', country: 'Malaysia', continent: 'Asia', age: 20, language: 'Clojure' }
];
write a function that adds the username property to each object in the input array:

[
  { firstName: 'Emily', lastName: 'N.', country: 'Ireland', continent: 'Europe', age: 30, language: 'Ruby', 
    username: 'emilyn1990' },
  { firstName: 'Nor', lastName: 'E.', country: 'Malaysia', continent: 'Asia', age: 20, language: 'Clojure', 
    username: 'nore2000' }
]
The value of the username property is composed by concatenating:

firstName in lower-case;
first letter of the lastName in lower-case; and
the birth year which for the purpose of this kata is calculated simply by subtracting age from the current year. Please make sure that your function delivers the correct birth year irrespective of when it will be executed, for example it should also work correctly for a meetup organised in 10-years-time. The example above assumes that the function is run in year 2020.
Notes:

The input array will always be valid and formatted as in the example above.
Age is represented by a number which can be any positive integer.
Lastname will always be one upper-cased letter followed by dot, e.g. 'N.'
Order of the objects in the array should be maintained but order of the properties in the individual objects does not matter.




This kata is part of the Coding Meetup series which includes a number of short and easy to follow katas which have been designed to allow mastering the use of higher-order functions. In JavaScript this includes methods like: forEach, filter, map, reduce, some, every, find, findIndex. Other approaches to solving the katas are of course possible.
*/
function addUsername(list) {
  return list.map(v=>{return{...v,username:(v.firstName.toLowerCase()+v.lastName.slice(0,1).toLowerCase()+(Date.prototype.getFullYear()-v.age).toString())}})
}


================================================
FILE: Coding Meetup #13 - Higher-Order Functions Series - Is the meetup language-diverse?.js
================================================
/*
Description:
You will be given an array of objects representing data about developers who have signed up to attend the next web development meetup that you are organising. Three programming languages will be represented: Python, Ruby and JavaScript.

Your task is to return either:

true if the number of meetup participants representing any of the three programming languages is ** at most 2 times higher than the number of developers representing any of the remaining programming languages**; or
false otherwise.
For example, given the following input array:

var list1 = [
  { firstName: 'Daniel', lastName: 'J.', country: 'Aruba', continent: 'Americas', age: 42, language: 'Python' },
  { firstName: 'Kseniya', lastName: 'T.', country: 'Belarus', continent: 'Europe', age: 22, language: 'Ruby' },
  { firstName: 'Sou', lastName: 'B.', country: 'Japan', continent: 'Asia', age: 43, language: 'Ruby' },
  { firstName: 'Hanna', lastName: 'L.', country: 'Hungary', continent: 'Europe', age: 95, language: 'JavaScript' },
  { firstName: 'Jayden', lastName: 'P.', country: 'Jamaica', continent: 'Americas', age: 18, language: 'JavaScript' },
  { firstName: 'Joao', lastName: 'D.', country: 'Portugal', continent: 'Europe', age: 25, language: 'JavaScript' }
];
your function should return false as the number of JavaScript developers (3) is 3 times higher than the number of Python developers (1). It can't be more than 2 times higher to be regarded as language-diverse.

Notes:

The strings representing all three programming languages will always be formatted in the same way (e.g. 'JavaScript' will always be formatted with upper-case 'J' and 'S'.
The input array will always be valid and formatted as in the example above.
Each of the 3 programming languages will always be represented.




This kata is part of the Coding Meetup series which includes a number of short and easy to follow katas which have been designed to allow mastering the use of higher-order functions. In JavaScript this includes methods like: forEach, filter, map, reduce, some, every, find, findIndex. Other approaches to solving the katas are of course possible.
*/
function isLanguageDiverse(list) {
  const arr = list.map(v=>v.language)
  const obj = {}
  arr.map(v=>obj[v]=obj[v]?obj[v]+1:1)
  const count = Object.values(obj).sort((a,b)=>b-a)
  const max = count.splice(0,1)
  return count.every(v=>v*2>=max)
}


================================================
FILE: Coding Meetup #15 - Higher-Order Functions Series - Find the odd names.js
================================================
/*
Description:
You will be given an array of objects representing data about developers who have signed up to attend the next coding meetup that you are organising.

Given the following input array:

var list1 = [
  { firstName: 'Aba', lastName: 'N.', country: 'Ghana', continent: 'Africa', age: 21, language: 'Python' },
  { firstName: 'Abb', lastName: 'O.', country: 'Israel', continent: 'Asia', age: 39, language: 'Java' }
];
write a function that when executed as findOddNames(list1) returns only the developers where if you add the ASCII representation of all characters in their first names, the result will be an odd number:

[
  { firstName: 'Abb', lastName: 'O.', country: 'Israel', continent: 'Asia', age: 39, language: 'Java' }
]
Explanation of the above:

Sum of ASCII codes of letters in 'Aba' is: 65 + 98 + 97 = 260 which is an even number
Sum of ASCII codes of letters in 'Abb' is: 65 + 98 + 98 = 261 which is an odd number
Notes:

Preserve the order of the original list.
Return an empty array [] if there is no developer with an "odd" name.
The input array and first names will always be valid and formatted as in the example above.




This kata is part of the Coding Meetup series which includes a number of short and easy to follow katas which have been designed to allow mastering the use of higher-order functions. In JavaScript this includes methods like: forEach, filter, map, reduce, some, every, find, findIndex. Other approaches to solving the katas are of course possible.
*/
function findOddNames(list) {
  return list.filter(v=>v.firstName.split``.reduce((a,b)=>a+b.charCodeAt(),0)%2!==0)
}


================================================
FILE: Coding Meetup #16 - Higher-Order Functions Series - Ask for missing details.js
================================================
/*
Description:
You will be given an array of objects representing data about developers who have signed up to attend the next coding meetup that you are organising.

Given the following input array:

var list1 = [
  { firstName: null, lastName: 'I.', country: 'Argentina', continent: 'Americas', age: 35, language: 'Java' },
  { firstName: 'Lukas', lastName: 'X.', country: 'Croatia', continent: 'Europe', age: 35, language: null },
  { firstName: 'Madison', lastName: 'U.', country: 'United States', continent: 'Americas', age: 32, language: 'Ruby' } 
];
write a function that

1) adds the question property to each object in the input array where the developer has not provided the relevant details (marked with a null value). The value of the question property should be the following string:

Hi, could you please provide your <property name>.

2) and returns only the developers with missing details:

[
  { firstName: null, lastName: 'I.', country: 'Argentina', continent: 'Americas', age: 35, language: 'Java', 
  question: 'Hi, could you please provide your firstName.' },
  { firstName: 'Lukas', lastName: 'X.', country: 'Croatia', continent: 'Europe', age: 35, language: null, 
  question: 'Hi, could you please provide your language.' }
]
Notes:

At most only one of the values will be null.
Preserve the order of the original list.
Return an empty array [] if there is no developer with missing details.
The input array will always be valid and formatted as in the example above.




This kata is part of the Coding Meetup series which includes a number of short and easy to follow katas which have been designed to allow mastering the use of higher-order functions. In JavaScript this includes methods like: forEach, filter, map, reduce, some, every, find, findIndex. Other approaches to solving the katas are of course possible.
*/
function askForMissingDetails(list) {
  let arr = [];
  list.map(list=>{
  for (let i in list){
    if (list[i]===null){
      list={...list,question:`Hi, could you please provide your ${i}.`}
      arr.push(list)
    }
  }})
  return arr 
}


================================================
FILE: Coding Meetup #7 - Higher-Order Functions Series - Find the most senior developer.js
================================================
/*
Description:
You will be given an array of objects representing data about developers who have signed up to attend the next coding meetup that you are organising.

Your task is to return an array which includes the developer who is the oldest. In case of a tie, include all same-age senior developers listed in the same order as they appeared in the original input array.

For example, given the following input array:

var list1 = [
  { firstName: 'Gabriel', lastName: 'X.', country: 'Monaco', continent: 'Europe', age: 49, language: 'PHP' },
  { firstName: 'Odval', lastName: 'F.', country: 'Mongolia', continent: 'Asia', age: 38, language: 'Python' },
  { firstName: 'Emilija', lastName: 'S.', country: 'Lithuania', continent: 'Europe', age: 19, language: 'Python' },
  { firstName: 'Sou', lastName: 'B.', country: 'Japan', continent: 'Asia', age: 49, language: 'PHP' },
];
your function should return the following array:

[
  { firstName: 'Gabriel', lastName: 'X.', country: 'Monaco', continent: 'Europe', age: 49, language: 'PHP' },
  { firstName: 'Sou', lastName: 'B.', country: 'Japan', continent: 'Asia', age: 49, language: 'PHP' },
]
Notes:

The input array will always be valid and formatted as in the example above.




This kata is part of the Coding Meetup series which includes a number of short and easy to follow katas which have been designed to allow mastering the use of higher-order functions. In JavaScript this includes methods like: forEach, filter, map, reduce, some, every, find, findIndex. Other approaches to solving the katas are of course possible.
*/
function findSenior(list) {
  let max = Math.max(...list.map(v=>v.age))
  return list.filter(v=>v.age===max)
}


================================================
FILE: Coding Meetup #8 - Higher-Order Functions Series - Will all continents be represented?.js
================================================
/*
Description:
You will be given an array of objects (associative arrays in PHP) representing data about developers who have signed up to attend the next coding meetup that you are organising.

Your task is to return:

true if all of the following continents / geographic zones will be represented by at least one developer: 'Africa', 'Americas', 'Asia', 'Europe', 'Oceania'.
false otherwise.
For example, given the following input array:

var list1 = [
  { firstName: 'Fatima', lastName: 'A.', country: 'Algeria', continent: 'Africa', age: 25, language: 'JavaScript' },
  { firstName: 'Agustín', lastName: 'M.', country: 'Chile', continent: 'Americas', age: 37, language: 'C' },
  { firstName: 'Jing', lastName: 'X.', country: 'China', continent: 'Asia', age: 39, language: 'Ruby' },
  { firstName: 'Laia', lastName: 'P.', country: 'Andorra', continent: 'Europe', age: 55, language: 'Ruby' },
  { firstName: 'Oliver', lastName: 'Q.', country: 'Australia', continent: 'Oceania', age: 65, language: 'PHP' },
];
your function should return true as there is at least one developer from the required 5 geographic zones.

Notes:

The input array and continent names will always be valid and formatted as in the list above for example 'Africa' will always start with upper-case 'A'.




This kata is part of the Coding Meetup series which includes a number of short and easy to follow katas which have been designed to allow mastering the use of higher-order functions. In JavaScript this includes methods like: forEach, filter, map, reduce, some, every, find, findIndex. Other approaches to solving the katas are of course possible.
*/
function allContinents(list) {
  return ['Africa', 'Americas', 'Asia', 'Europe', 'Oceania'].every(x => list.some(y => x==y.continent));
}


================================================
FILE: Coding Meetup #9 - Higher-Order Functions Series - Is the meetup age-diverse?.js
================================================
/*
Description:
You will be given an array of objects (associative arrays in PHP) representing data about developers who have signed up to attend the next coding meetup that you are organising.

Your task is to return:

true if developers from all of the following age groups have signed up: teens, twenties, thirties, forties, fifties, sixties, seventies, eighties, nineties, centenarian (at least 100 years young).
false otherwise.
For example, given the following input array:

var list1 = [
  { firstName: 'Harry', lastName: 'K.', country: 'Brazil', continent: 'Americas', age: 19, language: 'Python' },
  { firstName: 'Kseniya', lastName: 'T.', country: 'Belarus', continent: 'Europe', age: 29, language: 'JavaScript' },
  { firstName: 'Jing', lastName: 'X.', country: 'China', continent: 'Asia', age: 39, language: 'Ruby' },
  { firstName: 'Noa', lastName: 'A.', country: 'Israel', continent: 'Asia', age: 40, language: 'Ruby' },
  { firstName: 'Andrei', lastName: 'E.', country: 'Romania', continent: 'Europe', age: 59, language: 'C' },
  { firstName: 'Maria', lastName: 'S.', country: 'Peru', continent: 'Americas', age: 60, language: 'C' },
  { firstName: 'Lukas', lastName: 'X.', country: 'Croatia', continent: 'Europe', age: 75, language: 'Python' },
  { firstName: 'Chloe', lastName: 'K.', country: 'Guernsey', continent: 'Europe', age: 88, language: 'Ruby' },
  { firstName: 'Viktoria', lastName: 'W.', country: 'Bulgaria', continent: 'Europe', age: 98, language: 'PHP' },
  { firstName: 'Piotr', lastName: 'B.', country: 'Poland', continent: 'Europe', age: 128, language: 'JavaScript' }
];
your function should return true as there is at least one developer from each age group.

Notes:

The input array will always be valid and formatted as in the example above.
Age is represented by a number which can be any positive integer up to 199.




This kata is part of the Coding Meetup series which includes a number of short and easy to follow katas which have been designed to allow mastering the use of higher-order functions. In JavaScript this includes methods like: forEach, filter, map, reduce, some, every, find, findIndex. Other approaches to solving the katas are of course possible.
*/
function isAgeDiverse(list) {
  const check = [0,0,0,0,0,0,0,0,0,0]
  list.map(v=>{
    const age=v.age;
    age>9&&age<20?check[0]=1:0;
    age>19&&age<30?check[1]=1:0;
    age>29&&age<40?check[2]=1:0;
    age>39&&age<50?check[3]=1:0;
    age>49&&age<60?check[4]=1:0;
    age>59&&age<70?check[5]=1:0;
    age>69&&age<80?check[6]=1:0;
    age>79&&age<90?check[7]=1:0;
    age>89&&age<100?check[8]=1:0;
    age>100?check[9]=1:0;
  })
  return check.every(v=>v===1)
}


================================================
FILE: Collatz.js
================================================
/*
Description:
Preface
A collatz sequence, starting with a positive integern, is found by repeatedly applying the following function to n until n == 1 :

collatz sequence
 n = { n / 2 for even n ;
      3n + 1 for odd n }
=======

A more detailed description of the collatz conjecture may be found on Wikipedia.

The Problem
Create a function collatz that returns a collatz sequence string starting with the positive integer argument passed into the function, in the following form:

"X0->X1->...->XN"

Where Xi is each iteration of the sequence and N is the length of the sequence.

Sample Input
collatz(4); // should return "4->2->1"
collatz(3); // should return "3->10->5->16->8->4->2->1"
Don't worry about invalid input. Arguments passed into the function are guaranteed to be valid integers >= 1.
*/
function collatz(n){
  let num=[];
  for (let i=n;;){
    if (i===1){
    num.push(i)
    break
    }
    if (i%2===0) {
    num.push(i)
    i=i/2
    } else {
    num.push(i)
    i=i*3+1
    }
  }
  return num.join('->')
}


================================================
FILE: Color Choice.js
================================================
/*
Description:
You know combinations: for example, if you take 5 cards from a 52 cards deck you have 2,598,960 different combinations.

In mathematics the number of x combinations you can take from a set of n elements is called the binomial coefficient of n and x, or more often n choose x. The formula to compute m = n choose x is: m = n! / (x! * (n - x)!) where ! is the factorial operator.

You are a renowned poster designer and painter. You are asked to provide 6 posters all having the same design each in 2 colors. Posters must all have a different color combination and you have the choice of 4 colors: red, blue, yellow, green. How many colors can you choose for each poster?

The answer is two since 4 choose 2 = 6. The combinations will be: {red, blue}, {red, yellow}, {red, green}, {blue, yellow}, {blue, green}, {yellow, green}.

Now same question but you have 35 posters to provide and 7 colors available. How many colors for each poster? If you take combinations 7 choose 2 you will get 21 with the above formula. But 21 schemes aren't enough for 35 posters. If you take 7 choose 5 combinations you will get 21 too. Fortunately if you take 7 choose 3 or 7 choose 4 combinations you get 35 and so each poster will have a different combination of 3 colors or 5 colors. You will take 3 colors because it's less expensive.

Hence the problem is:

knowing m (number of posters to design), knowing n (total number of available colors), let us search x (number of colors for each poster so that each poster has a unique combination of colors and the number of combinations is exactly the same as the number of posters).

In other words we must find x such as n choose x = m (1) for a given m and a given n; m >= 0 and n > 0. If many x are solutions give as result the smallest x. It can happen that when m is given at random there are no x satisfying equation (1) then return -1.

Examples:

checkchoose(6, 4) --> 2
checkchoose(4, 4) --> 1
checkchoose(4, 2) --> -1
checkchoose(35, 7) --> 3
checkchoose(36, 7) --> -1

a = 47129212243960
checkchoose(a, 50) --> 20
checkchoose(a + 1, 50) --> -1
*/
function checkchoose(m, n) {
  let x = 1;
  for (let i = 1; i < n; i++) {
    x = Math.round(x * (n + 1 - i) / i)
    if (x == m) 
      return i;
  }
  return -1;
}


================================================
FILE: Combinator Flip.js
================================================
/*
Description:
Create a combinator function named flip that takes a function as an argument and returns that function with it's arguments reversed.

For example:

flip(print)(4,5) // returns "5 -> 4"
function print(a,b) {
  return a + " -> " + b;
}
The idea is to reverse any number of arguments using a higher order function, without any concern for the function being passed into it.
*/
function flip(fn) {
    return (...args)=>fn(...(args.reverse()))
}


================================================
FILE: Compare Versions.js
================================================
/*
Description:
Karan's company makes software that provides different features based on the version of operating system of the user.

For finding which version is more recent, Karan uses the following method:

function compareVersions (version1, version2) {
  return parseFloat(version1) >= parseFloat(version2);
}
While this function worked for OS versions 10.6, 10.7, 10.8 and 10.9, the Operating system company just released OS version 10.10.

Karan's function fails for the new version:

compareVersions ("10.9", "10.10");       // returns true, while it should return false
Karan now wants to spend some time to right a more robust version comparison function that works for any future version/sub-version updates.

Help Karan write this function. Here are a few sample cases:

compareVersions("11", "10");                    // returns true
compareVersions("11", "11");                    // returns true
compareVersions("10.4.6", "10.4");              // returns true
compareVersions("10.4", "11");                  // returns false
compareVersions("10.4", "10.10");               // returns false
compareVersions("10.4.9", "10.5");              // returns false
It can be assumed that version strings are non empty and only contain numeric literals and the character '.'
*/
function compareVersions (version1, version2) {
    let arr1 = version1.split('.');
    let arr2 = version2.split('.');

    let maxLength = Math.max(arr1.length, arr2.length);

    for (let i = 0; i < maxLength; i++) {
        if (Number(arr1[i] || 0) < Number(arr2[i] || 0)) {
            return false;
        }
    } return true;
}


================================================
FILE: Compare powers.js
================================================
/*
Description:
You certainly can tell which is the larger number between 210 and 215.

But what about, say, 210 and 310? You know this one too.

Things tend to get a bit more complicated with both different bases and exponents: which is larger between 39 and 56?

Well, by now you have surely guessed that you have to build a function to compare powers, returning -1 if the first member is larger, 0 if they are equal, 1 otherwise; powers to compare will be provided in the [base, exponent] format:

comparePowers([2,10],[2,15])===1
comparePowers([2,10],[3,10])===1
comparePowers([2,10],[2,10])===0
comparePowers([3,9],[5,6])===-1
comparePowers([7,7],[5,8])===-1
Only positive integers will be tested, incluing bigger numbers - you are warned now, so be diligent try to implement an efficient solution not to drain too much on CW resources ;)!
*/
function comparePowers([a,b],[x,y]){
  let f =Math.log10(a)*b;
  let s =Math.log10(x)*y;
  return f===s?0:f>s?-1:1
}


================================================
FILE: Compare section numbers.js
================================================
/*
Description:
Section numbers are strings of dot-separated integers. The highest level sections (chapters) are numbered 1, 2, 3, etc. Second level sections are numbered 1.1, 1.2, 1.3, 2.1, 2.2, 2.3, etc. Next level sections are numbered 1.1.1, 1.1.2, 1.1.2, 1.2.1, 1.2.2, erc. There is no bound on the number of sections a document may have, nor is there any bound on the number of levels.

A section of a certain level may appear directly inside a section several levels higher without the levels between. For example, section 1.0.1 may appear directly under section 1, without there being any level 2 section. Section 1.1 comes after section 1.0.1. Sections with trailing ".0" are considered to be the same as the section with the trailing ".0" truncated. Thus, section 1.0 is the same as section 1, and section 1.2.0.0 is the same as section 1.2.

Write a function cmp(section1, section2) that returns -1, 0, or 1 depending on whether section1 is before, same as, or after section2 respectively.
*/
function cmp(section1,section2) {
  const one = section1.split('.');
  const two = section2.split('.');

  for (let i = 0; i < Math.max(one.length, two.length); i++) {
    const s1 = +one[i] || 0;
    const s2 = +two[i] || 0;
    if (s1 > s2) return 1;
    else if (s2 > s1) return -1;
  }
  return 0;
}


================================================
FILE: Complete Fibonacci Series.js
================================================
/*
Description:
The function 'fibonacci' should return an array of fibonacci numbers. The function takes a number as an argument to decide how many no. of elements to produce. If the argument is less than or equal to 0 then return empty array

Example:

fibonacci(4); // should return [0,1,1,2]
fibonacci(-1); // should return []
*/
function fibonacci(n) {
 if (n<1) return [];
 if (n<2) return [0];
 let arr=[0,1];
 for (let i=2;i<n;i++){
 arr.push(arr[i-2]+arr[i-1])
 }
 return arr
}


================================================
FILE: Complete The Pattern #12.js
================================================
/*
###Task:

You have to write a function pattern which returns the following Pattern(See Examples) upto (2n-1) rows, where n is parameter.

Note:Returning the pattern is not the same as Printing the pattern.
####Parameters:

pattern(        n        );
                ^                     
                |                     
         Term upto which   
       Basic Pattern(this)     
            should be         
             created            
####Rules/Note:

If n < 1 then it should return "" i.e. empty string.
The length of each line is same, and is equal to the length of longest line in the pattern i.e (2n-1).
Range of Parameters (for the sake of CW Compiler) :
n ∈ (-∞,100]
###Examples:

pattern(5):

  1       1
   2     2 
    3   3  
     4 4   
      5    
     4 4   
    3   3  
   2     2 
  1       1
pattern(10):

  1                 1
   2               2 
    3             3  
     4           4   
      5         5    
       6       6     
        7     7      
         8   8       
          9 9        
           0         
          9 9        
         8   8       
        7     7      
       6       6     
      5         5    
     4           4   
    3             3  
   2               2 
  1                 1
pattern(15):

  1                           1
   2                         2 
    3                       3  
     4                     4   
      5                   5    
       6                 6     
        7               7      
         8             8       
          9           9        
           0         0         
            1       1          
             2     2           
              3   3            
               4 4             
                5              
               4 4             
              3   3            
             2     2           
            1       1          
           0         0         
          9           9        
         8             8       
        7               7      
       6                 6     
      5                   5    
     4                     4   
    3                       3  
   2                         2 
  1                           1
*/
function pattern(n){
 var output="";
   let arr = [];
   for (let i=1,j=(n-1)*2-1;i<=n;i++,j-=2){
     if (i===n) output+=' '.repeat(i-1)+i%10+' '.repeat(i-1)+'\n'
     else output+=' '.repeat(i-1)+i%10+' '.repeat(j)+i%10+' '.repeat(i-1)+'\n'
   }
 return output+output.split`\n`.slice(0,-2).reverse().join`\n`;
}


================================================
FILE: Complete The Pattern #16.js
================================================
/*
###Task:

You have to write a function pattern which returns the following Pattern(See Examples) upto n number of rows.

Note:Returning the pattern is not the same as Printing the pattern.
####Rules/Note:

The pattern should be created using only unit digits.
If n < 1 then it should return "" i.e. empty string.
The length of each line is same, and is equal to the number of characters in a line i.e n.
Range of Parameters (for the sake of CW Compiler) :
n ∈ (-50,150]
###Examples:

pattern(8):

88888888
87777777
87666666
87655555
87654444
87654333
87654322
87654321
pattern(17):

77777777777777777
76666666666666666
76555555555555555
76544444444444444
76543333333333333
76543222222222222
76543211111111111
76543210000000000
76543210999999999
76543210988888888
76543210987777777
76543210987666666
76543210987655555
76543210987654444
76543210987654333
76543210987654322
76543210987654321
*/
function pattern(n){
  if (n<=0) return ''
  let s = n.toString().split``.reverse()[0]
  let output=[`${s}`.repeat(n)];
  for (let i=n,j=0;i>0;i--,j++){
    if (s===-1){
      s=9
    }
    output.push((output[j].slice(0,j)+`${s--}`.repeat(n-j)))
  }
  return output.slice(1).join`\n`
}


================================================
FILE: Complete The Pattern #8 - Number Pyramid.js
================================================
/*
Description:
###Task:

You have to write a function pattern which creates the following Pattern(See Examples) upto n(parameter) number of rows.

####Rules/Note:

If the Argument is 0 or a Negative Integer then it should return "" i.e. empty string.
All the lines in the pattern have same length i.e equal to the number of characters in the last line.
Range of n is (-∞,100]
###Examples:

pattern(5):

    1    
   121   
  12321  
 1234321 
123454321
pattern(10):

         1         
        121        
       12321       
      1234321      
     123454321     
    12345654321    
   1234567654321   
  123456787654321  
 12345678987654321 
1234567890987654321
pattern(15):

              1              
             121             
            12321            
           1234321           
          123454321          
         12345654321         
        1234567654321        
       123456787654321       
      12345678987654321      
     1234567890987654321     
    123456789010987654321    
   12345678901210987654321   
  1234567890123210987654321  
 123456789012343210987654321 
12345678901234543210987654321
pattern(20):

                   1                   
                  121                  
                 12321                 
                1234321                
               123454321               
              12345654321              
             1234567654321             
            123456787654321            
           12345678987654321           
          1234567890987654321          
         123456789010987654321         
        12345678901210987654321        
       1234567890123210987654321       
      123456789012343210987654321      
     12345678901234543210987654321     
    1234567890123456543210987654321    
   123456789012345676543210987654321   
  12345678901234567876543210987654321  
 1234567890123456789876543210987654321 
123456789012345678909876543210987654321
*/
function pattern(n){
  return Array.from({length: n}, (_, i) => {
    let arr = Array.from({length: i}, (v, j) => (j + 1) % 10);
    return ' '.repeat(n - i - 1) + arr.join('') + (i + 1) % 10 + arr.reverse().join('') + ' '.repeat(n - i - 1);
  }).join('\n');
}


================================================
FILE: Complete The Pattern #9 - Diamond.js
================================================
/*
Description:
Task:
You have to write a function pattern which returns the following Pattern(See Examples) upto (2n-1) rows, where n is parameter.

Rules/Note:
If the Argument is 0 or a Negative Integer then it should return "" i.e. empty string.
All the lines in the pattern have same length i.e equal to the number of characters in the longest line.
Range of n is (-∞,100]
Examples:
pattern(5):

    1    
   121   
  12321  
 1234321 
123454321
 1234321 
  12321  
   121   
    1    
pattern(10):

         1         
        121        
       12321       
      1234321      
     123454321     
    12345654321    
   1234567654321   
  123456787654321  
 12345678987654321 
1234567890987654321
 12345678987654321 
  123456787654321  
   1234567654321   
    12345654321    
     123454321     
      1234321      
       12321       
        121        
         1         
pattern(15):

              1              
             121             
            12321            
           1234321           
          123454321          
         12345654321         
        1234567654321        
       123456787654321       
      12345678987654321      
     1234567890987654321     
    123456789010987654321    
   12345678901210987654321   
  1234567890123210987654321  
 123456789012343210987654321 
12345678901234543210987654321
 123456789012343210987654321 
  1234567890123210987654321  
   12345678901210987654321   
    123456789010987654321    
     1234567890987654321     
      12345678987654321      
       123456787654321       
        1234567654321        
         12345654321         
          123454321          
           1234321           
            12321            
             121             
              1              
pattern(20):

                   1                   
                  121                  
                 12321                 
                1234321                
               123454321               
              12345654321              
             1234567654321             
            123456787654321            
           12345678987654321           
          1234567890987654321          
         123456789010987654321         
        12345678901210987654321        
       1234567890123210987654321       
      123456789012343210987654321      
     12345678901234543210987654321     
    1234567890123456543210987654321    
   123456789012345676543210987654321   
  12345678901234567876543210987654321  
 1234567890123456789876543210987654321 
123456789012345678909876543210987654321
 1234567890123456789876543210987654321 
  12345678901234567876543210987654321  
   123456789012345676543210987654321   
    1234567890123456543210987654321    
     12345678901234543210987654321     
      123456789012343210987654321      
       1234567890123210987654321       
        12345678901210987654321        
         123456789010987654321         
          1234567890987654321          
           12345678987654321           
            123456787654321            
             1234567654321             
              12345654321              
               123454321               
                1234321                
                 12321                 
                  121                  
                   1             
*/
function pattern(n){
  if (n===1) return '1'
  let output="";
  for (let i=1;i<=n;i++){
    let arr = Array(i).fill(0).map((v,i)=>(i+1)%10).join``
    let arr2 = arr.split``.reverse().join``.slice(1)
    output+=' '.repeat(n-i)+arr+arr2+' '.repeat(n-i)+'\n'
  }
 return output+(output.split`\n`.reverse().slice(2).join`\n`);
}


================================================
FILE: Complete the table pattern.js
================================================
/*
When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said

Description:
Give you two number rows , columns and a string str. Returns a rows x columns table pattern and fill in the str(each grid fill in a char, the length of str is always less than or equals to the total numbers of grids):

 If rows = 4 and columns = 4, str = "Hello World!"
 The pattern should be a 4x4 table like this:
 +---+---+---+---+
 | H | e | l | l |   From left to right
 +---+---+---+---+
 | o |   | W | o |   and from top to bottom
 +---+---+---+---+
 | r | l | d | ! |   each row separated by "\n"
 +---+---+---+---+
 |   |   |   |   |
 +---+---+---+---+
Some examples:
pattern(3, 3, "codewars") should return:
+---+---+---+
| c | o | d |
+---+---+---+
| e | w | a |
+---+---+---+
| r | s |   |
+---+---+---+

pattern(4, 3, "Nice pattern") should return:
+---+---+---+
| N | i | c |
+---+---+---+
| e |   | p |
+---+---+---+
| a | t | t |
+---+---+---+
| e | r | n |
+---+---+---+

pattern(3, 4, "Nice pattern") should return:
+---+---+---+---+
| N | i | c | e |
+---+---+---+---+
|   | p | a | t |
+---+---+---+---+
| t | e | r | n |
+---+---+---+---+
*/
function pattern(rows,columns,str){
  const arr = str.split``
  let i=0;
  const s = ('+---'.repeat(columns)+'+'+'\n'+'|   '.repeat(columns)+'|'+'\n').repeat(rows)+'+---'.repeat(columns)+'+'
  return s.replace(/\s\s\s/g,v=>' '+(arr[i++]||' ')+' ')
}


================================================
FILE: Consecutive strings
================================================
/*
You are given an array strarr of strings and an integer k. Your task is to return the first longest string consisting of k consecutive strings taken in the array.

#Example: longest_consec(["zone", "abigail", "theta", "form", "libe", "zas", "theta", "abigail"], 2) --> "abigailtheta"

n being the length of the string array, if n = 0 or k > n or k <= 0 return "".
*/

function longestConsec(strarr, k) {
    var longest = "";
    for(var i=0;k>0 && i<=strarr.length-k;i++){
      var tempStr = strarr.slice(i,i+k).join("");
      if(tempStr.length > longest.length){
        longest = tempStr;
      }
    }
    return longest;
}


================================================
FILE: Consonant value,js
================================================
/*
To introduce the problem think to my neighbor who drives a tanker truck. The level indicator is down and he is worried because he does not know if he will be able to make deliveries. We put the truck on a horizontal ground and measured the height of the liquid in the tank.

Fortunately the tank is a perfect cylinder and the vertical walls on each end are flat. The height of the remaining liquid is h, the diameter of the cylinder is d, the total volume is vt (h, d, vt are positive or null integers). You can assume that h <= d.

Could you calculate the remaining volume of the liquid? Your function tankvol(h, d, vt) returns an integer which is the truncated result (e.g floor) of your float calculation.

Examples:

tankvol(40,120,3500) should return 1021 (calculation gives about: 1021.26992027)

tankvol(60,120,3500) should return 1750

tankvol(80,120,3500) should return 2478 (calculation gives about: 2478.73007973)
Tank vertical section:

alternative text
*/
function solve(s) {
  s=s.toLowerCase();
  let arr=s.slice().replace(/[aeiuo]/g,' ').replace(/\s+/g,' ');
  arr=arr.split(' ').map(v=>v.split('').map(v=>v.charCodeAt()-96).reduce((a,b)=>a+b,0))
  return Math.max(...arr);
};


================================================
FILE: Convert integer to Whitespace format.js
================================================
/*
Description:
Story
Hereinafter, [space] refers to " ", [tab] refers to "\t", and [LF] refers to "\n" for illustrative purposes. This does not mean that you can use these placeholders in your solution.

In esoteric language called Whitespace, numbers are represented in the following format:

first character represents the sign: [space] for plus, [tab] for minus;
characters after that and until [LF] are the binary representation of the integer: [space] for 0, [tab] for 1.
the integer MUST be terminated by [LF].
Notes
Valid Whitespace number must always have at least two characters: a sign and the terminator. In case there are only two characters, the number is equal to zero.
For the purposes of this kata, zero must always be represented as [space][LF].
In this kata, the output should not contain any leading zeros.
In Whitespace, only space, tabulation and linefeed are meaningful characters. All other characters are ignored. However, for the purposes of this simple kata, please do not add any other characters in the output.
In this kata, input will always be a valid negative or positive integer.
For your convenience, in this kata we will use unbleach() function when evaluating your results. This function replaces whitespace characters with [space], [tab], and [LF] to make fail messages more obvious. You can see how it works in Example Test Cases.
Examples
1 in Whitespace is " \t\n".
0 in Whitespace is " \n".
-1 in Whitespace is "\t\t\n".
2 in Whitespace is " \t \n".
-3 in Whitespace is "\t\t\t\n".
More on Whitespace
If you liked this kata, you may also enjoy a much harder Whitespace-related kata: Whitespace interpreter by @jacobb.
*/
function whitespaceNumber(n) {
    let b = n.toString(2)
    if (n===0) return ' \n'
    if (n<0){
    let str = '\t'
      for (let i=1;i<b.length;i++){
        if (b[i]==1) str+='\t'
        else str+=' '
      }
      return str+'\n'
    }
    if (n>=0){
    let str = ' '
      for (let i=0;i<b.length;i++){
        if (b[i]==1) str+='\t'
        else str+=' '
      }
      return str+'\n'
    }
  }


================================================
FILE: Convert string to camel case
================================================
/*
Description:
Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the original word was capitalized.

Examples
toCamelCase("the-stealth-warrior") // returns "theStealthWarrior"

toCamelCase("The_Stealth_Warrior") // returns "TheStealthWarrior"
*/

function toCamelCase(str){
  return str.replace(/[-_](.)/g, (_, c) => c.toUpperCase());
}


================================================
FILE: Coordinates Validator
================================================
/*
Description:
You need to create a function that will validate if given parameters are valid geographical coordinates.

Valid coordinates look like the following: "23.32353342, -32.543534534". The return value should be either true or false.

Latitude (which is first float) can be between 0 and 90, positive or negative. Longitude (which is second float) can be between 0 and 180, positive or negative.

Coordinates can only contain digits, or one of the following symbols (including space after comma) -, .

There should be no space between the minus "-" sign and the digit after it.

Here are some valid coordinates:

-23, 25
24.53525235, 23.45235
04, -23.234235
43.91343345, 143
4, -3
And some invalid ones:

23.234, - 23.4234
2342.43536, 34.324236
N23.43345, E32.6457
99.234, 12.324
6.325624, 43.34345.345
0, 1,2
0.342q0832, 1.2324
*/

function isValidCoordinates(coordinates){
  return /^(-?((\d|[0-8]\d)(\.\d+)?)|90),\s?(-?((\d\d?|[01][0-7]\d)(\.\d+)?)|180)$/.test(coordinates);
}


================================================
FILE: Count Repeats.js
================================================
/*
Description:
Write a function that returns the count of characters that have to be removed in order to get a string with no consecutive repeats.

Note: This includes any characters

Examples
'abbbbc'  => 'abc'    #  answer: 3
'abbcca'  => 'abca'   #  answer: 2
'ab cca'  => 'ab ca'  #  answer: 1
*/
function countRepeats(str) {
    return str.length-str.replace(/(.)\1+/g,'$1').length
}


================================================
FILE: Count characters in your string
================================================
/*Description:
The main idea is to count all the occuring characters(UTF-8) in string. If you have string like this aba then the result should be { 'a': 2, 'b': 1 }

What if the string is empty ? Then the result should be empty object literal { }

For C#: Use a Dictionary<char, int> for this kata!
*/

function count (string) {  
   let cache={};
   string.split('').map(v=>cache[v]=cache[v]+1||1)
   return cache;
}


================================================
FILE: Count letters in string.js
================================================
/*
Description:
In this kata, you've to count lowercase letters in a given string and return the letter count in a hash with 'letter' as key and count as 'value'. The key must be 'symbol' instead of string in Ruby and 'char' instead of string in Crystal.

Example:

letter_count('arithmetics') #=> {"a": 1, "c": 1, "e": 1, "h": 1, "i": 2, "m": 1, "r": 1, "s": 1, "t": 2}
*/
function letterCount(s){
  return s.split``.reduce((a,b)=>(a[b]=a[b]+1||1,a),{})
}


================================================
FILE: Count the days!.js
================================================
/*
Description:
Little Annie is very excited for upcoming events. She want's to know how many days she have to wait for a specific event.

Your job is to help her out.

Task: Write a function which returns the number of days from today till the given date. The function will take a Date object as parameter. You have to round the amount of days.

If the event is in the past, return "The day is in the past!"
If the event is today, return "Today is the day!"
Else, return "x days"

PS: This is my first kata. I hope you have fun^^

This kata is part of the Collection "Date fundamentals":

#1 Count the Days!
#2 Minutes to Midnight
#3 Can Santa save Christmas?
#4 Christmas Present Calculator
*/
function countDays(d){
  let time = d
  let today=new Date()
  let todayCheck= time.getFullYear()===today.getFullYear()&&time.getMonth()===today.getMonth()&&time.getDay()===today.getDay()
  if (todayCheck) return "Today is the day!"
  let past = today.getTime()>time.getTime()
  if (past) return 'The day is in the past!'
  return `${Math.round((time.getTime()-today.getTime())/1000/60/60/24)} days`
}


================================================
FILE: Count the divisible numbers.js
================================================
/*
Description:
Write function divisibleCount(x, y, k) that takes in 3 numbers x, y and k, and returns the number of integers within the range [x..y] that are divisible by k i.e.:
{ i : x ≤ i ≤ y, i mod k = 0 }
For example:
x = 6, y = 11 and k = 2, your function should return 3, because there are three numbers divisible by 2 within the range [6..11], namely 6, 8 and 10.
Note: x<=y
*/
function divisibleCount(x, y, k) {
  return Math.floor(y/k) - Math.floor((x-1)/k)
}


================================================
FILE: Count the smiley faces!
================================================
/*
Description:
Given an array (arr) as an argument complete the function countSmileys that should return the total number of smiling faces.

Rules for a smiling face:
-Each smiley face must contain a valid pair of eyes. Eyes can be marked as : or ;
-A smiley face can have a nose but it does not have to. Valid characters for a nose are - or ~
-Every smiling face must have a smiling mouth that should be marked with either ) or D.
No additional characters are allowed except for those mentioned.
Valid smiley face examples:
:) :D ;-D :~)
Invalid smiley faces:
;( :> :} :] 

Example cases:

countSmileys([':)', ';(', ';}', ':-D']);       // should return 2;
countSmileys([';D', ':-(', ':-)', ';~)']);     // should return 3;
countSmileys([';]', ':[', ';*', ':$', ';-D']); // should return 1;
*/


function countSmileys(arr) {
  return arr.filter(v=>v.match(/(:|;)(-|~)?(\)|D)/)).length
}


================================================
FILE: Countdown - Longest Word.js
================================================
/*
Description:
#Detail

Countdown is a British game show with number and word puzzles. The letters round consists of the contestant picking 9 shuffled letters - either picking from the vowel pile or the consonant pile. The contestants are given 30 seconds to try to come up with the longest English word they can think of with the available letters - letters can not be used more than once unless there is another of the same character.

#Task

Given an uppercase 9 letter string, letters, find the longest word that can be made with some or all of the letters. The preloaded array words (or $words in Ruby) contains a bunch of uppercase words that you will have to loop through. Only return the longest word; if there is more than one, return the words of the same lengths in alphabetical order. If there are no words that can be made from the letters given, return None/nil/null.

##Examples

letters = "ZZZZZZZZZ"
longest word = None

letters = "POVMERKIA", 
longest word = ["VAMPIRE"]

letters = "DVAVPALEM"
longest word = ["VAMPED", "VALVED", "PALMED"]
*/
function longestWord(letters){
  let dict = letters.split``.reduce((a,b)=>(a[b]=a[b]+1||1,a),{})
  let arr = []
  for (let i=0;i<words.length;i++){
    let c = {...dict}
    for (let j=0;j<words[i].length;j++){
      if (c[words[i][j]]){
        if (c[words[i][j]]>0){
          c[words[i][j]]--
          if (j===words[i].length-1){
           arr.push(words[i])
          }
        } else {
          break
        }
      } else {
        break
      }
    }
  }
  if (arr.length===0) return null
  let max = Math.max(...arr.map(v=>v.length))
  return arr.filter(v=>v.length===max)
}


================================================
FILE: Counting DNA Nucleotides.js
================================================
/*
Description:
For a given DNA genectic code represented by a string, count the number of times the letters A (adenine), C (cytosine), G (guanine) and T (thymine) appears and return and object.

All letters must be in uppercase.

For example:

var genCode = 'TCCAGAAAGGTAAGCCTCGCGTTGCGAAAATGTCAAGTTACCACATCCACACCACCTCGAGCAGCTTCTATAGCTAGCCAGCACAGAGACTCGCAGTCCCTCTACAAGCTTCCAATTGGAAGAGAGCTCGGGCCAAGCGTTTGTCGCCCCCCTCCCATTGAGATAAACCCGCATTCATTCAGGTACGAACGGATGCAGCTTGATTCTCCCCATGTAGTTAACTCGCTACATCCTATCAGCCTGAGGGTCCAAGTTGCTAGACCTACATTCACTCCTGCGCTCCTCATAAGCGACCTATCGACTAGTCTTGGCTTACACCTCAGAAGTGCGCTATTGGGCGGGTATTCAGTGGTTGCACGGCGCTTATGTGGGACGCGGTGTCTTAGAGGACAGAAGATGTACAGTCAATGGAGGGATCCTCCCGAGTCGCCATCTACCCATGCGTCTGAGATATGAAAGCAGCTACCAGCCTTTCAGCCACTCTGAAAGATTTCCGTCCTCTATCAAACGACCTGCCCCAGGCTTACTGTTACTAGTTCTTTGCAAATTAACTGTACTCATTTGGGAGAGTTCGCATGCGCCTCTCCATCATACTAGCGCAAAACCTGACATTCAAACGATTCCGCACCCAAAGCCGCGAATGTGTCCCCTTACATTTCGGAGAAAACCGGCTCGACTTGGCACCAAGAACTTTTATACGCTGGGTTGTGCCATGTCTTTATGTTTATCCTTTGGGCGGCAGGAGCGTCCTCACTGTTGCTCTGAAACAGTACATGCACATGTCTAGACGAACCTGAAGAACCCCTGAACACGCCATGCACCGCGCGTAAAGCCAGTTTCGACTGGTATATATAATGATGTTGTGAAACAAATCGGGAAGGCGCAGAAAAGAATGTGGTTGGACGAAGTCCATAACTGAAGGTTAGCGA';

getCountedNucleotides(genCode); // return {A: 238, C: 254, G: 212, T: 225}
*/
function getCountedNucleotides(genCode){
  const DNA = {A: 0, C: 0, G: 0, T: 0};
  genCode.toUpperCase().split``.map(v=>DNA[v]=DNA[v]?DNA[v]+1:1)
  return DNA
}


================================================
FILE: Counting Duplicates
================================================
/*
Description:
Count the number of Duplicates
Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits.

Example
"abcde" -> 0 # no characters repeats more than once
"aabbcde" -> 2 # 'a' and 'b'
"aabBcde" -> 2 # 'a' occurs twice and 'b' twice (`b` and `B`)
"indivisibility" -> 1 # 'i' occurs six times
"Indivisibilities" -> 2 # 'i' occurs seven times and 's' occurs twice
"aA11" -> 2 # 'a' and '1'
"ABBA" -> 2 # 'A' and 'B' each occur twice
*/

function duplicateCount(text){
  return (text.toLowerCase().split('').sort().join('').match(/([^])\1+/g) || []).length;
}


================================================
FILE: Create Four Letter Birding Codes from Bird Names.js
================================================
/*
Description:
In the world of birding there are four-letter codes for the common names of birds. These codes are created by some simple rules:

If the bird's name has only one word, the code takes the first four letters of that word.
If the name is made up of two words, the code takes the first two letters of each word.
If the name is made up of three words, the code is created by taking the first letter from the first two words and the first two letters from the third word.
If the name is four words long, the code uses the first letter from all the words.
(There are other ways that codes are created, but this Kata will only use the four rules listed above)

Complete the function that takes an array of strings of common bird names from North America, and create the codes for those names based on the rules above. The function should return an array of the codes in the same order in which the input names were presented.

Additional considertations:

The four-letter codes in the returned array should be in UPPER CASE.
If a common name has a hyphen/dash, it should be considered a space.
Example
If the input array is: ["Black-Capped Chickadee", "Common Tern"]

The return array would be: ["BCCH", "COTE"]
*/
function birdCode(arr){
  return arr.map(v=>{
    v=v.replace(/-./g,v=>v.toUpperCase())
    let arr =v.match(/[A-Z]./g)
    if (arr.length===1){
      return v.slice(0,4).toUpperCase()
    }
    if (arr.length===2){
      return arr.join``.toUpperCase()
    }
    if (arr.length===3){
      return arr[0][0]+arr[1][0]+arr[2].toUpperCase()
    }
    return arr.map(v=>v[0].toUpperCase()).join``
  })
}


================================================
FILE: Create Parse HTML CSS Colors.js
================================================
/*
Description:
In this kata you parse RGB colors represented by strings. The formats are primarily used in HTML and CSS. Your task is to implement a function which takes a color as a string and returns the parsed color as a map (see Examples).
Input:
The input string represents one of the following:
6-digit hexadecimal - "#RRGGBB"
e.g. "#012345", "#789abc", "#FFA077"
Each pair of digits represents a value of the channel in hexadecimal: 00 to FF
3-digit hexadecimal - "#RGB"
e.g. "#012", "#aaa", "#F5A"
Each digit represents a value 0 to F which translates to 2-digit hexadecimal: 0->00, 1->11, 2->22, and so on.
Preset color name
e.g. "red", "BLUE", "LimeGreen"
You have to use the predefined map PRESET_COLORS (JavaScript, Python, Ruby), presetColors (Java, C#, Haskell), or preset-colors (Clojure). The keys are the names of preset colors in lower-case and the values are the corresponding colors in 6-digit hexadecimal (same as 1. "#RRGGBB").
Examples:
parseHTMLColor('#80FFA0');    // => { r: 128, g: 255, b: 160 }
parseHTMLColor('#3B7');       // => { r: 51,  g: 187, b: 119 }
parseHTMLColor('LimeGreen');  // => { r: 50,  g: 205, b: 50  }
*/
function parseHTMLColor(c) {
  if (!c.match("#")) c = PRESET_COLORS[c.toLowerCase()];

  c = c.replace('#', '');

  if (c.length < 6) c = c.replace(/(.)/g, "$1$1");

  return {
    r: parseInt(c.substring(0, 2), 16),
    g: parseInt(c.substring(2, 4), 16),
    b: parseInt(c.substring(4, 6), 16)
  };
}


================================================
FILE: Create a frame!.js
================================================
/*
Description:
*************************
*  Create a frame!      *
*           __     __   *
*          /  \~~~/  \  *
*    ,----(     ..    ) *
*   /      \__     __/  *
*  /|         (\  |(    *
* ^  \  /___\  /\ |     *
*    |__|   |__|-..     *
*************************
Given an array of strings and a character to be used as border, output the frame with the content inside.

Notes:

Always keep a space between the input string and the left and right borders.
The biggest string inside the array should always fit in the frame.
The input array is never empty.
Example
frame(['Create', 'a', 'frame'], '+')

Output:

++++++++++
+ Create +
+ a      +
+ frame  +
++++++++++
*/
const frame = (text, char) => {
  let max =Math.max(...text.map(v=>v.length))
  let top = char.repeat(max+4)
  return top+`\n`+text.map(v=>`${char} `+v+' '.repeat(max-v.length)+` ${char}`).join`\n`+`\n`+top;
};


================================================
FILE: Creating a string for an array of objects from a set of words.js
================================================
/*
Description:
You're given a string containing a sequence of words separated with whitespaces. Let's say it is a sequence of patterns: a name and a corresponding number - like this:

"red 1 yellow 2 black 3 white 4"

You want to turn it into a different string of objects you plan to work with later on - like this:

"[{name : 'red', id : '1'}, {name : 'yellow', id : '2'}, {name : 'black', id : '3'}, {name : 'white', id : '4'}]"

Doing this manually is a pain. So you've decided to write a short function that would make the computer do the job for you. Keep in mind, the pattern isn't necessarily a word and a number. Consider anything separeted by a whitespace, just don't forget: an array of objects with two elements: name and id.

As a result you'll have a string you may just copy-paste whenever you feel like defining a list of objects - now without the need to put in names, IDs, curly brackets, colon signs, screw up everything, fail searching for a typo and begin anew. This might come in handy with large lists.
*/
function wordsToObject(input) {
  let arr = []
  input=input.split` `
  for (let i=0;i<input.length;i+=2){
    arr.push([input[i],input[i+1]])
  }
    arr =arr.map(v=>{
    return v=`{name : \'${v[0]}\', id : \'${v[1]+''}\'}`})
    return '['+arr.join`, `+']'
}


================================================
FILE: Cryptography #1 - Viva Cesare.js
================================================
/*
Description:
Let’s get to know our hero: Agent #134 - Mr. Slayer.

He was sent by his CSV agency to Ancient Rome in order to resolve some important national issues. However, something incredible has happened - the enemies have taken Julius Caesar as a prisoner!!!

Caesar, not a simple man as you know, managed to send cryptic message with coordinates of his location hoping that somebody would break the code. Here our agent of the secret service comes to the stage.

But he needs your help!

Mission:

You have to implement the function “Encode” of CaesarCrypto class that codes or decodes text based on Caesar’s algorithm.

the function receives 2 parameters: an original text of any length of type “string” and a number of type “int” that represents shifts;
only letters in both cases must be encrypted;
alphabet contains only letters in this range: a-zA-Z;
by encryption the letter can change the case;
shift could be either positive or negative (for left shift);
If the input text is empty, null or includes only whitespaces, return an empty string.
Time's ticking away. The life of Caesar is on the chopping block! Go for it!
*/
function CaesarCryptoEncode(text, shift) {
  if (!text) return '';
  shift = (shift % 52 + 52) % 52;
  const letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return text.trim().replace(/[a-z]/ig, c => letters[(letters.indexOf(c) + shift) % 52]); 
}


================================================
FILE: Cumulative Triangle.js
================================================
/*
Description:
Imagine a triangle of numbers which follows this pattern:

Starting with the number "1", "1" is positioned at the top of the triangle. As this is the 1st row, it can only support a single number.
The 2nd row can support the next 2 numbers: "2" and "3"
Likewise, the 3rd row, can only support the next 3 numbers: "4", "5", "6"
And so on; this pattern continues.
    1
   2 3
  4 5 6
 7 8 9 10
...
Given N, return the sum of all numbers on the Nth Row:

1 <= N <= 10,000
*/
let arr = []
const heheboi=()=>{
  let num = 0
  for (let i=1;i<=10000;i++){
  let tempArr = []
    for (let j=0;j<i;j++){
      num++
      tempArr.push(num)
    }
    arr.push(tempArr)
  }
}
heheboi()
function cumulativeTriangle(n) {
  return arr[n-1].reduce((a,b)=>a+b,0)
}


================================================
FILE: Custom Array Filters.js
================================================
/*
Description:
Dave has a lot of data he is required to apply filters to, which are simple enough, but he wants a shorter way of doing so.

He wants the following functions to work as expected:

even    // [1,2,3,4,5].even() should return [2,4]
odd     // [1,2,3,4,5].odd() should return [1,3,5]
under   // [1,2,3,4,5].under(4) should return [1,2,3]
over    // [1,2,3,4,5].over(4) should return [5]
inRange // [1,2,3,4,5].inRange(1,3) should return [1,2,3]
They should also work when used together, for example:

[1,2,18,19,20,21,22,30,40,50,100].even().inRange(18,30) // should return [18, 20, 22, 30]
And finally the filters should only accept integer values from an array, for example:

["a", 1, "b", 300, "x", "q", 63, 122, 181, "z", 0.83, 0.11].even() // should return [300, 122]
*/
Array.prototype.even = function(){
   return this.filter(v=>v%2===0&&typeof v==='number'&&v!==0&&Number.isInteger(v))
}

Array.prototype.odd = function(){

  return this.filter(v=>v%2!==0&&typeof v==='number'&&Number.isInteger(v))
}

Array.prototype.under = function(x){
  return this.filter(v=>v<x&&typeof v==='number'&&Number.isInteger(v))
}

Array.prototype.over = function(x){
  return this.filter(v=>v>x&&typeof v==='number'&&Number.isInteger(v))
}

Array.prototype.inRange = function(min,max){
   return this.filter(v=>v>=min&&v<=max&&typeof v==='number'&&Number.isInteger(v))
}


================================================
FILE: Custom Setters and Getters.js
================================================
/*
Description:
Let's take a look at an interesting feature of JS: custom Getters and Setters for objects.

Skimming over this may help you prepare for this kata: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects?redirectlocale=en-US&redirectslug=JavaScript%2FGuide%2FWorking_with_Objects#Defining_Getters_and_Setters (thanks to @contablebrew for pointing out the more "forward-compatible" approach to this.)

The object of this exercise will be to provide a constructor named "Archiver" that creates a "self-archiving" object with respect to its "temperature" property, but otherwise looks and acts just like a normal JS object. Each time the "temperature" property is assigned, the object should add a log entry to an array (the "archive") that it returns via a "getArchive" function. The log entry should be formed as such: {date: //the Date when the "temperature" property was assigned, val: //the value that was written to the "temperature" property.} . The "date" property of the log entry should be a valid JS Date object.

so e.g.:

//new Date() == '2013-09-24...Z'
var arc = new Archiver();
arc.temperature = 33;
arc.temperature = 28;
arc.temperature = 21;
arc.getArchive() // == [{date: 2013-09-24..., val:33},{date: 2013-09-24..., val:28},{date: 2013-09-24..., val:21}]
*/
function Archiver() {
    var temperature = null;
    var archive = [];
    Object.defineProperty(this, 'temperature', {
      get: function() { return temperature; },
      set: function(value) { 
        temperature = value;
        archive.push({ date: new Date(), val: temperature });
      }
    });
    this.getArchive = function() {return archive;};
}


================================================
FILE: Custom each() Array method.js
================================================
/*
Description:
JavaScript provides an Array.prototype.forEach method that allows you to iterate over array values. For this exercise you will create your own array method called 'each'. It will be similar to the forEach method, except for one difference. If the callback function returns true then the loop will stop and no additional values will be iterated.

The following shows a contrived example of how this new method would be used:

var letters = ['a', 'b', 'c', 'd', 'e']
var allowedLetters = []
letters.each(function(letter, index){
  // break out of the loop if we reached a letter with the value 'd'
  if(letter == 'd') {
    return true;
  }
  allowedLetters.push(letter);   
})

// allowedLetters should equal ['a', 'b', 'c']
In Ruby, you would use it like this:

letters = ['a', 'b', 'c', 'd', 'e']
allowedLetters = []

letters.each_until_true do |letter, index|
  # break out of the loop if we reached a letter with the value 'd'
  if letter == 'd'
    true
  else
    allowedLetters.push(letter);   
  end
end

# allowedLetters should equal ['a', 'b', 'c']
*/
Array.prototype.each = [].some


================================================
FILE: Custom sort function.js
================================================
/*
Description:
Complete the sort function so that it returns the items passed into it in alphanumerical order. Conveniently enough, the standard array sort method has been disabled for you so that you are forced to create your own.

Example:

sort([1,3,2]) // should return [1,2,3]
*/
function sort(array) {
    if (array.length === 1) return array;
    let left = array.slice(0, array.length / 2);
    let right = array.slice(array.length / 2 );
    left = sort(left);
    right = sort(right);
    return merge(left, right);
}
function merge(left, right) {
    let arr = [];
    while (left.length > 0 && right.length > 0) {
        if (left[0] > right[0]) {
            arr.push(right[0]);
            right.shift()
        } else {
            arr.push(left[0]);
            left.shift();
        }
    }
    while (left.length) {
        arr.push(left[0]);
        left.shift();
    }
    while (right.length) {
        arr.push(right[0]);
        right.shift();
    }
    return arr
}


================================================
FILE: Cycle Detection: greedy algorithm.js
================================================
/*
Description:
In computer science, cycle detection is the algorithmic problem of finding a cycle in a sequence of iterated function values.

For any function ƒ, and any initial value x0 in S, the sequence of iterated function values

x0,x1=f(x0), x2=f(x1), ...,xi=f(x{i-1}),...
may eventually use the same value twice under some assumptions: S finite, f periodic ... etc. So there will be some i ≠ j such that xi = xj. Once this happens, the sequence must continue by repeating the cycle of values from xi to xj−1. Cycle detection is the problem of finding i and j, given ƒ and x0. Let μ be the smallest index such that the value associated will reappears and λ the smallest value such that xμ = xλ+μ, λ is the loop length.

Example:

Consider the sequence:

2, 0, 6, 3, 1, 6, 3, 1, 6, 3, 1, ....
The cycle in this value sequence is 6, 3, 1. μ is 2 (first 6) λ is 3 (length of the sequence or difference between position of consecutive 6).

The goal of this kata is to build a function that will return [μ,λ] when given a short sequence. Simple loops will be sufficient. The sequence will be given in the form of an array. All array will be valid sequence associated with deterministic function. It means that the sequence will repeat itself when a value is reached a second time. (So you treat two cases: non repeating [1,2,3,4] and repeating [1,2,1,2], no hybrid cases like [1,2,1,4]). If there is no repetition you should return [].

This kata is followed by two other cycle detection algorithms: Loyd's: http://www.codewars.com/kata/cycle-detection-floyds-tortoise-and-the-hare Bret's: http://www.codewars.com/kata/cycle-detection-brents-tortoise-and-hare
*/
function cycle(a) {
  const sndIdx = a.findIndex( (v,i) =>{
  return a.slice(0,i).includes(v) });
  if ( sndIdx===-1 )
    return [];
  else {
    const fstIdx = a.indexOf(a[sndIdx]);
    return [ fstIdx, sndIdx-fstIdx ];
  }
}


================================================
FILE: Cycle a list of values.js
================================================
/*
Description:
Prologue
You're part of a team porting MS Paint into the browser and currently working on a new UI component that allows user to control the canvas zoom level.

According to the wireframes delivered to you in PowerPoint format the user should be able to cycle through specified zoom levels by clicking a button in the UI repeatedly. The reverse direction should work with shift key held.

A new function is needed to support this behavior, so you alt-tab to Visual Studio and get to work.

Instructions
Implement a function which when given the arguments

Direction to which to cycle the current value
List of values
Current value
returns the value next to current value in the specified direction.

The function should pick the next value from the other side of the list in case there are no values in the given direction.

Examples
cycle(1, [1,2,3], 1)   // => 2
// Given the direction 1, returns the value next to 1 on the right

cycle(-1, [1,2,3], 1)  // => 3
// Given the direction -1 and value 1, wraps around list returning the last element

cycle(1, [1,2,3], 0)   // => null
// 0 does not exist in the list, returns null

cycle(1, [1,2,2,3], 2) // => 2
// Corner case: multiple instances of given value, picks next relative to first occurrence
*/
function cycle(dir, arr, cur) {
	if (!arr.includes(cur)) return null; 
  const index=arr.indexOf(cur) 
  return arr[(index+dir)%arr.length]?arr[(index+dir)%arr.length]:arr.reverse()[index%arr.length]
}


================================================
FILE: Cylon Evolution.js
================================================
/*
Description:
There are all types of cylons. The trick is, some look like humans. Using prototypical inheritance, create a prototype for Cylon. Cylons should have a model, and should have an attack function, which will return the string "Destory all humans!"

Since some cylons appear human, then make a child object called HumanSkin. This should have a model, as Cylons do, and should have the same attack. However, it should also have a function called infiltrate, which will return the string "Infiltrate the colonies".
*/
class Cylon{
  constructor(model){
  this.model=model
  }
  attack(){
  return "Destroy all humans!"
  }
}

class HumanSkin extends Cylon{
  constructor(model){
  super(model)
  this.model=model
  }
  infiltrate(){
  return "Infiltrate the colonies"
  }
}


================================================
FILE: Dashatize it.js
================================================
/*
Description:
Given a number, return a string with dash'-'marks before and after each odd integer, but do not begin or end the string with a dash mark.

Ex:

dashatize(274) -> '2-7-4'
dashatize(6815) -> '68-1-5'
*/

function dashatize(num) {
  return String(num)
    .replace(/([13579])/g, "-$1-")
    .replace(/--+/g, "-")
    .replace(/(^-|-$)/g, "")
}


================================================
FILE: Data Reverse.js
================================================
/*
Description:
A stream of data is received and needs to be reversed.

Each segment is 8 bits long, meaning the order of these segments needs to be reversed, for example:

11111111  00000000  00001111  10101010
 (byte1)   (byte2)   (byte3)   (byte4)
should become:

10101010  00001111  00000000  11111111
 (byte4)   (byte3)   (byte2)   (byte1)
The total number of bits will always be a multiple of 8.

The data is given in an array as such:

[1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,0,1,0,1,0]
*/

const dataReverse = function(data){
  if (data.length===0) return []
  const arrayBytes = [];
  const tam = data.length / 8;
  for (var i = 0; i < tam; i++){
    arrayBytes.push(data.splice(0,8));
  }
  return arrayBytes.reverse().join().split(',').map(v=>v*1);
}


================================================
FILE: Data compression using run-length encoding.js
================================================
/*
Description:
Run-length encoding (RLE) is a very simple form of lossless data compression in which runs of data are stored as a single data value and count.

A simple form of RLE would encode the string "AAABBBCCCD" as "3A3B3C1D" meaning, first there are 3 A, then 3 B, then 3 C and last there is 1 D.

Your task is to write a RLE encoder and decoder using this technique. The texts to encode will always consist of only uppercase characters, no numbers.
*/
function encode(input) {
  let count=1;
  let str='';
  for (let i=0;i<input.length;i++){
  if (input[i]===input[i+1]){
    count++
  } else {
    str+=`${count}${input[i]}`
    count=1
  }}
  return str;
}

function decode(input) {
  const arr=input.slice().replace(/\d/gi,' ').replace(/\s+/g,' ').split(' ').filter(v=>v);
  const arr2=input.slice().replace(/\D/gi,' ').replace(/\s+/g,' ').split(' ').filter(v=>v)
  let str='';
  for (let i=0;i<arr.length;i++){
  str+=`${arr[i].repeat(arr2[i]*1)}`
  }
  return str
}


================================================
FILE: Dead Ants.js
================================================
/*
Description:
An orderly trail of ants is marching across the park picnic area.

It looks something like this:

..ant..ant.ant...ant.ant..ant.ant....ant..ant.ant.ant...ant..
But suddenly there is a rumour that a dropped chicken sandwich has been spotted on the ground ahead. The ants surge forward! Oh No, it's an ant stampede!!

Some of the slower ants are trampled, and their poor little ant bodies are broken up into scattered bits.

The resulting carnage looks like this:

...ant...ant..nat.ant.t..ant...ant..ant..ant.anant..t
Can you find how many ants have died?

Notes
When in doubt, assume that the scattered bits are from the same ant. e.g. 2 heads and 1 body = 2 dead ants, not 3
*/
deadAntCount = function(ants) {
  if (!ants) return 0
  let str = ants.replace(/ant/g,'')
  let head =  str.replace(/[^a]/g,'').length
  let body =  str.replace(/[^n]/g,'').length
  let tail =  str.replace(/[^t]/g,'').length
  return Math.max(head,body,tail)
}


================================================
FILE: Decipher this!.js
================================================
/*
Description:
You are given a secret message you need to decipher. Here are the things you need to know to decipher it:

For each word:

the second and the last letter is switched (e.g. Hello becomes Holle)
the first letter is replaced by its character code (e.g. H becomes 72)
Note: there are no special characters used, only letters and spaces

Examples

decipherThis('72olle 103doo 100ya'); // 'Hello good day'
decipherThis('82yade 115te 103o'); // 'Ready set go'
*/
function decipherThis(str) {
  return str.replace(/\d+/g,v=>String.fromCharCode(v*1)).split(' ')
  .map(v=>v.length>2?v.slice(0,1)+v.slice(-1)+v.slice(2,-1)+v.slice(1,2):v).join` `
}; 


================================================
FILE: Decode Morse.js
================================================
/*
Description:
Oh no! You have stumbled upon a mysterious signal consisting of beeps of various lengths, and it is of utmost importance that you find out the secret message hidden in the beeps. There are long and short beeps, the longer ones roughly three times as long as the shorter ones. Hmm... that sounds familiar.

That's right: your job is to implement a decoder for the Morse alphabet. Rather than dealing with actual beeps, we will use a common string encoding of Morse. A long beep is represened by a dash (-) and a short beep by a dot (.). A series of long and short beeps make up a letter, and letters are separated by spaces (). Words are separated by double spaces.

You should implement the International Morse Alphabet. You need to support letters a-z and digits 0-9 as follows:

a .-      h ....    o ---     u ..-      1 .----     6 -....
b -...    i ..      p .--.    v ...-     2 ..---     7 --...
c -.-.    j .---    q --.-    w .--      3 ...--     8 ---..
d -..     k -.-     r .-.     x -..-     4 ....-     9 ----.
e .       l .-..    s ...     y -.--     5 .....     0 -----
f ..-.    m --      t -       z --..
g --.     n -.
Examples
.... . .-.. .-.. --- .-- --- .-. .-.. -.. → "hello world"

.---- ... - .- -. -.. ..--- -. -.. → "1st and 2nd"
*/
function decode(str) {
  const morse = {'1':'.----','2':'..---','3':'...--','4':'....-',5:'.....',6:'-....',7:'--...',8:'---..',9:'----.',0:'-----','a':".-", 'b':"-...", 'c':"-.-.", 'd':"-..", 'e':".", 'f':"..-.", 'g':"--.", 'h':"....", 'i':"..", 'j':".---", 'k':"-.-", 'l':".-..", 'm':"--", 'n':"-.",
   'o':"---", 'p':".--.", 'q':"--.-", 'r':".-.", 's':"...", 't':"-", 'u':"..-", 'v':"...-", 'w':".--", 'x':"-..-", 'y':"-.--", 'z':"--.."}
 const morse2={}
 for (let i in morse){
   morse2[morse[i]]=i
 }
 return str.split` `.map(v=>morse2[v]||' ').join``
}


================================================
FILE: Decode the Morse code
================================================
/*
Description:
Part of Series 1/3
This kata is part of a series on the Morse code. After you solve this kata, you may move to the next one.

In this kata you have to write a simple Morse code decoder. While the Morse code is now mostly superceded by voice and digital data communication channels, it still has its use in some applications around the world.
The Morse code encodes every character as a sequence of "dots" and "dashes". For example, the letter A is coded as ·−, letter Q is coded as −−·−, and digit 1 is coded as ·−−−−. The Morse code is case-insensitive, traditionally capital letters are used. When the message is written in Morse code, a single space is used to separate the character codes and 3 spaces are used to separate words. For example, the message HEY JUDE in Morse code is ···· · −·−− ·−−− ··− −·· ·.

NOTE: Extra spaces before or after the code have no meaning and should be ignored.

In addition to letters, digits and some punctuation, there are some special service codes, the most notorious of those is the international distress signal SOS (that was first issued by Titanic), that is coded as ···−−−···. These special codes are treated as single special characters, and usually are transmitted as separate words.

Your task is to implement a function that would take the morse code as input and return a decoded human-readable string.

For example:

decodeMorse('.... . -.--   .--- ..- -.. .')
//should return "HEY JUDE"
NOTE: For coding purposes you have to use ASCII characters . and -, not Unicode characters.

The Morse code table is preloaded for you as a dictionary, feel free to use it:

Coffeescript/C++/Go/JavaScript/PHP/Python/Ruby/TypeScript: MORSE_CODE['.--']
C#: MorseCode.Get(".--") (returns string)
Elixir: morse_codes variable
Haskell: morseCodes ! ".--" (Codes are in a Map String String)
Java: MorseCode.get(".--")
Kotlin: MorseCode[".--"] ?: "" or MorseCode.getOrDefault(".--", "")
Rust: self.morse_code
All the test strings would contain valid Morse code, so you may skip checking for errors and exceptions. In C#, tests will fail if the solution code throws an exception, please keep that in mind. This is mostly because otherwise the engine would simply ignore the tests, resulting in a "valid" solution.

Good luck!

After you complete this kata, you may try yourself at Decode the Morse code, advanced.
*/

decodeMorse = function(morseCode){
  return morseCode.split(' ').map((v,i)=>MORSE_CODE[v]!=undefined?MORSE_CODE[v]:1).join('').replace(/11/g,' ').replace(/1/g,' ').trim()
}


================================================
FILE: Decompose a number.js
================================================
/*
Description:
Decompose a number num into an array (tuple in Haskell, array of arrays long[][] in C# or Java) of the form [[k1,k2,k3...], r], ([k1,k2,k3...], r) in Haskell, [[k1,k2,k3...], [r]] in C# or Java) such that:

each kn is more than one
eack kn is maximized (first maximizing for 2 then 3 then 4 and so on)
and 2k1 + 3k2 + 4k3 + ... + nkn-1 + r = num
##Examples

# when there are no `k` more than 1:

3 

[[], 3] = 

3

# when the remainder is zero:

8330475

[[22, 13, 10, 8, 7, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2], 0] = 

2 ^ 22 + 3 ^ 13 + 4 ^ 10 + 5 ^ 8 + 6 ^ 7 + 7 ^ 6 + 8 ^ 6 + 9 ^ 5 + 10 ^ 5 + 11 ^ 5 + 12 ^ 4 + 13 ^ 4 + 14 ^ 4 + 15 ^ 3 + 16 ^ 3 + 17 ^ 3 + 18 ^ 3 + 19 ^ 3 + 20 ^ 3 + 21 ^ 2 + 22 ^ 2 + 23 ^ 2 + 24 ^ 2 + 0 = 8330475

# when there is both `k` and a remainder:

26 

[[4, 2], 1] = 

2 ^ 4 + 3 ^ 2 + 1 = 26

# when there is neither `k` nor a remainder:

0

[[], 0] = 

0
*/
function decompose(num) {
  let i = 2;
  let pow = 50
  let arr = []
  while (num>0){
    if (pow===1){break}
    if (num<Math.pow(i,pow)){
    pow--
    } else {
    num-=Math.pow(i,pow)
    arr.push(pow)
    i++
    }
  }
  return [arr,num]
}


================================================
FILE: Deep Freeze.js
================================================
/*
Description:
Create a complement to the Object.freeze function, Object.deepFreeze

This method should apply the Object.freeze function to an object and, recursively, all of its properties that are objects.

The freeze operation should prevent objects from being modified.
*/
Object.deepFreeze = function (object) {
  Object.freeze(object)
  for (let i in object){
    Object.deepFreeze(object[i])
  }
}


================================================
FILE: Delete occurrences of an element if it occurs more than n times
================================================
/*
Description:
Enough is enough!
Alice and Bob were on a holiday. Both of them took many pictures of the places they've been, and now they want to show Charlie their entire collection. However, Charlie doesn't like this sessions, since the motive usually repeats. He isn't fond of seeing the Eiffel tower 40 times. He tells them that he will only sit during the session if they show the same motive at most N times. Luckily, Alice and Bob are able to encode the motive as a number. Can you help them to remove numbers such that their list contains each number only up to N times, without changing the order?

Task
Given a list lst and a number N, create a new list that contains each number of lst at most N times without reordering. For example if N = 2, and the input is [1,2,3,1,2,1,2,3], you take [1,2,3,1,2], drop the next [1,2] since this would lead to 1 and 2 being in the result 3 times, and then take 3, which leads to [1,2,3,1,2,3].

Example
  deleteNth ([1,1,1,1],2) // return [1,1]

  deleteNth ([20,37,20,21],1) // return [20,37,21]
*/

function deleteNth(arr,n){
  let cache={};
  return arr.filter(v=>(cache[v]=~~cache[v]+1)<=n)
}


================================================
FILE: Descriptive selections of data.js
================================================
/*
Description:
Fill in the functions with the help of the provided methods only, i.e. just compose with them:

rest(), map(), first(), second(), third(), zip()

Example

return map(table, second);
Here are their descriptions:

rest([5, 4, 3, 2, 1]);
=> [4, 3, 2, 1]

map([1, 2, 3], function(num){ return num * 3; });
=> [3, 6, 9]

first([5, 4, 3, 2, 1]); // second, third ...
=> 5

zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
=> [["moe", 30, true], ["larry", 40, false], ["curly", 50, false]]
*Note: * The first row within the data array will always be the column names. These column names will always have the same order. No need to determine which index a column should be dynamically.
*/
const selectNames = table => map(rest(table), first)
const selectVoices = table => map(rest(table), third)
const selectNamesAndVoices = table => zip(selectNames(table), selectVoices(table))


================================================
FILE: Design a Simple Automaton (Finite State Machine).js
================================================
/*
Description:
Create a finite automaton that has three states. Finite automatons are the same as finite state machines for our purposes.

Our simple automaton, accepts the language of A, defined as {0, 1} and should have three states: q1, q2, and q3. Here is the description if the states:

q1 is our start state, we begin reading commands from here
q2 is our accept state, we return true if this is our last state
And the transitions:

q1 moves to q2 when given a 1, and stays at q1 when given a 0
q2 moves to q3 when given a 0, and stays at q2 when given a 1
q3 moves to q2 when given a 0 or 1
The automaton should return whether we end in our accepted state (q2), or not (true/false).

Your task
You will have to design your state objects, and how your Automaton handles transitions. Also make sure you set up the three states, q1, q2, and q3 for the myAutomaton instance. The test fixtures will be calling against myAutomaton.

As an aside, the automaton accepts an array of strings, rather than just numbers, or a number represented as a string, because the language an automaton can accept isn't confined to just numbers. An automaton should be able to accept any 'symbol.'

Here are some resources on DFAs (the automaton this Kata asks you to create):

http://en.wiki
Download .txt
gitextract_eg3a47vk/

├── "this" is an other problem.js
├── "this" is an other solution.js
├── (L33T + Grεεκ) Case.js
├── +1 Array.js
├── 1 n- Cycle.js
├── 1RM Calculator.js
├── 80's Kids #7: She's a Small Wonder.js
├── A Rule of Divisibility by 13.js
├── A String of Sorts.js
├── A Taste of Curry.js
├── A disguised sequence (I).js
├── A tetrahedron of cannonballs.js
├── ASCII hex converter.js
├── Ackermann Function.js
├── Adding Binary Numbers.js
├── Adding ordinal indicator suffixes to numbers.js
├── Adjacent pairs in a string.js
├── Almost Even.js
├── Alphabet war - airstrike - letters massacre.js
├── Alphabetized.js
├── Alternating Loops.js
├── Anagram difference.js
├── Anything to integer.js
├── Arabian String.js
├── Are they the "same"?
├── Are we alternate?.js
├── Array Deep Count.js
├── Array Helpers.js
├── Array#reduce.js
├── Array.diff
├── Arrays Similar.js
├── Arrh, grabscrab!.js
├── Atbash Cipher Helper.js
├── Autocomplete! Yay!.js
├── Baby Magpies.js
├── Backspaces in string.js
├── Backwards Read Primes.js
├── Balance the arrays.js
├── Ball Upwards.js
├── Banker's Plan.js
├── Base Conversion.js
├── Basic Encryption.js
├── Binary string.js
├── Binary to Text (ASCII) Conversion.js
├── Binding within the List Monad.js
├── Bingo Card.js
├── Bit Counting
├── Bleatrix Trotter (The Counting Sheep).js
├── Body mass index calculation.js
├── Bouncing Balls
├── Bowling Pins.js
├── Braces status.js
├── Bracket Duplicates.js
├── Braking well.js
├── Break camelCase.js
├── Breaking search bad.js
├── Build Tower
├── Build Tower Advanced.js
├── Build a pile of Cubes
├── Buying a car
├── ByState.js
├── Calculate Hypotenuse of Right-angled Triangle.js
├── Calculate String Rotation.js
├── Calculate number of inversions in array.js
├── Calculate the area of a regular n sides polygon inside a circle of radius r.js
├── Calculate the function f(x) for a simple linear sequence (Easy).js
├── Calculate the function f(x) for a simple linear sequence (Medium).js
├── Cambridge Word Scramble.js
├── CamelCase Method.js
├── CamelCase to underscore.js
├── Can you keep a secret?.js
├── Case Reversal of Consecutive Duplicates.js
├── Cat Kata, Part 1.js
├── Cat and Mouse - Harder Version.js
├── Catalog.js
├── Chain Evaluation.js
├── Character frequency.js
├── Character limits: How long is your piece of string?.js
├── Character with longest consecutive repetition.js
├── Check if two words are isomorphic to each other.js
├── Checkerboard Generation.js
├── Checkered Board.js
├── Checking Groups
├── Chess Fun #1: Chess Board Cell Color.js
├── Chess Fun #2: Bishop And Pawn.js
├── Christmas Day.js
├── Christmas tree.js
├── Circularly Sorted Array.js
├── Clay Pigeon Shooting.js
├── Clock in Mirror.js
├── Clocky Mc Clock-Face.js
├── Closures and Scopes.js
├── Coding Meetup #10 - Higher-Order Functions Series - Create usernames.js
├── Coding Meetup #13 - Higher-Order Functions Series - Is the meetup language-diverse?.js
├── Coding Meetup #15 - Higher-Order Functions Series - Find the odd names.js
├── Coding Meetup #16 - Higher-Order Functions Series - Ask for missing details.js
├── Coding Meetup #7 - Higher-Order Functions Series - Find the most senior developer.js
├── Coding Meetup #8 - Higher-Order Functions Series - Will all continents be represented?.js
├── Coding Meetup #9 - Higher-Order Functions Series - Is the meetup age-diverse?.js
├── Collatz.js
├── Color Choice.js
├── Combinator Flip.js
├── Compare Versions.js
├── Compare powers.js
├── Compare section numbers.js
├── Complete Fibonacci Series.js
├── Complete The Pattern #12.js
├── Complete The Pattern #16.js
├── Complete The Pattern #8 - Number Pyramid.js
├── Complete The Pattern #9 - Diamond.js
├── Complete the table pattern.js
├── Consecutive strings
├── Consonant value,js
├── Convert integer to Whitespace format.js
├── Convert string to camel case
├── Coordinates Validator
├── Count Repeats.js
├── Count characters in your string
├── Count letters in string.js
├── Count the days!.js
├── Count the divisible numbers.js
├── Count the smiley faces!
├── Countdown - Longest Word.js
├── Counting DNA Nucleotides.js
├── Counting Duplicates
├── Create Four Letter Birding Codes from Bird Names.js
├── Create Parse HTML CSS Colors.js
├── Create a frame!.js
├── Creating a string for an array of objects from a set of words.js
├── Cryptography #1 - Viva Cesare.js
├── Cumulative Triangle.js
├── Custom Array Filters.js
├── Custom Setters and Getters.js
├── Custom each() Array method.js
├── Custom sort function.js
├── Cycle Detection: greedy algorithm.js
├── Cycle a list of values.js
├── Cylon Evolution.js
├── Dashatize it.js
├── Data Reverse.js
├── Data compression using run-length encoding.js
├── Dead Ants.js
├── Decipher this!.js
├── Decode Morse.js
├── Decode the Morse code
├── Decompose a number.js
├── Deep Freeze.js
├── Delete occurrences of an element if it occurs more than n times
├── Descriptive selections of data.js
├── Design a Simple Automaton (Finite State Machine).js
├── Detect Pangram
├── Difference of 2.js
├── Digital cypher vol 3 - missing key.js
├── Disease Spread.js
├── Disgruntled Employee.js
├── Disguised sequences (II).js
├── Divisible Ints.js
├── Does my number look big in this?
├── Don't rely on luck.
├── Doors in the school.js
├── Dragon's Curve.js
├── Drunk friend.js
├── Dubstep
├── Duplicate Arguments
├── Duplicate Encoder
├── Ease the StockBroker.js
├── Easter egg list in ReactJS.js
├── Easy Balance Checking.js
├── Easy Diagonal.js
├── Emotional Sort ( ︶︿︶).js
├── Encrypt this!.js
├── English beggars.js
├── Enigeliisohe too Eniigeeliiisoohee Toroanisoliatooro.js
├── Equal Sides Of An Array
├── Errors : histogram.js
├── Escape HTML Markup.js
├── Esolang Interpreters #1 - Introduction to Esolangs and My First Interpreter (MiniStringFuck).js
├── Esolang: MiniBitMove.js
├── Esolang: Tick.js
├── Even Fibonacci Sum.js
├── Evil Autocorrect Prank.js
├── Exclamation marks series #17: Put the exclamation marks and question marks to the balance, Are they balanced?.js
├── Exercise in Summing.js
├── Extract Nested Object Reference.js
├── Extract last names of people named Michael.js
├── Extract the IDs from the data set.js
├── FIXME: Hello.js
├── Factorial length.js
├── Faro Shuffle Count.js
├── Fat Fingers.js
├── Feynman's square question.js
├── Fibonacci Reloaded.js
├── Fibonacci, Tribonacci and friends.js
├── File Path Operations.js
├── Financing Plan on Planet XY140Z-n.js
├── Financing a purchase.js
├── Find The Duplicated Number in a Consecutive Unsorted List - Tougher Version.js
├── Find The Parity Outlier
├── Find X.js
├── Find heavy ball - level: conqueror.js
├── Find the Mine!.js
├── Find the Nexus of the Codewars Universe.js
├── Find the Nth longest string in an Array.js
├── Find the missing letter
├── Find the missing term in an Arithmetic Progression
├── Find the odd int
├── Find the unique number
├── Find the unique number.js
├── Find within array.js
├── FizzBuzz Array! (Custom).js
├── Flexible Card Game.js
├── Floating-point Approximation (I).js
├── Fold an array.js
├── Follow that Spy.js
├── Football - Yellow and Red Cards.js
├── Format Text.js
├── Format a string of names like 'Bart, Lisa & Maggie'.
├── Format words into a sentence.js
├── Framed Reflection.js
├── Free pizza.js
├── Friday the 13ths.js
├── Frog jumping.js
├── Fruit Machine.js
├── Fun with lists: countIf.js
├── Fun with lists: filter.js
├── Fun with lists: map.js
├── Fun with lists: reduce.js
├── Fun with trees: max sum.js
├── Function Composition
├── Function composition.js
├── Function iteration.js
├── Functional Lists.js
├── GA-DE-RY-PO-LU-KI cypher vol 2.js
├── Genetic Algorithm Series - #5 Roulette wheel selection.js
├── Get All Possible Anagrams from a Hash.js
├── Get all array elements except those with specified indexes.js
├── Give me a Diamond
├── Good vs Evil
├── Greatest Position Distance Between Matching Array Values.js
├── Grill it!.js
├── Grouped by commas.js
├── Guess the number!.js
├── HTML dynamic color string generation.js
├── Hamming Distance.js
├── Handshake problem
├── Hanoi record.js
├── Happy numbers.js
├── Hard Time Bomb.js
├── Harshad or Niven numbers.js
├── Help Mrs Jefferson.js
├── Help the bookseller !.js
├── Hidden "Cubic" numbers.js
├── Highest Rank Number in an Array.js
├── Highest Scoring Word
├── Ho Ho Ho with Functions!.js
├── Holiday Shopping Priority Queue.js
├── Holy cats.js
├── House of cards.js
├── How Many Reindeers?.js
├── How Much?.js
├── How many feelings?.js
├── How much hex is the fish.js
├── How new Works.js
├── I need more speed!.js
├── IP Address to Number.js
├── IP Validation
├── IPv4 to int32
├── IQ Test
├── Ideal electron distribution.js
├── If you can read this....js
├── Image host filename generator.js
├── Implementing Array.prototype.groupBy method.js
├── Inserting multiple strings into another string.js
├── Inside Out Strings.js
├── Integer depth.js
├── Integers: Recreation Two.js
├── Irreducible Sum of Rationals.js
├── Is Integer Array ?.js
├── Is a number prime?
├── Javascript filter - 2.js
├── Javascript filter - 3.js
├── JoJo's Bizarre Kata.js
├── Ka Ka Ka cypher - words only vol 1.js
├── Kebabize.js
├── Killer Garage Door.js
├── LICENSE.md
├── LOTTO 6 aus 49 - 6 of 49.js
├── Length of missing array
├── Letter Changes.js
├── Levenshtein Distance.js
├── Linear Regression of Y on X.js
├── Linked Lists - Insert Nth Node.js
├── Linked Lists - Insert Sort.js
├── Linked Lists - Recursive Reverse.js
├── Linked Lists - Remove Duplicates.js
├── Linked Lists - Shuffle Merge.js
├── Linked Lists - Sorted Insert.js
├── Linked Lists-Length & Count.js
├── Look and say numbers.js
├── Loose Change.js
├── Lottery Ticket
├── Lowest product of 4 consecutive numbers.js
├── Lucas numbers.js
├── MTV Cribs.js
├── Make the Deadfish swim..js
├── Making Change.js
├── Manhattan Distance.js
├── Master of Files.js
├── Matrix Addition.js
├── Matrix Transpose.js
├── Max Accessor Function.js
├── Maze Runner.js
├── Meeting.js
├── Mexican Wave.js
├── Midpoint Sum.js
├── Minutes to Midnight.js
├── Mirror object - tcejbo rorriM.js
├── Mirror, Mirror.js
├── Missing Alphabet.js
├── Mix Fruit Juice.js
├── Moduli number system.js
├── Most Frequent Weekdays.js
├── Moves in squared strings (II).js
├── Moves in squared strings (III).js
├── Moves in squared strings (IV).js
├── Mr. Safety's treasures.js
├── Multi-tap Keypad Text Entry on an Old Mobile Phone
├── Multiples of 3 and 5 redux.js
├── Multiples of 3 or 5
├── Multiplication Tables.js
├── Multiplication table.js
├── Mutual Recursion.js
├── Mysterious function.js
├── N smallest elements in original order.js
├── N-th Fibonacci.js
├── Name That Integer.js
├── Name to Matrix.js
├── New Cashier Does Not Know About Space or Shift.js
├── Next Version.js
├── Non-even substrings.js
├── None shall pass.js
├── Not prime numbers.js
├── Nuclear Missile Manager.js
├── Number Format.js
├── Number Shortening Filter.js
├── Number Zoo Patrol.js
├── Number of anagrams in an array of words.js
├── Number of measurements to spot the counterfeit coin.js
├── Number of permutations without repetitions.js
├── Number pattern.js
├── Numerical Palindrome #1.5.js
├── Numericals of a String.js
├── Numerology.js
├── Odd Even number of divisors.js
├── Odd-heavy Array.js
├── Once.js
├── Only Duplicates.js
├── Ordinal Numbers.js
├── Ore Numbers.js
├── Organise duplicate numbers in list.js
├── PI approximation.js
├── Pad Left and Right.js
├── Padovan numbers.js
├── Pair of gloves.js
├── Palindrome for your Dome.js
├── Palindromes Below.js
├── Palindromic Numbers.js
├── Palindromization.js
├── Parabolic Arc Length.js
├── Parity bit - Error detecting code.js
├── Parse a linked list from a string.js
├── Pascal's Triangle #2.js
├── Pascal's Triangle.js
├── Password generator.js
├── Paths in the Grid.js
├── PatternCraft - Decorator.js
├── PatternCraft - State.js
├── PatternCraft - Strategy.js
├── Pentabonacci.js
├── Permutations and Dot Products.js
├── Persistent Bugger.
├── Pete, the baker (part 2).js
├── Piano Kata, Part 1.js
├── Piano Kata, Part 2.js
├── Ping-Pong service problem.js
├── Pizza pieces.js
├── Playing on a chessboard.js
├── Playing with digits
├── Playing with passphrases.js
├── Plenty of Fish in the Pond.js
├── Point in Polygon.js
├── Points On A Line.js
├── Points in the circle.js
├── Pokemon Damage Calculator.js
├── Polybius square cipher - encode.js
├── Pong! [Basics].js
├── Positions Average.js
├── Prefill an Array.js
├── Prime Factors.js
├── Prime factorization.js
├── Primorial Of a Number.js
├── Prize Draw.js
├── Proof Read.js
├── Pyramid Array.js
├── Quick (n choose k) calculator.js
├── README.md
├── RNA to Protein Sequence Translation.js
├── Rainfall.js
├── Range function.js
├── Rank Vector.js
├── Ranking System.js
├── Reach Me and Sum my Digits.js
├── Rectangle into Squares
├── Reducing by rules to get the result.js
├── Reducing by steps.js
├── Regex Tic Tac Toe Win Checker.js
├── Regexp Basics - is it IPv4 address?.js
├── Regexp basics - parsing time.js
├── Remember.js
├── Repeated Substring.js
├── Replace With Alphabet Position
├── Return 1, 2, 3 randomly.js
├── Reverse every other word in the string.js
├── Reverse or rotate?.js
├── Reverse polish notation calculator
├── RoboScript #1 - Implement Syntax Highlighting.js
├── Roman Numerals Decoder
├── Roman Numerals Encoder
├── Rotate Array (JS).js
├── Rotation Cipher Cracker.js
├── Round by 0.5 steps.js
├── Routes in a square grid.js
├── Run-length encoding.js
├── Running Average.js
├── Salesman's Travel.js
├── Same Array?.js
├── Santa's Master Plan.js
├── Scheduling (Shortest Job First or SJF).js
├── Schrödinger's Boolean.js
├── Scrabble best word.js
├── Secret Message.js
├── Separate The Wheat From The Chaff.js
├── Sequence generator.js
├── Sequences and Series.js
├── Shortest steps to a number.js
├── Simple Encryption #1 - Alternating Split
├── Simple Fun #116: Prime String.js
├── Simple Fun #135: Missing Alphabets.js
├── Simple Fun #165: Withdraw.js
├── Simple Fun #170: Sum Groups.js
├── Simple Fun #23: Square Digits Sequence.js
├── Simple Fun #258: Is Divisible By 6.js
├── Simple Fun #303: Prime Product.js
├── Simple Fun #319: Number And IP Address.js
├── Simple Fun #79: Delete a Digit.js
├── Simple Sentences.js
├── Simple Simple Simple String Expansion.js
├── Simple Substitution Cipher Helper.js
├── Simple Web Framework #1: Create a basic router.js
├── Simple card game.js
├── Simple frequency sort.js
├── Simple prime streaming.js
├── Simple string indices.js
├── Simple sum of pairs.js
├── Simple transposition.js
├── Simpson's Rule - Approximate Integration.js
├── Single Word Pig Latin.js
├── Single character palindromes.js
├── Sometimes.js
├── Sort Arrays (Ignoring Case).js
├── Sort My Animals.js
├── Sort odd and even numbers in different order.js
├── Sort sentence pseudo-alphabetically.js
├── Sort the odd
├── Sorting by bits.js
├── Special Multiples.js
├── Spelling Bee.js
├── Split Strings
├── Sqrt approximation.js
├── Squares in a Rectangle.js
├── Srot the inner ctonnet in dsnnieedcg oredr.js
├── Statistics for an Athletic Association.js
├── Steps in Primes.js
├── Stop gninnipS My sdroW!
├── Street Fighter 2 - Character Selection.js
├── String Breakers.js
├── String Integer Greater-than.js
├── String Shortener (shrink).js
├── String Suffixes.js
├── String array revisal.js
├── String average.js
├── String character frequency.js
├── String reduction.js
├── String searching with wildcard.js
├── String tops.js
├── String transformer.js
├── Stringing me along.js
├── Strip Url Params.js
├── Sum The Tree.js
├── Sum consecutives.js
├── Sum of Digits Digital Root
├── Sum of Two Integers.js
├── Sum of a Sequence [Hard-Core Version].js
├── Sum of many ints.js
├── Sum of nested numbers.js
├── Summarize ranges.js
├── Sums of Parts.js
├── Surrounding Primes for a value.js
├── T.T.T.17: Split odd and even.js
├── Take a Number And Sum Its Digits Raised To The Consecutive Powers And ....¡Eureka!!
├── Take a Ten Minute Walk
├── Tank Truck.js
├── Temperature converter.js
├── The Book of Mormon.js
├── The Deaf Rats of Hamelin.js
├── The Desperate Rocket Scientist.js
├── The Enigma Machine - Part 1: The Plugboard.js
├── The Freeway Game.js
├── The Modulo-3 Sequence.js
├── The Most Sacred of Days.js
├── The Non-Discriminate Factorial.js
├── The Office V - Find a Chair.js
├── The Shell Game.js
├── The Spider and the Fly (Jumping Spider).js
├── The Supermarket Queue.js
├── The Vowel Code.js
├── The elegance of the code.js
├── The maximum and minimum difference -- Simple version
├── The maximum sum value of ranges -- Simple version.js
├── The nth smallest integer.js
├── The range() function.js
├── The takeWhile Function.js
├── Think how isArray function can be implemented.js
├── Thinkful - Logic Drills: Red and bumpy.js
├── Three added Characters.js
├── Throwing Darts.js
├── Tick Toward.js
├── Time-like string format.js
├── Title Case
├── Tortoise racing
├── Transform To Prime.js
├── Tree Depth.js
├── Triangle number check.js
├── Triangle type
├── Tribonacci Sequence
├── Trim a String.js
├── Triple trouble
├── Tug-o'-War.js
├── Turkish National Identity Number.js
├── Two Joggers
├── Two Sum.js
├── Two cube sums.js
├── Typer.js
├── Unary function chainer.js
├── Unique In Order
├── Unwanted dollars.js
├── Update inventory in your smartphone store.js
├── Upside down numbers.js
├── Upside-Down Pyramid Addition...REVERSED!.js
├── Urban Dictionary.js
├── Valid Braces
├── Valid Phone Number
├── Valid string.js
├── Validate Credit Card Number.js
├── Vasya - Clerk.js
├── Vasya and Stairs.js
├── Vasya and System of Equations.js
├── Vowel Recognition.js
├── Vowel Shifting.js
├── Walter's miraculous FizzBuzz factory.js
├── WeIrD StRiNg CaSe
├── What century is it?.js
├── What's in a name?.js
├── Wheel of Fortune.js
├── Where is my parent!?(cry).js
├── Which are in?
├── Which filetypes are you using the most?.js
├── Who likes it?
├── Who won the election?.js
├── Wind component calculation.js
├── Word Mesh.js
├── Word Patterns.js
├── Word Segmentation: MaxMatch.js
├── Word a10n (abbreviation)
├── Wordify an integer.js
├── World Bits War.js
├── Write JavaScript's 'call' function using apply..js
├── Write Number in Expanded Form
├── Write Number in Expanded Form - Part 2.js
├── X marks the spot!.js
├── Your Ride Is Here.js
├── Your order, please
├── Zero fill... for the Queen!.js
├── Ziiiiip!.js
├── bit "Wise" #1: XOR-cism.js
├── bit "Wise" #2: SHIFT-iness.js
├── compute cube as sums.js
├── extract file name.js
├── first character that repeats.js
├── longest_palindrome.js
├── mkdir -p.js
├── new with apply.js
├── replaceAll(input, find, replace).js
├── search in multidimensional array.js
├── uniq (UNIX style).js
├── up AND down.js
└── zipWith.js
Download .txt
SYMBOL INDEX (539 symbols across 447 files)

FILE: "this" is an other problem.js
  class NamedOne (line 53) | class NamedOne {
    method constructor (line 54) | constructor(f, l) { this.firstName = f; this.lastName = l }
    method fullName (line 55) | get fullName() { return this.firstName + ' ' + this.lastName }
    method fullName (line 56) | set fullName(v) { if (/ /.test(v)) [this.firstName, this.lastName] = v...

FILE: "this" is an other solution.js
  function OnceNamedOne (line 54) | function OnceNamedOne(first, last) {

FILE: (L33T + Grεεκ) Case.js
  function GrεεκL33t (line 27) | function GrεεκL33t(str){

FILE: +1 Array.js
  function upArray (line 14) | function upArray(arr){

FILE: 1 n- Cycle.js
  function cycle (line 25) | function cycle(n) {

FILE: 1RM Calculator.js
  function calculate1RM (line 13) | function calculate1RM(w, r){

FILE: 80's Kids #7: She's a Small Wonder.js
  function Robot (line 23) | function Robot() {

FILE: A Rule of Divisibility by 13.js
  function thirt (line 35) | function thirt(n) {

FILE: A String of Sorts.js
  function sortString (line 14) | function sortString(string,ordering) {

FILE: A disguised sequence (I).js
  function fcn (line 15) | function fcn (n) {

FILE: A tetrahedron of cannonballs.js
  function tetrahedron (line 59) | function tetrahedron(size) {

FILE: Adding Binary Numbers.js
  function add (line 15) | function add(a,b){

FILE: Adding ordinal indicator suffixes to numbers.js
  function numberToOrdinal (line 20) | function numberToOrdinal(n) {

FILE: Adjacent pairs in a string.js
  function countAdjacentPairs (line 32) | function countAdjacentPairs(searchString) {

FILE: Alphabet war - airstrike - letters massacre.js
  function alphabetWar (line 32) | function alphabetWar(fight)

FILE: Alphabetized.js
  function alphabetized (line 13) | function alphabetized(s) {

FILE: Alternating Loops.js
  function combine (line 15) | function combine(...arr) {

FILE: Anagram difference.js
  function anagramDifference (line 13) | function anagramDifference(str1,str2){

FILE: Anything to integer.js
  function toInteger (line 13) | function toInteger(n) {

FILE: Arabian String.js
  function camelize (line 12) | function camelize(str){

FILE: Are we alternate?.js
  function isAlt (line 13) | function isAlt(word) {

FILE: Array Deep Count.js
  function deepCount (line 17) | function deepCount(a){

FILE: Arrays Similar.js
  function arraysSimilar (line 14) | function arraysSimilar(arr1, arr2) {

FILE: Arrh, grabscrab!.js
  function grabscrab (line 18) | function grabscrab(anagram, dictionary) {

FILE: Atbash Cipher Helper.js
  function AtbashCipher (line 23) | function AtbashCipher(abc) {

FILE: Autocomplete! Yay!.js
  function autocomplete (line 20) | function autocomplete(input, d){

FILE: Baby Magpies.js
  function getDifference (line 44) | function getDifference(bird1,bird2) {

FILE: Backspaces in string.js
  function clean_string (line 13) | function clean_string(s) {

FILE: Backwards Read Primes.js
  function backwardsPrime (line 19) | function backwardsPrime(start, stop){
  function isPrime (line 36) | function isPrime(n) {

FILE: Balance the arrays.js
  function balance (line 10) | function balance (arr1, arr2){

FILE: Ball Upwards.js
  function maxBall (line 16) | function maxBall(v0) {

FILE: Base Conversion.js
  function convert (line 36) | function convert(input, source, target) {

FILE: Basic Encryption.js
  function encrypt (line 15) | function encrypt(text, rule) {

FILE: Binary string.js
  function toBinaryString (line 9) | function toBinaryString(num){

FILE: Binary to Text (ASCII) Conversion.js
  function binaryToString (line 13) | function binaryToString(binary) {

FILE: Bingo Card.js
  function getCard (line 22) | function getCard() {
  function getRandomIntInclusive (line 52) | function getRandomIntInclusive(min, max) {

FILE: Bleatrix Trotter (The Counting Sheep).js
  function trotter (line 22) | function trotter(n){

FILE: Body mass index calculation.js
  function calculateBmi (line 21) | function calculateBmi(weight, height) {

FILE: Bowling Pins.js
  function bowlingPins (line 31) | function bowlingPins(arr){

FILE: Bracket Duplicates.js
  function stringParse (line 9) | function stringParse(string){

FILE: Braking well.js
  function dist (line 35) | function dist(v, mu) {
  function speed (line 40) | function speed(d, mu) {

FILE: Break camelCase.js
  function solution (line 8) | function solution(string) {

FILE: Breaking search bad.js
  function search (line 13) | function search(searchTerm) {

FILE: Build Tower Advanced.js
  function towerBuilder (line 39) | function towerBuilder(nFloors, nBlockSz) {

FILE: ByState.js
  function byState (line 36) | function byState(str) {

FILE: Calculate Hypotenuse of Right-angled Triangle.js
  function calculateHypotenuse (line 14) | function calculateHypotenuse(a,b){

FILE: Calculate String Rotation.js
  function shiftedDiff (line 20) | function shiftedDiff(first,second){
  function rotLeft (line 27) | function rotLeft(arr, n) {

FILE: Calculate number of inversions in array.js
  function countInversions (line 18) | function countInversions( array ){

FILE: Calculate the area of a regular n sides polygon inside a circle of radius r.js
  function areaOfPolygonInsideCircle (line 16) | function areaOfPolygonInsideCircle(r, s) {

FILE: Calculate the function f(x) for a simple linear sequence (Easy).js
  function getFunction (line 15) | function getFunction(seq) {

FILE: Calculate the function f(x) for a simple linear sequence (Medium).js
  function getFunction (line 18) | function getFunction(sequence) {

FILE: Cambridge Word Scramble.js
  function mixwords (line 25) | function mixwords(str){

FILE: Can you keep a secret?.js
  function createSecretHolder (line 13) | function createSecretHolder(secret) {

FILE: Case Reversal of Consecutive Duplicates.js
  function reverseCase (line 15) | function reverseCase(string) {

FILE: Cat Kata, Part 1.js
  function peacefulYard (line 48) | function peacefulYard(yd, d) {

FILE: Cat and Mouse - Harder Version.js
  function catMouse (line 25) | function catMouse(x, j){

FILE: Catalog.js
  function catalog (line 28) | function catalog(s, article) {

FILE: Character frequency.js
  function letterFrequency (line 13) | function letterFrequency(text){

FILE: Character limits: How long is your piece of string?.js
  function charCheck (line 27) | function charCheck(text, max, spaces){

FILE: Character with longest consecutive repetition.js
  function longestRepetition (line 9) | function longestRepetition(s) {

FILE: Check if two words are isomorphic to each other.js
  function isomorph (line 22) | function isomorph(a, b) {

FILE: Checkerboard Generation.js
  function checkerboard (line 28) | function checkerboard (size) {

FILE: Checkered Board.js
  function checkeredBoard (line 28) | function checkeredBoard(dimension) {

FILE: Chess Fun #1: Chess Board Cell Color.js
  function chessBoardCellColor (line 24) | function chessBoardCellColor(cell1, cell2) {

FILE: Chess Fun #2: Bishop And Pawn.js
  function bishopAndPawn (line 32) | function bishopAndPawn(bishop, pawn) {

FILE: Christmas Day.js
  function findOutChristmasWeekday (line 19) | function findOutChristmasWeekday(date) {

FILE: Christmas tree.js
  function christmasTree (line 18) | function christmasTree(height) {

FILE: Circularly Sorted Array.js
  function isCircleSorted (line 21) | function isCircleSorted( arr ){

FILE: Clay Pigeon Shooting.js
  function shoot (line 21) | function shoot(x){

FILE: Clock in Mirror.js
  function WhatIsTheTime (line 31) | function WhatIsTheTime(timeInMirror){

FILE: Closures and Scopes.js
  function createFunctions (line 11) | function createFunctions(n) {

FILE: Coding Meetup #10 - Higher-Order Functions Series - Create usernames.js
  function addUsername (line 34) | function addUsername(list) {

FILE: Coding Meetup #13 - Higher-Order Functions Series - Is the meetup language-diverse?.js
  function isLanguageDiverse (line 32) | function isLanguageDiverse(list) {

FILE: Coding Meetup #15 - Higher-Order Functions Series - Find the odd names.js
  function findOddNames (line 31) | function findOddNames(list) {

FILE: Coding Meetup #16 - Higher-Order Functions Series - Ask for missing details.js
  function askForMissingDetails (line 38) | function askForMissingDetails(list) {

FILE: Coding Meetup #7 - Higher-Order Functions Series - Find the most senior developer.js
  function findSenior (line 30) | function findSenior(list) {

FILE: Coding Meetup #8 - Higher-Order Functions Series - Will all continents be represented?.js
  function allContinents (line 29) | function allContinents(list) {

FILE: Coding Meetup #9 - Higher-Order Functions Series - Is the meetup age-diverse?.js
  function isAgeDiverse (line 35) | function isAgeDiverse(list) {

FILE: Collatz.js
  function collatz (line 25) | function collatz(n){

FILE: Color Choice.js
  function checkchoose (line 31) | function checkchoose(m, n) {

FILE: Combinator Flip.js
  function flip (line 13) | function flip(fn) {

FILE: Compare Versions.js
  function compareVersions (line 27) | function compareVersions (version1, version2) {

FILE: Compare powers.js
  function comparePowers (line 18) | function comparePowers([a,b],[x,y]){

FILE: Compare section numbers.js
  function cmp (line 9) | function cmp(section1,section2) {

FILE: Complete Fibonacci Series.js
  function fibonacci (line 10) | function fibonacci(n) {

FILE: Complete The Pattern #12.js
  function pattern (line 88) | function pattern(n){

FILE: Complete The Pattern #16.js
  function pattern (line 46) | function pattern(n){

FILE: Complete The Pattern #8 - Number Pyramid.js
  function pattern (line 73) | function pattern(n){

FILE: Complete The Pattern #9 - Diamond.js
  function pattern (line 116) | function pattern(n){

FILE: Complete the table pattern.js
  function pattern (line 48) | function pattern(rows,columns,str){

FILE: Convert integer to Whitespace format.js
  function whitespaceNumber (line 27) | function whitespaceNumber(n) {

FILE: Count Repeats.js
  function countRepeats (line 12) | function countRepeats(str) {

FILE: Count letters in string.js
  function letterCount (line 9) | function letterCount(s){

FILE: Count the days!.js
  function countDays (line 22) | function countDays(d){

FILE: Count the divisible numbers.js
  function divisibleCount (line 9) | function divisibleCount(x, y, k) {

FILE: Countdown - Longest Word.js
  function longestWord (line 22) | function longestWord(letters){

FILE: Counting DNA Nucleotides.js
  function getCountedNucleotides (line 13) | function getCountedNucleotides(genCode){

FILE: Create Four Letter Birding Codes from Bird Names.js
  function birdCode (line 22) | function birdCode(arr){

FILE: Create Parse HTML CSS Colors.js
  function parseHTMLColor (line 20) | function parseHTMLColor(c) {

FILE: Creating a string for an array of objects from a set of words.js
  function wordsToObject (line 15) | function wordsToObject(input) {

FILE: Cryptography #1 - Viva Cesare.js
  function CaesarCryptoEncode (line 23) | function CaesarCryptoEncode(text, shift) {

FILE: Cumulative Triangle.js
  function cumulativeTriangle (line 31) | function cumulativeTriangle(n) {

FILE: Custom Setters and Getters.js
  function Archiver (line 18) | function Archiver() {

FILE: Custom sort function.js
  function sort (line 9) | function sort(array) {
  function merge (line 17) | function merge(left, right) {

FILE: Cycle Detection: greedy algorithm.js
  function cycle (line 21) | function cycle(a) {

FILE: Cycle a list of values.js
  function cycle (line 33) | function cycle(dir, arr, cur) {

FILE: Cylon Evolution.js
  class Cylon (line 7) | class Cylon{
    method constructor (line 8) | constructor(model){
    method attack (line 11) | attack(){
  class HumanSkin (line 16) | class HumanSkin extends Cylon{
    method constructor (line 17) | constructor(model){
    method infiltrate (line 21) | infiltrate(){

FILE: Dashatize it.js
  function dashatize (line 11) | function dashatize(num) {

FILE: Data compression using run-length encoding.js
  function encode (line 9) | function encode(input) {
  function decode (line 22) | function decode(input) {

FILE: Decipher this!.js
  function decipherThis (line 16) | function decipherThis(str) {

FILE: Decode Morse.js
  function decode (line 21) | function decode(str) {

FILE: Decompose a number.js
  function decompose (line 42) | function decompose(num) {

FILE: Design a Simple Automaton (Finite State Machine).js
  function Automaton (line 42) | function Automaton()

FILE: Difference of 2.js
  function twosDifference (line 19) | function twosDifference(input){

FILE: Digital cypher vol 3 - missing key.js
  function findTheKey (line 41) | function findTheKey(message, code)
  function findSeq (line 50) | function findSeq(arr){

FILE: Disease Spread.js
  function epidemic (line 32) | function epidemic(tm, n, s0, i0, b, a) {

FILE: Disgruntled Employee.js
  function off (line 21) | function off(n) {

FILE: Disguised sequences (II).js
  function fact (line 33) | function fact($num) {
  function u1 (line 38) | function u1(n, p) {
  function v1 (line 47) | function v1(n, p) {

FILE: Divisible Ints.js
  function getCount (line 44) | function getCount(n)

FILE: Doors in the school.js
  function doors (line 28) | function doors(n){

FILE: Drunk friend.js
  function decode (line 7) | function decode(str) {

FILE: Ease the StockBroker.js
  function balanceStatements (line 48) | function balanceStatements(list){

FILE: Easy Balance Checking.js
  function balance (line 32) | function balance(book) {

FILE: Easy Diagonal.js
  function diagonal (line 19) | function diagonal(n, p) {

FILE: Emotional Sort ( ︶︿︶).js
  function sortEmotions (line 34) | function sortEmotions(arr, order){

FILE: English beggars.js
  function beggars (line 13) | function beggars(values, n){

FILE: Errors : histogram.js
  function hist (line 37) | function hist(s) {

FILE: Esolang Interpreters #1 - Introduction to Esolangs and My First Interpreter (MiniStringFuck).js
  function myFirstInterpreter (line 63) | function myFirstInterpreter(code) {

FILE: Esolang: MiniBitMove.js
  function interpreter (line 16) | function interpreter(tape, array) {

FILE: Esolang: Tick.js
  function interpreter (line 24) | function interpreter(tape) {

FILE: Even Fibonacci Sum.js
  function fibonacci (line 15) | function fibonacci(max) {

FILE: Evil Autocorrect Prank.js
  function autocorrect (line 17) | function autocorrect(input){

FILE: Exclamation marks series #17: Put the exclamation marks and question marks to the balance, Are they balanced?.js
  function balance (line 15) | function balance(left,right){

FILE: Exercise in Summing.js
  function minimumSum (line 17) | function minimumSum(values, n) {
  function maximumSum (line 22) | function maximumSum(values, n) {

FILE: Extract last names of people named Michael.js
  function getMichaelLastName (line 17) | function getMichaelLastName(s) {

FILE: Extract the IDs from the data set.js
  function extractIds (line 21) | function extractIds(data){

FILE: FIXME: Hello.js
  class Dinglemouse (line 24) | class Dinglemouse {
    method constructor (line 25) | constructor() {
    method setAge (line 34) | setAge(age) {
    method setSex (line 44) | setSex(sex) {
    method setName (line 54) | setName(name) {
    method hello (line 64) | hello() {

FILE: Factorial length.js
  function count (line 13) | function count(n) {

FILE: Faro Shuffle Count.js
  function faroCount (line 17) | function faroCount(deckSize){

FILE: Feynman's square question.js
  function countSquares (line 24) | function countSquares(n){

FILE: Fibonacci Reloaded.js
  function fib (line 17) | function fib(n) {

FILE: Fibonacci, Tribonacci and friends.js
  function Xbonacci (line 15) | function Xbonacci(s,n){

FILE: File Path Operations.js
  class FileMaster (line 54) | class FileMaster {
    method constructor (line 55) | constructor(filepath) {
    method extension (line 59) | extension() {
    method filename (line 63) | filename() {
    method dirpath (line 67) | dirpath() {

FILE: Financing Plan on Planet XY140Z-n.js
  function finance (line 30) | function finance(n) {

FILE: Financing a purchase.js
  function amort (line 54) | function amort(r, b, t, n) {

FILE: Find X.js
  function findX (line 33) | function findX(n) {

FILE: Find heavy ball - level: conqueror.js
  function findBall (line 28) | function findBall(scales) {

FILE: Find the Mine!.js
  function mineLocation (line 14) | function mineLocation(f){

FILE: Find the Nexus of the Codewars Universe.js
  function nexus (line 19) | function nexus(users) {

FILE: Find the Nth longest string in an Array.js
  function longest (line 5) | function longest(arr, n) {

FILE: Find the unique number.js
  function findUnique (line 15) | function findUnique(numbers) {

FILE: Flexible Card Game.js
  function Card (line 43) | function Card(suit, rank) {
  method face_card (line 56) | get face_card() {
  function Deck (line 68) | function Deck() {

FILE: Floating-point Approximation (I).js
  function f (line 21) | function f(x) {

FILE: Fold an array.js
  function foldArray (line 36) | function foldArray(a, n) {

FILE: Follow that Spy.js
  function findRoutes (line 12) | function findRoutes(routes) {

FILE: Football - Yellow and Red Cards.js
  function menStillStanding (line 13) | function menStillStanding(cards) {

FILE: Format Text.js
  function format (line 32) | function format(text, width) {

FILE: Format words into a sentence.js
  function formatWords (line 9) | function formatWords(words){

FILE: Framed Reflection.js
  function mirror (line 13) | function mirror(text){

FILE: Free pizza.js
  function pizzaRewards (line 12) | function pizzaRewards(customers, minOrders, minPrice) {

FILE: Friday the 13ths.js
  function fridayTheThirteenths (line 20) | function fridayTheThirteenths(start, end=start) {

FILE: Frog jumping.js
  function solution (line 22) | function solution(a) {

FILE: Fruit Machine.js
  function fruit (line 82) | function fruit(reels, spins){

FILE: Fun with lists: countIf.js
  function countIf (line 17) | function countIf(head, p) {

FILE: Fun with lists: filter.js
  function Node (line 17) | function Node(data, next = null) {
  function filter (line 21) | function filter(head, p) {

FILE: Fun with lists: map.js
  function map (line 28) | function map(head, func) {

FILE: Fun with lists: reduce.js
  function reduce (line 31) | function reduce(head, f, init) {

FILE: Fun with trees: max sum.js
  function maxSum (line 27) | function maxSum(root) {

FILE: Functional Lists.js
  function List (line 47) | function List() {}
  function EmptyList (line 49) | function EmptyList() {}
  function ListNode (line 60) | function ListNode(value, next) { this.v = value; this.n = next; }

FILE: GA-DE-RY-PO-LU-KI cypher vol 2.js
  function encode (line 39) | function encode(str,key)
  function decode (line 52) | function decode(str,key)

FILE: Get All Possible Anagrams from a Hash.js
  function getWords (line 11) | function getWords(hash){
  function permute (line 22) | function permute(permutation) {

FILE: Grill it!.js
  function grille (line 19) | function grille(message, code) {

FILE: Grouped by commas.js
  function groupByCommas (line 18) | function groupByCommas(n) {

FILE: Hamming Distance.js
  function hamming (line 11) | function hamming(a,b) {

FILE: Happy numbers.js
  function isHappy (line 16) | function isHappy(n) {

FILE: Help Mrs Jefferson.js
  function shortestArrang (line 25) | function shortestArrang(n) {

FILE: Help the bookseller !.js
  function stockList (line 30) | function stockList(lA, lC){

FILE: Hidden "Cubic" numbers.js
  function isSumOfCubes (line 25) | function isSumOfCubes(s){

FILE: Highest Rank Number in an Array.js
  function highestRank (line 16) | function highestRank(arr){

FILE: Ho Ho Ho with Functions!.js
  function ho (line 16) | function ho(ho) {

FILE: Holiday Shopping Priority Queue.js
  function HolidayPriorityQueue (line 38) | function HolidayPriorityQueue(){

FILE: Holy cats.js
  function holycats (line 5) | function holycats(input){

FILE: House of cards.js
  function houseOfCards (line 14) | function houseOfCards(floors){

FILE: How Many Reindeers?.js
  function reindeers (line 16) | function reindeers(presents) {

FILE: How Much?.js
  function howmuch (line 33) | function howmuch(m, n) {

FILE: How many feelings?.js
  function countFeelings (line 26) | function countFeelings(string, array) {

FILE: How much hex is the fish.js
  function fisHex (line 15) | function fisHex(str) {

FILE: I need more speed!.js
  function reverse (line 13) | function reverse(arr) {

FILE: IP Address to Number.js
  function ipToNum (line 41) | function ipToNum(ip) {
  function numToIp (line 44) | function numToIp(num) {

FILE: Ideal electron distribution.js
  function atomicNumber (line 16) | function atomicNumber(num){

FILE: If you can read this....js
  function to_nato (line 19) | function to_nato(words) {

FILE: Image host filename generator.js
  function generateName (line 18) | function generateName()

FILE: Inserting multiple strings into another string.js
  function insertAtIndexes (line 20) | function insertAtIndexes(phrase,word,indexes){

FILE: Inside Out Strings.js
  function insideOut (line 11) | function insideOut(x){

FILE: Integer depth.js
  function computeDepth (line 21) | function computeDepth (x){

FILE: Integers: Recreation Two.js
  function prod2sum (line 30) | function prod2sum(a, b, c, d) {

FILE: Is Integer Array ?.js
  function isIntArray (line 12) | function isIntArray(arr) {

FILE: Javascript filter - 2.js
  function roomMates (line 21) | function roomMates( rooms, floor ){

FILE: Javascript filter - 3.js
  function searchNames (line 19) | function searchNames( logins ){

FILE: JoJo's Bizarre Kata.js
  function isJojo (line 43) | function isJojo(name){

FILE: Ka Ka Ka cypher - words only vol 1.js
  function kaCokadekaMe (line 31) | function kaCokadekaMe(word)

FILE: Kebabize.js
  function kebabize (line 12) | function kebabize(str) {

FILE: LOTTO 6 aus 49 - 6 of 49.js
  function getRandomIntInclusive (line 50) | function getRandomIntInclusive(min, max) {
  function checkForWinningCategory (line 55) | function checkForWinningCategory(checkCombination, winningCombination) {

FILE: Letter Changes.js
  function letterChange (line 11) | function letterChange(str) {

FILE: Levenshtein Distance.js
  function levenshtein (line 9) | function levenshtein(a, b) {

FILE: Linear Regression of Y on X.js
  function regression_line (line 27) | function regression_line(x,y){

FILE: Linked Lists - Insert Nth Node.js
  function Node (line 16) | function Node(data) {
  function insertNth (line 21) | function insertNth(head, index, data) {

FILE: Linked Lists - Insert Sort.js
  function Node (line 13) | function Node(data) {
  function insertSort (line 18) | function insertSort(head) {

FILE: Linked Lists - Recursive Reverse.js
  function Node (line 10) | function Node(data = null, next = null) {
  function reverse (line 15) | function reverse(list, prev = null) {

FILE: Linked Lists - Remove Duplicates.js
  function Node (line 37) | function Node(data) {
  function removeDuplicates (line 42) | function removeDuplicates(head) {

FILE: Linked Lists - Shuffle Merge.js
  function Node (line 12) | function Node(data) {
  function shuffleMerge (line 17) | function shuffleMerge(first, second) {

FILE: Linked Lists - Sorted Insert.js
  function Node (line 12) | function Node(data, nxt) {
  function sortedInsert (line 16) | function sortedInsert(head, data) {

FILE: Linked Lists-Length & Count.js
  function Node (line 19) | function Node(data) {
  function length (line 24) | function length(head) {
  function count (line 33) | function count(head, data) {

FILE: Look and say numbers.js
  function lookAndSay (line 20) | function lookAndSay(data,len){

FILE: Loose Change.js
  function looseChange (line 14) | function looseChange(cents){

FILE: Lowest product of 4 consecutive numbers.js
  function lowestProduct (line 11) | function lowestProduct(input) {

FILE: Lucas numbers.js
  function lucasnum (line 36) | function lucasnum(n){

FILE: Make the Deadfish swim..js
  function parse (line 16) | function parse( data )

FILE: Manhattan Distance.js
  function manhattanDistance (line 19) | function manhattanDistance([a1,a2], [b1,b2]){

FILE: Matrix Addition.js
  function matrixAddition (line 30) | function matrixAddition(a, b){

FILE: Matrix Transpose.js
  function transpose (line 16) | function transpose(matrix) {

FILE: Max Accessor Function.js
  function max (line 14) | function max(data, accessor) {

FILE: Maze Runner.js
  function mazeRunner (line 34) | function mazeRunner(maze, directions) {

FILE: Meeting.js
  function meeting (line 14) | function meeting(s) {

FILE: Mexican Wave.js
  function wave (line 18) | function wave(str){

FILE: Minutes to Midnight.js
  function minutesToMidnight (line 26) | function minutesToMidnight(d){

FILE: Mirror, Mirror.js
  function evilTwin (line 18) | function evilTwin(obj) {

FILE: Missing Alphabet.js
  function insertMissingLetters (line 22) | function insertMissingLetters (str){

FILE: Mix Fruit Juice.js
  function mixFruit (line 11) | function mixFruit (arr) {

FILE: Moduli number system.js
  function fromNb2Str (line 26) | function fromNb2Str(n,sys){

FILE: Most Frequent Weekdays.js
  function mostFrequentDays (line 20) | function mostFrequentDays(year){

FILE: Moves in squared strings (II).js
  function rot (line 45) | function rot(strng) {
  function selfieAndRot (line 49) | function selfieAndRot(strng) {
  function oper (line 55) | function oper(fct, s) {

FILE: Moves in squared strings (III).js
  function rot90Clock (line 42) | function rot90Clock(strng) {
  function diag1Sym (line 54) | function diag1Sym(strng) {
  function selfieAndDiag1 (line 66) | function selfieAndDiag1(strng) {
  function oper (line 78) | function oper(fct, s) {

FILE: Moves in squared strings (IV).js
  function diag2Sym (line 41) | function diag2Sym(strng) {
  function rot90Counter (line 53) | function rot90Counter(strng) {
  function selfieDiag2Counterclock (line 65) | function selfieDiag2Counterclock(strng) {
  function oper (line 71) | function oper(fct, s) {

FILE: Mr. Safety's treasures.js
  function unlock (line 18) | function unlock(str){

FILE: Multiples of 3 and 5 redux.js
  function solution (line 19) | function solution(number){

FILE: Multiplication Tables.js
  function multiplicationTable (line 18) | function multiplicationTable(row,col){

FILE: Mutual Recursion.js
  function F (line 13) | function F(n) {
  function M (line 18) | function M(n) {

FILE: N smallest elements in original order.js
  function firstNSmallest (line 19) | function firstNSmallest(array, n){

FILE: N-th Fibonacci.js
  function nthFibo (line 15) | function nthFibo(n) {

FILE: Name That Integer.js
  function detectInt (line 28) | function detectInt() {

FILE: New Cashier Does Not Know About Space or Shift.js
  function getOrder (line 30) | function getOrder(input) {

FILE: Non-even substrings.js
  function solve (line 12) | function solve(s){

FILE: Not prime numbers.js
  function notPrimes (line 17) | function notPrimes(a,b){
  function isPrime (line 24) | function isPrime(n) {

FILE: Nuclear Missile Manager.js
  function launchAll (line 9) | function launchAll(launchMissile) {

FILE: Number Shortening Filter.js
  function shortenNumber (line 21) | function shortenNumber(suffixes, base) {

FILE: Number Zoo Patrol.js
  function findNumber (line 18) | function findNumber(array) {

FILE: Number of anagrams in an array of words.js
  function anagramCounter (line 12) | function anagramCounter (wordsArray) {

FILE: Number of measurements to spot the counterfeit coin.js
  function howManyMeasurements (line 15) | function howManyMeasurements(n){

FILE: Number of permutations without repetitions.js
  function perms (line 24) | function perms(element) {

FILE: Numerical Palindrome #1.5.js
  function palindrome (line 23) | function palindrome(num,s) {

FILE: Numericals of a String.js
  function numericals (line 16) | function numericals(s){

FILE: Numerology.js
  function solution (line 7) | function solution(date){

FILE: Odd Even number of divisors.js
  function oddity (line 13) | function oddity(n){

FILE: Odd-heavy Array.js
  function isOddHeavy (line 14) | function isOddHeavy(n){

FILE: Once.js
  function once (line 14) | function once(func) {

FILE: Only Duplicates.js
  function onlyDuplicates (line 11) | function onlyDuplicates(str) {

FILE: Ordinal Numbers.js
  function ordinal (line 19) | function ordinal(number, brief) {

FILE: Ore Numbers.js
  function isOre (line 14) | function isOre(n){

FILE: Organise duplicate numbers in list.js
  function group (line 11) | function group(arr) {

FILE: PI approximation.js
  function iterPi (line 25) | function iterPi(epsilon) {

FILE: Padovan numbers.js
  function padovan (line 26) | function padovan(n) {

FILE: Pair of gloves.js
  function numberOfPairs (line 22) | function numberOfPairs(gloves){

FILE: Palindrome for your Dome.js
  function palindrome (line 22) | function palindrome(string) {

FILE: Palindromic Numbers.js
  function palindromize (line 25) | function palindromize(num){

FILE: Palindromization.js
  function palindromization (line 30) | function palindromization(s, n){

FILE: Parabolic Arc Length.js
  function lenCurve (line 9) | function lenCurve(n) {

FILE: Parity bit - Error detecting code.js
  function parityBit (line 28) | function parityBit(binary) {

FILE: Pascal's Triangle #2.js
  function pascal (line 17) | function pascal(depth) {

FILE: Pascal's Triangle.js
  function pascalsTriangle (line 17) | function pascalsTriangle(n) {

FILE: Password generator.js
  function passwordGen (line 14) | function passwordGen(){
  function gen (line 21) | function gen(){

FILE: Paths in the Grid.js
  function numberOfRoutes (line 14) | function numberOfRoutes(m, n){
  function factorial (line 17) | function factorial(n){

FILE: PatternCraft - Decorator.js
  class Marine (line 29) | class Marine {
    method constructor (line 30) | constructor(_damage, _armor) {
  class MarineWeaponUpgrade (line 36) | class MarineWeaponUpgrade {
    method constructor (line 37) | constructor(marine) {
  class MarineArmorUpgrade (line 43) | class MarineArmorUpgrade {
    method constructor (line 44) | constructor(marine) {

FILE: PatternCraft - State.js
  class SiegeState (line 29) | class SiegeState {
    method constructor (line 30) | constructor() {
  class TankState (line 36) | class TankState {
    method constructor (line 37) | constructor() {
  class Tank (line 43) | class Tank {
    method constructor (line 44) | constructor() {
    method canMove (line 47) | get canMove() {return this.state.move  }
    method damage (line 48) | get damage() {return this.state.dmg  }

FILE: PatternCraft - Strategy.js
  class Fly (line 29) | class Fly {
    method move (line 30) | move(unit) {
  class Walk (line 35) | class Walk {
    method move (line 36) | move(unit) {
  class Viking (line 41) | class Viking {
    method constructor (line 42) | constructor() {
    method move (line 47) | move() {

FILE: Pentabonacci.js
  function countOddPentaFib (line 27) | function countOddPentaFib(n) {

FILE: Pete, the baker (part 2).js
  function getMissingIngredients (line 20) | function getMissingIngredients(recipe, added) {

FILE: Piano Kata, Part 1.js
  function blackOrWhiteKey (line 25) | function blackOrWhiteKey(keyPressCount) {

FILE: Piano Kata, Part 2.js
  function whichNote (line 22) | function whichNote(keyPressCount) {

FILE: Ping-Pong service problem.js
  function service (line 19) | function service(score){

FILE: Pizza pieces.js
  function maxPizza (line 15) | function maxPizza(cut) {

FILE: Playing on a chessboard.js
  function game (line 39) | function game(n) {

FILE: Playing with passphrases.js
  function playPass (line 27) | function playPass(s, n) {

FILE: Plenty of Fish in the Pond.js
  function fish (line 73) | function fish(shoal){

FILE: Point in Polygon.js
  function pointInPoly (line 26) | function pointInPoly(poly, point) {

FILE: Points On A Line.js
  function onLine (line 7) | function onLine(points) {

FILE: Points in the circle.js
  function pointsNumber (line 12) | function pointsNumber(r){

FILE: Pokemon Damage Calculator.js
  function calculateDamage (line 33) | function calculateDamage(yourType, opponentType, attack, defense) {

FILE: Polybius square cipher - encode.js
  function polybius (line 21) | function polybius (text) {

FILE: Pong! [Basics].js
  class Pong (line 35) | class Pong {
    method constructor (line 36) | constructor(maxScore) {
    method play (line 43) | play(ballPos, playerPos) {

FILE: Positions Average.js
  function posAverage (line 28) | function posAverage(s) {

FILE: Prefill an Array.js
  function prefill (line 28) | function prefill(n, v) {

FILE: Prime factorization.js
  function PrimeFactorizer (line 11) | function PrimeFactorizer(n) {

FILE: Primorial Of a Number.js
  function numPrimorial (line 34) | function numPrimorial(n){
  function isPrime (line 42) | function isPrime(n) {

FILE: Prize Draw.js
  function rank (line 38) | function rank(st, we, n) {

FILE: Proof Read.js
  function proofread (line 11) | function proofread (str) {

FILE: Pyramid Array.js
  function pyramid (line 11) | function pyramid(n) {

FILE: Quick (n choose k) calculator.js
  function choose (line 18) | function choose(n,k){

FILE: RNA to Protein Sequence Translation.js
  function protein (line 12) | function protein(rna) {

FILE: Rainfall.js
  function calculateData (line 21) | function calculateData(town, strng, calulateCallback) {
  function mean (line 42) | function mean(town, strng) {
  function variance (line 46) | function variance(town, strng) {

FILE: Range function.js
  function range (line 11) | function range(a,b,c){

FILE: Rank Vector.js
  function ranks (line 11) | function ranks(a) {

FILE: Ranking System.js
  function rankings (line 15) | function rankings(arr){

FILE: Reach Me and Sum my Digits.js
  function sumDigNthTerm (line 46) | function sumDigNthTerm(initval, patternl, nthterm) {

FILE: Reducing by rules to get the result.js
  function reduceByRules (line 32) | function reduceByRules(numbers, rules){

FILE: Regex Tic Tac Toe Win Checker.js
  function regexTicTacToeWinChecker (line 31) | function regexTicTacToeWinChecker(board) {

FILE: Remember.js
  function remember (line 19) | function remember(str) {

FILE: Repeated Substring.js
  function f (line 23) | function f(s) {
  function findCycle (line 28) | function findCycle(arr){

FILE: Return 1, 2, 3 randomly.js
  function one_two_three (line 9) | function one_two_three() {

FILE: Reverse every other word in the string.js
  function reverse (line 5) | function reverse(str){

FILE: Reverse or rotate?.js
  function revrot (line 23) | function revrot(str, sz) {

FILE: RoboScript #1 - Implement Syntax Highlighting.js
  function highlight (line 29) | function highlight(code) {

FILE: Rotate Array (JS).js
  function rotate (line 41) | function rotate(array, n) {

FILE: Rotation Cipher Cracker.js
  function decode (line 28) | function decode(msg,contents){

FILE: Round by 0.5 steps.js
  function solution (line 15) | function solution(n){

FILE: Routes in a square grid.js
  function routes (line 23) | function routes(n){

FILE: Running Average.js
  function runningAverage (line 22) | function runningAverage() {

FILE: Salesman's Travel.js
  function travel (line 34) | function travel(r, zipcode) {

FILE: Same Array?.js
  function same (line 15) | function same(a1, a2)

FILE: Santa's Master Plan.js
  function getAttendees (line 24) | function getAttendees(peopleInvited, responses){

FILE: Scheduling (Shortest Job First or SJF).js
  function SJF (line 28) | function SJF(jobs, index){

FILE: Scrabble best word.js
  function getBestWord (line 15) | function getBestWord(points,words){

FILE: Secret Message.js
  function findSecretMessage (line 15) | function findSecretMessage(paragraph) {

FILE: Separate The Wheat From The Chaff.js
  function wheatFromChaff (line 35) | function wheatFromChaff(values) {

FILE: Sequences and Series.js
  function getScore (line 21) | function getScore(n) {

FILE: Shortest steps to a number.js
  function shortestStepsToNum (line 40) | function shortestStepsToNum(num) {

FILE: Simple Fun #116: Prime String.js
  function primeString (line 19) | function primeString(s) {

FILE: Simple Fun #135: Missing Alphabets.js
  function missingAlphabets (line 40) | function missingAlphabets(s) {

FILE: Simple Fun #165: Withdraw.js
  function withdraw (line 19) | function withdraw(n) {

FILE: Simple Fun #170: Sum Groups.js
  function sumGroups (line 30) | function sumGroups(ar) {

FILE: Simple Fun #23: Square Digits Sequence.js
  function squareDigitsSequence (line 46) | function squareDigitsSequence(a0) {

FILE: Simple Fun #258: Is Divisible By 6.js
  function isDivisibleBy6 (line 34) | function isDivisibleBy6(s) {

FILE: Simple Fun #303: Prime Product.js
  function primeProduct (line 32) | function primeProduct(n){
  function isPrime (line 46) | function isPrime(n) {

FILE: Simple Fun #319: Number And IP Address.js
  function numberAndIPaddress (line 35) | function numberAndIPaddress(s){
  function ipToNum (line 39) | function ipToNum(ip) {
  function numToIp (line 42) | function numToIp(num) {

FILE: Simple Fun #79: Delete a Digit.js
  function deleteDigit (line 19) | function deleteDigit(n) {

FILE: Simple Sentences.js
  function makeSentence (line 18) | function makeSentence(parts) {

FILE: Simple Simple Simple String Expansion.js
  function stringExpansion (line 21) | function stringExpansion(s) {

FILE: Simple Substitution Cipher Helper.js
  function SubstitutionCipher (line 20) | function SubstitutionCipher(ab1, ab2) {

FILE: Simple Web Framework #1: Create a basic router.js
  class Router (line 21) | class Router {
    method constructor (line 23) | constructor() {
    method bind (line 27) | bind(url, method, action) {
    method runRequest (line 31) | runRequest(url, method) {

FILE: Simple card game.js
  function winner (line 31) | function winner(deckSteve, deckJosh) {

FILE: Simple frequency sort.js
  function solve (line 13) | function solve(arr){

FILE: Simple prime streaming.js
  function solve (line 16) | function solve(a,b){

FILE: Simple string indices.js
  function solve (line 18) | function solve(str,idx){

FILE: Simple sum of pairs.js
  function solve (line 19) | function solve(n) {

FILE: Simple transposition.js
  function simpleTransposition (line 15) | function simpleTransposition(text) {

FILE: Simpson's Rule - Approximate Integration.js
  function simpson (line 23) | function simpson(n) {

FILE: Single Word Pig Latin.js
  function pigLatin (line 20) | function pigLatin(string){

FILE: Single character palindromes.js
  function solve (line 14) | function solve(s){

FILE: Sometimes.js
  function sometimes (line 29) | function sometimes(fn) {

FILE: Sort My Animals.js
  function sortAnimal (line 13) | function sortAnimal(animal) {

FILE: Sort odd and even numbers in different order.js
  function sortArray (line 14) | function sortArray(array) {

FILE: Sort sentence pseudo-alphabetically.js
  function sort (line 9) | function sort(s){

FILE: Sorting by bits.js
  function sortByBit (line 23) | function sortByBit(arr) {

FILE: Special Multiples.js
  function countSpecMult (line 17) | function countSpecMult(n, mxval) {

FILE: Sqrt approximation.js
  function sqrtApproximation (line 16) | function sqrtApproximation(number){

FILE: Squares in a Rectangle.js
  function findSquares (line 7) | function findSquares(x,y){

FILE: Srot the inner ctonnet in dsnnieedcg oredr.js
  function sortTheInnerContent (line 23) | function sortTheInnerContent(words)

FILE: Statistics for an Athletic Association.js
  function stat (line 32) | function stat(str) {
  function calculateTime (line 58) | function calculateTime(totalSeconds){

FILE: Steps in Primes.js
  function step (line 39) | function step(g, m, n){
  function isPrime (line 45) | function isPrime(n) {

FILE: Street Fighter 2 - Character Selection.js
  function streetFighterSelection (line 71) | function streetFighterSelection(fighters, position, moves){

FILE: String Breakers.js
  function stringBreakers (line 20) | function stringBreakers(n, string){

FILE: String Integer Greater-than.js
  function stringIntGreaterThan (line 8) | function stringIntGreaterThan(a, b) {

FILE: String Shortener (shrink).js
  function shorten (line 29) | function shorten(string, length, glue='...') {

FILE: String Suffixes.js
  function stringSuffix (line 17) | function stringSuffix(s) {

FILE: String array revisal.js
  function dup (line 15) | function dup(s) {

FILE: String average.js
  function averageString (line 9) | function averageString(str) {

FILE: String character frequency.js
  function solve (line 15) | function solve(s){

FILE: String reduction.js
  function solve (line 13) | function solve(a, b) {

FILE: String searching with wildcard.js
  function find (line 24) | function find(needle, haystack){

FILE: String tops.js
  function tops (line 25) | function tops(msg) {

FILE: String transformer.js
  function stringTransformer (line 12) | function stringTransformer(str) {

FILE: Stringing me along.js
  function createMessage (line 9) | function createMessage(str) {

FILE: Strip Url Params.js
  function stripUrlParams (line 11) | function stripUrlParams(url, paramsToStrip){

FILE: Sum The Tree.js
  function sumTheTreeValues (line 48) | function sumTheTreeValues(root){

FILE: Sum of Two Integers.js
  function add (line 23) | function add(x, y)

FILE: Sum of a Sequence [Hard-Core Version].js
  function sequenceSum (line 15) | function sequenceSum(begin, end, step){

FILE: Sum of many ints.js
  function f (line 11) | function f(n, m) {

FILE: Sum of nested numbers.js
  function sumNestedNumbers (line 10) | function sumNestedNumbers(arr) {

FILE: Summarize ranges.js
  function summaryRanges (line 13) | function summaryRanges(nums) {

FILE: Sums of Parts.js
  function partsSums (line 29) | function partsSums(ls) {

FILE: Surrounding Primes for a value.js
  function primeBefAft (line 29) | function primeBefAft(num) {
  function isPrime (line 44) | function isPrime(n) {

FILE: T.T.T.17: Split odd and even.js
  function splitOddAndEven (line 25) | function splitOddAndEven(n) {

FILE: Tank Truck.js
  function tankvol (line 20) | function tankvol(h, d, vt) {

FILE: Temperature converter.js
  function convertTemp (line 47) | function convertTemp(temp, from, to) {

FILE: The Book of Mormon.js
  function Mormons (line 13) | function Mormons(startingNumber, reach, target){

FILE: The Desperate Rocket Scientist.js
  function fix_countdown (line 26) | function fix_countdown() {

FILE: The Modulo-3 Sequence.js
  function sequence (line 17) | function sequence(n){

FILE: The Most Sacred of Days.js
  function blackFriday (line 9) | function blackFriday(year) {

FILE: The Non-Discriminate Factorial.js
  function factorial (line 17) | function factorial(n) {

FILE: The Office V - Find a Chair.js
  function meeting (line 24) | function meeting(x, need){

FILE: The Supermarket Queue.js
  function queueTime (line 35) | function queueTime(customers, n) {

FILE: The Vowel Code.js
  function encode (line 23) | function encode(string){
  function decode (line 33) | function decode(string){

FILE: The elegance of the code.js
  function factorial (line 19) | function factorial(num){

FILE: The maximum sum value of ranges -- Simple version.js
  function maxSum (line 29) | function maxSum(arr,range){

FILE: The nth smallest integer.js
  function nthSmallest (line 17) | function nthSmallest(arr, n) {

FILE: The range() function.js
  function range (line 30) | function range(start = 0, end, step = 1) {

FILE: The takeWhile Function.js
  function takeWhile (line 15) | function takeWhile (arr, pred) {

FILE: Thinkful - Logic Drills: Red and bumpy.js
  function colorProbability (line 23) | function colorProbability(color, texture){

FILE: Three added Characters.js
  function addedChar (line 35) | function addedChar(s1, s2){

FILE: Throwing Darts.js
  function scoreThrows (line 21) | function scoreThrows(r){

FILE: Tick Toward.js
  function tickToward (line 12) | function tickToward([s1,s2],[e1,e2]){

FILE: Time-like string format.js
  function solution (line 14) | function solution(hour) {

FILE: Transform To Prime.js
  function minimumNumber (line 26) | function minimumNumber(numbers){
  function isPrime (line 32) | function isPrime(n) {

FILE: Tree Depth.js
  function recordDepth (line 12) | function recordDepth(tree, d = 0) {

FILE: Triangle number check.js
  function isTriangleNumber (line 28) | function isTriangleNumber(number) {

FILE: Tug-o'-War.js
  function tug_o_war (line 27) | function tug_o_war(teams) {

FILE: Turkish National Identity Number.js
  function checkValidTrNumber (line 27) | function checkValidTrNumber(n) {

FILE: Two Sum.js
  function twoSum (line 12) | function twoSum(numbers, target) {

FILE: Two cube sums.js
  function hasTwoCubeSums (line 13) | function hasTwoCubeSums(n) {

FILE: Unary function chainer.js
  function chained (line 11) | function chained(functions) {

FILE: Update inventory in your smartphone store.js
  function updateInventory (line 15) | function updateInventory(curStock, newStock) {

FILE: Upside down numbers.js
  function solve (line 19) | function solve(x, y) {

FILE: Upside-Down Pyramid Addition...REVERSED!.js
  function reverse (line 23) | function reverse(right) {

FILE: Validate Credit Card Number.js
  function validate (line 34) | function validate(n){

FILE: Vasya - Clerk.js
  function tickets (line 17) | function tickets(peopleInLine){

FILE: Vasya and System of Equations.js
  function solution (line 21) | function solution(n, m){

FILE: Vowel Recognition.js
  function vowelRecognition (line 12) | function vowelRecognition(input){

FILE: Vowel Shifting.js
  function vowelShift (line 28) | function vowelShift(text, n) {

FILE: Walter's miraculous FizzBuzz factory.js
  function fizzBuzzFactory (line 32) | function fizzBuzzFactory (arr){

FILE: What century is it?.js
  function whatCentury (line 15) | function whatCentury(year)

FILE: What's in a name?.js
  function nameInStr (line 39) | function nameInStr(str, name){

FILE: Wheel of Fortune.js
  function winner (line 30) | function winner(c) {

FILE: Which filetypes are you using the most?.js
  function solve (line 31) | function solve(files) {

FILE: Who won the election?.js
  function getWinner (line 32) | function getWinner(l) {

FILE: Wind component calculation.js
  function windComponents (line 30) | function windComponents(rwy, windDirection, windSpeed) {

FILE: Word Mesh.js
  function wordMesh (line 28) | function wordMesh(arr){

FILE: Word Patterns.js
  function wordPattern (line 15) | function wordPattern(pattern, str) {

FILE: Word Segmentation: MaxMatch.js
  function maxMatch (line 17) | function maxMatch(sentence){

FILE: Wordify an integer.js
  function wordify (line 21) | function wordify(n){

FILE: World Bits War.js
  function bitsWar (line 13) | function bitsWar(numbers) {

FILE: Write Number in Expanded Form - Part 2.js
  function expandedForm (line 12) | function expandedForm(num) {

FILE: X marks the spot!.js
  function x (line 19) | function x(n) {

FILE: Your Ride Is Here.js
  function ride (line 28) | function ride(group,comet){

FILE: Zero fill... for the Queen!.js
  function zeroFill (line 13) | function zeroFill(number, size) {

FILE: Ziiiiip!.js
  function zipObject (line 21) | function zipObject(keys, values=[]) {

FILE: bit "Wise" #1: XOR-cism.js
  function swapper (line 18) | function swapper(a, b) {

FILE: compute cube as sums.js
  function findSummands (line 18) | function findSummands(n){

FILE: extract file name.js
  class FileNameExtractor (line 27) | class FileNameExtractor {
    method extractFileName (line 28) | static extractFileName (dirtyFileName) {

FILE: first character that repeats.js
  function firstDup (line 9) | function firstDup (s) {

FILE: longest_palindrome.js
  function isPalindrome (line 28) | function isPalindrome(line) {

FILE: mkdir -p.js
  function mkdirp (line 23) | function mkdirp(root, ...path) {

FILE: new with apply.js
  function construct (line 45) | function construct(Class,...args) {

FILE: replaceAll(input, find, replace).js
  function replaceAll (line 9) | function replaceAll(input, find, replace) {

FILE: search in multidimensional array.js
  function flatten (line 13) | function flatten(arr){

FILE: uniq (UNIX style).js
  function uniq (line 10) | function uniq(a) {

FILE: up AND down.js
  function arrange (line 37) | function arrange(strng) {

FILE: zipWith.js
  function zipWith (line 21) | function zipWith(fn,a0,a1) {
Condensed preview — 607 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (937K chars).
[
  {
    "path": "\"this\" is an other problem.js",
    "chars": 2193,
    "preview": "/*\nDescription:\nAfter you've solved @priyankaherur's problem ( http://www.codewars.com/kata/this-is-a-problem/javascript"
  },
  {
    "path": "\"this\" is an other solution.js",
    "chars": 1897,
    "preview": "/*\nDescription:\nIn a previous kata ( http://www.codewars.com/kata/547f1a8d4a437abdf800055c ) we try to create an object "
  },
  {
    "path": "(L33T + Grεεκ) Case.js",
    "chars": 1790,
    "preview": "/*\nDescription:\nGetting Familiar: LEET: (sometimes written as \"1337\" or \"l33t\"), also known as eleet or leetspeak, is an"
  },
  {
    "path": "+1 Array.js",
    "chars": 790,
    "preview": "/*\nDescription:\nGiven an array of integers of any length, return an array that has 1 added to the value represented by t"
  },
  {
    "path": "1 n- Cycle.js",
    "chars": 865,
    "preview": "/*\nDescription:\nLet be n an integer prime with 10 e.g. 7.\n\n1/7 = 0.142857 142857 142857 ....\n\nWe see that the decimal pa"
  },
  {
    "path": "1RM Calculator.js",
    "chars": 1009,
    "preview": "/*\nDescription:\nYou just got done with your set at the gym, and you are wondering how much weight you could lift if you "
  },
  {
    "path": "80's Kids #7: She's a Small Wonder.js",
    "chars": 1636,
    "preview": "/*\nDescription:\nVicky is quite the small wonder. Most people don't even realize she's not a real girl, but a robot livin"
  },
  {
    "path": "A Rule of Divisibility by 13.js",
    "chars": 1531,
    "preview": "/*\nDescription:\nWhen you divide the successive powers of 10 by 13 you get the following remainders of the integer divisi"
  },
  {
    "path": "A String of Sorts.js",
    "chars": 867,
    "preview": "/*\nDescription:\nDefine a method that accepts 2 strings as parameters. The method returns the first string sorted by the "
  },
  {
    "path": "A Taste of Curry.js",
    "chars": 1898,
    "preview": "/*\nDescription:\nYour relative have decided to open a small Indian restaurant, and so she bought an automatic cooker. It "
  },
  {
    "path": "A disguised sequence (I).js",
    "chars": 487,
    "preview": "/*\nDescription:\nGiven u0 = 1, u1 = 2 and the relation 6unun+1-5unun+2+un+1un+2 = 0 calculate un for any integer n >= 0.\n"
  },
  {
    "path": "A tetrahedron of cannonballs.js",
    "chars": 2198,
    "preview": "/*\nDescription:\nPreviously on Codewars...\n\n\"Triangular numbers are so called because of the equilateral triangular shape"
  },
  {
    "path": "ASCII hex converter.js",
    "chars": 661,
    "preview": "/*\nWrite a module Converter that can take ASCII text and convert it to hexadecimal. The class should also be able to tak"
  },
  {
    "path": "Ackermann Function.js",
    "chars": 1156,
    "preview": "/*\nDescription:\nThe Ackermann function is a famous function that played a big role in computability theory as the first "
  },
  {
    "path": "Adding Binary Numbers.js",
    "chars": 677,
    "preview": "/*\nDescription:\n##Task: You have to write a function add which takes two binary numbers as strings and returns their sum"
  },
  {
    "path": "Adding ordinal indicator suffixes to numbers.js",
    "chars": 1284,
    "preview": "/*\nDescription:\nFinish the function numberToOrdinal, which should take a number and return it as a string with the corre"
  },
  {
    "path": "Adjacent pairs in a string.js",
    "chars": 1640,
    "preview": "/*\nDescription:\nYou know how sometimes you write the the same word twice in a sentence, but then don't notice that it ha"
  },
  {
    "path": "Almost Even.js",
    "chars": 924,
    "preview": "/*\nDescription:\nWe need the ability to divide an unknown integer into a given number of even parts — or at least as even"
  },
  {
    "path": "Alphabet war - airstrike - letters massacre.js",
    "chars": 1527,
    "preview": "/*\nDescription:\nIntroduction\nThere is a war and nobody knows - the alphabet war!\nThere are two groups of hostile letters"
  },
  {
    "path": "Alphabetized.js",
    "chars": 609,
    "preview": "/*\nDescription:\nThe alphabetized kata\nRe-order the characters of a string, so that they are concatenated into a new stri"
  },
  {
    "path": "Alternating Loops.js",
    "chars": 613,
    "preview": "/*\nDescription:\nWrite\n\nfunction combine()\nthat combines arrays by alternatingly taking elements passed to it.\n\nE.g\n\ncomb"
  },
  {
    "path": "Anagram difference.js",
    "chars": 971,
    "preview": "/*\nDescription:\nGiven two words, how many letters do you have to remove from them to make them anagrams?\nExample\nFirst w"
  },
  {
    "path": "Anything to integer.js",
    "chars": 516,
    "preview": "/*\nDescription:\nYour task is to program a function which converts any input to an integer.\n\nDo not perform rounding, the"
  },
  {
    "path": "Arabian String.js",
    "chars": 483,
    "preview": "/*\nDescription:\nYou must create a method that can convert a string from any format into CamelCase. This must support sym"
  },
  {
    "path": "Are they the \"same\"?",
    "chars": 1648,
    "preview": "/*\nDescription:\nGiven two arrays a and b write a function comp(a, b) (compSame(a, b) in Clojure) that checks whether the"
  },
  {
    "path": "Are we alternate?.js",
    "chars": 719,
    "preview": "/*\nDescription:\nCreate a function isAlt() that accepts a string as an argument and validates whether the vowels (a, e, i"
  },
  {
    "path": "Array Deep Count.js",
    "chars": 512,
    "preview": "/*\nDescription:\nArray.prototype.length will give you the number of top-level elements in an array.\n\nYour task is to crea"
  },
  {
    "path": "Array Helpers.js",
    "chars": 1451,
    "preview": "/*\nDescription:\nThis kata is designed to test your ability to extend the functionality of built-in classes. In this case"
  },
  {
    "path": "Array#reduce.js",
    "chars": 921,
    "preview": "/*\nDescription:\nIn this kata, you must define the Array.reduce method.\n\nI have disabled the pre-existing reduce methods."
  },
  {
    "path": "Array.diff",
    "chars": 436,
    "preview": "/*\nDescription:\nYour goal in this kata is to implement a difference function, which subtracts one list from another and "
  },
  {
    "path": "Arrays Similar.js",
    "chars": 637,
    "preview": "/*\nDescription:\nWrite a function that determines whether the passed in arrays are similar. Similar means they contain th"
  },
  {
    "path": "Arrh, grabscrab!.js",
    "chars": 785,
    "preview": "/*\nDescription:\nPirates have notorious difficulty with enunciating. They tend to blur all the letters together and screa"
  },
  {
    "path": "Atbash Cipher Helper.js",
    "chars": 1487,
    "preview": "/*\nDescription:\nThe Atbash cipher is a simple substitution cipher originally known to be implemented using the Hebrew al"
  },
  {
    "path": "Autocomplete! Yay!.js",
    "chars": 1363,
    "preview": "/*\nDescription:\nIt's time to create an autocomplete function! Yay!\n\nThe autocomplete function will take in an input stri"
  },
  {
    "path": "Baby Magpies.js",
    "chars": 1508,
    "preview": "/*\nMagpies are my favourite birds\nBaby ones even more so...\n\n\nIt is a little known fact^ that the black & white colours "
  },
  {
    "path": "Backspaces in string.js",
    "chars": 463,
    "preview": "/*\nDescription:\nAssume \"#\" is like a backspace in string. This means that string \"a#bc#d\" actually is \"bd\"\n\nYour task is"
  },
  {
    "path": "Backwards Read Primes.js",
    "chars": 1678,
    "preview": "/*\nDescription:\nBackwards Read Primes are primes that when read backwards in base 10 (from right to left) are a differen"
  },
  {
    "path": "Balance the arrays.js",
    "chars": 557,
    "preview": "/*\nDescription:\nCheck that the two provided arrays both contain the same number of different unique items, regardless of"
  },
  {
    "path": "Ball Upwards.js",
    "chars": 1029,
    "preview": "/*\nYou throw a ball vertically upwards with an initial speed v (in km per hour). The height h of the ball at each time t"
  },
  {
    "path": "Banker's Plan.js",
    "chars": 2249,
    "preview": "/*\nDescription:\nJohn has some amount of money of which he wants to deposit a part f0 to the bank at the beginning of yea"
  },
  {
    "path": "Base Conversion.js",
    "chars": 2086,
    "preview": "/*\nDescription:\nIn this kata you have to implement a base converter, which converts positive integers between arbitrary "
  },
  {
    "path": "Basic Encryption.js",
    "chars": 703,
    "preview": "/*\nDescription:\nThe most basic encryption method is to map a char to another char by a certain math rule. Because every "
  },
  {
    "path": "Binary string.js",
    "chars": 404,
    "preview": "/*\nDescription:\nGiven a positive (or 0) number, return a string of 1's and 0's representing it's binary value: toBinaryS"
  },
  {
    "path": "Binary to Text (ASCII) Conversion.js",
    "chars": 620,
    "preview": "/*\nDescription:\nWrite a function that takes in a binary string and returns the equivalent decoded text (the text is ASCI"
  },
  {
    "path": "Binding within the List Monad.js",
    "chars": 1118,
    "preview": "/*\nDescription:\nIn Haskell, Monads are simple containers, or even 'box-like' datastructures, of which lists are included"
  },
  {
    "path": "Bingo Card.js",
    "chars": 1713,
    "preview": "/*\nDescription:\nAfter yet another dispute on their game the Bingo Association decides to change course and automize the "
  },
  {
    "path": "Bit Counting",
    "chars": 399,
    "preview": "/*\nDescription:\nWrite a function that takes an integer as input, and returns the number of bits that are equal to one in"
  },
  {
    "path": "Bleatrix Trotter (The Counting Sheep).js",
    "chars": 1391,
    "preview": "/*\nDescription:\nBleatrix Trotter the sheep has devised a strategy that helps her fall asleep faster. First, she picks a "
  },
  {
    "path": "Body mass index calculation.js",
    "chars": 1493,
    "preview": "/*\nDescription:\nFor long period JavaScript warriors trained a lot in coding kata. But to find way warrior also need phys"
  },
  {
    "path": "Bouncing Balls",
    "chars": 1148,
    "preview": "/*Description:\nA child is playing with a ball on the nth floor of a tall building. The height of this floor, h, is known"
  },
  {
    "path": "Bowling Pins.js",
    "chars": 819,
    "preview": "/*\nDescription:\nMount the Bowling Pins!\nTask:\nDid you ever play Bowling? Short: You have to throw a bowl into 10 Pins ar"
  },
  {
    "path": "Braces status.js",
    "chars": 746,
    "preview": "/*\nDescription:\nWrite a function that checks the braces status in a string, and return True if all braces are properly c"
  },
  {
    "path": "Bracket Duplicates.js",
    "chars": 809,
    "preview": "/*\nDescription:\nCreate a program that will take in a string as input and, if there are duplicates of more than two alpha"
  },
  {
    "path": "Braking well.js",
    "chars": 1757,
    "preview": "/*\nDescription:\nBraking distance d1 is the distance a vehicle will go from the point when it brakes to when it comes to "
  },
  {
    "path": "Break camelCase.js",
    "chars": 251,
    "preview": "/*\nComplete the solution so that the function will break up camel casing, using a space between words.\n\nExample\nsolution"
  },
  {
    "path": "Breaking search bad.js",
    "chars": 479,
    "preview": "/*\nDescription:\nWe have a search function who return an array of titles that match the String passed as an argument.\n\nva"
  },
  {
    "path": "Build Tower",
    "chars": 785,
    "preview": "/*\nDescription:\nBuild Tower\nBuild Tower by the following given argument:\nnumber of floors (integer and always greater th"
  },
  {
    "path": "Build Tower Advanced.js",
    "chars": 1159,
    "preview": "/*\nDescription:\nBuild Tower Advanced\nBuild Tower by the following given arguments:\nnumber of floors (integer and always "
  },
  {
    "path": "Build a pile of Cubes",
    "chars": 904,
    "preview": "/*\nDescription:\nYour task is to construct a building which will be a pile of n cubes. The cube at the bottom will have a"
  },
  {
    "path": "Buying a car",
    "chars": 2204,
    "preview": "/*\nDescription:\nLet us begin with an example:\n\nA man has a rather old car being worth $2000. He saw a secondhand car bei"
  },
  {
    "path": "ByState.js",
    "chars": 1906,
    "preview": "/*\nDescription:\nGiven a string with friends to visit in different states:\n\nad3=\"John Daggett, 341 King Road, Plymouth MA"
  },
  {
    "path": "Calculate Hypotenuse of Right-angled Triangle.js",
    "chars": 971,
    "preview": "/*\nDescription:\nTo solve this Kata, complete the function, calculateHypotenuse(a,b), which will return the length of the"
  },
  {
    "path": "Calculate String Rotation.js",
    "chars": 1329,
    "preview": "/*\nDescription:\nWrite a function that receives two strings and returns n, where n is equal to the number of characters w"
  },
  {
    "path": "Calculate number of inversions in array.js",
    "chars": 865,
    "preview": "/*\nDescription:\nArray inversion indicates how far the array is from being sorted.\n\nInversions are pairs of elements in a"
  },
  {
    "path": "Calculate the area of a regular n sides polygon inside a circle of radius r.js",
    "chars": 769,
    "preview": "/*\nDescription:\nWrite the following function:\n\nfunction areaOfPolygonInsideCircle(circleRadius, numberOfSides)\nIt should"
  },
  {
    "path": "Calculate the function f(x) for a simple linear sequence (Easy).js",
    "chars": 793,
    "preview": "/*\nFor any given linear sequence, calculate the function [f(x)] and return it as a string.\n\nFor example:\n\ngetFunction([0"
  },
  {
    "path": "Calculate the function f(x) for a simple linear sequence (Medium).js",
    "chars": 940,
    "preview": "/*\nDescription:\nThis is a follow-up from my previous Kata which can be found here: http://www.codewars.com/kata/5476f4ca"
  },
  {
    "path": "Cambridge Word Scramble.js",
    "chars": 1693,
    "preview": "/*\nDescription:\nOne of the first chain emails I ever received was about a supposed Cambridge University study that sugge"
  },
  {
    "path": "CamelCase Method.js",
    "chars": 527,
    "preview": "/*\nDescription:\nWrite simple .camelCase method (camel_case function in PHP, CamelCase in C# or camelCase in Java) for st"
  },
  {
    "path": "CamelCase to underscore.js",
    "chars": 1363,
    "preview": "/*\nDescription:\nYou wrote all your unit test names in camelCase. But some of your colleagues have troubles reading these"
  },
  {
    "path": "Can you keep a secret?.js",
    "chars": 541,
    "preview": "/*\nThere's no such thing as private properties on a coffeescript object! But, maybe there are?\n\nImplement a function cre"
  },
  {
    "path": "Case Reversal of Consecutive Duplicates.js",
    "chars": 779,
    "preview": "/*\nDescription:\nThe aim of this Kata is to write a function which will reverse the case of all consecutive duplicate let"
  },
  {
    "path": "Cat Kata, Part 1.js",
    "chars": 3829,
    "preview": "/*\nDescription:\nThe story you are about to hear is true\nOur cat, Balor, sadly died of cancer in 2015.\n\nWhile he was aliv"
  },
  {
    "path": "Cat and Mouse - Harder Version.js",
    "chars": 1110,
    "preview": "/*\nDescription:\nYou will be given a string (x) featuring a cat 'C', a dog 'D' and a mouse 'm'. The rest of the string wi"
  },
  {
    "path": "Catalog.js",
    "chars": 1322,
    "preview": "/*\nDescription:\nYou are given a small extract of a catalog:\n\ns = \"<prod><name>drill</name><prx>99</prx><qty>5</qty></pro"
  },
  {
    "path": "Chain Evaluation.js",
    "chars": 707,
    "preview": "/*\nDescription:\nMethod chaining is a very interesting way to keep your program clean.\n\nAs a part of this Kata, you need "
  },
  {
    "path": "Character frequency.js",
    "chars": 1186,
    "preview": "/*\nDescription:\nWrite a function that takes a piece of text in the form of a string and returns the letter frequency cou"
  },
  {
    "path": "Character limits: How long is your piece of string?.js",
    "chars": 1442,
    "preview": "/*\nDescription:\nCara is applying for several different jobs. The online application forms ask her to respond within a sp"
  },
  {
    "path": "Character with longest consecutive repetition.js",
    "chars": 894,
    "preview": "/*\nDescription:\nFor a given string s find the character c with longest consecutive repetition and return a tuple (c, l) "
  },
  {
    "path": "Check if two words are isomorphic to each other.js",
    "chars": 926,
    "preview": "/*\nDescription:\nTwo strings a and b are called isomorphic if there is a one to one mapping possible for every character "
  },
  {
    "path": "Checkerboard Generation.js",
    "chars": 1917,
    "preview": "/*\nDescription:\nCheckerboard\nWrite a method checkerboard/Checkerboard which takes an integer size and returns a checkerb"
  },
  {
    "path": "Checkered Board.js",
    "chars": 1969,
    "preview": "/*\nDescription:\nWrite a function which takes one parameter representing the dimensions of a checkered board. The board w"
  },
  {
    "path": "Checking Groups",
    "chars": 917,
    "preview": "/*\nDescription:\nIn English and programming, groups can be made using symbols such as () and {} that change meaning. Howe"
  },
  {
    "path": "Chess Fun #1: Chess Board Cell Color.js",
    "chars": 854,
    "preview": "/*\nDescription:\nTask\nGiven two cells on the standard chess board, determine whether they have the same color or not.\n\nEx"
  },
  {
    "path": "Chess Fun #2: Bishop And Pawn.js",
    "chars": 1405,
    "preview": "/*\nDescription:\nTask\nGiven the positions of a white bishop and a black pawn on the standard chess board, determine wheth"
  },
  {
    "path": "Christmas Day.js",
    "chars": 791,
    "preview": "/*\nDescription:\nSometimes it's useful to know on which day of the week Christmas, the holly holiday, will occur.\nWrite a"
  },
  {
    "path": "Christmas tree.js",
    "chars": 573,
    "preview": "/*\nDescription:\nCreate a function christmasTree(height) that returns a christmas tree of the correct height\n\nchristmasTr"
  },
  {
    "path": "Circularly Sorted Array.js",
    "chars": 795,
    "preview": "/*\nDescription:\nWrite a method, isCircleSorted(int[] A) (Java, JavaScript), or Array#circularly_sorted? (Ruby) that dete"
  },
  {
    "path": "Clay Pigeon Shooting.js",
    "chars": 1330,
    "preview": "/*\nDescription:\nPete and his mate Phil are out in the countryside shooting clay pigeons with a shotgun - amazing fun.\n\nT"
  },
  {
    "path": "Clock in Mirror.js",
    "chars": 957,
    "preview": "/*\nDescription:\nPeter can see a clock in the mirror from the place he sits in the office. When he saw the clock shows 12"
  },
  {
    "path": "Clocky Mc Clock-Face.js",
    "chars": 872,
    "preview": "/*\nDescription:\nStory\nDue to lack of maintenance the minute-hand has fallen off Town Hall clock face.\n\nAnd because the l"
  },
  {
    "path": "Closures and Scopes.js",
    "chars": 670,
    "preview": "/*\nDescription:\nWe want to create a function, which returns an array of functions, which return their index in the array"
  },
  {
    "path": "Coding Meetup #10 - Higher-Order Functions Series - Create usernames.js",
    "chars": 2053,
    "preview": "/*\nDescription:\nGiven the following input array:\n\nvar list1 = [\n  { firstName: 'Emily', lastName: 'N.', country: 'Irelan"
  },
  {
    "path": "Coding Meetup #13 - Higher-Order Functions Series - Is the meetup language-diverse?.js",
    "chars": 2394,
    "preview": "/*\nDescription:\nYou will be given an array of objects representing data about developers who have signed up to attend th"
  },
  {
    "path": "Coding Meetup #15 - Higher-Order Functions Series - Find the odd names.js",
    "chars": 1622,
    "preview": "/*\nDescription:\nYou will be given an array of objects representing data about developers who have signed up to attend th"
  },
  {
    "path": "Coding Meetup #16 - Higher-Order Functions Series - Ask for missing details.js",
    "chars": 2089,
    "preview": "/*\nDescription:\nYou will be given an array of objects representing data about developers who have signed up to attend th"
  },
  {
    "path": "Coding Meetup #7 - Higher-Order Functions Series - Find the most senior developer.js",
    "chars": 1696,
    "preview": "/*\nDescription:\nYou will be given an array of objects representing data about developers who have signed up to attend th"
  },
  {
    "path": "Coding Meetup #8 - Higher-Order Functions Series - Will all continents be represented?.js",
    "chars": 1770,
    "preview": "/*\nDescription:\nYou will be given an array of objects (associative arrays in PHP) representing data about developers who"
  },
  {
    "path": "Coding Meetup #9 - Higher-Order Functions Series - Is the meetup age-diverse?.js",
    "chars": 2674,
    "preview": "/*\nDescription:\nYou will be given an array of objects (associative arrays in PHP) representing data about developers who"
  },
  {
    "path": "Collatz.js",
    "chars": 1030,
    "preview": "/*\nDescription:\nPreface\nA collatz sequence, starting with a positive integern, is found by repeatedly applying the follo"
  },
  {
    "path": "Color Choice.js",
    "chars": 2270,
    "preview": "/*\nDescription:\nYou know combinations: for example, if you take 5 cards from a 52 cards deck you have 2,598,960 differen"
  },
  {
    "path": "Combinator Flip.js",
    "chars": 458,
    "preview": "/*\nDescription:\nCreate a combinator function named flip that takes a function as an argument and returns that function w"
  },
  {
    "path": "Compare Versions.js",
    "chars": 1619,
    "preview": "/*\nDescription:\nKaran's company makes software that provides different features based on the version of operating system"
  },
  {
    "path": "Compare powers.js",
    "chars": 965,
    "preview": "/*\nDescription:\nYou certainly can tell which is the larger number between 210 and 215.\n\nBut what about, say, 210 and 310"
  },
  {
    "path": "Compare section numbers.js",
    "chars": 1308,
    "preview": "/*\nDescription:\nSection numbers are strings of dot-separated integers. The highest level sections (chapters) are numbere"
  },
  {
    "path": "Complete Fibonacci Series.js",
    "chars": 486,
    "preview": "/*\nDescription:\nThe function 'fibonacci' should return an array of fibonacci numbers. The function takes a number as an "
  },
  {
    "path": "Complete The Pattern #12.js",
    "chars": 2520,
    "preview": "/*\n###Task:\n\nYou have to write a function pattern which returns the following Pattern(See Examples) upto (2n-1) rows, wh"
  },
  {
    "path": "Complete The Pattern #16.js",
    "chars": 1182,
    "preview": "/*\n###Task:\n\nYou have to write a function pattern which returns the following Pattern(See Examples) upto n number of row"
  },
  {
    "path": "Complete The Pattern #8 - Number Pyramid.js",
    "chars": 2210,
    "preview": "/*\nDescription:\n###Task:\n\nYou have to write a function pattern which creates the following Pattern(See Examples) upto n("
  },
  {
    "path": "Complete The Pattern #9 - Diamond.js",
    "chars": 3666,
    "preview": "/*\nDescription:\nTask:\nYou have to write a function pattern which returns the following Pattern(See Examples) upto (2n-1)"
  },
  {
    "path": "Complete the table pattern.js",
    "chars": 1476,
    "preview": "/*\nWhen no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the"
  },
  {
    "path": "Consecutive strings",
    "chars": 633,
    "preview": "/*\nYou are given an array strarr of strings and an integer k. Your task is to return the first longest string consisting"
  },
  {
    "path": "Consonant value,js",
    "chars": 1196,
    "preview": "/*\nTo introduce the problem think to my neighbor who drives a tanker truck. The level indicator is down and he is worrie"
  },
  {
    "path": "Convert integer to Whitespace format.js",
    "chars": 2067,
    "preview": "/*\nDescription:\nStory\nHereinafter, [space] refers to \" \", [tab] refers to \"\\t\", and [LF] refers to \"\\n\" for illustrative"
  },
  {
    "path": "Convert string to camel case",
    "chars": 451,
    "preview": "/*\nDescription:\nComplete the method/function so that it converts dash/underscore delimited words into camel casing. The "
  },
  {
    "path": "Coordinates Validator",
    "chars": 990,
    "preview": "/*\nDescription:\nYou need to create a function that will validate if given parameters are valid geographical coordinates."
  },
  {
    "path": "Count Repeats.js",
    "chars": 390,
    "preview": "/*\nDescription:\nWrite a function that returns the count of characters that have to be removed in order to get a string w"
  },
  {
    "path": "Count characters in your string",
    "chars": 418,
    "preview": "/*Description:\nThe main idea is to count all the occuring characters(UTF-8) in string. If you have string like this aba "
  },
  {
    "path": "Count letters in string.js",
    "chars": 457,
    "preview": "/*\nDescription:\nIn this kata, you've to count lowercase letters in a given string and return the letter count in a hash "
  },
  {
    "path": "Count the days!.js",
    "chars": 1098,
    "preview": "/*\nDescription:\nLittle Annie is very excited for upcoming events. She want's to know how many days she have to wait for "
  },
  {
    "path": "Count the divisible numbers.js",
    "chars": 471,
    "preview": "/*\nDescription:\nWrite function divisibleCount(x, y, k) that takes in 3 numbers x, y and k, and returns the number of int"
  },
  {
    "path": "Count the smiley faces!",
    "chars": 889,
    "preview": "/*\nDescription:\nGiven an array (arr) as an argument complete the function countSmileys that should return the total numb"
  },
  {
    "path": "Countdown - Longest Word.js",
    "chars": 1649,
    "preview": "/*\nDescription:\n#Detail\n\nCountdown is a British game show with number and word puzzles. The letters round consists of th"
  },
  {
    "path": "Counting DNA Nucleotides.js",
    "chars": 1432,
    "preview": "/*\nDescription:\nFor a given DNA genectic code represented by a string, count the number of times the letters A (adenine)"
  },
  {
    "path": "Counting Duplicates",
    "chars": 779,
    "preview": "/*\nDescription:\nCount the number of Duplicates\nWrite a function that will return the count of distinct case-insensitive "
  },
  {
    "path": "Create Four Letter Birding Codes from Bird Names.js",
    "chars": 1624,
    "preview": "/*\nDescription:\nIn the world of birding there are four-letter codes for the common names of birds. These codes are creat"
  },
  {
    "path": "Create Parse HTML CSS Colors.js",
    "chars": 1456,
    "preview": "/*\nDescription:\nIn this kata you parse RGB colors represented by strings. The formats are primarily used in HTML and CSS"
  },
  {
    "path": "Create a frame!.js",
    "chars": 892,
    "preview": "/*\nDescription:\n*************************\n*  Create a frame!      *\n*           __     __   *\n*          /  \\~~~/  \\  *\n"
  },
  {
    "path": "Creating a string for an array of objects from a set of words.js",
    "chars": 1292,
    "preview": "/*\nDescription:\nYou're given a string containing a sequence of words separated with whitespaces. Let's say it is a seque"
  },
  {
    "path": "Cryptography #1 - Viva Cesare.js",
    "chars": 1407,
    "preview": "/*\nDescription:\nLet’s get to know our hero: Agent #134 - Mr. Slayer.\n\nHe was sent by his CSV agency to Ancient Rome in o"
  },
  {
    "path": "Cumulative Triangle.js",
    "chars": 765,
    "preview": "/*\nDescription:\nImagine a triangle of numbers which follows this pattern:\n\nStarting with the number \"1\", \"1\" is position"
  },
  {
    "path": "Custom Array Filters.js",
    "chars": 1374,
    "preview": "/*\nDescription:\nDave has a lot of data he is required to apply filters to, which are simple enough, but he wants a short"
  },
  {
    "path": "Custom Setters and Getters.js",
    "chars": 1676,
    "preview": "/*\nDescription:\nLet's take a look at an interesting feature of JS: custom Getters and Setters for objects.\n\nSkimming ove"
  },
  {
    "path": "Custom each() Array method.js",
    "chars": 1108,
    "preview": "/*\nDescription:\nJavaScript provides an Array.prototype.forEach method that allows you to iterate over array values. For "
  },
  {
    "path": "Custom sort function.js",
    "chars": 991,
    "preview": "/*\nDescription:\nComplete the sort function so that it returns the items passed into it in alphanumerical order. Convenie"
  },
  {
    "path": "Cycle Detection: greedy algorithm.js",
    "chars": 1893,
    "preview": "/*\nDescription:\nIn computer science, cycle detection is the algorithmic problem of finding a cycle in a sequence of iter"
  },
  {
    "path": "Cycle a list of values.js",
    "chars": 1473,
    "preview": "/*\nDescription:\nPrologue\nYou're part of a team porting MS Paint into the browser and currently working on a new UI compo"
  },
  {
    "path": "Cylon Evolution.js",
    "chars": 784,
    "preview": "/*\nDescription:\nThere are all types of cylons. The trick is, some look like humans. Using prototypical inheritance, crea"
  },
  {
    "path": "Dashatize it.js",
    "chars": 357,
    "preview": "/*\nDescription:\nGiven a number, return a string with dash'-'marks before and after each odd integer, but do not begin or"
  },
  {
    "path": "Data Reverse.js",
    "chars": 777,
    "preview": "/*\nDescription:\nA stream of data is received and needs to be reversed.\n\nEach segment is 8 bits long, meaning the order o"
  },
  {
    "path": "Data compression using run-length encoding.js",
    "chars": 980,
    "preview": "/*\nDescription:\nRun-length encoding (RLE) is a very simple form of lossless data compression in which runs of data are s"
  },
  {
    "path": "Dead Ants.js",
    "chars": 956,
    "preview": "/*\nDescription:\nAn orderly trail of ants is marching across the park picnic area.\n\nIt looks something like this:\n\n..ant."
  },
  {
    "path": "Decipher this!.js",
    "chars": 657,
    "preview": "/*\nDescription:\nYou are given a secret message you need to decipher. Here are the things you need to know to decipher it"
  },
  {
    "path": "Decode Morse.js",
    "chars": 1835,
    "preview": "/*\nDescription:\nOh no! You have stumbled upon a mysterious signal consisting of beeps of various lengths, and it is of u"
  },
  {
    "path": "Decode the Morse code",
    "chars": 2538,
    "preview": "/*\nDescription:\nPart of Series 1/3\nThis kata is part of a series on the Morse code. After you solve this kata, you may m"
  },
  {
    "path": "Decompose a number.js",
    "chars": 1167,
    "preview": "/*\nDescription:\nDecompose a number num into an array (tuple in Haskell, array of arrays long[][] in C# or Java) of the f"
  },
  {
    "path": "Deep Freeze.js",
    "chars": 406,
    "preview": "/*\nDescription:\nCreate a complement to the Object.freeze function, Object.deepFreeze\n\nThis method should apply the Objec"
  },
  {
    "path": "Delete occurrences of an element if it occurs more than n times",
    "chars": 1147,
    "preview": "/*\nDescription:\nEnough is enough!\nAlice and Bob were on a holiday. Both of them took many pictures of the places they've"
  },
  {
    "path": "Descriptive selections of data.js",
    "chars": 906,
    "preview": "/*\nDescription:\nFill in the functions with the help of the provided methods only, i.e. just compose with them:\n\nrest(), "
  },
  {
    "path": "Design a Simple Automaton (Finite State Machine).js",
    "chars": 1966,
    "preview": "/*\nDescription:\nCreate a finite automaton that has three states. Finite automatons are the same as finite state machines"
  },
  {
    "path": "Detect Pangram",
    "chars": 538,
    "preview": "/*\nDescription:\nA pangram is a sentence that contains every single letter of the alphabet at least once. For example, th"
  },
  {
    "path": "Difference of 2.js",
    "chars": 742,
    "preview": "/*\nDescription:\nThe objective is to return all pairs of integers from a given array of integers that have a difference o"
  },
  {
    "path": "Digital cypher vol 3 - missing key.js",
    "chars": 2267,
    "preview": "/*\nDescription:\nIntroduction\nDigital Cypher assigns a unique number to each letter of the alphabet:\n\n a  b  c  d  e  f  "
  },
  {
    "path": "Disease Spread.js",
    "chars": 2407,
    "preview": "/*\nDescription:\nIn 1978 the British Medical Journal reported on an outbreak of influenza at a British boarding school. T"
  },
  {
    "path": "Disgruntled Employee.js",
    "chars": 1251,
    "preview": "/*\nDescription:\nSir Bobsworth is a custodian at a local data center. As he suspected, Bobsworth recently found out he is"
  },
  {
    "path": "Disguised sequences (II).js",
    "chars": 1781,
    "preview": "/*\nDescription:\nLet us define two sums u(n, p) and v(n, p):\n\n\\large u(n, p) = \\sum_{k=0}^{n}{(-1)^k}*p*{4^{n-k}}*\\binom{"
  },
  {
    "path": "Divisible Ints.js",
    "chars": 1746,
    "preview": "/*\nDescription:\nYou are given an integer N. Your job is to figure out how many substrings inside of N divide evenly with"
  },
  {
    "path": "Does my number look big in this?",
    "chars": 774,
    "preview": "/*\nDescription:\nA Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the nu"
  },
  {
    "path": "Don't rely on luck.",
    "chars": 372,
    "preview": "/*\nDescription:\nThe test fixture I use for this kata is pre-populated.\n\nIt will compare your guess to a random number ge"
  },
  {
    "path": "Doors in the school.js",
    "chars": 1200,
    "preview": "/*\nDescription:\nIn the morning all the doors in the school are closed. The school is quite big: there are N doors. Then "
  },
  {
    "path": "Dragon's Curve.js",
    "chars": 1322,
    "preview": "/*\nDescription:\nThe dragon's curve is a self-similar fractal which can be obtained by a recursive method.\n\nStarting with"
  },
  {
    "path": "Drunk friend.js",
    "chars": 962,
    "preview": "/*\nDescription:\nYou're hanging out with your friends in a bar, when suddenly one of them is so drunk, that he can't spea"
  },
  {
    "path": "Dubstep",
    "chars": 1479,
    "preview": "/*\nDescription:\nPolycarpus works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performan"
  },
  {
    "path": "Duplicate Arguments",
    "chars": 553,
    "preview": "/*\nDescription:\nComplete the solution so that it returns true if it contains any duplicate argument values. Any number o"
  },
  {
    "path": "Duplicate Encoder",
    "chars": 877,
    "preview": "/*\nDescription:\nThe goal of this exercise is to convert a string to a new string where each character in the new string "
  },
  {
    "path": "Ease the StockBroker.js",
    "chars": 2296,
    "preview": "/*\nDescription:\nClients place orders to a stockbroker as strings. The order can be simple or multiple.\n\nType of a simple"
  },
  {
    "path": "Easter egg list in ReactJS.js",
    "chars": 1090,
    "preview": "/*\nDescription:\nYou decide to create a simple list of your favourite Easter eggs in React.\n\nChallenge\nLearn about nestin"
  },
  {
    "path": "Easy Balance Checking.js",
    "chars": 2047,
    "preview": "/*\nDescription:\nYou are given a (small) check book as a - sometimes - cluttered (by non-alphanumeric characters) string:"
  },
  {
    "path": "Easy Diagonal.js",
    "chars": 1158,
    "preview": "/*\nDescription:\nIn the drawing below we have a part of the Pascal's triangle, lines are numbered from zero (top). The le"
  },
  {
    "path": "Emotional Sort ( ︶︿︶).js",
    "chars": 1384,
    "preview": "/*\nDescription:\nEmotional Sort ( ︶︿︶)\nYou'll have a function called \"sortEmotions\" that will return an array of emotions"
  },
  {
    "path": "Encrypt this!.js",
    "chars": 1029,
    "preview": "/*\nDescription:\nAcknowledgments:\nI thank yvonne-liu for the idea and for the example tests :)\n\nDescription:\nEncrypt this"
  },
  {
    "path": "English beggars.js",
    "chars": 1220,
    "preview": "/*\nDescription:\nBorn a misinterpretation of this kata, your task here is pretty simple: given an array of values and an "
  },
  {
    "path": "Enigeliisohe too Eniigeeliiisoohee Toroanisoliatooro.js",
    "chars": 2156,
    "preview": "/*\nDescription:\nCreate an English to Enigeliisohe Translator, which after each consonant or semivowel inserts in lower c"
  },
  {
    "path": "Equal Sides Of An Array",
    "chars": 1828,
    "preview": "/*\nDescription:\nYou are going to be given an array of integers. Your job is to take that array and find an index N where"
  },
  {
    "path": "Errors : histogram.js",
    "chars": 2199,
    "preview": "/*\nDescription:\nIn a factory a printer prints labels for boxes. The printer uses colors which, for the sake of simplicit"
  },
  {
    "path": "Escape HTML Markup.js",
    "chars": 726,
    "preview": "/*\nDescription:\nCreate a function, which escapes all HTML markup of a given string. Replacing entities of special charac"
  },
  {
    "path": "Esolang Interpreters #1 - Introduction to Esolangs and My First Interpreter (MiniStringFuck).js",
    "chars": 8590,
    "preview": "/*\nDescription:\nFor the rest of this Kata, I would recommend considering \"fuck\" to be non-profane.\n\nEsolang Interpreters"
  },
  {
    "path": "Esolang: MiniBitMove.js",
    "chars": 1093,
    "preview": "/*\nDescription:\nTask:\nThis kata asks you to make a custom esolang interpreter for the language [MiniBitMove](http://esol"
  },
  {
    "path": "Esolang: Tick.js",
    "chars": 1839,
    "preview": "/*\nDescription:\nTask\nMake a custom esolang interpreter for the language Tick. Tick is a descendant of Ticker but also ve"
  },
  {
    "path": "Even Fibonacci Sum.js",
    "chars": 550,
    "preview": "/*\nDescription:\nGive the summation of all even numbers in a Fibonacci sequence up to, but not including, the maximum val"
  },
  {
    "path": "Evil Autocorrect Prank.js",
    "chars": 1038,
    "preview": "/*\nDescription:\nYour friend won't stop texting his girlfriend. It's all he does. All day. Seriously. The texts are so mu"
  },
  {
    "path": "Exclamation marks series #17: Put the exclamation marks and question marks to the balance, Are they balanced?.js",
    "chars": 721,
    "preview": "/*\nDescription:\nEach exclamation mark weight is 2; Each question mark weight is 3. Put two string left and right to the "
  },
  {
    "path": "Exercise in Summing.js",
    "chars": 883,
    "preview": "/*\nDescription:\nYour task is to finish two functions, minimumSum and maximumSum, that take 2 parameters:\n\nvalues: an arr"
  },
  {
    "path": "Extract Nested Object Reference.js",
    "chars": 735,
    "preview": "/*\nDescription:\nYou are given a complex object that has many deeply nested variables. You don't want to go the usual if "
  },
  {
    "path": "Extract last names of people named Michael.js",
    "chars": 821,
    "preview": "/*\nDescription:\nGiven a text, for example:\n\nconst inputText = \"Michael, how are you? - Cool, how is John Williamns and M"
  },
  {
    "path": "Extract the IDs from the data set.js",
    "chars": 633,
    "preview": "/*\nDescription:\nComplete the method so that it returns an array of all ID's passed in. The data structure will be simila"
  },
  {
    "path": "FIXME: Hello.js",
    "chars": 1792,
    "preview": "/*\nDescription:\nThe code provided has a method hello which is supposed to show only those attributes which have been exp"
  },
  {
    "path": "Factorial length.js",
    "chars": 449,
    "preview": "/*\nDescription:\nIn this Kata, you will implement a function count that takes an integer and returns the number of digits"
  },
  {
    "path": "Faro Shuffle Count.js",
    "chars": 933,
    "preview": "/*\nDescription:\nA faro shuffle of a deck of playing cards is a shuffle in which the deck is split exactly in half and th"
  },
  {
    "path": "Fat Fingers.js",
    "chars": 1927,
    "preview": "/*\nDescription:\nFreddy has a really fat left pinky finger, and every time Freddy tries to type an A, he accidentally hit"
  },
  {
    "path": "Feynman's square question.js",
    "chars": 1018,
    "preview": "/*\nDescription:\nFeynman's squares\nRichard Phillips Feynman was a well-known American physicist and a recipient of the No"
  },
  {
    "path": "Fibonacci Reloaded.js",
    "chars": 622,
    "preview": "/*\nDescription:\nAnd here is Fibonacci again. This time we want to go one step further. Our fib() function must be faster"
  },
  {
    "path": "Fibonacci, Tribonacci and friends.js",
    "chars": 1192,
    "preview": "/*\nDescription:\nIf you have completed the Tribonacci sequence kata, you would know by now that mister Fibonacci has at l"
  },
  {
    "path": "File Path Operations.js",
    "chars": 1923,
    "preview": "/*\nDescription:\nTask:\nThis kata requires you to write an object that receives a file path and does operations on it. NOT"
  },
  {
    "path": "Financing Plan on Planet XY140Z-n.js",
    "chars": 1222,
    "preview": "/*\nDescription:\nI need to save some money to buy a gift. I think I can do something like that:\n\nFirst week (W0) I save n"
  },
  {
    "path": "Financing a purchase.js",
    "chars": 2910,
    "preview": "/*\nDescription:\nThe description is rather long but it tries to explain what a financing plan is.\n\nThe fixed monthly paym"
  },
  {
    "path": "Find The Duplicated Number in a Consecutive Unsorted List - Tougher Version.js",
    "chars": 456,
    "preview": "/*\nDescription:\nSpin-off of this kata, here you will have to figure out an efficient strategy to solve the problem of fi"
  },
  {
    "path": "Find The Parity Outlier",
    "chars": 637,
    "preview": "/*\nDescription:\nYou are given an array (which will have a length of at least 3, but could be very large) containing inte"
  },
  {
    "path": "Find X.js",
    "chars": 997,
    "preview": "/*\nDescription:\nPart 2 version Find X Ⅱ\n\nWe have a function that takes in an integer n, and returns a number x.\n\nLets ca"
  },
  {
    "path": "Find heavy ball - level: conqueror.js",
    "chars": 1693,
    "preview": "/*\nDescription:\nThere are 8 balls numbered from 0 to 7. Seven of them have the same weight. One is heavier. Your task is"
  }
]

// ... and 407 more files (download for full content)

About this extraction

This page contains the full source code of the Automedon/CodeWars-6-kyu-Soluitions GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 607 files (858.5 KB), approximately 302.5k tokens, and a symbol index with 539 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!