Programming challenges are off-site challenges meant to offer programmers educational experiences while testing their abilities.
-1
votes
0answers
4 views
Find the maximum number of times and element must be added to get desired sum? [on hold]
There is an array o unique elements. You can add any element any number of times to get desired sum.
But you nned to find the count where maximum elements are added.
For eg a=[1,2,3,4]
To get desired ...
-5
votes
0answers
28 views
calculate the user age java code [on hold]
i need help with this
• Print a message inviting the user to enter his name and birthday (dd/mm/yyyy).
• Calculate the user age
• (Ignore leap years and different days in months)
• Displays ...
5
votes
2answers
297 views
Convert an integer to its Roman numeral equivalent
I got sent a challenge from a friend;
You are given a file that contains numbers, one number per line. Convert the numbers from the file into roman numerals.
...
1
vote
2answers
47 views
Find median of list of integers
This code is meant to find the median of a list of integers. The list is assumed to be of odd length.
This is based of this HackerRank question.
I'm doing this to improve my style and to improve my ...
2
votes
2answers
49 views
CodeChef Chewing challenge
The ZCO is today and I did 5 problems to prepare for it overnight. One of the problems is the CodeChef Chewing problem.
The code takes an integer N that specifies the number of chewing gums, integer ...
5
votes
2answers
273 views
Reduce as many adjacent chars as possible in string
This code is meant to reduce a given string as much as possible by deleting adjacent characters. Here are some examples:
...
-2
votes
0answers
15 views
Difference between Python and C++ code for Finding the minimum lcm of list of numbers [on hold]
I am trying to solve this problem:
https://www.codechef.com/problems/ALEXTASK
and I have two solutions for this. One in C++
...
2
votes
1answer
42 views
HackerRank Strange Counter
I wrote a solution to HackerRank Strange Counter:
The counter counts down in cycles. At t = 1, the counter displays the number 3. At each subsequent second, the number displayed by the counter ...
10
votes
3answers
840 views
Rounding a number up to the nearest multiple of a power of 2
I'm doing some programming challenges over at CodeEval and came across a pretty straight forward simple one:
Given numbers x and n, where n is a power of 2, ...
1
vote
0answers
30 views
Euler Project 14 (Longest Collatz Sequence)
Project Euler 14 asks: Which starting number, under one million, produces the longest Collatz sequence?
I've been trying to optimize this solution to execute in less then 1s. Agenda for first 50 ...
3
votes
3answers
310 views
C++ implementation of Hackerrank's “Maximum Element in a Stack”
I just attempted the Maximum Element Challenge on Hackerrank. This question has been posted before in swift Swift Hackerrank Maximum Element in a Stack but it has attracted low views/no answers. ...
4
votes
1answer
31 views
HackerRank Ransom Note, solved using Data.Map as a hash table
I try to solve this hackerrank using Haskell but not sure if I use Data.Map corretly.
Problem in brief:
given 2 strings, magazine and ...
1
vote
1answer
43 views
Hackerrank Inherited Code
I'm back at it again with an Hackerrank challenge-Inherited Code . I just learnt exception and I thought it will be a great idea to get a second opinion on my implemented ...
1
vote
1answer
30 views
Hackerrank Box It
I decided to solve the Box It! challenge in Hackerrank to improve my C++ knowledge as I'm still new to the language.
Design a class named Box whose dimensions are integers and private to
the ...
4
votes
2answers
80 views
Turning numbers into a string of words - challenge
I just completed this challenge at CodeEval.
You are given a positive integer number. This represents the sales made that day in your department store. The payables department however, needs this ...
1
vote
1answer
55 views
Student Class in C++ using sstream for format
Based on my previous review, I'm posting another Hackerrank Class solution.
Problem Statement
We can store details related to a student in a class consisting of his
age (int), first_name (...
5
votes
2answers
684 views
Solution to Chef and Squares challenge, timing out in Java but not in C++
I was solving a problem on codechef (online judge and contest organizer). I was writing my code in Java and was getting TLE at last testcase where as I wrote the same code in C++ and it was accepted. ...
4
votes
1answer
65 views
Finding the max cost from the minimum cost incurred on travelling
This problem is from INOI 2014 , where I have find out the maximum cost of traveling through the cities but taking the minimum possible route cost , here is an excerpt from it,
Indian National ...
4
votes
1answer
66 views
Hackerrank Sum vs XoR
I'm in the process of improving my coding style and performance hence I decided to delve into bit manipulation on Hackerrank. I thought the question was straight forward but on large input, my ...
6
votes
4answers
110 views
Repeatedly partitioning an array equally as far as possible
I solved HackerRank Nikita and the Game. The implementation is correct as program passes all test cases.
Nikita just came up with a new array game. The rules are as follows:
Initially, ...
-1
votes
2answers
69 views
Calculating the number of extended family members [closed]
The problem here says to find the number of extended family members of the president,
N people live in Sequence Land. Instead of a name, each person is
identified by a sequence of integers, ...
2
votes
3answers
102 views
Hackerrank Insertion Sort Algorithm 1 (creating duplicates to show shifting)
During an interview, I was given this Hackerrank question to solve within 15 minutes but at that time I was interested in solving this without performance in my mind. I know a similar question has ...
1
vote
1answer
55 views
Summing integers in stream using Fenwick tree
In short, the input is an ordered list of numbers, and we have to sum the numbers from index a to b quickly. For example, assume array[] = {1, 2, 3}. Please sum ...
-1
votes
1answer
65 views
Largest prime factor of a given number
I'm solving Problem 3 in Project Euler:
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143?
Most answers I found made use of array to ...
2
votes
1answer
64 views
Jolly jumpers programming challenge
I have posted my solution to the jolly jumpers programming challenge(detailed here) for your review:
A sequence of n > 0 integers is called a jolly jumper if the absolute
values of the ...
1
vote
2answers
54 views
Find the highest product between elements in a set [closed]
I'm solving a programming challenge that essentially consists of finding the highest product of elements in a set.
This is my current solution, and is passing all the test cases but one. The test ...
6
votes
3answers
104 views
Interpreter programming challenge
I have posted here my working and accepted solution to the intepreter programming challenge (detailed here) for your review. The challenge is as follows:
A certain computer has 10 registers and ...
5
votes
1answer
708 views
C program circular array rotation
I'm trying to solve a Hackerrank problem where you perform k array[n] rotations, and at the end, ask for ...
3
votes
1answer
38 views
Generalized Project Euler #11 in Python: Largest product in a grid
This solves Project Euler #11: In the 20×20 grid below, four numbers along a diagonal line have been marked as bold.
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 ...
2
votes
3answers
136 views
Pangrams implementation using Linq
This is a continuation of my LINQ stories from Pangrams-Hackerrank. Similarly, this challenge has been asked before in python Pangrams python Implementation but I have tried to accomplish this ...
3
votes
2answers
58 views
Diagonal difference using Linq
Recently, I have been trying my hands on LINQ. So I've implemented the diagonal difference using Linq in Hackerrank. I know a similar question has been asked in python Diagonal Difference
Here is ...
2
votes
1answer
602 views
Function that returns another function, for a programming task
This is a task I was given for an online course. This is my solution to the problem.
Task:
Write a function called general_poly, that meets the specifications ...
2
votes
4answers
144 views
Circular array rotation Java
I have a solution to the HackerRank Circular Array Rotation challenge. It passes 7 test cases out of 15. The rest of them are getting timed out. I think it's because of the huge data set that has ...
8
votes
2answers
105 views
Graphical editor programming challenge
I have posted here my working and accepted solution to the graphical editor programming challenge (detailed here) for your review.
The program recognizes the following image editing commands:
...
1
vote
3answers
61 views
Finding the nth machine encountered on the journey
Recently I came across this problem in the IARCS server,here is an little excerpt from it,
A well-known bandit who used to haunt the forests around Siruseri was
eliminated by the policemen a few ...
1
vote
1answer
58 views
Project Euler #4 - Largest Palindrome Project - Python
I solved the HackerRank version of the Largest palindrome problem (similar to Project Euler 4) in Python:
Find the largest palindrome made from the product of two 3-digit numbers which is less than ...
3
votes
3answers
134 views
Last five non-zero digits of a factorial in base b
This HackerRank problem (based on Project Euler problem 160) says:
For any \$n\$, let \$f_b(n)\$ be the last five digits before the trailing zeroes in \$n!\$ written in base \$b\$.
For example,...
2
votes
2answers
106 views
Remove duplicates from a sorted array
I have solved the LeetCode Remove Duplicates From Sorted Array problem:
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. It ...
2
votes
2answers
51 views
Project Euler #15 in Python
I've wrote the code for Project Euler #15 and it runs amazingly fast. I know I can write it using binomials but I wanted to calculate by brute force as if I do not know Binomials. But I think it must ...
6
votes
6answers
1k views
Generalized Project Euler #4: Largest palindrome from product of two n-digit numbers in Python
This solves Project Euler 4: Largest palindrome product using Python (not limited to 3 digit numbers). I need suggestions for improvements to either the Python code or the math/algorithm since time of ...
1
vote
2answers
61 views
LCD Display Programming challenge solution
I have submitted here my solution to the LCD Diplay programming challege(detailed here)
Please review my code and let me know what you think.
...
2
votes
1answer
90 views
Internship coding challenge post-mortem
I wrote this in 78 minutes as part of an application to an internship program. We were allowed to use whatever language we wanted, so I picked Rust because that's what I use the most. I'm a ...
2
votes
1answer
53 views
Project Euler #1: multiples of 3 and 5 Ruby
Total newbie here and wouldn't mind learning from Rubyists to look at how I tried to solve this challenge.
I started with 2 variables n which starts at 0 and total which is an array where I intend to ...
7
votes
2answers
832 views
Maximize result of bitwise AND
This was the problem from "30 Days of Code" on Hackerrank:
Given set \$S = \lbrace{1,2,3,\dots,N}\rbrace\$, find two integers \$A\$ and \$B\$ (where \$A \lt B\$), from set \$S\$ such that the ...
2
votes
2answers
77 views
The Trip Programming challenge UVA10137
I have the following solution for the Trip problem from Skiena's and Revilla's Programming Challenges (full problem description here).
...
0
votes
1answer
47 views
Recovering permutation from its image sequence
Recently while practicing I came across this problem , here is an excerpt from it,
A permutation of the numbers 1, ..., N is a rearrangment of these
numbers. For example
2 4 5 1 7 6 3 ...
3
votes
1answer
38 views
Project Euler #12 in Scala — Highly divisible triangular numbers
I generally work in Python for programming competitions, but I'm teaching myself Scala. As an exercise, I've attempted Project Euler problem #12 in Scala. I hope that somebody familiar with Scala can ...
4
votes
2answers
75 views
Find The Triangular Number With More Than N Divisors
My code is a general solution to the following problem from Project Euler #12:
What is the value of the first triangle number to have over five hundred divisors?
MY CODE
...
3
votes
2answers
75 views
Efficient solution to Project Euler 14 (Longest Collatz sequence)
This is an iterative review. I asked for reviews on a Collatz sequence generator here. I tried to address all of the suggestions that were made.
I've added a new function ...
1
vote
1answer
66 views
Dijkstra's Algorithm not optimized enough
I was attempting a question on HackerRank-Dijkstra's Shortest Reach 2 and upon submission my programs times out in 3/7 test cases. One of the test cases had 200 nodes and about 2000 connections. Here ...