Earlier quoted context omitted.
Couldn't you split 3 into [4,-1] ?
None of the implementations support negative numbers, but the rules say integer which includes negative numbers, so that should be a legal move.
Here's a puzzle game. I call it Reverse the List of Integers
111–120 of 188 posts
Re: Here's a puzzle game. I call it Reverse the List of Integers
#112This can be transformed into a problem with pegs and moving blocks. Like tower of hanoi[1], but you can add or remove empty pegs, blocks are the same size and can be stacked in any order, you can move as many blocks as you want and you cannot have towers with the same amount of blocks. Unless you want to deal with negative integers, then it would get more tricky. [1]: https://en.m.wikipedia.org/wiki/Tower_of_Hanoi
The charm of towers of Hanoi is that you can make a physical version where the legality of moves is easily verified because of the differently sized blocks. I think the “you cannot have towers with the same amount of blocks” rule will make this a lot less charming, certainly if any of the numbers are larger than, say, 10. There also is the issue of adding pegs, but that’s solvable by fixing the number of stacks (the…
The biggest issue with this game is that there's no guarantee that any arbitrary starting state has a valid solution. A much needed improved would be a simple rule for guaranteed reversible starting formations (if one even exists).
Re: Here's a puzzle game. I call it Reverse the List of Integers
#113I 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 Integers
#114There are a couple of obvious downsides like: What if it turns out the problem is too trivial? Move on to the next one. What if the interviewee has already encountered the problem before? No different than if the interviewer posed an already-solved problem.
It would be incumbent upon the interviewer to not reveal a solution if they come up with it first of course. And the evaluation of "how you approach and work through the problem" is less definite than whether an answer (brute-force or optimal) was achieved; but if approach is indeed the important thing, that needs to be evaluated regardless. I'm sure there are other downsides I'm not seeing off the top of my head.
I can't be the first person to come up with this strategy, nor try it in real interviews. Has anybody attempted this? Was it successful or not, and why?
I can't tell if this strategy that just popped into my head is of value :-).
Re: Here's a puzzle game. I call it Reverse the List of Integers
#115the best I can find for [7, 5, 3] is: 7 5 3 7 1 4 3 2 5 1 4 3 2 5 1 7 2 6 7 2 1 5 7 3 5 7
753 7512 34512 3462 34152 3417 357
753 7512 762 7152 34152 3417 357
753 7512 762 3462 34152 3417 357
753 7143 25143 2643 21543 2157 357
753 7143 25143 2643 267 2157 357
753 7143 25143 2517 267 2157 357
Discovered using SAT/SMT
Re: Here's a puzzle game. I call it Reverse the List of Integers
#116Hi. I'm the post's author. This was something I dashed off quickly, so I was a bit imprecise in the language. Clarifications: Only positive integers are meant to be allowed. (Zero excluded.) Combining is meant to work on adjacent pairs of integers. If this is used in coding interviews, I deny any responsibility. Unless it's used in interviewing me, in which case I will totally take credit.
Re: Here's a puzzle game. I call it Reverse the List of Integers
#117My first reaction to this was, "neat coding question for interviews". I started to try to solve it for a few seconds, then thought of when I've asked coding questions. Invariably starting by saying "The goal is to see how you approach and work through the problem, and less so whether you come up with the optimal solution". Then I thought, what if the interviewer and interviewee tackled the problem together, both comi…
Re: Here's a puzzle game. I call it Reverse the List of Integers
#118Earlier quoted context omitted.
To be pedantic, this isn't the operation he gave - "split an integer into 2 smaller integers" is the operation, but 2 into [3, -1] is splitting it into a larger and smaller integer. Read literally, the numbers are constrained to not jump over the 0. It might depend on interpretation (absolute value or distance from positive infinity?); but negatives are tricky to handle with these rules and I think they might be ille…
> To be pedantic, I don't think that's pedantry. That's just a straightforward reading of the rules, and I missed the word "smaller", somehow. *shrug*
Re: Here's a puzzle game. I call it Reverse the List of Integers
#119Earlier quoted context omitted.
The charm of towers of Hanoi is that you can make a physical version where the legality of moves is easily verified because of the differently sized blocks. I think the “you cannot have towers with the same amount of blocks” rule will make this a lot less charming, certainly if any of the numbers are larger than, say, 10. There also is the issue of adding pegs, but that’s solvable by fixing the number of stacks (the…
You can make a physical version by having one fixed height pole for each integer up to the max, and then an equal number of post holes. Eg. If you wanted to support a game up to the integer 10 you would need 10 posts with lengths from 1 to 10 units, and 10 post holes. The biggest issue with this game is that there's no guarantee that any arbitrary starting state has a valid solution. A much needed improved would be a…
Hanoi isn't a good model for this, because the posts are not fixed in place and the units are all identical.
It's a bad physical game because the player has to do all the work to enforce the rules. The environment doesn't provide any useful assistance.