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
2
votes
2answers
78 views

return the sum of the squares that is equal to n²

I'm struggling to solve this Kata. My code works but I can't pass because it's timing out. I have googled it and even tried other people's code but still doesn't pass. Any suggestion on how can I make ...
0
votes
0answers
40 views

Print all combinations from dictionary which will result in number N

Print all combinations from dictionary which will result in the number N ...
-1
votes
0answers
43 views

Is my approach not correct? [closed]

Numbers of length N and value less than K I have been trying this mathematical question, from past few hours The approach I followed is simple, we can put less valued digits, at each position of given ...
3
votes
2answers
60 views

Python 3 approximate pi using 9 algorithms

Note: this script requires gmpy2, if you are using Python 3.9.5 x64 on Windows 10 21H1 like me, then you need to download the pre-built ...
0
votes
0answers
28 views

Merging a list of lists

I'm doing the following challenge from leetcode.com, that requires merging a list of lists. https://leetcode.com/problems/merge-k-sorted-lists/ This is the challenge: You are given an array of k ...
3
votes
1answer
89 views

Python Place +,-, nothing between 1, 2, …, 9 (in this order) whose sum is 100

So this is a programming challenge I saw: Write a program that outputs all possibilities to put + or - or nothing between the numbers 1,2,…,9 (in this order) such that the result is 100. For example ...
6
votes
2answers
1k views

Hamming distance between two strings

I wrote this module to find the Hamming distance between two strings. (It's a problem from exercism.io's Haskell track.) As I saw it, the problem has two distinct ...
2
votes
2answers
57 views

Find the 10001st prime number

Project Euler 7: What is the 10 001st prime number? I currently have this code: ...
4
votes
3answers
222 views

Python random word generator that generates a wordlike pronounceable string

This is a random word generator I wrote in Python 3 today, I don't know how many Python implemetations of this exist, but this is my first try and it is completely working. It returns a random word ...
3
votes
1answer
20 views

Python script that converts Windows Registry Scripts (.reg) into PowerShell scripts (.ps1)

Well this a re-implementation of a PowerShell script that I wrote which does exactly the same thing, and I have ported it into Python. After a quick Google search I found that there is only one other ...
2
votes
2answers
54 views

LeetCode Reverse Nodes in k-Group

Link: https://leetcode.com/problems/reverse-nodes-in-k-group/ Problem description: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive ...
-2
votes
1answer
118 views

HackerRank frequency queries

need some help or advice, HackerRank's frequency-queries challenge, the challenge of this Hackerrank problem is to check if the frequencies of number in your data structure matches the queries. small ...
3
votes
1answer
51 views

Python code to find greatest common divisor of multiple numbers

Hmm, I know this has been implemented countless times, and Python 3.9.5 math standard library has a built-in gcd() method that ...
2
votes
1answer
89 views

Project Euler Problem #755

As the title indicates this is one of the last most problems of Project Euler. The problem is straightforward. However, similar to the rest of the Euler Project problems either ...
0
votes
1answer
41 views

Return the prime numbers that are dividers of a some numbers in a list

What I need to do is to return the prime numbers that are dividers of a some numbers in a list, so if I = [12, 15] # result = [[2, 12], [3, 27], [5, 15]] and this ...
5
votes
2answers
251 views

Spliting Greeter class to multiple small classes

Write a Greeter class with greet function that receives a name as input and outputs ...
1
vote
3answers
82 views

Hackerrank: Fraudulent Activity Notifications

I'm having trouble on a question from Hackerrank, this solution works for smaller lists but seems to collapse when the list grows to 200,000 where I get the error "Wrong Solution". The ...
3
votes
1answer
88 views

PowerShell script binary-decimal-hexadecimal-ipv4 convertor

This is a fully functional PowerShell script I wrote not long ago that converts data (numerical data) among 4 data formats: binary, decimal, hexadecimal and ipv4. It supports 12 conversions, it can ...
1
vote
2answers
94 views

Improving my solution to the Quiz project from Gophercises in Golang

I'm new to Go and I completed the first challenge from Gophercises. Any feedback would be highly appreciated. There are some things that I am unsure of if they are made in an optimal way. Github repo ...
0
votes
2answers
166 views

InterviewBit Problem: Stringoholics

I am trying to solve https://www.interviewbit.com/problems/stringoholics/ InterviewBit problem. Problem Statement: You are given an array A consisting of strings made up of the letters ‘a’ and ‘b’ ...
4
votes
1answer
51 views

