As of May 31, 2023, we have updated our Code of Conduct.

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 votes
1 answer
26 views

Python Logic Gate Circuit Simulator [closed]

I have recently become interested in simulating logic circuits because of a electronics class at school. I have created a functioning simulator for logic gate circuits in Python. My implementation ...
turt1edman's user avatar
0 votes
3 answers
75 views

Efficient Solution for Finding Product of Largest Pair in Array

Hello fellow developers, I have written a function called max_product that aims to find the product of the largest two integers in a unique array of positive ...
TAHER El Mehdi's user avatar
1 vote
0 answers
18 views

LeetCode 399 Evaluate Division using Scala

In order to gain familiarity with Scala I am trying to solve the following problem https://leetcode.com/problems/evaluate-division/description/ You are given an array of variable pairs equations and ...
ThePunisher's user avatar
1 vote
1 answer
93 views

Determine the chance a streak of 6 HEADs or 6 TAILS appear in 100 flips, repeated 10000 times [closed]

Here's the problem from the book Automate the boring stuff: write a program to find out how often a streak of six heads or a streak of six tails comes up in a randomly generated list of heads and ...
Nova's user avatar
  • 113
5 votes
2 answers
110 views

Generating Pascal's Triangle in C99

I recently completed the Pascal's Triangle challenge on leetcode. I would like to have my code reviewed. You don't need a leetcode account to see the description of the challenge linked above, but for ...
Gabriel's user avatar
  • 1,053
4 votes
1 answer
86 views

Find the longest palindromic subsequence - Using a hashmap in Rust

This is a leetcode question which I wanted to solve using Rust as I'm learning Rust at the moment. I would appreciate some feedback on how to write it idiomatically. Link to the question: https://...
bluprince13's user avatar
2 votes
3 answers
448 views

Recursive palindrome check

I'm trying to solve this which basically calls for a recursive palindrome check with some minor extra steps (Special characters and whitespace can be ignored). The test inputs' length can be 100000 ...
YaMiN's user avatar
  • 125
1 vote
2 answers
209 views

Split the Bill and calculate the Tip

I have created a Bill Splitter page that asks for the total bill amount, tip percentage, and the number of people. Then it displays the tip and the total amount (including the tip) each person has to ...
Ultimate's user avatar
3 votes
3 answers
101 views

Solution to Codejam 2021 1C (Closest Pick) in C

The following code is my solution to the Closest Pick problem from Codejam 2021. You are entering a raffle for a lifetime supply of pancakes. N tickets have already been sold. Each ticket contains a ...
Panic's user avatar
  • 287
1 vote
1 answer
81 views

Count islands in a binary grid

This is the No of Island code challenge. Please review my implementation in Haskell. I know there must be some better way of doing this. Given an m x n 2D binary grid grid which represents a map of '...
presci's user avatar
  • 249
-1 votes
1 answer
69 views

Using JavaScript to interface with REST APIs

The website TryHackMe came up with a challenge that involves using HTTP requests to interface with REST APIs (here, task #14/day 9). The challenge basically involves querying a basic REST API to ...
Aleksey's user avatar
  • 101
3 votes
1 answer
100 views

Validating a Sudoku Board in Python

The problem statement is as follows: Sudoku is a game played on a 9x9 grid. The goal of the game is to fill all cells of the grid with digits from 1 to 9, so that each column, each row, and each of ...
yorkdev123's user avatar
4 votes
3 answers
119 views

Improving efficiency of Rust algorithm ported from Python generator

I'm learning Rust by solving ProjectEuler problems. To this end, I am trying to port a solution to problem 88 (link) in Python that heavily relies on generators to Rust (which doesn't have generators)....
Bram's user avatar
  • 93
2 votes
2 answers
119 views

Generate the number of partitions of each integer

I've coded a program that calculates the number of partitions of n into at least two distinct parts, and is relatively quick too (about N^1.5 complexity). For input 30 000 it takes roughly 4 seconds. ...
svok's user avatar
  • 21
3 votes
0 answers
136 views

Advent of Code 2021 Day 19

I am taking advantage of the recent layoffs to teach myself Kotlin. I am a career Java programmer, I've touched Kotlin before but not actively, and not for a few years. I wrote it all in one file ...
durron597's user avatar
  • 918
4 votes
3 answers
131 views

Simple photomosaic generator

I wrote an implementation of Robert Heaton's Programming Exercise for Advanced Beginners #4 (photomosaics) in C99 using the MagickCore library. The full code is as follows: ...
Wilson's user avatar
  • 43
