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

learn more… | top users | synonyms (2)

0
votes
0answers
23 views

Codility Fish Test 50%? [on hold]

I am getting a 50% overall mark (75% correctness and 25% performance) on the Codility Fish problem and my solution seems to be O(N) but I am only getting 25% performance. The results can be seen here ...
-1
votes
0answers
17 views

Bubble sort algorithm in swift [on hold]

import Foundation var array: [Int] = [99, 88, 56, 3, 1, 91, 43, 11, 53] func swapNum(indexOne :Int, indexTwo :Int) { let tempNum = array[indexOne] ...
2
votes
1answer
79 views

Primes & Squares

Codeforces #230B Question Whether a number has exactly three factors. (i.e. 1, itself and its square root, thus squares of primes) [Time limit is 2 sec, Memory 256 MB] Input Number of testcases, n ...
2
votes
1answer
52 views

Beating a dead horse: Project Euler 4

The task A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the ...
2
votes
1answer
39 views

Raindrops in Java

Problem Statement: Write a program that converts a number to a string, the contents of which depends on the number's prime factors. If the number contains 3 as a prime factor, output ...
3
votes
0answers
33 views

Time Limit Exceeded with shortest path algorithm

The problem: SHPATH You are given a list of cities. Each direct connection between two cities has its transportation cost (an integer bigger than 0). The goal is to find the paths of ...
3
votes
3answers
48 views

Binary string to decimal conversion

Problem Statement: Write a program that will convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles Implement binary to decimal ...
2
votes
1answer
33 views

Calculate the lattice paths in an n*n lattice (Project Euler #15)

Project Euler #15 is to find out all the distinct possible ways there are to move from the first point (1,1) to point (n,n) in an n*n lattice. ...
1
vote
0answers
28 views

Optimizing a Java solution to Project Euler Problem 23

I've tried to make something optimized for the Project Euler problem 23, named "Non-abundant sums". I've fine-tuned my solution to the following: I added divisors to the slots of each number to ...
5
votes
1answer
68 views

Let's revisit Roman numbers

Problem Statement: Write a function to convert from normal numbers to Roman Numerals: e.g. 1 => I 10 => X 7 => VII Code: ...
0
votes
0answers
23 views

Project Euler problem 54 - Poker Hands

The full text of the problem can be found here: https://projecteuler.net/problem=54 This code doesn't give me the right solution, but it does work on test cases I've run (and it runs fast, in 0.08 s. ...
4
votes
3answers
115 views

Pythagorean triplet adding up to 1000

Project Euler problem 9 says: A Pythagorean triplet is a set of three natural numbers, \$a < b < c\$, for which, $$a^2 + b^2 = c^2$$ For example, \$3^2 + 4^2 = 9 + 16 = 25 = 5^2\$. ...
1
vote
0answers
30 views

SPOJ DIVSUM - DIvisor Summation

DIVSUM - Divisor Summation #number-theory Given a natural number n (1 <= n <= 500000), please output the summation of all its proper divisors. Definition: A proper divisor of a ...
2
votes
1answer
45 views

HackerRank - The Grid Search

Was playing around tonight and thought this problem was interesting enough to post here. Given a 2D array of digits, try to find the location of a given 2D pattern of digits. Input Format ...
3
votes
0answers
57 views

Poker Hands in Python

Project Euler problem 54 asks: The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by a single space): the first five ...
-2
votes
0answers
51 views

Can anybody help me with this (graph theory)?

I am preparing for job interviews and learning Analysis and design of algorithms. I have solved many problems using dynamic programming and greedy methods, but I am struck with this problem and unable ...
2
votes
2answers
77 views

Let's play Scrabble

Problem: Write a program that, given a word, computes the scrabble score for that word. Code: ...
14
votes
12answers
3k views

Project Euler 8: Maximum product of 13 adjacent digits

Problem 8 on Project Euler which asks Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the product? This is my solution in Visual C#. ...
4
votes
1answer
74 views

Checking to see if array can be sorted using only one operation

I'm doing this HackerRank problem, which asks whether an array of up to 100000 integers can be sorted in ascending order by exactly one of the following: swapping two elements reversing a subarray ...
6
votes
1answer
97 views

Palindromes that are sum of consecutive squares

I have been working on a Project Euler: 125, which took me ages to solve. The problem and source are cited below The palindromic number 595 is interesting because it can be written as the sum ...
3
votes
2answers
99 views

Largest palindrome product

From the Project Euler challenge series: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest ...
1
vote
1answer
39 views

Google Code Jam Google String problem: a sequence resulting from bit flips and reversals

I'm currently having a go at some past Google Code Jam problems to help me practice my programming skills. One of these problems is Problem A ("Googol String") from Round A APAC Test 2016. Here is ...
5
votes
3answers
441 views

The Genetic Code

This question is part of a series solving the Rosalind challenges. For the previous question in this series, see Wascally wabbits. The repository with all my up-to-date solutions so far can be found ...
5
votes
1answer
73 views

Write a program that, given an age in seconds, calculates how old someone is in terms of a given planet's solar years

Problem: Write a program that, given an age in seconds, calculates how old someone is in terms of a given planet's solar years. Earth: orbital period 365.25 Earth days, or 31557600 ...
1
vote
1answer
68 views

Prime generator SPOJ problem in Python 3

I am trying to solve an SPOJ problem: print all prime numbers in a given range (as large as \$10^9\$). I have used the Sieve of Eratosthenes algorithm. But it is still slow when input is in range of ...
2
votes
1answer
113 views

The trip programming challenge

I would like some feedback on my solution for the trip programming challenge. Please go through my code understanding that I am interested in interviewing for a dev position at some point and am also ...
-1
votes
0answers
54 views

SPOJ prime generator problem in Python 3

I am trying to solve an SPOJ problem using Python 3: print all prime numbers in a given range (as large as 109). ...
3
votes
1answer
63 views

Write a small archiving program that stores students' names along with the grade that they are in

Problem: Write a small archiving program that stores students' names along with the grade that they are in. In the end, you should be able to: Add a student's name to the roster for ...
4
votes
2answers
83 views

Let me fix thou number

Problem Statement: Write a program that cleans up user-entered phone numbers so that they can be sent SMS messages. The rules are as follows: If the phone number is less than 10 ...
-4
votes
0answers
33 views

Printing numbers to a given number n and calculating the sum and count as well [closed]

This prints numbers to a given number n and calculating the sum and count as well, but my program is giving "time limit exceeded." Please suggest ways to reduce the complexity. ...
1
vote
3answers
69 views

3n+1 problem rejected by uva judge: time limit exceeded

I am trying to get into the habit of solving programming puzzles in my spare time but am stuck on the first one(which I know can be for a large number of reasons hence my posting for help). Shown ...
5
votes
1answer
52 views

Let's have a meetup

Problem statement: Calculate the date of meetups. Typically meetups happen on the same day of the week. Examples are the first Monday the third Tuesday the Wednesteenth the ...
15
votes
5answers
1k views

Generating Robot Name

Problem: Write a program that manages robot factory settings. When robots come off the factory floor, they have no name. The first time you boot them up, a random name is generated, such ...
2
votes
1answer
57 views

Swift solution to Leetcode “Longest Substring Without Repeating Characters”

From LeetCode medium 3. Longest Substring Without Repeating Characters: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", ...
18
votes
3answers
3k views

What does the Bob say?

Description: Bob is a lackadaisical teenager. In conversation, his responses are very limited. Bob answers 'Sure.' if you ask him a question. He answers 'Whoa, chill out!' if you yell ...
3
votes
3answers
93 views

Calculate the Hamming difference between two DNA strands

Write a program that can calculate the Hamming difference between two DNA strands. GAGCCTACTAACGGGAT CATCGTAATGACGGCCT ^ ^ ^ ^ ^ ^^ The Hamming distance between these two ...
3
votes
3answers
79 views

Wascally Wabbits

This question is part of a series solving the Rosalind challenges. For the previous question in this series, see Mendelian inheritance. The repository with all my up-to-date solutions so far can be ...
2
votes
2answers
70 views

Adding two singly linked lists in C++

I took a challenge from a web site. I aim to have a runtime performance as good as possible. My solution was accepted, though I think it is not the most efficient because I saw others having a faster ...
2
votes
1answer
58 views

Finding the total time elapsed in the union of time intervals

Given a set of time intervals, I have to find the total time elapsed in the union of the intervals. Test Cases: ...
1
vote
1answer
69 views

Project Euler problem #11 - Largest product in a grid

I have recently solved the following Project Euler problem: In the 20×20 grid below, four numbers along a diagonal line have been marked in red [here bold]. ...
7
votes
2answers
304 views

Make Depth First Search program more efficient

This is a problem from programming contest. The original problem can be found here on hackerearth.com. In the first line there is one integer T denoting the number of test cases. Description of ...
4
votes
4answers
95 views

Advent of Code Day 6: toggling lights in a grid with Powershell

I am using the "Advent of Code" series to help with my PowerShell education. The Day 6 puzzle has a 1000 × 1000 grid of lights. After processing instructions to turn on, turn off, or toggle rectangles ...
3
votes
1answer
52 views

Celebration Party Problem - Algorithm

I solved the following problem: Let's consider the following situation. You've invited a lot of children to a celebration party, and you want to entertain them and also teach them something in the ...
4
votes
3answers
155 views

Count words in a string

Continuing my TDD from exercism. Write a program that given a phrase can count the occurrences of each word in that phrase. For example for the input ...
7
votes
3answers
202 views

Nucleotide Count

I am learning Java and hence practicing it from here. The solution seems pretty trivial to me but still I would like to have a honest review which would guide me to following ideas: Am I maintaining ...
4
votes
1answer
71 views

Sieve of Eratosthenes solution for CodeEval

The code below takes integer n as input, and delivers a list of all primes up to integer n using the Sieve of Eratosthenes. My question is, could you please help me optimize this code? Is it ...
2
votes
1answer
43 views

LeetCode Rotate Array

I have started learning Java and was trying to solve some easy problems from different websites like HackerRank and leetcode.I am relatively new to programming so please don't mind if this is too ...
1
vote
2answers
39 views

Project Euler Problem 10

Project Euler problem 10 is to find the sum of all primes less than 2 million. I have written a program that does this, and it works, but it takes an excruciatingly long amount of time. What I'm ...
4
votes
1answer
54 views

Mendelian inheritance

I started out with the Rosalind problems a while back. Turns out it's a great way to learn a new language. I'm still trying to learn Ruby, and while I haven't managed to use regular expressions as ...
5
votes
0answers
70 views

Topological sort using recursive DFS

I am currently learning Graph algorithms by solving questions on online judges. The below code is for implementing Topological sort, using recursive DFS. Also, it is my first time with C++ STL. ...