Programming challenges are off-site challenges meant to offer programmers educational experiences while testing their abilities.
-1
votes
1answer
105 views
On Finding Coin Jams
The problem can be found here and is essentially asking us to generate J many numbers containing N many digits, where these digits have to be either 0 or 1. The catch is that the these numbers that we ...
4
votes
2answers
34 views
Copy Constructor for a linked list with self-referential pointers
I came across a coding challenge that looked something like this (recreating from memory, sorry)
Suppose you have the following interface for a linked list. Implement an efficient and correct ...
4
votes
2answers
29 views
Number of ways to make change for an amount
Task
Write a program that, given the amount to make change for and a list of coins prints out how many different ways you can make change from the coins to STDOUT.
My approach
The number to make ...
4
votes
2answers
240 views
Find prime positioned prime number
This is a question from programming contest. This contest is already over.
Now, all the prime numbers are arranged sequentially in ascending order. i.e:- 2, 3, 5,7...and so on. Now, your task is to ...
-1
votes
0answers
12 views
MultiTouch HTML [on hold]
I would like to know if it is possible for MultiTouch to be implemented on HTML.
Scenario like this:
...
3
votes
1answer
183 views
Generators in Javascript; Project Euler #2
I'm trying to learn javascript using project euler and I decided to try to force myself to learn about generators in javascript using problem number 2 which asks us to: ...
4
votes
2answers
70 views
Project Euler #23 Non-abundant sums
I'm having trouble optimizing the Project Euler problem number 23 :
A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of ...
3
votes
2answers
85 views
Project Euler GUI for Problem #1 through #11
I've been working on the Project Euler problems, so I created a GUI and a Solver class for all the code I've been creating. I'd like to share it with you guys and to get general feedback on my coding ...
3
votes
1answer
51 views
Two solutions to Project Euler 12, but one is drastically faster
My code for #12 (first triangular number with over 500 divisors) is as follows:
...
1
vote
0answers
51 views
Project Euler #11 Largest product in a grid
Question
Link to the exercise : https://projecteuler.net/problem=11
I'm currently working on the Project Euler exercise's and I just finished the eleven exercise. It's working fast enough it takes ...
20
votes
7answers
5k views
Project Euler #7 10001st prime
I decided to start working on the Euler project exercises. I'm doing fine for now but the seventh problem is running quite slow and I can't think of anything to make it work faster. It takes around ...
2
votes
2answers
43 views
Determine whether input-output pairs represent something that could be a proper math function
The input is read in line by line from stdin.
Input Format
The first line contains an integer, T, denoting the number of test
cases. The subsequent lines describe T test cases, and ...
-1
votes
1answer
29 views
CodeEval “Read More” challenge [closed]
Here is the task, which is basically to truncate lines of input to 55 characters, or to 40 characters (also stripping a space if it happens to end in a space) and appending ...
1
vote
2answers
43 views
Project Euler - Smallest multiple (Ruby)
My code is very slow to run, and I am trying to find a way to make it more efficient. I know there must be a better way than to write each modulo operation.
The goal of the script is to find the ...
9
votes
2answers
101 views
Finding all contiguous sublists such that each member appears an even number of times
The program needs to find all contiguous sublists of numbers where the number of occurrences of every member in the contiguous sublist is divisible by 2.
The first line of input is N (the number of ...
1
vote
1answer
133 views
Google Foobar challenge: Rabbit Test Subjects
The diabolical Professor Boolean has captured you and a group of your
hapless rabbit kin as test subjects for his terrible experiments!
You're not sure what his real plans are, but currently it ...
1
vote
1answer
80 views
UVA #10258 - Contest Scoreboard
The problem statement is here.
Problem Description
The task is to rank the contestants in the contest based on following criteria
Contestants are ranked first by the number of problems solved (the ...
3
votes
1answer
77 views
Matrix rotation
Continuing on my VB.NET quest, I came across this slightly more challenging problem.
You are given a 2D matrix, a, of dimension \$M\$x\$N\$ and a positive
integer \$R\$. You have to rotate the ...
3
votes
3answers
55 views
Hackerrank Insertion Sort Part 2
I have started learning Java recently and was looking into the challenges on sorting on Hackerrank.I solved the following problemHackerrank on Insertion Sort.
The challenge was :
In Insertion ...
4
votes
1answer
48 views
Project Euler #127 abc-hits
Problem (Rephrased from here):
The radical of \$n\$, \$rad(n)\$, is the product of distinct prime factors of \$n\$. For example, \$504 = 2^3 × 3^2 × 7\$, so \$rad(504) = 2 × 3 × 7 = 42\$.
...
5
votes
1answer
57 views
Equivalent passwords ACPC 2014
I am preparing for ACM-TCPC (Tunisia). So I started solving problems from past ACM-ACPC versions. But I got stuck in the Problem I from 2014.
The problem consists of finding the number of ...
4
votes
1answer
41 views
Segmented Sieve of Eratosthenes in Scala
I'm trying to solve PRIME1 in SPOJ with the following Scala snippet:
Peter wants to generate some prime numbers for his cryptosystem. Help
him! Your task is to generate all prime numbers between ...
2
votes
2answers
43 views
PE # 34 - “Digit Factorials” with no loops
I posted a similar question “Curious Numbers” (HackerRank PE 34) recently (but in a different language/platform altogether). I'm starting to learn JavaScript and decided to take the challenge again ...
9
votes
5answers
230 views
Pizza Hut math problem #1 in Haskell
I'm currently attempting to learn Haskell after a fair history of imperative programming. When I saw the Pizza Hut Pi Day math problems, I thought the first one would be a good candidate for my ...
3
votes
3answers
88 views
Chess board in JS
I've completed the small challenge in the eloquent JS book to create a chess board pattern:
Write a program that creates a string that represents an 8×8 grid,
using newline characters to ...
1
vote
2answers
65 views
Google Code Jam: Store Credit Java Solution
It would be great if I could get this code reviewed.
I would love tips on how I could improve my code.
Problem
You receive a credit C at a local store and would like to buy two items. You ...
4
votes
1answer
91 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
57 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 ...
8
votes
1answer
71 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
126 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
80 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 ...
6
votes
2answers
87 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
124 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
43 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
71 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
43 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
78 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
53 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
75 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
85 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
79 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
47 views
4
votes
1answer
56 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
90 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
190 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
39 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
37 views
2
votes
1answer
46 views
Happy Number Counter
Task
Write an implementation that determines the count of happy numbers between a given start and end value.
Implementation
...