0 votes
0 answers
39 views

Modified PoC for BlogEngine.NET CMS (CVE-2019-6714)

This is a modified exploit proof of concept targeting the BlogEngine.NET content management system (CVE-2019-6714) for the .NET framework. I modified it (from Cobb 2019) to execute payloads via ...
Aleksey's user avatar
  • 101
0 votes
1 answer
501 views

sum of intervals kata in codewars

instructions for the kata: Write a function called sumIntervals/sum_intervals() that accepts an array of intervals, and returns the sum of all the interval lengths. Overlapping intervals should only ...
mlk's user avatar
  • 47
0 votes
1 answer
105 views

Permutations CodeWars problem solved!

i have solved a question in codewars: https://www.codewars.com/kata/5254ca2719453dcc0b00027d/python , here's my solution is it unefficient to use itertools because people are blaming that is cheating ...
mcccuklev's user avatar
  • 127
0 votes
1 answer
215 views

Calculate score of rock-paper-scissors (Advent of Code 2022: Day 2)

Advent of code, Day 2. Here is my code. Less verbose version of the question follows. ...
Infinity's user avatar
  • 505
1 vote
2 answers
141 views

Implementation of aho corasick algorithm - slow suffix construction

EDIT: Dequeu was the correct guess EDIT: I did the BFS method for the suffix link/output link construction I'm doing a hackerrank challenge and I came up with this implementation of the aho corasick ...
Nicolas Menettrier's user avatar
5 votes
1 answer
76 views

Möbius function using iterators for prime factors

While working on Project Euler, I have come across a few questions involving usage of the little omega function, big omega function, and Möbius function. My prior code wrote factors into an array and ...
Ethan Slota's user avatar
3 votes
1 answer
44 views

Generate total property sold for given postcode

I had to implement the below as a coding challenge. There are two http endpoints. The first http endpoints returns a list of postcodes. The second http endpoint takes a postcode as a parameter and ...
hulike2286's user avatar
2 votes
1 answer
158 views

Finger Exercise: Update book cipher by creating new book

I'm working my way through the finger exercises in John Guttag's book Introduction to Python Programming, third edition. The following finger exercise on page 143 describes encryption/decryption with ...
Wolric's user avatar
  • 123
6 votes
2 answers
821 views

Find all combinations of length 3 whose sum is divisible by a given number

I came up with a suitable solution to a HackerRank problem that failed because the execution took longer than 10 seconds on lists that were of very large size. The problem: Given a list ...
Nicholas Hansen-Feruch's user avatar
3 votes
1 answer
78 views

Number to Roman in Rust

I solved LC12 (Integer to Roman) in Rust. I am a beginner with Rust, so I translated my previous solution from C++ to Rust. I am looking for feedback on how I could improve the following Rust code. ...
Mircea's user avatar
  • 300
4 votes
1 answer
238 views

Leetcode, longest palindromic substring

Here's a link Given a string s, return the longest palindromic substring in s. A string is called a palindrome string if the reverse of that string is the same as the original string. Example 1: ...
watch-this's user avatar
1 vote
2 answers
239 views

Find the cheapest flight to reach from source to destination

As the input you get the flight schedule as an array, each element of which is the price of a direct flight between 2 cities ...
meallhour's user avatar
  • 133
1 vote
1 answer
132 views

Leetcode 55. Jump Game solution

I was working on Jump Game problem on leetcode Question You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your ...
D_S_X's user avatar
  • 189
6 votes
1 answer
386 views

HackerEarth challenge: Lunch boxes

I was solving the lunch boxes problem on HackerEarth but as I submitted my solution most of the test cases were passed and the rest showed 'Time Limit Exceeded'. I would be very grateful if you could ...
Devansh Kumar's user avatar
3 votes
3 answers
542 views

Creating Phone Number challenge from Code Wars

I solved a question on Codewars about creating a phone number: Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone ...
mcccuklev's user avatar
  • 127
2 votes
1 answer
119 views

LeetCode#494 target sum (dart is slower than python)

I'm trying to solve a LeetCode problem target-sum, in two languages: Python & Dart. The difference of time taken is shocking for me" Python took ~70ms while Dart took ~900ms !! Why does Dart ...
Abhishek Patil's user avatar
2 votes
1 answer
109 views

An evolutionary algorithm written in Java to crack an XOR cipher

Alright. So TryHackme is a website that tries to teach hacking with hands on labs. They have a room called JVM Reverse Engineering where the user gets to reverse engineer Java apps, and in particular ...
Aleksey's user avatar
  • 101
