@El'endiaStarman fair enough, I was just explaining the meaning for people who didn't know; and it's something that benefits from an abbreviation because it's a) frequently useful and b) really long, so it's not surprising that one grew up
After nearly two hours of fiddling, I am nearly able to elevate a PowerShell script, in the same working directory, passing a path that contains spaces as an argument, without losing the output from stderr.
When you have an infinite loop that takes input, and eclipse is shouting at you for not closing the input scanner, but if you do close it after the loop it shouts at you for "unreachable code"
@redstarcoder I find IRC a much more convenient system than this one (e.g. on IRC I don't have to move my hand to the mouse for basic operations like replying to a post)
but IRC's also designed to be a lot more transient than SE chat is; everything here is logged as a matter of course, so I guess we're supposed to ensure that everything we say makes sense in retrospect
@TimmyD yeah, originally I had that, but I'm probably closing it wrong because it seemed to completely close input and error when another scanner is opened
(you can turn sound off in chat just above the title where it says "The Nineteenth Byte"; that would have the same effect without having to turn off your speakers)
Anyone, does anyone know if you're allowed to return a function which returns the result in PPCG? For example, for the add two numbers challenge, could you submit something which is called via f(4+5)() instead of just f(4,5)
@FlipTack Why is the loop infinite? I assume it has to end at some point, so just ake it exit the loop, close the input, then do whatever (even if that's only exiting the program).
An example in python would be for finding the length of a string, returning f=lambda s:s.__len__, which than has to be called again like f("string")()?
what I meant is, for example in Java, returning the toString method rather than the actual string, and get the user to call the function and then call the result
@Geobits in this case the edit would be an attempt to let people know how to help the question be reopened (it's still receiving upvotes), and putting the post into the reopen queue early would defeat that
Submission formats are always flexible here on PPCG. Named functions, anonymous functions or even full programs that perform IO, are all fine.
Even currying is acceptable, for example, taking arguments as f(4)(5) rather than f(4, 5).
But what about returning a function that returns the result? ...
Solve all of these OEIS questions at once!
code-golfsequenceinternet
Task
Your task is to write a program or function that takes the numeric name for any OEIS sequence (e.g. A000001), and outputs the first N elements of it in any way.
Input
Your program or function will take two inputs,
...
I haven't tried drafting any instructions yet, but would there be interest in a KotH + Cops and Robbers competition where the "Cops" compete to build the most difficult Sudoku puzzle generators and the "Robbers" compete to build the fastest Sudoku puzzle solvers?
Submission formats are always flexible here on PPCG. Named functions, anonymous functions or even full programs that perform IO, are all fine.
Even currying is acceptable, for example, taking arguments as f(4)(5) rather than f(4, 5).
But what about returning a function that returns the result? ...
NP Cops and Robbers
This is an idea I've had for a while, and I really want to get it to work, but there are some large hurdles.
Hurdle 1: I need to pick a puzzle, preferably one that is NP-Complete. I think lots of Nikoli puzzles are good candidates, and I am leaning towards Light Up
Cops:
...
> Members of the "hacking" community known as PPCG have assisted authorities in seizing one of the largest single-day drug hauls in the history of the United States. Asked how they infiltrated the criminal gang's hideout to secure the location of the drugs, one of the PPCG residents said "I dunno, I just clicked on a random camera link." -- CNN
@NathanMerrill I don't see why. Sudoku may be P (not quite sure it is), but it still takes a fair amount of search to brute-force an answer. I am unaware of algorithms to calculate a solution formulaically, but maybe there are some.
in languages like Python it wouldn't really help but in Java you'd be able to return a "function property" of an object without the parenthesis, saving bytes @DJMcMayhem
Outputs are consistent if they are equal in the sanest and most obvious way of comparing them. For example, if you have two char * strings in C or C++, and you try
a == b
you will get a falsy value even if the strings are equal. But every half-decent C programmer knows that you don't compare s...
@NathanMerrill I still don't see why you're saying that, but maybe it's because we're looking at this differently. I am curious to see if there is a way to generate standard Sudoku puzzles that can reliably slow down Sudoku solvers. The only way to test that is to have programs generate many puzzles, and then see if different solvers consistently take longer for any generator's puzzles than other generators'.
@NathanMerrill Finding the solutions is likely to still be fast, but a puzzle that averages at 1s is more interesting than one that averages at 10ms, right?
@sadakatsu for cops, that's somewhat interesting, but you also want it to be interesting for the robbers. If a cop is using some weird puzzle generation that slows down most solvers, I think it'd be fairly trivial to make a solver that solves it quicker.
"The general problem of solving Sudoku puzzles on n^2 × n^2 boards of n × n blocks is known to be NP-complete.[1] For n=3 (classical Sudoku), however, this result is of little relevance: algorithms such as Dancing Links can solve puzzles in fractions of a second."
The class of Sudoku puzzles consists of a partially completed row-column grid of cells partitioned into N regions each of size N cells, to be filled in using a prescribed set of N distinct symbols (typically the numbers {1, ..., N}), so that each row, column and region contains exactly one of each element of the set. The puzzle can be investigated using mathematics.
== Overview ==
The mathematical analysis of Sudoku falls into two main areas: analyzing the properties of a) completed grids and b) puzzles. Grid analysis has largely focused on counting (enumerating) possible solutions for different...
I guess it depends upon how long individual solutions will take. If they're so short that factors like context switching and OS lack of fairness will determine the winners, then bigger boards are necessary. If not, then 9x9 is fine (and more interesting to me since I will want to take a crack at the winner's puzzles XD ).
@NathanMerrill No, I can put in a clause requiring that the puzzle generators be able to generate a puzzle given a size, and solvers need to be able to determine a puzzle's size based upon the passed input, then have them generate puzzles with 9, 16, 25, etc. puzzles when I run the competition.
I was thinking I'd use something like a Wilcoxon rank-sum to determine the winner. That would not care so much about the puzzle sizes or the actual times spent.
I had been planning that scoring system before I thought of different puzzle sizes.
Basically, all times for all puzzle solves are ordered from fastest to slowest. Each is assigned an index for where it is in the list. All the indices for the solvers and generators are summed together. The solver and the generator with the lowest sums win.
that's not a bad system. It's interesting because it makes languages more competitive against each other than against themselves
like, I need to be hyper aware of the other submissions to identify where I should improve so that I can rank past more submissions
however, if 9x9 still comes down to microoptimizations like output speed and context switching, they'd still get a better score for improving on those factors
By having each generator generate a lot of puzzles (I was thinking 100) and allowing each solver to solve each puzzle multiple times, I think it will be fair to both generators and solvers. Generators will not be faulted too much if they accidentally generate one problem that is too easy, and solvers will not be faulted too much if they perform poorly against just one problem.
Challenge
Print the following characters:
abdcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
The catch is that you may not use any one of them in your code.
You may print them in arbitrary order, with or without a leading or trailing newline, but you may not print any other char...
Hm. I also want to make sure that I can run the competition in a reasonable amount of time. If I have COPS * 100 puzzles, and each solver solves each puzzle 100 times, then I have to run COPS * ROBBERS * 10000 tests.
TIL PowerShell variables don't need to be alphanumeric provided you encapsulate the variable name in curly brackets -- i.e., ${#} is a valid variable name
Maybe it's just me, but having cops submit puzzles, with robbers writing a solution to all of them, sounds like it needs a new label. It's not exactly cops-and-robbers imo.
@NathanMerrill If someone writes a stochastic robber, they could get really lucky and try the right solution quickly, scoring really well for his timing and hurting the generator. Similarly, operating system performance variations could make a fast robber perform slowly on a puzzle in comparison to other solvers. However, multiple runs for each robber for each puzzle should smooth that error out.
I was actually really surprised that so many people thought my prime-checking regex solution for this is so good. It isn't all that well golfed, and the regex has been floating around for a while.
@NathanMerrill I figure it's a difficult problem to generate puzzles at all. However, the quality of the problem is dependent upon how difficult it is to solve, and that is measured by how robbers perform when solving it.
right, but if you aren't time-scoring the cops, and simply setting a time limit, then cops have to spend as much time as possible generating a puzzle while hoping it doesn't go over the time limit on your computer
I'm writing a 2d language similar to befunge or ><>. Does anyone know I can handle integers? I don't know how to differentiate push 4, push 8 and push 48
@PhiNotPi I'm interested in what you think (above conversation). What's a good way of scoring cops in a cops-n-robbers challenge where they generate/solve np-complete puzzles?
@NathanMerrill (still waiting to hear what PhiNotPi thinks) If I think about the typical idea being Cops and Robbers, these are cryptographic puzzles in some way. Thus, a Cop that generates puzzles that take the most time to crack are better than those that take less, even if that Cop is slower than those other ones. I am worried that any kind of composite score will lose that.
I'm sure this is not really brightening anyone's day.
You're not doing that person any favors. Someone might look at that and think this person is guilty of vote fraud. Please stop voting this way, it's more annoying than anything else.
It's a cool moment for me. Both of the two languages I've written were used to answer the same challenge within the first hour it was posted, and neither of them was written by me. :D