Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [programming-challenge]

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

-1
votes
1answer
39 views

Pramp: Flatten a Dictionary skipping empty keys

This is a question from pramp: A dictionary is a type of data structure that is supported natively in all major interpreted languages such as JavaScript, Python, Ruby and PHP, where it’s known ...
-5
votes
0answers
22 views

Is the #100DaysOfCodeChallenge literally an hour a day? Including the part where we get stuck on code? [on hold]

Pardon if this question is very poorly formed but I'll give a background. I recently started my #100DaysOfCode Challenge and I spare out some time from a really hectic routine. An hour. Everyday. I ...
7
votes
3answers
2k views

Add multiples of 3 or 5 below 1000, Can this code be optimised. Project Euler #1

I have seen some solution here for the same problem, this and this I have found better ways to solve this problem. I just want to know how good or bad my code and way of approaching this problem is. <...
0
votes
2answers
384 views

“Spread the Word” CodeChef challenge

I am solving the "Spread the Word" problem on CodeChef: Snackdown 2019 is coming! People have started to spread the word and tell other people about the contest. There are \$N\$ people numbered 1 ...
-1
votes
0answers
18 views

Pythagorean triplet [on hold]

Project Euler problem on one pythagorean triplet a + b + c = 1000 def pythagorean(): for a in xrange(500): for b in xrange(a+1,500): c=1000-(a+b) if a2+b2==c**2: ...
-3
votes
0answers
43 views

return the longest size period of turbulence in A - codility [on hold]

Your team is analysing a flight of a plane. Your task is to find the longest period of turbulence. The height of the plane above the ground is measured once every second of the flight. The ...
-1
votes
1answer
24 views

Print the last 7 leap years [on hold]