5 votes
1 answer
218 views

Connecting ropes with minimum cost

Question: There are given N ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. The task is to connect the ropes ...
Sherlock-Holmes-2-2-1's user avatar
3 votes
0 answers
88 views

Finding the number of possible paths in a cave system (Python)

I've finally come up with working solution for day 12 of AdventOfCode, where you have to find the number of possible paths in a cave system following a given set of rules (described below). My ...
Oleg Shevchenko's user avatar
5 votes
2 answers
971 views

Find the best couple of an array in 1.5 seconds

I faced this exercise. Given a sequence \$S\$ (\$2 <= |S| <= 10^6\$) of numbers (\$1 <= S_x <= 10^7\$), determine \$max(abs(S_i - S_j) + abs(i -j))\$. Here is the solution I found: ...
Nicolò Teseo's user avatar
2 votes
0 answers
553 views

Determining the winning bingo from a set of bingo boards and sequence of draws

I've learned Python basics about two years ago and did a few personal projects, one big one that turned out to be useful in my line of work, a few small programs for my hobbies and I've also began ...
Oleg Shevchenko's user avatar
3 votes
2 answers
255 views

Euler Project: Sums of Digit Factorials

MY CODE: ...
CaptainPotato's user avatar
-1 votes
1 answer
61 views

Sum of differences between products and LCMs

I've been trying to solve this Codewars problem https://www.codewars.com/kata/56e56756404bb1c950000992 In this kata you need to create a function that takes a 2D array/list of non-negative integer ...
post_lupy's user avatar
5 votes
2 answers
421 views

Leet Code 139 (Word Break) using a trie with recursion

I was attempting to solve LeetCode 139 - Word Break Given a string s and a dictionary of strings wordDict, return ...
Shawn Frank's user avatar
2 votes
1 answer
52 views

Small typesafe assertion library, is()

I need to write a function with the following requirements (Programming TypeScript book by B. Cherny, Chapter 4, exercise 5): Implement a small typesafe assertion library, ...
user3132457's user avatar
4 votes
2 answers
684 views

Hangman Game: Revealing guessed letters

I solved this problem: the Edabit Hangman Game challenge. Create a function that, given a phrase and a number of letters guessed, returns a string with hyphens - ...
mcccuklev's user avatar
  • 127
6 votes
2 answers
115 views

LeetCode 126: Word Ladder II -- Memory limit exceeded

I am trying to solve LC126, and got a memory limit exceeded for the following solution. I've seen the answer here -- so I'll try to use Dijkstra as well, but I would like to understand why I get the ...
Mircea's user avatar
  • 300
4 votes
2 answers
157 views

Project Euler #51: "Prime digit replacements" in Rust

Problem: https://projecteuler.net/problem=51 "Find the smallest prime which, by replacing part of the number (not necessarily adjacent digits) with the same digit, is part of an eight prime ...
sarema's user avatar
  • 449
6 votes
2 answers
538 views

Codeforces #806 Problem D: Double Strings

I tried solving the following problem by following the suggested approach to solving the problem in the problem tutorial. However, the online judge still says my solution exceeds the time limit. Is ...
Sam's user avatar
  • 61
1 vote
2 answers
194 views

Coin Change in Java

Inspired by a leetcode exercise, I wrote my own coin changer: You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of ...
Martin Frank's user avatar
  • 2,581
4 votes
1 answer
139 views

Decibinary for xth number (Python code)

I created the code for the problem description below. It works for \$N\le10^6\$ but after that it gives a time out error. What I don't understand is how to optimize the code using dynamic programming. ...
vijayalakshmi_bhagat's user avatar
4 votes
1 answer
120 views

Time limit error in 'The Minion Game' using python in Hacker Rank

This is the question link for the quick reference. Problem : There are two players Kevin and Stuart have to play a game in which they're pleased to create multiple strings and will get +1 score for ...
Sanjay Varyani's user avatar
4 votes
2 answers
372 views

Geektrust coding challenge: simulating a marketplace for loans

This is the my solution to a coding challenge in Geektrust. The question is linked here. A shortened version would be as follows. The aim is to simulate a marketplace for banks to lend money to ...
SATW's user avatar
  • 43
3 votes
2 answers
155 views

Leetcode 14. Longest Common Prefix beats only ~50% of C++ solutions

The task is to find the longest common prefix. While I had no trouble to find the solution, I'm interested in the statistics of my code: Runtime: 7 ms, faster than 56.36% of C++ online submissions ...
infinitezero's user avatar

1
2 3 4 5
65