Skip to content

Darex1991/code-eval-solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

CodeEval Solutions

A sample collection of solutions for challenges at codeeval.com.

See my profile and stats at https://www.codeeval.com/profile/Trindaz/.

Challenge Summaries

Fizz-Buzz

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.


Penultimate Word

Write a program which finds the next-to-last word in a string.


Prime Palindrome

Write a program to determine the biggest prime palindrome under 1000.


Reverse Words

Write a program to reverse the words of an input sentence.


Sum of Primes

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)


Detecting Cycles

Given a sequence, write a program to detect cycles within it.


Longest Lines

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.


Minimum Coins

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.


Distinct Subsequences

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>

About

Solutions for CodeEval Challenges

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published