Questions tagged [programming-challenge]

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

130 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
0answers
70 views

Spiralling Advent, Get To The Point

Advent of Code Day 3 Challenge Part 1: Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up while spiraling outward. For example, the first ...
1
vote
0answers
322 views

Fetching weather data from API

I was experimenting with some code to fetch the current weather data as well as getting the hourly forecast. I could have done ...
1
vote
0answers
218 views

Cellular Automata: Counting preimages

One of the Google Foobar challenges requires you to write a program to count the the number of preimages of a position in a 2D cellular automaton, under the following rules: You find that the ...
1
vote
0answers
179 views

Haskell - Adjacency Matrix

This program is used to solve Challenge #140 [Intermediate] on /r/dailyprogrammer. The challenge is, given a input set of directed edges, print the corresponding ...
1
vote
0answers
111 views

Design Twitter LeetCode

I solved this Challenge from LeetCode Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the user's ...
1
vote
0answers
85 views

Longest Absolute File Path in Leetcode

I solved the Longest Absolute File Path challenge from Leetcode. The question is Suppose we abstract our file system by a string in the following manner: The string ...
1
vote
0answers
437 views

Hackerrank > Woman's CodeSprint 2 > stone division, Revisited ( recursive function)

Problem statement You have a pile of n stones that you want to split into multiple piles, as well as a set, S, of ...
1
vote
0answers
94 views

UVA: Y2K Accounting Bug

The Challenge Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc. All what they remember is that MS Inc. posted ...
1
vote
0answers
277 views

UVa 524 - Prime Ring

The challenge A ring is composed of n (even number) circles as shown in diagram. Put natural numbers 1,2,...,n into each circle separately, and the sum of numbers in two adjacent circles should be ...
1
vote
0answers
66 views

Algorithm design for CodeChef - Base Attack

I was working on a CodeChef challenge: Base attack. I have a working solution but it is not fast enough. Could you recommend anything to make it faster? ...
1
vote
0answers
34 views

Outputting closest free index

It's a coding challenge you have to output the closest free index. It has to run sub 1 second. Input looks like this: The first line is 2 numbers. The first of them is the number of indexes that is. ...
1
vote
0answers
133 views

Getting TLE for SPOJ Bitplay challenge program

I have tried a naive way to solve this problem: Given a even number N (N ≤ 109) and an integer K, you have to find the greatest odd number M less than N such that the sum of digits in binary ...
1
vote
0answers
111 views

Idiomatic string from/to integer conversions in Julia (Project Euler #33)

I am starting to learn Julia. For getting fluent in the syntax, I am solving some of the easier Project Euler challenges. Problem 33 is about so-called curious fractions, which keep their value after ...
1
vote
0answers
144 views

Greedy solution to minimize the max-min spread

I wrote this solution to contest challenge and I am new to D and was hoping for some tips to make it faster or more Dish. The challenge is to select K integers from a list of N integers (2 ≤ N ≤ 105, ...
1
vote
0answers
66 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 ...
1
vote
0answers
149 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. ...
1
vote
0answers
1k views

Payment Gateway - single payment with credit card (handling path & choosing gateway)

This was an assignment and I am new to Node.js. You can find the complete project here. The code worked fine but was rejected, and wasn't given any reason even after asked. Statement: Create a ...
1
vote
1answer
375 views

Find max in-order difference in array

Given an array A of integers, find the maximum of j - i subjected to the constraint of A[i] <= A[j]. If there is no solution possible, return 0. Example : A : [3 5 4 2] Output : 2 for the pair ...
0
votes
0answers
511 views

Function to sum values of most significant digit contained

ABOUT For each subsequence, look at its position in the original decimal representation of \$x\$. Let's say that the most significant digit it contained was the \$e\$-th digit, where \$e=0\$ ...
0
votes
0answers
293 views

Digit Sum find number of ways and max people

I applied for a job, and the prospective employer sent me the following HackerRank problem, which cannot be found in the public area. There is a lottery with n ...
0
votes
1answer
50 views

Project Euler # 37 Truncatable primes in Python

The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can ...
0
votes
0answers
73 views

Merge Two Sorted Lists in JavaScript

The task is taken from LeetCode Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. ...
0
votes
0answers
51 views

Split string into as few substrings as possible such that each substring is a palindrome

The task Given a string, split it into as few strings as possible such that each string is a palindrome. For example, given the input string racecarannakayak, return ["racecar", "anna", "...
0
votes
0answers
133 views

Hackerrank All Women's Codesprint 2019: Visually Balanced Sections

Link: https://www.hackerrank.com/contests/hackerrank-all-womens-codesprint-2019/challenges/visually-balanced-sections/problem Problem Description A rack has \$n\$ horizontal compartments. The ...
0
votes
0answers
210 views

Time limit exceeded on HackerRank “Username Disparity”

Here is the hackerrank question: For two strings A and B, we define the similarity of the strings to be the length of the longest prefix common to both strings. For example, the similarity of ...
0
votes
0answers
44 views

Optimize the file content comparison

Program to compare if files within two directories are having same content I followed the approach of getting the list of files under two directories recursively and store it in different list with ...
0
votes
0answers
53 views

Advent of Code 2017 Day 5 (part 2) in Functional Programming (FP)

I wanted to practice functional programming (fp) without using any library but using vanilla JS only. So I took a problem from Advent of Code (the 2nd part of Day 5): https://adventofcode.com/2017/...
-1
votes
2answers
72 views

Project Euler problem # 3 is this the most efficient approach in Python or can I do better?

The problem statement: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? This code takes 9 seconds!, is there a better way? ...
-3
votes
0answers
44 views

A problem: HackerEarth says it is TIme limit exceeded

I have written a solution to Memorise me problem on Hacker Earth but it takes a lot of memory space and time limit exceeds in the last test case. The first line of input will contain N, an integer, ...
-3
votes
1answer
66 views

Project Euler #5 Optimized

I have seen multiple questions on this problem but none seem to answer my specific question. To start, the basic question is asking to find the smallest number that is divisible by numbers 1 to 20. ...