Skip to main content

All Questions

1 vote
1 answer
106 views

Finding the number of distinct decompositions a number has using only repdigits

This is a problem from a previous semester that I am trying to upsolve. I am trying to solve a problem involving the total number of ways of decomposing a number using only repdigits. A repdigit is a ...
Lesserrafim's user avatar
8 votes
3 answers
294 views

Refactor the code which performs "cross-product", "reduce", "product of list" and "sum of list"

I have come up with a sequence of steps to find the maximum product of y positive numbers which add up to x. But the program is ...
Yozachar's user avatar
  • 227
5 votes
1 answer
2k views

Project Euler 76: Counting summations

Project Euler Problem 76 asks: How many different ways can one hundred be written as a sum of at least two positive integers? My code is correct but just works slowly. ...
camarman's user avatar
  • 519
2 votes
1 answer
93 views

Total of maximum values in all subarrays

This is the crux of a problem found on one of those code challenge sites. I'm fairly new to programming and this was a difficult challenge. I've attempted to solve this with stacks and calculating ...
Paul K's user avatar
  • 373
1 vote
1 answer
2k views

Create all combinations of length N from a given alphabet

I have some (very limited) experience in Java 6 and decided to revisit the language. To do so I wrote a solution for the following challenge: You are given a number N and a string S. Print all of the ...
yuri's user avatar
  • 4,508
9 votes
2 answers
1k views

Return all valid expressions with specific target

The problem is stated as: Given a string that contains only digits 0-9 and a target value, return all expressions that are created by adding some binary operators (+, -, or *) between the digits so ...
user1179317's user avatar
3 votes
2 answers
525 views

Finding Permutations of Numbers

I'm trying to solve this challenge, which consists of finding the next biggest number formed by the digits of the passed in number. If it is impossible to find a number larger than the passed in ...
Tom Pridham's user avatar
1 vote
1 answer
1k views

Print the lexicographically smallest permutation that satisfies the given formation

Problem Statement: A DOTA game has N heroes, each with a distinct rank from [1..N]. In DOTA every formation is characterized as a permutation [1...N] of ranks of players. A formation is Imba ...
darthShadow's user avatar
4 votes
1 answer
2k views

Necklace counting problem-with consecutive prime constraint

This is codeEval challenge to count the number of chains possible to make with beads holding numbers. Constraint is sum of the consecutive beads of chain should be a prime number. The standard ...
Steephen's user avatar
  • 1,250
4 votes
2 answers
347 views

Project Euler 78: Counting Partitions

Project Euler problem 78: Let \$p(n)\$ represent the number of different ways in which \$n\$ coins can be separated into piles. For example, five coins can be separated into piles in exactly seven ...
castle-bravo's user avatar
2 votes
1 answer
5k views

Optimizing Diwali Lights problem in C

I was trying to solve the Diwali Lights challenge on HackerRank. Problem Statement On the eve of Diwali, Hari is decorating his house with a serial light bulb set. The serial light bulb set ...
thebenman's user avatar
  • 1,168
2 votes
1 answer
99 views

Accessing list elements when counting the number of rectilinear paths

I am trying to solve the RIVALS problem on SPOJ: Starting from (0, 0), how many paths are there to reach point (X, Y), only taking one-unit steps moving to the right or up? Constraints: 0 ≤ X ≤ 106, ...
Lakshman's user avatar
  • 258