Programming challenges are off-site challenges meant to offer programmers educational experiences while testing their abilities.

learn more… | top users | synonyms (2)

2
votes
3answers
107 views

Reverse digits and add until a palindrome appears

The following code is a C solution to the following problem UVA 10018. The Problem The "reverse and add" method is simple: choose a number, reverse its digits and add it to the original. If ...
-1
votes
0answers
46 views

hackerrank test not pass Project Euler #14: Longest Collatz sequence [closed]

i was just trying this problem in hackerrank but its not pass and i a little confused why, someone can give me a tip, code is: ...
4
votes
1answer
37 views

Project Euler - Largest Product In A Grid

My code solves Project Euler problem #011: What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid? I looked over one ...
5
votes
1answer
94 views

How to lose plants and aggravate people

Courtesy of a few posts around here I've discovered HackerRank. Poisonous Plants is one of their challenges. Of course, skip the following if you'd like to try it yourself. Challenge: There are ...
3
votes
2answers
64 views

Find two numbers that add up to a given total, from a formatted string

The full challenge from codeeval.com can be viewed here. Input Your program should accept as its first argument a filename. This file will contain a comma separated list of sorted numbers ...
0
votes
0answers
39 views

Comparing two integers without logical, relational or bitwise operators - followup

Requirement: Compare the input numbers (granted to be non-negative) without logical, relational or bitwise operators and no if/else statement or ...
4
votes
1answer
71 views

Comparing two integers without logical, relational or bitwise operators

I answered a question on SO today, however it did't receive any up-votes, so I want to know what's wrong with my code. The requirement is to compare the input numbers(granted to be positive) without ...
3
votes
1answer
74 views

Redirecting arriving customers to the nearest empty queue

I have a task to make a checkout line controller. First it receives, as input, an amount of checkouts and commands. Then commands that are C for coming and L for leaving, and after those the number of ...
3
votes
2answers
47 views

“ACM ICPC Team” challenge on Hackerrank

ACM ICPC Team You are given a list of \$N\$ people who are attending ACM-ICPC World Finals. Each of them are either well versed in a topic or they are not. Find out the maximum number of ...
4
votes
2answers
67 views

Computing the divisor sum in bulk without division, multiplication or factorisation (SPOJ DIVSUM)

SPOJ problem #0074 DIVSUM - Divisor Summation requires computing the sums of proper divisors in bulk (200000 test cases, time limit 3 seconds): Given a natural number n (1 <= n <= 500000), ...
4
votes
2answers
84 views

Finding the indices of the two items whose price adds up to to a value

I've solved the Google Jam store credit problem. but there's some inefficiencies that I want to get rid of them to improve the algorithm and reduce the multiple iteration. What are other better ways ...
3
votes
0answers
73 views

ACM-ICPC HackerRank challenge in C++

I was doing a programming question in C++ at HackerRank. Given a set of up to 500 bitstrings, each up to 500 bits long, the task is to find the pair a and b such that the bitwise OR contains the most ...
4
votes
1answer
41 views
3
votes
1answer
50 views

Perimeter of a polygon given its vertices

I recently completed this code challenge so just looking for some feedback on my code. The task is to read polygon coordinates from a file and calculate the perimeter, I was provided with a script ...
9
votes
3answers
75 views

C itoa implementation

As an exercise, I limited my self to the man pages. I didn't look for a previous existing implementation because I wanted to see how well I could do on my own. I also tried to handle as many cases as ...
3
votes
3answers
178 views

Finding the 10001st prime in C#

In an effort to learn C# / improve my coding skills, I've started working on the Project Euler problems. I see that I may have been overthinking things a bit after finishing problem 7: By listing ...
0
votes
0answers
35 views

Performance Optimized Project Euler Problem 14 in Clojure

Here is the problem: The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using the rule above and starting ...
2
votes
1answer
34 views

Project Euler 18/67 : Maximum Path using Memoization

Problem statement of PE18 is : ...
2
votes
1answer
45 views

Happy Number Counter

Task Write an implementation that determines the count of happy numbers between a given start and end value. Implementation ...
3
votes
1answer
39 views

“The Trip” expense-equalizing challenge [closed]

I've solved The trip from Programming Challenges. My solution suffers from lack of floating-point precision, though. The problem: Your job is to compute, from a list of expenses, the minimum ...
4
votes
4answers
343 views

Expanding compressed string

I wrote this for a problem in one of the online contest at hackerearth. Problem statement is: Input: The first line contains the compressed string in form a2b4h5a2 Expanding it ...
3
votes
4answers
920 views

Project Euler 17: counting letters needed to write numbers

The statement of the problem is : If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers ...
8
votes
2answers
117 views

Next number with the same sum of digits

