CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Practice(MEDIUM)
Try your hand at one of the practice
         problems, and submit your solution in the language of your choice
         (our judge accepts solutions in over 35+ languages). Receive points,
         and move up through the CodeChef ranks. Get better, and better prepare
         yourself for the competitions
  • Easy
  • Medium
  • Hard
  • Challenge
  • Peer
Name Code Successful Submissions Accuracy
Bytelandian gold coins COINS 1881 12.68
Prime Generator PRIME1 1007 10.93
Marbles MARBLES 797 20.23
The Next Palindrome PALIN 470 8.28
Array Transform ARRAYTRM 447 23.7
Stepford Houses INSOMA3 423 18.13
Mixtures MIXTURES 274 24.4
Flipping Coins FLIPCOIN 236 8.75
Pouring water POUR1 167 15.68
Play on Words WORDS1 162 10
The Rise and Fall of Power MARCHA4 134 5.05
Money Matters MONEY 113 13.53
Buttons BUTTONS 107 8.15
XAndOr INSOMA5 100 32.08
Name Chopping INSOMA4 68 18.89
Multiples of 3 MULTQ3 62 5.93
Adding Fractions ADDFRAC 58 15.07
The Sports Stadium STADIUM 57 20.04
Stable Marriage Problem STABLEMP 56 28.73
Sphere in a tetrahedron TETRA 55 57.28
AND Rounds RESN01 49 15.92
Domain Dilemma DDILEMMA 45 9.66
The LCS Problem Revisited J2 43 24.68
A Home for Chef CHEFHOME 43 37.58
Rotate the String ROTSTRNG 41 9.8
Pleasing Chief CHIEFETT 39 20.21
Squirrel and chestnut SQUIRREL 38 14.13
Collect the Chocolate Chips TKCHOCS 37 35.61
Help the soldier SOLDIER 36 14.29
The Matrix Game SNCK01 31 30.6
Monitoring Madness MMADNESS 30 7.29
Tautology TAUT 27 34.59
Equation Solver EQUATIO 25 31.87
Preparing Dishes PREPARE 25 23.44
Zeta-Nim Game TAKEAWAY 25 43.88
Squash the Bugs B5 24 15.38
Angry Chef - Crispy Chips KCHIPS 24 21.83
The N Queens Puzzle Revisited J3 22 38.79
Logging Game LOGGERS 22 46.88
Sum of numbers NUMSUM 22 2.03
Ciel and Quiz Game CIELQUIZ 22 20.16
Birthday Gift CHEFGIFT 21 28.46
Box and Ball System BBSYSTEM 20 23.4
Bonus ACMKANPB 19 13.93
Kayaks H2 19 17.12
Fetching Cooking Tools TOOLS 19 29.73
Restore the Recipe RSRECIPE 19 24.74
Parallel Computing PARALLEL 18 38.67
Divisible Pairs DIVPAIR 18 21.08
Just a simple sum H4 18 7.74
Ripple-Carry Adder RIPPLE 18 20.18
Grouping Chefs GROUPING 17 28
Selection for Training Camps TRAINING 16 22.99
Crease Painting PAINTING 15 28.77
New Restaurant NEWREST 15 25.81
N Knights Problem KNIGHTS 15 32.91
K-Unique Sequence KUNIQUE 15 24.14
The Traveling Photographer PHOTOS 15 30.77
Colorful Chain COLCHAIN 15 32.2
Ciel and Eggs STREGGS 14 27.45
Bombing BOMBING 14 14.58
Chess Pushing Game CHESSGM 14 37.5
Little Elephant and Swapping LUCKYSWP 13 34.09
Careful Calculation CAREFUL 13 40
Longest Arithmetic Progressions ARITHPR 13 23.08
Repeated String REPSTR 13 26.15
Little Elephant and Median MEDIAN 13 13.59
Soccer League M3 13 13.08
Choosing Cook Off Problems COOKOFF 12 21.31
Lucky Sum LUCKY3 12 57.58
Palindrome Palindrome PALIPALI 11 13.91
Mean Mean Medians MEANMEDI 11 23.96
Ciel and Battle Arena CIELBTL 11 40.91
The Grand Cook Off COOKOFF2 10 36.11
SudokuX J1 10 22.22
Target Practice TARPRACT 10 14.1
Remys last tour FALLDOWN 10 30.43
PDS Number PDSNUM 10 30
Quadratic Equations E4 10 15.15
Best Buggy Ratings TMRATING 9 54.17
Moving between Floors FLOORSMV 8 39.47
Newspaper Puzzle PUZZLES 8 36.36
Restock RESTOCK 8 33.93
Closest Ranking VOTING 8 32.26
Lights Off E2 8 38.1
Graph on a Plane GRAPLANE 8 23.53
Integer Sequences SEQUENCE 8 34.78
Head office building BUILDING 7 21.62
A Coin Game G3 7 18.42
The Postal Service POSTAL 7 26.67
Little Elephant and Filling LUCKFILL 7 11.43
Battleship V B3 7 15.09
Squares Game SQUAGAME 7 16.07
The Lucky Draw D2 7 5.26
Trees Again TREES 7 22.22
An interesting subsequence C5 7 4.55
First non-Palindrome NONPALIN 7 24.44
A Bowling Game G1 7 30.77
The powerful sum C2 6 5
Dinner Party Socializing SOCIAL 6 20
Ciel and a new island CIELLAND 6 26.76
Odd Binomial Coefficients ODDBIN 6 41.18
The Perfect Chocolate Candy CANDY 6 22.22
Time of collisions COLLTIME 6 10.53
Bytelandian Robots F2 6 22.58
The Cursed Room MMATCH 6 20.29
Robot Game TR2 6 25.64
Maze of Digits K3 6 71.79
Balanced Walks BALANCED 6 57.14
Wireless Network NETWORK 6 27.27
Gap Filler Game GAPFILL 5 23.81
Menu MENU 5 17.24
K-important Strings N3 5 17.86
Restaurant Expansion RESTEXP 5 35
Dance Floor Energy ENERGY 5 38.89
Two Chefs TWOCHEFS 5 20
Glass Measurement GLASS 5 17.74
Paragraph Formatting H5 5 15.15
Ciel and Genjiko CIELGAME 5 29.41
Smart Frog G2 4 4.95
Prime words C3 4 10.91
Spaghetti Monsters B1 4 15.38
Cell Phone Towers L1 4 4.6
Chefs Bad Day GRIDCHEF 4 71.43
Counting Terms TERM 4 16.28
Curry Stained Napkin F3 4 50
Circle of towers L4 4 23.86
Buying Candies BUYING 4 7.84
Cosine Partition Function PARCOS 4 29.17
Magic sequence F5 4 40
Xor it XOR 4 6.67
Cutting off Squares CUTSQRS 4 41.67
The battlefield D3 4 57.14
Primary Proposal PROPOSAL 3 50
Super Factor Sum FACTSUM 3 3.1
Exit code ECODE 3 2.8
Fossil in the Ice TFOSS 3 2.53
Sinking Time DCE01 3 23.81
Best Sums BESTSUM 3 0.4
Permute Digits PERMDIG 2 9.52
I for Insomnia INSOMB3 2 6.9
Icing Crowns CROWNS 2 25
Relevant Phrases of Annihilation PHRASES 2 2
Swarm of Polygons SWARM 2 10.53
Little Elephant and CNSes LUCKYCOM 2 23.08
Happy Days HAPPY 2 6.67
The Baking Business BAKE 2 14.29
Summing Slopes SUMSLOPE 2 1.43
Lucky Array LUCKY4 2 100
Seeding The Pattern SEEDS 2 12.5
Trial of Doom YALOP 2 22.22
Block Drop BLOCKDRO 0 0

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold

HELP

Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:

 

  • Accepted Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark.
  • Time Limit Exceeded Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.
  • Wrong Answer Your program compiled and ran succesfully but the output did not match the expected output.
  • Runtime Error Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.
  • Compilation Error Your code was unable to compile. When you see this icon, click on it for more information.
  • If you are still having problems, see a sample solution here.

CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com