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

String represents a road. One character travels on the road obeying the stops - Code challenge (advent.js day 5)

This is my code to solve the 5th Adventjs challenge. In that link you can read the instructions. How can I improve it? It's a bit messy... and I'm repeating some part of the code. All must be in just ...
Sofia Chardin's user avatar
3 votes
2 answers
943 views

Advent of code 2023 day 4 mostly in Bash

Yesterday I thought was the last day of Advent Of Code 2023 that I do in Bash. I was wrong. I'm not even sure anymore that today will be the one. We'll just have to see tomorrow! Part 1 To paraphrase ...
janos's user avatar
  • 111k
1 vote
0 answers
73 views

Advent of code 2023 day 3 in pure Bash

Yes I'll keep doing this until I cannot be bothered to do it in Bash ;-) (Well today is probably the last one ;-)) Part 1 To paraphrase the puzzle, given some input ("engine schematic") like ...
janos's user avatar
  • 111k
1 vote
0 answers
59 views

Advent of Code 2023 Day 2 in C#

To paraphrase the puzzle, Santa takes a walk with an Elf, and they play a game involving a bag of colorful cubes. In each game, there is an unknown number of each colored cubes in the bag, and the Elf ...
Natecat's user avatar
  • 111
6 votes
2 answers
1k views

Advent of code 2023 day 2 in pure Bash

To paraphrase the puzzle, Santa takes a walk with an Elf, and they play a game involving a bag of colorful cubes. In each game, there is an unknown number of each colored cubes in the bag, and the Elf ...
janos's user avatar
  • 111k
5 votes
1 answer
119 views

Advent of code 2023 day 1 mostly in Bash

It's that time of the year again! Although there's no more Winter Bash, we can still have all the Bash we want in winter ;-) Part 1 To paraphrase the description: For each line in the input: Find ...
janos's user avatar
  • 111k
0 votes
1 answer
29 views

Print a hollow Rhombus [closed]

I am beginner in java, here is my code to print a hollow rhombus: ...
Gagandeep Singh's user avatar
0 votes
1 answer
63 views

HackerRank Algorithm Problem: Climbing the Leaderboard (Python)

Here is the Hackerrank problem which is related to dense ranking and below is my solution which didn't pass the time limit cases. Any better way to optimize this? ...
peternish's user avatar
3 votes
2 answers
266 views

Trailing Digits

https://www.acmicpc.net/problem/23204 I've solved a programming challenge where you need to count the occurrences of a specific digit at the end of the product of multiples of a given number within a ...
qleoz12's user avatar
  • 141
-1 votes
1 answer
103 views

HackerRank Project Euler 12 (Python) | Highly Divisible Triangular Numbers

I again share my Python code which didn't pass time limit test cases in the HackerRank contest of ProjectEuler. ...
peternish's user avatar
1 vote
1 answer
69 views

Project Euler 10(Python) | Summation of Primes

This is my Python3 code which solved the 10th problem of Project Euler. I haven't passed the last 2 time limit test cases. ...
peternish's user avatar
3 votes
1 answer
200 views

Project Euler 60: Prime Pair Sets

Project Euler Prime Pair Sets: The primes 3, 7, 109, and 673 are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 ...
peternish's user avatar
1 vote
0 answers
27 views

Determine top t values with few calls to order(), a given procedure to order k values

Trying to write a decent answer to Most efficient way to get the largest 3 elements of an array using no comparisons but a procedure for ordering 5 elements descendantly, I came up with something ugly....
greybeard's user avatar
  • 6,104
2 votes
1 answer
90 views

Codeforces: Dasha & Nightmares

so I got started with competitive programming about a day ago and I got stuck on the first random question I tried on codeforces. It's called Dasha and Nightmares. Problem Description: The problem ...
st0n3r's user avatar
  • 73
2 votes
2 answers
154 views

Given an array, remove zero or more elements to maximize the reduction where you add odd values and subtract even values

Here's a code challenge I got. (I could not solve the challenge, I ran out of time. I rephrased the challenge language and I am trying the challenge again for personal growth & computer science ...
Nate Anderson's user avatar
1 vote
5 answers
246 views

Sum of bitwise XOR of each subarray weighted by length

here is the problem statement You are given an array a of length n consisting of non-negative integers. You have to calculate the value of \$\sum_{l=1}^n \sum_{r=l}^n f(l,r)\cdot (r - l + 1)\$ where \...
Gurnoor Singh's user avatar
2 votes
1 answer
89 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
240 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
  • 167
3 votes
1 answer
72 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
778 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
320 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
147 views

HackerRank "Digit sum" challenge

Here's the question: ...
The Infinite Star's user avatar
4 votes
4 answers
885 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
109 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
163 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
138 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 ...
XM01 - stands with Palestine's user avatar
1 vote
0 answers
58 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
119 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
132 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
114 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
474 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
420 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
  • 123
3 votes
3 answers
119 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
96 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
106 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
475 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
146 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
191 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
142 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
137 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
83 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
1k 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
175 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
268 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
169 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
81 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
180 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
1k 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
94 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

1
2 3 4 5
65