Programming challenges are off-site challenges meant to offer programmers educational experiences while testing their abilities.
2
votes
1answer
33 views
A Game Of Simon
This is one of the projects from freeCodeCamp. It's a game of Simon (a memory game). I would like a review on my code.
...
1
vote
0answers
17 views
Project Euler Problem 11: largest product of 4 adjacent numbers
I am a fairly beginner-level programmer, and I have been working through the Project Euler Puzzles. I am currently on Problem #11, which asks to find the largest product of four consecutive numbers ...
0
votes
0answers
31 views
Exercism: clean and format a phone number in Clojure
Problem statement
Phone Number
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 ...
2
votes
1answer
27 views
Hackerrank Funny String python solution
"Funny String" problem from Hackerrank
Suppose you have a String, \$S\$ of length \$N\$ indexed from \$0\$ to \$N-1\$. You also have some String, \$R\$, that is the reverse of \$S\$, where \$S\$ ...
3
votes
1answer
66 views
Number of unique sequences of 3 digits, given a length is equal to sum
This is the "Minion's bored game" problem from Google's "Foobar challenge":
There you have it. Yet another pointless "bored" game created by the bored minions of Professor Boolean.
The game ...
3
votes
1answer
95 views
Number of divisors of a factorial
I was solving the DIVFACT problem from Sphere Online Judge:
Given a number, find the total number of divisors of the factorial of the number.
Since the answer can be very large, print the answer ...
0
votes
0answers
29 views
Implementation of the Minimum Stop Algorithm in Javascript
I started taking the Algorithm design class from Coursera. So into the third week they talk about Greedy algorithms and walks through a sample problem.
This is the Problem Statement that I could find ...
-1
votes
1answer
49 views
Function that returns zero-based indices of two distinct elements whose sum is equal to a target sum [on hold]
I've been working on an example test question: Example Problem
Write a function that, given a list and a target sum, returns zero-based indices of any two distinct elements whose sum is equal to ...
3
votes
1answer
122 views
Project Euler #549: Divisibility of factorials
This is the problem:
Calculate
$$\sum_{i=2}^{10^8} s(i)$$
where \$s(n)\$ is the smallest \$m\$ such that \$n\$ divides \$m!\$.
Quite mathematical, I've found a better way than brute ...
8
votes
2answers
309 views
Chocolate Distribution in a school
Problem Statement
In a School, Chocolate bars have to be distributed to children waiting in a queue. Each Chocolate bar is rectangular in shape. Consider its side lengths are integer values.
The ...
2
votes
1answer
28 views
Basic F# Programming Challenge
I wrote some code to solve this problem https://www.hackerrank.com/challenges/string-o-permute which basically states: take an even length string and swap all the even indexed characters. For example ...
0
votes
0answers
35 views
Codility Fish Test 50%? [closed]
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 ...
2
votes
2answers
100 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
55 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
45 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
35 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
54 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
34 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
29 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
71 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
25 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
148 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
47 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
63 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
52 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
79 views
Let's play Scrabble
Problem:
Write a program that, given a word, computes the scrabble score for
that word.
Code:
...
15
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
101 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 ...
6
votes
3answers
452 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
76 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
55 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
68 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
89 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 ...
1
vote
3answers
73 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
53 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 ...
16
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
67 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", ...
19
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
95 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 ...
4
votes
3answers
84 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
71 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
59 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:
...
2
votes
1answer
71 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
306 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 ...