Questions tagged [programming-challenge]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
9 views

CodingBat: without_end

Link To Question Given a string, return a version without the first and last char, so "Hello" yields "ell". The string length will be at least 2. without_end('Hello') → 'ell' ...
3
votes
1answer
14 views

Project Euler # 22 names scores in Python

Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. ...
0
votes
0answers
21 views

Coding Challenge: Kattis - Antiarithmetic?

Short problem description: A sequence of numbers are antiarithemtic if there exists no three numbers a_i, a_j, a_k – where a_i preceeds a_j which then again preceeds a_k in the sequence – such that ...
0
votes
1answer
18 views

Project Euler # 21 amicable numbers Python

Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b ...
2
votes
1answer
26 views

Project Euler # 20 factorial digit sum in Python

n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the ...
2
votes
1answer
28 views

Project Euler # 19 Counting Sundays in Python

You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have ...
4
votes
2answers
50 views

Letter case permutation

The question can be found here https://leetcode.com/problems/letter-case-permutation Given a string S, we can transform every letter individually to be lowercase or uppercase to create another ...
-3
votes
0answers
20 views

karatsuba's integer multiplication algorithm python [on hold]

This code is not passing all the test cases, can somebody help? I only pass the straight forward test then it loses precision. ...
-1
votes
1answer
29 views

HarckerRank 2D Arrays Hourglass challenge

About this 2D Arrays HackerRank problem. The task is to find the maximum sum of a region in a 2D array. Specifically, it is to find the maximum sum of an "hourglass" region, defined as a 3x3 square ...
0
votes
1answer
70 views

Adding a Node to the Linked List is taking a longer Time when using a reference to the Tail Node

I am trying to add two numbers in the form of linked List and return their result in a Linked List as given in https://leetcode.com/problems/add-two-numbers/ Question: You are given two non-empty ...
2
votes
2answers
88 views

Staircase challenge - Python

Your task is to print all unique ways to climb a staircase of length n where, from each step, you can take steps of size x where ...
2
votes
1answer
35 views

Project Euler #17: Number Letter Counts

If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) ...
5
votes
4answers
73 views

Project Euler #14: Longest Collatz Sequence starting point

Problem statement: 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 with 13, we ...
3
votes
2answers
68 views

Counting valleys traversed below sea level, given elevation changes

Problem Statement: Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly steps. For every step ...
14
votes
6answers
3k views

Project Euler, problem # 9, Pythagorean triplet

Project Euler #9, Pythagorean triplet is 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
votes
1answer
28 views

Project Euler Problem # 8 maximum product of sequences

Is there any room for improvement? Your feedback would be helpful. Problem Statement: The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. Find ...
-1
votes
2answers
63 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? ...
11
votes
5answers
2k views

HackerRank: Electronics Shop

Challenge from Hacker Rank - Monica wants to buy a keyboard and a USB drive from her favorite electronics store. The store has several models of each. Monica wants to spend as much as possible for ...
-1
votes
0answers
23 views

Counting co-occurence of a file encoded in UTF-8 [closed]

I need to write a script that can count co-occurences in a UTF-8 encoded file. The length of the co-ocurence is between 2 to ...
6
votes
3answers
288 views

Bishop game - python

A bishop can capture any other bishop if it lies along the same diagonal line, so long as no other bishop is in its path. Given a list of coordinates of the bishops locations, and a board size, ...
2
votes
2answers
40 views

Counting Valleys - HackerRank Challenge

For this challenge on HackerRank: A valley is a sequence of consecutive steps below sea level, starting with a step down from sea level and ending with a step up to sea level. Given Gary's ...
-3
votes
0answers
24 views

Google Foobar challenge “queue-to-do” Python partial test case errors [closed]

I started foobar challenge a few days ago, and I'm now in the 3rd stage first question, and I've got the "Queue-to-do" challenge. The problem is that I get some partial errors in the verifying process....
1
vote
0answers
24 views

test oriented design; Python test script to test a company's API, print test results, log exceptions

I'd like some constructive feedback on the code that I have written to test the API for smartsh33t.com I wrote it in Python. I wrote the program to take .json files and read them into the testrunner....
2
votes
2answers
50 views

“When to take medicine” CodeChef Challenge MEDIC

I just submitted this code to solve the "When to take medicine" challenge on CodeChef: ...
7
votes
3answers
524 views

Cracking the Coding Interview — 1.5 One Away

I would like to know any suggestions about to improve my code solution and your rating of my approach to the problem, I based my code on the fact that if the strings have different length removing one ...
1
vote
0answers
24 views

Find a Sum of Particles in A Set of Boxes Given a Number of Rows and Columns

This is a code challenge, from Codewars, the details of the specific challenge in depth can be found here: https://www.codewars.com/kata/magnet-particules-in-boxes/javascript. The summary of it ...
8
votes
5answers
2k views

Find The One Element In An Array That is Different From The Others

https://www.codewars.com/kata/find-the-stray-number/train/javascript I solved this challenge by sorting from least to greatest, and checking if the first element in the array matched the second ...
6
votes
2answers
107 views