I recently came across a email bot that would give you random problems to solve. Here is the problem. Please write a function in python which receives a natural decimal N-digit number (1 to 15 ...
8
votes
3answers
72 views

CodeWars mathematical expresion evaluator

I recently wrote the following code for a codewars.com kata for evaluating mathematical expressions. I've been writing ruby for years, but almost everything I do is for personal use and isn't ...
4
votes
2answers
62 views

Printing letters in order like a pyramid

There is this hackerrank question, where we need a rhombus of letters. As to my opinion it can be viewed as some fractal, or similar logic. Well I solved the question, but I am obviously disappointed ...
2
votes
1answer
56 views

Bracket Pairs Validation

Purpose Validate whether the open brackets within a String have matching closed brackets, in the correct order. The three types of valid brackets are ...
2
votes
0answers
61 views

Project Euler #14 in Clojure (finding long Collatz sequence chain)

I'm working on a Clojure implementation for Project Euler #14, which asks for the initial element, under 106, that produces the longest collatz-sequence chain. I'm trying to make use of every ...
3
votes
1answer
46 views

Generate String with Random Consonants and Vowels

Purpose This problem comes from this dailyProgrammer subreddit challenge. The task is to take an input of C / ...
5
votes
3answers
323 views

“Researcher Hatim is right or wrong” challenge

I wrote a program to solve a problem, I am not so good in python so want help to find areas where this program can be improved or simplified and readable too:- I got this problem in a code challenge ...
5
votes
1answer
127 views

Vowels in a String are in Alphabetical Order

Task Write an implementation that returns whether a String has vowels (English language) in alphabetical (A-Z) order or not. Feedback Is my ...
5
votes
1answer
50 views

Sherlock is going against the Beast with PowerShell

I ran into this challenge a couple of times today and thought I could tackle it with PowerShell. I refused to look at other peoples approaches to this hoping to complete it on my own. I'm sure the ...
5
votes
5answers
501 views

Armstrong Number Validator

Purpose Validate if a number is an Armstrong Number. An Armstrong Number is a number such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong ...
2
votes
1answer
112 views

Generating the largest decent number of given number of digits

The Sherlock and the Beast challenge from HackerRank asks to generate the following number with \$n\$ digits for \$T\$ test cases: A Decent Number has the following properties: its digits can only ...
4
votes
2answers
90 views

Calculating Garland Degree of String

Purpose A garland word is a word formed by chopping off the last few letters and “wrapping around” to the start. For example: You can chop off the the trailing “on” from “onion” and still ...
3
votes
1answer
29 views

USACO TRAINING - Section 1.2 - PROB Transformations

I'm trying to improve my coding skills by going through the USACO TRAINING PROGRAM. I would like a review of my code for solving the transform problem. Here is the problem statement: A square ...
2
votes
1answer
37 views

Heaping up with the inqueries

Challenge: Given three query types simulate heap operations. Specifications: 1. "1 v" - Add an element v to the heap. 2. "2 v" - Delete the element v from the heap. 3. Print the ...
0
votes
0answers
148 views

Solution to King Kohima problem in Python

King Kohima problem: King Kohima has reserved a new exclusive street for his executive class employees where they can build their homes. He has assigned you to plan that street. You have to ...
3
votes
2answers
119 views

Evaluate whether string is in alphabetical order or reverse alphabetical order

Purpose This problem comes from this question on the dailyprogrammer subreddit. Basically, the task is to write an implementation that identifies if the characters in a ...
1
vote
2answers
90 views

Two and a sub string

Challenge: Given two strings, A and B. Find if there is a substring that appears in both A and B. Specifications: Several test cases will be given to you in a single file. The first line ...
1
vote
2answers
103 views

Printing all the prime numbers between two bounds

I keep getting a time limit exceeded for this solution to SPOJ Prime1. I need to print all primes within a given interval (with intervals as large as 105, and numbers as large as 109). I've tried ...
4
votes
5answers
210 views

Pass Triangle challenge

In order to solve this challenge: Challenge Description By starting at the top of the triangle and moving to adjacent numbers on the row below, the maximum total from top to bottom is 27. ...
7
votes
1answer
69 views

Coconut, Sailors, and Monkeys

Problem There was an interesting problem on the dailyprogrammer subreddit: A number of sailors (let's call it N) are stranded on an island with a huge pile ...
1
vote
0answers
76 views

HackerRank: XOR-sequence

I am trying to solve the following problem at HackerRank: XOR-Sequence An array, \$A\$, is defined as follows: \$A_0 = 0\$ \$A_x = A_{x-1} \oplus x\$ for \$x>0\$, where ...
2
votes
1answer
66 views

Find the number closest to 0, breaking ties in favor of positive numbers

I'm a Perl beginner and I really love this language, and I was wondering if it was possible to reduce the size of this code, just for fun and so as to learn Perl specificities: ...
4
votes
1answer
104 views

Hacker rank Jesse and Cookies

I am trying to solve a problem in hacker rank and the question is as follows: Jesse loves cookies. He wants the sweetness of all his cookies to be greater than value \$K\$. To do this, Jesse ...
6
votes
5answers
1k views

Project Euler problem 12

The statement is as follows : The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ...
3
votes
2answers
51 views

Missing Numbers Between Two Lists

Purpose I came across this relatively simple question on HackerRank regarding finding missing values across two Lists. I took a fairly straight-forward approach, ...
3
votes
1answer
46 views

Modified Fibonacci Implementation

Purpose This question comes from a HackerRank problem called Fibonacci Modified. I think I have coded a valid solution, but would like feedback about my approach, implementation, and of course, any ...
6
votes
1answer
116 views

The Wolf, Goat and Cabbage Game

Everybody knows this river crossing puzzle solving game. I was playing a river crossing game in my cellphone and decided to try to implement every single game mode this app has. In case by any chance ...
4
votes
1answer
54 views

Simple Ruby program to model a prepaid transit card system

I have written a simple Ruby program to model a transit card system which aims to address the following user stories. I wanted to see whether I could get any feedback on it. My main interest is ...