Questions tagged [programming-challenge]

Use this tag when the code is a solution to a programming challenge. Always include a sufficient description of the problem to be solved - while a link to the challenge is welcome, the review request needs to be complete when the challenge site is unavailable.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
45 views

LeetCode: Remove Duplicate Letters [closed]

I'm trying to solve this question: https://leetcode.com/problems/remove-duplicate-letters/description/?envType=daily-question&envId=2023-09-26 which is Given a string s, remove duplicate letters ...
evirac's user avatar
  • 11
2 votes
1 answer
73 views

Project Euler Problem 1: Multiples of 3 or 5

The following is my solution to Project Euler Problem 1: Multiples of 3 or 5. ...
hexpev's user avatar
  • 23
3 votes
3 answers
168 views

Increment a large integer represented as array of digits

This problem can be found at LeetCode. Since I was studying idiomatic or 'pythonic' code in my language today, I decided to take the most 'pythonic' approach and challenged myself to do this in one ...
KhodeNima's user avatar
3 votes
1 answer
57 views

Autocomplete system with prefix tree

I am quite new to Haskell, and this problem is from dailycodingproblem.com: Implement an autocomplete system. That is, given a query string s and a set of all ...
Fin H's user avatar
  • 33
4 votes
3 answers
726 views

Codewars: Multiplying Polynomials

I'm trying to solve the following Kata from Codewars in Python. My code produces the desired result for all the tests, yet it is not optimal, so it takes too much time to accomplish the big tests. <...
GuntherOnFire's user avatar
3 votes
1 answer
306 views

Python function to find the count of digits of numerals in base n up to a given limit

This is a simple exercise to find the count of digits of all numerals in a given base up to a given limit (not including the limit), I wrote it to determine the ratio of bytes saved when the numbers ...
Ξένη Γήινος's user avatar
-1 votes
1 answer
96 views

HackerRank "Digit sum" challenge

Here's the question: ...
The Infinite Star's user avatar
4 votes
4 answers
797 views

Lottery Analysis (Python Crash Course, exercise 9-15)

I was working on Python Crash Course, exercise 9-15: 'Lottery Analysis'. It took me a very long time to get it to work. The reason it took that long is I wanted to use my existing class from the ...
snapieee's user avatar
1 vote
1 answer
101 views

Calculate the cost of Biryani lessons

Problem: According to a recent survey, Biryani is the most ordered food. Chef wants to learn how to make world-class Biryani from a MasterChef. The chef will be required to attend the MasterChef's ...
kvk30's user avatar
  • 113
0 votes
1 answer
122 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
118 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
44 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
105 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
128 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
97 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
461 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
330 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
  • 113
3 votes
3 answers
111 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
92 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
104 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
  • 153
3 votes
1 answer
234 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
132 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
150 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
140 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
136 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
59 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
  • 153
0 votes
1 answer
934 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
143 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
  • 139
0 votes
1 answer
240 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
158 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
79 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
170 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
871 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
90 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
  • 322
4 votes
1 answer
265 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
360 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
238 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
447 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
826 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
  • 139
2 votes
1 answer
131 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
137 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
  • 153
5 votes
1 answer
286 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
97 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
975 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
700 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
289 views

Euler Project: Sums of Digit Factorials

MY CODE: ...
CaptainPotato's user avatar
-1 votes
1 answer
65 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
453 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
54 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

1
2 3 4 5
65