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

learn more… | top users | synonyms (2)

3
votes
1answer
77 views

Lazy prime number generator

There are multiple Project Euler problems (e.g. 7, 10) that deal with prime numbers. I decided make a reusable solution that could be used for most of them. I wrote a method to generate an infinite* ...
7
votes
1answer
47 views

CS50 pset-1 itsa Mario - make a half-pyramid using parameters from user input

I'm taking Harvard's introduction to computer science (CS50) course online, and I've written a program that satisfies a coding challenge but I don't understand what I did or how I can improve it. I'm ...
7
votes
1answer
47 views

“Curious Numbers” (HackerRank PE 34)

I was inspired by a certain recent question to try my hand at this challenge: Project Euler #34: Digit factorials \$19!\$ is a curious number, as \$1!+9!=1+362880=362881\$ is divisible by ...
4
votes
1answer
116 views

Finding the longest path, avoiding obstacles in a 2D plane

The Scenario You are given a matrix of size m x n (width x height) with m*n spots where there are a few obstacles. Spots with obstacles are marked as 1, and those without are marked as 0. You can ...
-2
votes
1answer
13 views

ArrayList related method not functioning properly in main method [closed]

Could somebody look over this code and see what I'm doing wrong? ...
2
votes
1answer
61 views

Printing longest sequence of zeroes

I am doing a coding exercise in codility and I came across this question: A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ...
-2
votes
0answers
25 views

How to change coding style when there're lots of condition? [closed]

For example, I have 2 variables and my code needs to select call which function according to these 2 variables' values. ...
6
votes
2answers
77 views

Prime multiplication table

I am new to Ruby (1 year as hobby project on weekends) and solved a code challenge and it was not as good as they wanted. I want to know how i could make it better and how to make the structure ...
2
votes
3answers
116 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 ...
4
votes
1answer
39 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
96 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
68 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
42 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
75 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
75 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
50 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
73 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
76 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
45 views
3
votes
1answer
51 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 ...
10
votes
3answers
85 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
182 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
37 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
347 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
923 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
118 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
74 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
67 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
2answers
72 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
66 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
325 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
128 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
55 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
504 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
119 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
91 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
32 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
157 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
91 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
105 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
213 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
81 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 ...