Questions tagged [puzzle]

DO NOT USE - prefer constructive questions, or use more descriptive tags. Otherwise, your question might be appropriate for codegolf.stackexchange.com.

DO NOT USE - prefer constructive questions, or use more descriptive tags. Otherwise, your question might be appropriate for CodeGolf.


The questions tagged "puzzle" are essentially programming questions, that are as good as solving puzzles. These can be contrasted to the real-life problems, which are comparatively easy to solve.

859 questions
-4
votes
1 answer

reduce javascript code (stack overflow 2022)

I'm doing this puzzle, and sometimes when I give a new game the pieces go wrong, I added a function for it and from what I see it doesn't work, my head can't take it anymore. And I would also like to simplify the code a bit, that's why I asked…
rfvfeest
  • 1
  • 3
-4
votes
9 answers

What is a good non-recursive algorithm for deciding whether a passed in amount can be built additively from a set of numbers?

What is a non recursive algorithm for deciding whether a passed in amount can be built additively from a set of numbers. In my case I'm determining whether a certain currency amount (such as $40) can be met by adding up some combination of a set of…
Stimy
  • 1,491
  • 3
  • 15
  • 36
-4
votes
2 answers

SQL puzzle (Find the correct answer based on values given)

The table T has the following 4 columns Column 1 Guesses (Column2) Correct (Column3) Almost Correct (Column4) Game1 ABDC 2 2 Game1 ABCF 3 0 Game1 …
Datalearner
  • 183
  • 7
-4
votes
1 answer

Is it possible to solve the puzzle using python?

The puzzle I tried to solve puzzle with the below program. It is a 4x4 cross math puzzle. Is there any way to solve quickly def puzzleTwo (a): if(a[0] + a[1] - a[2] + a[3] == 19): #print ("1 equation Success") if(a[4] - a[5] - a[6] - a[7]…
Priya
  • 11
  • 3
-4
votes
1 answer

A puzzle game from codechef

Could somebody explain the solution to this problem in cpp and how it works Can this be made more efficient using STL? http://www.codechef.com/problems/H1 It would very helpful if you could explain this particular logic along with its time…
ruhuse
  • 5
  • 3
-4
votes
1 answer

Javascript Simple Puzzle

How can you optimize the following JS statement : obj.endDate = obj.status && (obj.status.length == 2 || (obj.status.length == 1 && obj.status[0] == 0)) ? undefined : obj.endDate; where obj.status is of array type and is allowed to take only the…
J Mako
  • 3
  • 1
-4
votes
2 answers

solving word puzzle c++

From word puzzle collect data in array 2 dimensions and display the results in the following figure. example : T TH THI THIS H HI HIS I IS S W WA WAT WATS A AT ATS T TS S I want to solve word puzzle and I can't to solve this…
R.TURK
  • 1
  • 3
-4
votes
3 answers

Bash script - a puzzle

The script takes only one argument (call it n). It then alternately adds and subtracts each digit of the numbers from 1 through n. For example: n = 12 1 - 2 + 3 - 4 + 5 - 6 + 7 - 8 + 9 - 1 + 0 - 1 + 1 - 1 + 2 output:…
vixero
  • 514
  • 1
  • 9
  • 21
-4
votes
1 answer

Examples of puzzles

So, an example of PUZZLE which its time complexity is linear is the problem of searching for a specific value in an array: it is easy to prove you can't do it with less than n comparsions, and we have an algorithm which solves this problem in…
Programmer
  • 750
  • 2
  • 9
  • 17
-4
votes
1 answer

Need a C programming logic code for a simple puzzle

A shop sells one chocolate @ Rs.1 each, and In exchange of 3 wrappers gives one chocolate again? I want to know the C program logic for this? Have tried it, but getting wrong result. Output should look like: Enter the amount given to shopkeeper in…
cpp-coder
  • 185
  • 1
  • 2
  • 12
-4
votes
3 answers

Hello world with only return in main

What is the way to write a program meeting following requirements: Prints "Hello world!" to stdout; Has empty main (just returning 0) i.e. int main(int argc, char** argv) { return 0; } main must contain no additional code except for that…
-4
votes
2 answers

Algorithmic Puzzle

How to distribute 1000$ in ten boxes so that any amount of money between $1 and $1000(both inclusive) can be given as some combinations of these boxes. Please provide any hints on how to approach this.I tried but couldn't make any solution.
user122345656
  • 1,523
  • 5
  • 15
  • 20
-5
votes
2 answers

Optimal Algorithm

I have got following problem. On a given mountain a girl is stuck and there are two paths. One path will take her to the rescuer (left turn) and the second one (right turn) will take her to a jungle from where there is no chance to come back. Now…
Varun Sharma
  • 2,591
  • 8
  • 45
  • 63
-5
votes
1 answer

C++ Chocolate Puzzle

Let's say I have N chocolates that have to be packed into exactly P boxes in the order they arrive. Each chocolate also has a number of calories X and each box has a capacity K which has to be less than or equal to 3*sum(x1, x2, ..., xn) + max(x1,…
Tuntuni
  • 481
  • 1
  • 7
  • 19
-6
votes
1 answer

How will C parse this sentence?

According to the official description of the C language, what number will be returned? int a, b; a = 5; b = a+++++a; return b;
Robert Martin
  • 16,759
  • 15
  • 61
  • 87
1 2 3
57
58