News for hackers. Stuff that matters.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by ch33zer on Friday April 12, 2024 @06:53AM (#40011198)
I thought the game was cool so I built a little version of it here:

https://blaise.gg/number_game/index.html

Re:"Here's a puzzle game. I call it Reverse the List of Inte... by Bewelge on Friday April 12, 2024 @07:10AM (#40011275)
Thought the same, you beat me to it! Really like the tree-like view, might steal that idea later :-)

https://bewelge.github.io/aNumberGame/ (does not format well on mobile)

Code: https://github.com/Bewelge/aNumberGame

Re:"Here's a puzzle game. I call it Reverse the List of Inte... by madcaptenor on Friday April 12, 2024 @11:09AM (#40013830)
I like that all possible moves are shown at once. Would it be possible to have the sequence be other than [7, 5, 3]?
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by Bewelge on Friday April 12, 2024 @12:17PM (#40014581)
I added an url parameter so you can load it up with any sequence.

Example for sequence 5,2,7

https://bewelge.github.io/aNumberGame?seq=5,2,7

Re:"Here's a puzzle game. I call it Reverse the List of Inte... by madcaptenor on Friday April 12, 2024 @03:40PM (#40016843)
Thanks!
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by dangond on Friday April 12, 2024 @07:13AM (#40011292)
Fun implementation! There's currently a bug that allows the same number to appear twice after a combination step (I was able to perform 2,3,7,5->5,7,5)
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by madcaptenor on Friday April 12, 2024 @11:06AM (#40013795)
Ran into this as well: I did [8, 1, 4] -> [5, 3, 1, 4] -> [5, 3, 5].
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by ch33zer on Friday April 12, 2024 @07:49PM (#40018847)
Should be fixed, thanks for the report.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by minikomi on Friday April 12, 2024 @07:40AM (#40011429)
Jumping in with my janky version: http://poyo.co/list-of-integers/
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by fragmede on Friday April 12, 2024 @02:54PM (#40016395)
I really like the visual aspect of your implementation
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by glenjamin on Friday April 12, 2024 @07:13AM (#40011293)
This is neat, but your implementation does seem to allow duplicates sometimes
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by ch33zer on Friday April 12, 2024 @07:51PM (#40018857)
Should be fixed now, sorry for trouble.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by b3orn on Friday April 12, 2024 @09:56AM (#40012951)
Interesting, it appears I've encountered an impossible combination of numbers: [2, 5, 1, 3]

The only possible move is to add 1 and 3. Can't ever split a 2 as that would result in [1, 1], can't split the 5 because that would be [4, 1] or [3, 2], can't split the 3, as that would be [2, 1] or [1, 2], can't add the 5 to anything as that would be larger than 5.

Re:"Here's a puzzle game. I call it Reverse the List of Inte... by kleiba on Friday April 12, 2024 @11:59AM (#40014380)
Couldn't you split 3 into [4,-1] ?
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by b3orn on Friday April 12, 2024 @12:08PM (#40014470)
None of the implementations support negative numbers, but the rules say integer which includes negative numbers, so that should be a legal move.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by fuglede_ on Friday April 12, 2024 @12:59PM (#40015104)
They also say that a given integer should be split into two smaller integers.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by Tao3300 on Friday April 12, 2024 @12:20PM (#40014624)
Negative numbers would break the game by making the number of possible splits infinite. E.g. 1 could split into [-2, 3], [-3, 4], [-4, 5], etc.

It also violates Rule 1 because one of the splits is larger than the original number.

Re:"Here's a puzzle game. I call it Reverse the List of Inte... by basil-rash on Friday April 12, 2024 @12:44PM (#40014926)
Rules say you can’t ever produce a number greater than the original largest number, so the possibilities will always be finite. (fixed number of ways to make a list of distinct integers that sum to N such that all values are <=M).
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by kleiba on Sunday April 14, 2024 @01:39PM (#40032803)
You're right in the first sentence, but you're second sentence if we're talking about splitting the largest original number itself that way.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by plg94 on Friday April 12, 2024 @06:57PM (#40018503)
I was given [1,2] in the second run. Even easier to see it's impossible.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by ch33zer on Friday April 12, 2024 @07:49PM (#40018844)
Yeah the generation is very simple, 2-4 random numbers between 1 and 9 inclusive. Definitely gives impossible puzzles sometimes (because I don't know a general algorithm for generating possible ones only).
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by hnfong on Saturday April 13, 2024 @02:19AM (#40020938)
If you only have numbers up to 9 an exhaustive search shouldn't be too bad (should be ~9! states if you memoize), you could implement a solver in Javascript and see whether a solution can be found before you give it to the user.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by spywaregorilla on Friday April 12, 2024 @10:50AM (#40013584)
Gave me [2,1] which is not possible
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by jxding on Friday April 12, 2024 @12:41PM (#40014886)
It does seem like [n,n+1] is always unsolvable!
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by ahahahahah on Friday April 12, 2024 @12:54PM (#40015039)
[9,8] -> [6,3,8] -> [6,2,1,8] -> [6,2,9] -> [8,9]
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by klyrs on Friday April 12, 2024 @02:43PM (#40016295)
Indeed,

   [n, n-1] 
   [n-3, 3, n-1]
   [n-3, 2, 1, n-1]
   [n-3, 2, n]
   [n-1, n]
Works for all n greater than... 6?
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by klyrs on Friday April 12, 2024 @05:05PM (#40017639)
Optimizing self-response! That fails for six because n-3 and 3 co-occur. With a slight modification we can make it work for all n>5

  [n, n-1]
  [2, n-2, n-1]
  [2, n-3, 1, n-1]
  [2, n-3, n]
  [n-1, n]
edit: and it's not hard to show that n<6 are impossible, so the solution above is optimal in that sense.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by adotbacon on Friday April 12, 2024 @03:01PM (#40016464)
Yeah, the [n,n+1] is only a problem when there isn't enough wiggle room between the numbers. ex: [2,3] and [3,4]

[3,4]

--> [1,2,4] --> 4 can't split because 2/2 and 3/1 are invalid

--> 4 can't initially split because 2/2 and 3/1 are both invalid

[5,6] --> [5,4,2] --> [5,1,3,2] --> [6,3,2] --> [6,5]

[7,8] --> [7,3,5] --> [7,1,2,5] --> [8,2,5] --> [8,7]

When you add more numbers, you need more wiggle room. So, [4,5,6] is problematic and probably [5,6,7].

[4,5,6]

--> [3,1,5,6] --> 6 can't break into 3, nor 5/1. It can do 4/2, but then 5 can't split. 5 also can't split.

--> [4,2,3,6] --> [4,2,3,1,5] --> [6,4,5] --> 4 can't split into 2/2. It can split to 3/1 but then 5 can't split

--> 6 can't initially split at all because 3/3, 4/2, and 5/1 are invalid

Even if [6,7,8] has a solution, I'm sure [6,7,8,9] does not.

Re:"Here's a puzzle game. I call it Reverse the List of Inte... by madcaptenor on Friday April 12, 2024 @03:51PM (#40016942)
A solution for [6,7,8,9]:

6,7,8,9

6,3,4,8,9

6,3,4,8,2,7

9,4,8,2,7

9,4,8,2,1,6

9,4,3,5,2,1,6

9,7,5,2,1,6

9,7,5,3,6

9,7,8,6

9,5,2,8,6

9,5,2,1,7,6

9,5,3,7,6

9,8,7,6

Re:"Here's a puzzle game. I call it Reverse the List of Inte... by adotbacon on Friday April 12, 2024 @04:24PM (#40017254)
Wow, well done! I found [6,7,8] as well:

6,7,8

6,7,5,3

6,7,1,4,3

6,8,4,3

6,8,7

6,3,5,7

6,2,1,5,7

8,1,5,7

8,6,7

8,4,2,1,6

8,4,3,6

8,7,6

Re:"Here's a puzzle game. I call it Reverse the List of Inte... by mywittyname on Friday April 12, 2024 @11:34AM (#40014088)
Would be nice if you allowed users to define their own puzzle. I had to set a break point at the right location and call startNew([..my array]) to do so.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by ch33zer on Friday April 12, 2024 @07:50PM (#40018856)
Added, you can use ?numbers=1~2~3 to specify your puzzle.

Like this:

https://blaise.gg/number_game/index.html?numbers=1%7E4%7E6%7...

Re:"Here's a puzzle game. I call it Reverse the List of Inte... by IshKebab on Friday April 12, 2024 @11:38AM (#40014130)
Nice. It does let me make the same integer twice though.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by ch33zer on Friday April 12, 2024 @07:51PM (#40018859)
Should be fixed now, sorry for trouble.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by joelthelion on Friday April 12, 2024 @01:03PM (#40015151)
I think it would be more fun if you only displayed problems that are solvable.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by ch33zer on Friday April 12, 2024 @07:50PM (#40018852)
Yeah, I would but finding such puzzles is kind of hard. Might look into it this weekend
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by joelthelion on Saturday April 13, 2024 @05:36AM (#40021775)
I'm sure we could write a brute force tester, and then you would only have to include a list in your webapp. Or harvest people's results
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by raverbashing on Friday April 12, 2024 @03:28PM (#40016729)
Cool!

Though I say the rule about repeated numbers is a bummer. I can see things might get easier (also it might be a more procedurally easy problem to solve) if this is allowed

Basically I don't think it's a "productive" complication

Re:"Here's a puzzle game. I call it Reverse the List of Inte... by two-star on Friday April 12, 2024 @09:19PM (#40019513)
Without that rule, you could decompose everything into 1's, and then recompose from there. Not the most efficient solution, but a boring one that always exists.
Re:"Here's a puzzle game. I call it Reverse the List of Inte... by raverbashing on Friday April 12, 2024 @11:51PM (#40020341)
Ok so how about allowing only non contiguous repeated numbers