This is my work with Pseudocode (I'm a new entrant in programming, please tell me the logical fallacies with my pseudocode): y:= 2018 while i = 1 to 7 ...
2
votes
0answers
41 views

Solo dice game (from Reiner Knizia’s Decathlon)

I'm trying to implement Reiner Knizia’s Decathlon, a set of 10 solo dice games played with 8 dices named after Decathlon events in Olympics. The first event is called "100 Metres". The player divides ...
0
votes
1answer
30 views

TLE in FOXLINGS SPOJ

Problem Statement: FOXLINGS It’s Christmas time in the forest, and both the Fox and the Wolf families are celebrating. The rather large Fox family consists of two parents as well as \$N\$ (\$...
1
vote
0answers
28 views

I have written two versions of Word Break exhaustive combinations. Please comment

I am solving Word Break II from leetcode. https://leetcode.com/problems/word-break-ii/description/ Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add ...
1
vote
1answer
62 views

Tic tac toe game using C++

I wrote this C++ code for Tic-tac-toe for an interview (The basic skeleton was pre-provided) and got rejected because the code was too complex and inefficient. I'm not an expert programmer so I'd like ...
2
votes
1answer
51 views

NAQ 2018 Problem D Froggie

Successful attempt at the ICPC North America Qualifier 2018 Problem D "Froggie." Any advice and all topical comments on code optimization and performance enhancement is appreciated! Problem Summary ...
-1
votes
0answers
22 views

Output of a program [closed]

I have a preliminary doubt regarding this code. #include <stdio.h> int main() { char *ptr = "GeeksQuiz"; printf("%c", *&*&ptr); return 0; } Why ...
0
votes
1answer
61 views

Euler #7 - 10001st prime [closed]

Here is my code of project Euler #7: ...
0
votes
1answer
36 views

CodingBat warm up: conditionally prepending “not” to a string

I solved this CodingBat problem: Given a string, return a new string where "not " has been added to the front. However, if the string already begins with "not", return the string unchanged. Note: ...
1
vote
0answers
45 views

Median of two sorted arrays JavaScript

Trying to find the median of two sorted arrays in O(log(m+n)) or better. I believe this is O(log(m+n) or O(log(m)) or O(n). ...
2
votes
2answers
115 views

BalancedPassword Codility task

Ok, now for some time I've been trying to conquer this challenge without success performance wise. And I'd like some hints about approaching this problem, or the general algorithms I should learn ...
7
votes
3answers
518 views

Count number of gemstones in a set of minerals

This is the "Gemstones" problem on Hackerrank. John has collected various rocks. Each rock has various minerals embeded in it. Each type of mineral is designated by a lowercase letter in the range ...
11
votes
2answers
3k views

Make a beautiful binary string

This is the "Beautiful Binary String" problem at HackerRank: Alice has a binary string. She thinks a binary string is beautiful if and only if it doesn't contain the substring 010. In one step,...
0
votes
2answers
45 views

Prime number generation - SPOJ

This is a program to generate prime numbers for a given range. The sieve of Eratosthenes algorithm was implemented, but still the SPOJ says time limit exceeded. Where can some optimizations be made? ...
3
votes
2answers
128 views

Hackerrank Luck Balance solution in C++

I solved the Hackerrank Luck Balance problem the "C" way (I am much more used to C) and I wanted to know if there were any C++ features I could have used that would have made my code more concise/...
2
votes
1answer
31 views

Pramp: Sales path

the question is taken from Pramp(really cool site!) there is a more straight forward solution. using recursion. but I thought trying it using BFS. please review only the code of GetCheapestCost ...
2
votes
1answer
63 views

MaxCounters Codility Challenge

I've been doing some Codility challenges lately and the MaxCounters challenge got me stumped: You are given N counters, initially set to 0, and you have two possible operations on them: ...
1
vote
1answer
76 views

Smallest job first algorithm implementation

I have implemented smallest job first algorithm using javascript. It was part of a coding challenge. I would like to ask for evaluation of my script. I would like to get suggestions to improve my code ...
0
votes
3answers
32 views

Subarray Sum Equals K

I've written a solution to the following leetcode problem: Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example ...
6
votes
2answers
57 views

Prime number segmented sieve

I tried to solve the SPOJ prime number problem below. The code produced correct results, but Time limit exceeded and also memory need around 970M which is not efficient(?) How can I optimize this ...
4
votes
2answers
43 views

Solve Project Euler #4 in PHP

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 product of two 3-digit ...
10
votes
3answers
2k views

Imgur URL parser

Fairly new to Python, and I have been doing a few Edabit challenges, to better help with my problem-solving. I have just completed a some what semi-difficult challenge, and I was hoping for some feed ...
6
votes
1answer
81 views

Frequency Analysis & Chi-Squared Test

Following up on my implementation of Cryptopals Challenge 1, this is my solution to Challenge 3. Single-byte XOR cipher The hex encoded string: ...
1
vote
1answer
74 views

TLE in JNEXT problem in SPOJ

Problem Statement: JNEXT DevG was challanged to find the just next greater number which can be formed using digits of a given number. Now DevG needs your help to find that just next greater number ...
0
votes
2answers
47 views

JavaScript Anagram checker

I have written a code that finds whether the entered words are anagrams or not. I tested and it works, but I know that there are some details that I must change or modify. So what do you think I have ...
11
votes
3answers
3k views

Python 3 function to rotate an image 90°

A coding challenge that rotates an image 90 degrees counterclockwise. The image is represented as an array matrix. I believe the time complexity is O(n2), but I'd like to know for sure, as well as any ...
5
votes
2answers
133 views

Finding all possible letter combinations from an inputted phone number

Prompt: Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the ...
2
votes
1answer
60 views

Convert hex to base64 (Cryptopals challenge 1)

I've been spending some time learning Rust and I came across the Cryptopals Challenges. This is my implementation of challenge 1 Convert hex to base64 The string: ...
4
votes
1answer
488 views

Time complexity of Max counters

As per the instructions are given in MaxCounters-Codility, You are given N counters, initially set to 0, and you have two possible operations on them: <...
3
votes
3answers
141 views

Morgan and a String HackerRank challenge

I am solving a HackerRank problem called 'Morgan and a String'. Given two strings, each consisting of up to 105 uppercase characters, the task is to form the lexicographically smallest string from ...
2
votes
0answers
54 views

HackerRank Attribute Parser

I wrote a program for solving the Attribute Parser challenge on HackerRank. The challenge is to read some specified number of lines of HTML-like markup (each line no more than 200 characters; for any ...
-2
votes
1answer
71 views

Dynamic Programming solution for one pile nim game

I have solved the following problem using dynamic programming: Little Deepu and his Girlfriend 1. To paraphrase, We have two players Little Deepu and Kate and M items in the bag B, also we have ...
9
votes
2answers
564 views

Generating the powerset in C

I am solving another problem in leetcode. Given a set, generate all the subsets of the set. Input: [1,2,3] Output: ...
5
votes
2answers
162 views

Deficient Numbers

I have found the following interesting challenge on the web: Deficient Numbers A number is considered deficient if the sum of its factors is less than twice that number. For example: 10 is a ...
5
votes
2answers
697 views

Sort characters in a Python string by frequency

I wrote a solution to the leetcode problem Sort characters by frequency and the solution passes 34/35 test cases. On the last test case, there is a "time limit exceeded" error with an input string of ...
7
votes
2answers
479 views

Palindrome program needs improvement

Here a string is taken as input and the program suppose to check whether the string is palindrome or not. Is there any way the code can be improved? Is it okay to use foreach to break the string into ...
6
votes
2answers
224 views

Decode the Morse Code

From Code Wars: This kata is part of a series on the Morse code. After you solve this kata, you may move to the next one. In this kata you have to write a simple Morse code decoder. While the ...
2
votes
1answer
86 views

Classic Hundred Doors Simulation

I am doing the 100 Doors problem as an exercise to practice user input and loops. I do understand the problem can be solved by outputting every square number up to the maximum number, but it defeats ...
5
votes
1answer
164 views

CodeForces: Creating the Contest

I wrote a solution to this question. The task is to take an input of n increasing positive integers (1 ≤ n ≤ 2∙105), each entry as large as 109, and find the length of the longest subsequence where ...
4
votes
1answer
80 views

Prime pair set finder (Project Euler problem 60)

I made a code that can find the prime sets: The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For ...
5
votes
2answers
182 views

Hacker Rank Challenge : Find count of substrings which are special palindrome

I am getting timeout for test cases having very large input. -= Challenge Link =- -= Test case example =- Code is working fine as can be checked on ideone. (Note: Here ...
3
votes
1answer
48 views

Spoj-Prime Generator

Question- Generate all prime numbers between two given numbers. https://www.spoj.com/problems/PRIME1/ My attempt- I used segmented sieve method. ...
1
vote
3answers
822 views

Project Euler Problem #5 Solution in C++

Project Euler #5: Smallest multiple 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is ...
2
votes
2answers
75 views

Hacker rank - Left rotation - PHP code feedback for Timeout

Here is the problem description: https://www.hackerrank.com/challenges/ctci-array-left-rotation A left rotation operation on an array of size \$n\$ shifts each of the array's elements 1 unit to the ...