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
0
votes
0answers
22 views

Enigma Implementation in 3 languages: C# pro, JAVA and Python newbie [closed]

I want to learn Java and Python, so I ported a C# Enigma implementation of mine. All of them have UnitTests and are running. I'm looking for a review, telling me, where I don't know best practices, ...
2
votes
2answers
59 views

An implementation of Uber's “Fare Estimator”

CodeSignal put out a challenge by Uber that involves writing a "fare estimator" that involves a function dependent on cost per minute, cost per mile, ride time and ride distance. The formula ...
4
votes
2answers
80 views

Bisection, linear recurrences and even Fibonacci numbers

So this code is yet another attempt at solving the second Project Euler problem to improve my handling of Python. The purpose of the code is to solve the problem below Each new term in the Fibonacci ...
2
votes
2answers
1k views

How to do modulo thing fast (less execution time)

I was solving a question on a coding website and this website has a limit for execution time of code. My code takes 1.01 sec but the limit is 1 sec. I am unable to find any changes in my code that ...
-2
votes
0answers
16 views

use hcubature from cubature C package in on a C++ custom function [closed]

I'm using a C++ code in R, through the R package Rcpp to speed up my algorithm. I would like to use the hcubature function from ...
2
votes
1answer
48 views

Project Euler 1 using functional programming in JS

So I am once again beating a dead horse, by solving the first Project Euler problem: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these ...
3
votes
2answers
632 views

Make Array Consecutive

Ratiorg got statues of different sizes as a present from CodeMaster for his birthday, each statue having an non-negative integer size. Since he likes to make things perfect, he wants to arrange them ...
1
vote
2answers
77 views

Leetcode kth largest element without using heaps

I was working on kth largest element problem on leetcode Question Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in ...
10
votes
4answers
3k views

First non-repeating Character, with a single loop in Python

I recently tried to solve the first non-repeating character problem. Please tell me if my solution is valid. I'm aiming for O(n) with a single loop. My thinking is, it would be easy to tell you what ...
0
votes
1answer
21 views

Cubic Permutations | Project Euler #62

The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits ...
3
votes
1answer
29 views

Attempting to solve minimum window substring problem using Python 3.8

Hello programming gurus/reviewers, I attempted to solve the Minimum Window Substring (Leetcode 76) problem using Python 3. My solution involved using Counters and backtracking. On submission, the ...
1
vote
1answer
34 views

Ratio of primes in square diagonals | Problem 58 Project Euler

I solved problem 58 in Project Euler and I am happy with my solution. However, are there any areas where I can improve my code here as I am learning how to write good python code. Prompt: Starting ...
1
vote
2answers
69 views

Permuted multiples in python

How can I improve efficiency/readability of the following code? It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the ...
1
vote
1answer
64 views

Google Foobar challenge optimization

I am trying to solve Google Foobar challenge prepare-the-bunnies-escape using my own approach, instead of BFS. I attempt to solve two ends of the maze and try to ...
2
votes
3answers
159 views

Finding n-th smallest Palindrome number (where 1<=n<=5000 and the palindrome number must have odd number of digits)

I am working on this code from 3 days from a website called Codechef, the code compiles, executes and even give correct results but my code is taking 1.01 sec, but the time limit for question is 1sec,...
3
votes
1answer
40 views

Find number of ways to traverse matrix of 0's and 1's

I solved a Daily Coding Challenge, but i suspect my code could be optimised. The challenge is the following: You are given an N by M matrix of 0s and 1s. Starting from the top left corner, how many ...
2
votes
1answer
255 views

Codechef: The Chefora Spell

This is the question currently I am trying to solve of codechef and I am able to get the given test cases result but I am getting Time Limit Exceeded when I am trying to submit. Please let me know ...
0
votes
0answers
23 views

Three Project Euler solutions in the D programming language

I recently wrote some programmes in D language to solve the first ten problems on Project Euler, but I'll be discussing only three of them (but you're free to check out my GitHub repo with all ten ...
4
votes
1answer
364 views

Find next smallest number that's representable as a sum of distinct powers of 3

I'm solving this challenge: Given a positive integer number, you have to find the smallest good number greater than or equal to the given number. The positive integer is called good if it can be ...
0
votes
1answer
69 views

Cheapest flights within k stops algorithm in JavaScript

The problem: There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is ...
1
vote
1answer
61 views

An implementation of Uber's “Fare Estimator” [CodeSignal]

CodeSignal put out a challenge by Uber that involves writing a "fare estimator" that involves a function dependent on cost per minute, cost per mile, ride time and ride distance. The formula ...
0
votes
0answers
53 views

Find the number of different submasses in a weighted string

I'm using a site similar to SPOJ (in Portuguese, so I don't think linking it will help), where I need to find the number of different submasses in a given weighted string. Through the use of an ...
4
votes
1answer
57 views

Python leetcode: scheduling courses to meet prerequisite requirements

This is my solution to Leetcode #210, Course Schedule II. There are a total of numCourses courses you have to take, labeled from ...
1
vote
3answers
141 views

Count prime numbers whose rotations are all prime

This code solves Project Euler problem 35: The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes ...
2
votes
1answer
148 views

Solution to LeetCode Two Sum problem in Rust

It's taking 2.4 MB of memory and 20 ms. It's my solution for Two Sum problem on LeetCode. How can I make it better using closures and other stuff? Kindly review the code. ...
3
votes
0answers
59 views

Generate valid combinations of parentheses

Playing on leetcode coding problem: "Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses." I realized that my understanding of Python was ...
4
votes
0answers
89 views

LeetCode 1632: Rank Transform of a Matrix in Rust

This is a problem-solving code for LeetCode 1632. Given an \$m \times n\$ matrix, return a new matrix answer where ...
3
votes
1answer
118 views

Killing a Hydra - Overengineered

Background This question is inspired by the question: Killing a hydra, and my response therein. I will restate the problem at hand in full so that this question is fully self contained You can only ...
2
votes
1answer
69 views

Python app thats simulate simple Stock Exchange

I wrote this simple app for creating a Stock Exchange platform. It is written with a flask framework. My main concerns are regarding the user_page route which feels too long and not DRY enough, But on ...
1
vote
0answers
30 views

Applied Solution Based On Polya Enumeration Theorem

Problem A function solution(w, h, s) that takes 3 integers and returns the number of unique, non-equivalent configurations that can be found on a grid w blocks wide, h blocks tall and s possible ...
3
votes
2answers
67 views

Q: Paying Debt Off a Year, MIT edX 6.001 U2/PS2/P1

Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month. The following variables contain ...
1
vote
0answers
29 views

Python script to replace GitHub password with tokens

I manage a fleet of IoT devices. As for now, GitHub announced that the username-password authentication would be deprecative soon, so I have to change the password on each device to the GitHub access ...
2
votes
2answers
112 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 ...
2
votes
2answers
231 views

Print all combinations from dictionary which will result in number N

Print all combinations from dictionary which will result in the number N ...
3
votes
2answers
68 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
33 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
92 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 ...
1
vote
2answers
79 views

Find the 10001st prime number

Project Euler 7: What is the 10 001st prime number? I currently have this code: ...
4
votes
3answers
324 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
29 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
56 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
120 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
68 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
109 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
42 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
260 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
120 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
119 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
99 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 ...

1
2 3 4 5
64