String manipulation with std::adjacent_find

For the given strings (not containing numbers), print their shortened versions, where each adjacent sequence of the same characters longer than 2, change to an expression consisting of a sign and ...
8
votes
1answer
79 views

Geektrust: Solve War problem in a OO way in Python

I solved this programming challenge whose objective is to come up with an OO solution to the problem. The problem statement is quite verbose and the tl;dr version would be: Given an enemy army(...
2
votes
1answer
64 views

Find A Series of Numbers Who when Squared and Summed are equal to a given Square

I am working on a CodeWars titled 'Square into Squares. Protect trees!' it can be found here: https://www.codewars.com/kata/54eb33e5bc1a25440d000891/train/javascript I have a working solution, the ...
1
vote
1answer
49 views

Maximum Width binary tree

Here is my code for the LeetCode problem For a given binary tree, find the maximum width of the binary tree. The width of one level is defined as the length between the end-nodes even if there are <...
5
votes
2answers
91 views

Compute Manhattan distance from origin given a set of left-right-step directions

I am solving the problems for Advent of Code 2016 to learn Rust programming. The prompt for the first problem can be summarized: I start at position 0,0 on a regular grid. I am given a set of ...
3
votes
2answers
94 views

Jump Game - Leetcode

Below is my solution for the LeetCode Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents ...
3
votes
1answer
59 views

Jumping on the clouds

I have started the Hackerrank interview preparation kit. The first problem I have solved with Swift is as follows: Emma is playing a new mobile game that starts with consecutively numbered clouds. ...
3
votes
2answers
221 views

Calculate the largest palindromic number from the product of two 6-digit numbers (100000 to 999999)

Are there any efficient ways to solve this problem, for example using bitwise operator? ...
1
vote
0answers
43 views

Graph-coloring solution using depth-first search

I'm trying to solve this question: Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them. The park consists of n ...
2
votes
1answer
78 views

Project Euler #3 with Python

I tried to solve some Euler's problems, this is the solution I found for problem #3 with Python. The problem asks: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor ...
8
votes
3answers
2k views

Tiny URL creator

Coding challenge: Convert a given long URL into a Tiny URL. The length of this Tiny URL should be fixed and the same for all URLs. You should return the full URL if given a shortened URL. I am ...
2
votes
1answer
86 views

Union, Intersection and Diff of two sorted arrays in C#

This is the original question https://www.geeksforgeeks.org/union-and-intersection-of-two-sorted-arrays-2/ Given two sorted arrays, find their union and intersection. ...
1
vote
2answers
117 views

Run length encoding in C#

This is the original question: https://www.geeksforgeeks.org/run-length-encoding/ Given an input string, write a function that returns the Run Length Encoded string for the input string. For ...
1
vote
2answers
86 views

My Sal's Shipping challenge on Codecademy

This is my attempt on the Python 3 Sal's Shipping challenge on Codecademy (Challenge Link (instructions in the link)). I'd really appreciate anyone to take the time to review my code. I'm a very new ...
1
vote
1answer
51 views

String Rotation

I have solved a previous year question of 2018 codevita (link) in Python. Problem Description: Rotate a given String in the specified direction by specified magnitude. After each rotation make a ...
4
votes
2answers
60 views

Finding a vertex of a tree such that every subtree rooted at that vertex is of a uniform color

I'm trying to optimally solve codeforces problem 763A: Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so ...
5
votes
1answer
63 views

Finding sum of divisors of numbers between the range (1 to 1e16)

The exact link to the question : https://www.spoj.com/problems/DIVSUM2/ Input: An integer stating the number of test cases (equal to 500), and that many lines follow, each containing one integer ...
1
vote
1answer
37 views

Find the sum of Fibonacci sequence

I have already done many of the Project Euler questions in other languages before, but whenever learning a new language, I like to do the problems again in that language. Here is my elixir version ...
1
vote
1answer
76 views

Boggle using Trie and DFS

I already mentioned in my previous code review, there are two solutions for this problem https://www.geeksforgeeks.org/boggle-find-possible-words-board-characters/ this is the first: Find all ...
3
votes
2answers
83 views

codekata: Binary search on an int array

I'm following Karate Chop kata for a binary search. I really wanted to avoid built in functionality within the language. I'm pretty new to C# so any recommendations is greatly appreciated. Spec: ...
1
vote
3answers
65 views

LeetCode:implement strstr C#

https://leetcode.com/problems/implement-strstr/ I implemented Rabin-Karp algorithm https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm please review for performance, also if you were in an ...
2
votes
2answers
107 views

Find all possible words in a board of characters

This question has 2 possible solutions and I am trying to implement the DFS solution. Here is the Trie and DFS solution: Boggle using Trie and DFS Please review for performance. Given a ...
-1
votes
2answers
79 views

Cracking the code interview: Problem 1 .6 basic string compression

I created a github repository containing my code solutions for some of the exercises proposed in the book, I updated my solution for the problem 1.6 at https://github.com/dariosicily/cracking-the-code-...