A sample collection of solutions for challenges at codeeval.com.
See my profile and stats at https://www.codeeval.com/profile/Trindaz/.
Players generally sit in a circle. The player designated to go first says the number "1", and each player thenceforth counts one number in turn. However, any number divisible by 'A' e.g. three is replaced by the word fizz and any divisible by 'B' e.g. five by the word buzz. Numbers divisible by both become fizz buzz. A player who hesitates or makes a mistake is either eliminated.
Write a program that prints out the the pattern generated by such a scenario given the values of 'A'/'B' and 'N' which are read from an input text file. The input text file contains three space delimited numbers i.e. A, B, N. The program should then print out the final series of numbers using 'F' for fizz, 'B' for 'buzz' and 'FB' for fizz buzz.
- Easy
- Solution at challenges/easy/fizz-buzz.js
- Details at https://www.codeeval.com/open_challenges/1/
Write a program which finds the next-to-last word in a string.
- Easy
- Solution at challenges/easy/penultimate-word.js
- Details at https://www.codeeval.com/open_challenges/92/
Write a program to determine the biggest prime palindrome under 1000.
- Easy
- Solution at challenges/easy/prime-palindrome.js
- Details at https://www.codeeval.com/open_challenges/3/
Write a program to reverse the words of an input sentence.
- Easy
- Solution at challenges/easy/reverse-words.js
- Details at https://www.codeeval.com/open_challenges/8/
Write a program to determine the sum of the first 1000 prime numbers. (Note: This challenge not using program input meant the solution was open for a super-efficient hack)
- Easy
- Solution at challenges/easy/sum-of-primes.js
- Details at https://www.codeeval.com/open_challenges/4/
Given a sequence, write a program to detect cycles within it.
- Moderate
- Solution at challenges/moderate/cycle-detection.js
- Details at https://www.codeeval.com/open_challenges/5/
Write a program to read a multiple line text file and write the 'N' longest lines to stdout. Where the file to be read is specified on the command line.
- Moderate
- Solution at challenges/moderate/longest-lines.js
- Details at https://www.codeeval.com/open_challenges/2/
You are given 3 coins of value 1, 3 and 5. You are also given a total which you have to arrive at. Find the minimum number of coins to arrive at it.
- Moderate
- Solution at challenges/moderate/minimum-coins.js
- Details at https://www.codeeval.com/open_challenges/74/
A subsequence of a given sequence S consists of S with zero or more elements deleted. Formally, a sequence Z = z1z2..zk
is a subsequence of X = x1x2...xm
, if there exists a strictly increasing sequence of indicies of X
such that for all j=1,2,...k
we have Xij = Zj
. E.g. Z=bcdb
is a subsequence of X=abcbdab
with corresponding index sequence <2,3,5,7>
- Hard
- Solution at challenges/hard/distinct-subsequences.js
- Details at https://www.codeeval.com/open_challenges/69/