Calculate probability that knight does not attempt to leave chessboard after at most k random moves (LeetCode #688)

I'm learning competitive programming and came across this question on LeetCode : 688. Knight Probability in Chessboard On an n x n chessboard, a knight starts at the cell (row, column) and attempts ...
1
vote
2answers
93 views

I want reduce the time complexity for this ladder problem to find the minimum ladders required

I was trying to attempt below given challenge. I tried multiple ways to solve the problem but none of them were good enough to pass the time limit. Please advise if you have any idea to improve on ...
4
votes
1answer
116 views

Contacts programming challenge

I successfully solved a problem on Hackerrank called Contacts, but I'm curious if my code in C++ looks good to C++ developers. If not, how it should be improved. Below is the short description of the ...
2
votes
2answers
69 views

OOP refactoring technique

I'm teaching myself Object Oriented Programming in JavaScript and I'm looking over this small P5 code of CodingTrain's No.78, which deals with flying particles in the canvas, as a material. The full ...
4
votes
1answer
87 views

Comparing Poker hands in Rust

I found this interesting challenge in Exercism. This is my approach to comparing poker hands in Rust. I've strived for code clarity. I wish I had figured out how to only implement Ord or PartialOrd, ...
2
votes
1answer
60 views

Molybdenum2019 challenge efficient implementation

I'm working on a solution that is correct but inefficient. https://app.codility.com/programmers/task/leader_slice_inc/ This is my code : ...
2
votes
1answer
51 views

Leetcode 3 sum code optimisation

I was working on 3sum problem on leetcode Question Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the ...
1
vote
2answers
99 views

Counting numbers that have an even number of digits

I solved this problem: given an array/vector of numbers, return how many of them contain an even number of digits. Constraints: ...
0
votes
0answers
77 views

LeetCode: Delete and Earn C#

https://leetcode.com/problems/delete-and-earn/ Given an array nums of integers, you can perform operations on the array. In each operation, you pick any nums[i] and delete it to earn nums[i] points. ...
0
votes
5answers
84 views

Determine whether a magazine contains the words needed for a ransom note

This is a website Question on Hackrrank called Hash Tables: Ransom Note: Given the words in the magazine and the words in the ransom note, print "Yes" if we can replicate the ransom note ...
2
votes
1answer
67 views

Find sub-list index with the closest to a given number sum

The task that I have to perform is to take an array of a specific length, and figure out which sub-list has the closest sum to another given number. Then, I need to print the index of that sub-array. ...
1
vote
1answer
78 views

Returning maximum number of consecutive 1s in list of binary numbers

This is what I implemented in Rust to get the maximum number of consecutive 1s in list of binary numbers. ...
1
vote
0answers
43 views

LeetCode: range sum query mutable c#

https://leetcode.com/problems/range-sum-query-mutable/ I am trying to solve this question using dynamic programming. I guess the guys in leetcode want to limit us to use segment tree or one of the ...
2
votes
2answers
57 views

Kattis 'Driver's Dilemma'

The full problem description can be found here, a slightly trimmed version below: A car driver is travelling on an isolated road (no gas stations, houses, or cell phone coverage). The driver glances ...
0
votes
1answer
77 views

LeetCode: Sort The Matrix Diagonally C#

https://leetcode.com/problems/sort-the-matrix-diagonally/ A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-...
2
votes
0answers
47 views

Cron expression parser

Problem Write a command line application or script which parses a cron string and expands each field to show the times at which it will run. ~$ your-program "*/15 0 1,15 * 1-5 /usr/bin/find"...
0
votes
2answers
142 views

std::sort custom compare function

I'm trying to solve the problem given here. Arrange given numbers to form the biggest number | Set 1 Given an array of numbers, arrange them in a way that yields the largest value. For example, if ...
2
votes
0answers
72 views

Partial Function composability in Haskell

Below is my solution for the CTFP chapter 4 challenges which essentially involves composing partial functions (that don't have defined outputs for all possible inputs i.e. returning a Maybe). The ...
0
votes
2answers
71 views

Next different permutation in C

This is a program which you can get the next "different", i.e. elements in A[] can be identical, permutation at each call. I've written a C++ program for ...
0
votes
0answers
45 views

UVA 101 - “The Blocks Problem”

I have been solving the problem from UVA 101. In this problem, there will be at most 24 position in a row at beginning, and this array is zero-indexed, and for each ...
2
votes
1answer
135 views

Counting binary substrings

The exercise i am working on requires me to read a binary sequence stored in a text file. The objective is to find the occurrences of all subsequences of length between a and b (their values are given ...
1
vote
1answer
74 views

return the number of times is state of bulb changed?

Today in an exam I faced a problem which is Toggled Switches(Hacker Earth) as it is an exam question So, I am unable to send the question or its link (exactly). Problem: we have to print a number ...
6
votes
1answer
828 views

Recognise numbers 1 to 6 in various notations

I'm embarrassed I spent so much time on this seemingly simple but tricky coding exercise. The task is this: input is various strings - digits, characters, non-English characters, e.g. some could be ...
-2
votes
1answer
50 views

Time Conversion Problem. What am I doing wrong? [closed]

I was trying to solve this time conversion problem on hackerrank but couldn't get the right output on test cases. I have given my best try along with the expected and my output below. Any optimisation ...
2
votes
2answers
239 views

PowerShell script to convert .reg files to PowerShell commands

This is a PowerShell script I wrote a while ago that converts Windows Registry files to PowerShell commands(New-Item, Remove-Item...
1
vote
1answer
57 views

“Sequence full of colors” challenge on HackerRank

This is the challenge: You are given a sequence of N balls in 4 colors: red, green, yellow and blue. The sequence is full of colors if and only if all of the ...
3
votes
4answers
221 views

A simplified regular expression matcher

I am working my way through some code challenges — partly to improve my problem solving, but also to improve my code quality. I think my current (fully-functional) solution to a challenge is pretty ...
0
votes
1answer
115 views

MSD Radix sort in Place in c++, Object/Pointer Oriented

Memory:O(log(max)base(mod)*mod)Speed:O(log(max)base(mod)*n) I did a radix sort in place to not get a auxliar array. In the process i discorver a few things. Is imposible to do LSD radix sort in place ...
1
vote
1answer
63 views

Advent of Code 2020 - Day 2: validating passwords (C++ version)

Original: Advent of Code 2020 - Day 2: validating passwords Problem statement I decided to translate my Rust solution to Advent of Code 2020 into C++ to increase my familiarity with C++. Here's the ...
0
votes
0answers
48 views

Convert hex to base64 and then fixed XOR

I've seen on the site questions where too simple tasks can be grouped into one. Here are Challenge 1 & 2 from Crypto Challenge Set 1 in Python. Any suggestions? ...

1
2 3 4 5
63