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

learn more… | top users | synonyms (2)

4
votes
1answer
19 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
44 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
44 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 ...
1
vote
0answers
33 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
32 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
285 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
123 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
40 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
489 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
76 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
89 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
24 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
34 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
61 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
107 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
85 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
84 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
201 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. ...
8
votes
1answer
63 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
68 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 ...
3
votes
1answer
55 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
61 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
49 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
42 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
106 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
45 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 ...
2
votes
1answer
33 views

Project Euler #7 in C: find 10001st prime using something like Sieve of Eratosthenes

I've gotten a solution for Project Euler #7 in C (find the 10,001st prime). I came up with the very simple algorithm myself (from what I can tell it's similar, if not identical, to the Sieve of ...
3
votes
2answers
40 views

Finding heaviest path through triangle

I am doing Project Euler problem 67 which involves finding the heaviest path through a triangle of integers like this one (this is a smaller version from an earlier problem) ...
3
votes
4answers
102 views

C++ Interrupted Bubble Sort

I've written an interrupted bubble sort, which prints the intermediate result after some specified number of iterations of bubble sort. But I seem to have an speed issue. Could anyone help me spot ...
2
votes
1answer
83 views

Project Euler Q7 - 10001st prime

The problem is (source)... By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? This is my second attempt ...
1
vote
1answer
72 views

Hackerrank challenge - Dictionaries and Maps in Erlang

This question is really similar to an existing one in Ruby. So the task is also the same: Day 8: Dictionaries and Maps! The problem is that on Hackerrank my solution only passes the first and last ...
7
votes
3answers
608 views

Sum all numbers in a range

I have implemented the "Sum All Numbers in a Range" challenge from Free Code Camp quoted below. The code works like a charm, but I don't think it's idiomatic. The challenge hints imply I should be ...
5
votes
2answers
63 views

Basic Scheduler, codingame 'Super Computer' Challenge

I have built a program that handles the basic scheduling requests for CodinGame's Super Computer challenge. Specifications (taken from CodinGame) The Goal In ...
11
votes
1answer
93 views

Glue Shredded Pieces (CodeEval)

I have solved problem 185 on CodeEval, Glue Shredded Pieces. The solution got a 100% score on all tests (edit: see comments), within the allotted time and memory constraints. I'm looking mostly ...
0
votes
1answer
73 views

Optimum Tree traversal algorithm Topcoder

I'm practicing a 1000 point algorithm problem on the topcoder.com arena. The problem is as follows:      You work for an electric company, and the power goes out in a rather large apartment complex ...
0
votes
2answers
75 views

Optimization of Factorial Function

This is solution to codechef problem FCTRL2 where we are supposed to find the factorial of numbers upto 100. I have tried several techniques but I am always exceeding their time limit (1 second). ...
2
votes
3answers
147 views

Wet Boxes problem: counting points on a triangular grid

As a solution to the B. Wet Boxes problem : B. Wet Boxes Bob works in a warehouse which contains a large pile of boxes. The position of a box can be described with a pair of integers (x, ...
2
votes
1answer
135 views

Finding the sum closest to a target number

Wallace the Weightlifting Walrus is training for a contest where it will have to lift 1000 kg. Wallace has some weight plates lying around, possibly of different weights, and its goal is to add ...
16
votes
5answers
1k views

Print the N longest lines in a file

I have implemented the "Find the N longest lines in a file" problem from CodeEval quoted below. I got a full 100 score and 182ms execution time of their data set on the site so I consider the code ...
5
votes
1answer
41 views

Computing the de Bruijn sequence

I'm trying to compute de Bruijn sequences for alphabets which have a number of characters which is a power of two. So the sequence must contain every possible subsequence of length \$N\$ from \$0\$ to ...
4
votes
2answers
247 views

Hackerrank challenge - Dictionaries and Maps

This is a solution for the Day 8 hackerrank.com challenge. The basic idea of the challenge is to create a mapping of names to phone numbers based on the the given input, and later look up the phone ...
4
votes
1answer
87 views

Project Euler Q2 - Sum of even Fibonacci numbers

I'm very new at F#, and am using Project Euler to help me learn. Question #2 kept me going for a while, as my initial attempt at an answer was very slow and inelegant. Then I learnt about Seq.unfold, ...
4
votes
1answer
81 views

Solution to Project Euler problem 5 (LCM of 1 to 20)

I'm an experienced C# developer trying to teach myself F#. I spent a day or 3 reading throught the F# wikibook trying to get to know the syntax and F# fundamentals. As an exercise I'm trying to go ...
4
votes
1answer
42 views

Rosalind problem “Consensus and Profile”

Source: Rosalind("Consensus and Profile") Brief summary ...
5
votes
1answer
51 views

Solving adventcode day 6 puzzle: toggling lights in a grid

I have solved the day 6 adventcode problem: --- Day 6: Probably a Fire Hazard --- Because your neighbors keep defeating you in the holiday house decorating contest year after year, you've ...
10
votes
3answers
356 views

Sum even fibonacci numbers up to a limit

After I have tackled the first problem I come to Project Euler Problem 2 which states Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 ...
11
votes
5answers
582 views

Solving Project Euler Problem 1 using extension methods

As a self taught developer I never did any of the Project Euler problems, so I decided to just start with Problem 1 which states If we list all the natural numbers below 10 that are multiples of ...
1
vote
2answers
74 views

Project Euler 21: Sum of Amicable Numbers

Problem 21: Let \$d(n)\$ be defined as the sum of proper divisors of \$n\$ (numbers less than \$n\$ which divide evenly into \$n\$). If \$d(a) = b\$ and \$d(b) = a\$, where \$a ≠ b\$, then \$a\$ ...
15
votes
2answers
306 views

Count the occurence of nucleobases in DNA string

Inspired by this meta question I decided to take a look at Rosalind. Their first challenge seemed easy enough: An example of a length 21 DNA string (whose alphabet contains the symbols 'A', 'C', ...