Wait, Javascript is weird. ++[[]][0] returns 1. If you do something like ++5 it errors (trying to overwrite a constant), same with ++[], but I guess putting it in another array creates a reference to the inner array as an object?
Decide a C integer literal
Objective
Given a string, decide whether it is a valid C integer literal.
C integer literal
A C integer literal consists of:
One of:
0 followed by zero or more octal digits (0–7)
A nonzero decimal digit followed by zero or more decimal digits (0–9)
0X or 0x, followe...
I'm 100% not against it, especially if it chooses between all open, positively-scored questions, just pointing out that something similar already exists
I bet there's a way to use Incident for this, but somebody with more smarts and/or patience than me will have to do it. :P I tried for about half an hour to get the language to output something--anything--before deciding that my sanity was more important.
Clearly it's possible to output stuff in Incident--TIO has a Hello World program. I figured AABBAB should loop and output forever; instead, it promptly halted with no output. And the debug output looks like this. O_o
Hmm, actually, I figured out the debug output, and also the mistake I made in analyzing my test program. Still not seeing how to write a big enough program to output something useful, though. I suspect that maybe 8 would be the easiest number to go for--its binary structure, 111000, might be helpful.
CMC: TIO boasts that it has '260 practical and 420 recreational programming languages, for a total of 681 languages'. Find out the only language which is neither practical nor recreational.
Side story: I forgot my headphones were on and connected so I went to turn them on only to hear "power off"
big brain time
Also, according to code golf statistics, only a small percentage of people who see my answers upvote them. So if you enjoying this answer, consider upvoting, it's free, and you can change your mind at any time (given you have ≥2k rep). Enjoy the answer.
Agreed. The Minecraft speedrunning community is awesome (such as dream on discord calls with other speedrunners wishing them good luck), and his other videos (manhunt, xray-always-on, etc.) are really, really fun to watch
Write a few lines of Python code, X, that does not reference any global variables, such that
def method():
X
print(a)
method()
prints 1 but
def method():
X
X
print(a)
method()
prints 2.
So, I hate to be a stickler, but it seems like vars and locals are actually glob...
It won't let me sort by closed, unfortunately. Votes are all I can base it on other than post date :/
Also, whoever spammed the starboard, please refrain from doing that in the future. One star per conversation is typically enough, and prevents it from covering up important or useful comments.
i'm not sure how i feel about these stars because the top half of my starboard is from the last half an hour and my screen's not that small, but it's not like they're meaningless messages or obviously bad stars.
i mean, the only thing starring does is place it on the starboard, so i star something if i think it's interesting/useful/important/funny and want it to go on the display section for other users to see. that's my personal usage
For a while now, most bounties on our site are rewards for existing answers. As a consequence, it's pretty hard to spot any bounty that would fall into the 'Draw attention' or 'Bonus / Side challenge' categories -- and we have to open each and every entry to figure it out. I've to admit that I pe...
The Knight's Dialer
Imagine you place a knight chess piece on a phone dial pad. This chess piece moves in an uppercase "L" shape: two steps horizontally followed by one vertically, or one step horizontally then two vertically:
+-+
|1| 2 3
+-+
`-------v
| +-+
4 | 5 |6|
...
The Great Code Golf Heist
Alternatively, the most literal cops'n'robbers you'll ever see
king-of-the-hillcops-and-robberspython
Backstory
Sandbox Note: This part will be specific to each thread, so I've provided each version
Robbers
For the last few years, you and your team of robbers have been p...
@HyperNeutrino Last I heard, he told all his viewers to vote for the glow squid in the recent mob vote thing, which turned out to be sh*t, so a bunch of people are mad at him because they wanted either yellow cow or ice man instead
A Portuguese sequence of numbers maths code-golf integer decision-problem
Context
Consider the following sequence of integers:
2, 10, 12, 16, 17, 18, 19, ...
Can you guess the next term? Well, it is 200. What about the next? It is 201... In case it hasn't become obvious to you, this is the sequen...
In mathematics an exclamation mark ! often means factorial and it comes after the argument.
In programming an exclamation mark ! often means negation and it comes before the argument.
For this challenge we'll only apply these operations to zero and one.
Factorial
0! = 1
1! = 1
Negation
!0 = 1
!1...
Given an input of a string consisting entirely of qs representing quarter
notes and es representing eighth notes, output the indices of the quarter
notes that are syncopated.
Syncopation is complex, but for
the purposes of this challenge, our definition of "syncopated" will be very
simple: a qua...
Figuring out whether a given number is prime, while not very complicated, is kind of hard. But making a guess doesn't need to be.
Seeing whether a number is a multiple of 2 or 5 is easy - you can just look at the last digit. Multiples of 3 isn't much harder, just add up the digits and see if you ...
Is there any challenge to "guess" which numbers fall into some set (like fibonacci or prime), and score based on a combination of code length and accuracy?
Most challenges like that have the accuracy as some kinda multiplier to code length, so the problem is that as soon as someone gets 100% accuracy, all they have to do is choose the golfiest language and they're unbeatable
What about scoring based on something like (bytes) * (1 + 1 / (accuracy))? That would be triple score for 50%, regular byte count for 100%, but something like 90% would still get close enough to regular byte count to be competitive sometimes
this reminds me of that, though it isn't scored on accuracy, it requires 100% accuracy, so I think the top answers try to guess and then hard-code the cases that fall through the filter.
But couldn't a 90% answer still be switched to a golfing language and potentially be even smaller? An 11% increase in score isn't insanely hard to work around if there's a clever way to mostly golf it
@RedwolfPrograms @Razetime and @cairdcoinheringaahing I just thought I would let you know that if you flag a post as "Not an answer" it doesn't actually go to the moderators it goes to the low quality post queue. If you want it to go to a moderator you should flag it with a custom flag explaining the issue. I generally think that with stuff that is bordering on spam this is the better option, but do what you want I guess. Going to the queues is better than not being flagged at all.
@WheatWizard Ah, I thought it did, but we were discussing this yesterday and I couldn't find anything in the FAQ on what happened with NAA flags. I'll make sure to remember that when dealing with NAA posts, thanks!
Oh you are right, you didn't flag it as naa. Maybe vlq also works the same way? Or maybe it got overridden by the naa? If you really want it to go to the moderators custom message is best, plus it makes it easier for us in general.
But again, do whatever, I'm just letting you know how you can use the tools not saying you should use them any way.
@Razetime Is it possible for you to correct this answer, rather than delete it? If it stays deleted, the next two answers in the chain will have to be deleted as well
Man, I forgot how stressful running an answer-chaining challenge can be when something goes wrong :/
Yeah, that's fine. Razetime's answer ^ is #12, which means that if it stays deleted, #13 and #14 will have to be deleted as well and the chain resets to #12
I think at one point during my last one (the OEIS one) we were about 150 answers in and someone pointed out that answer ~100 was invalid, at which point I went "screw it, just leave it"
I always want to try brute-forcing codegolf code. I've brutally golfed a digits-of-pi-in-powershell answer to get ~220 chars, and primo-ppcg has /quartered/ it at 57. It's unthinkable, you can't get bignums or good integer division or base conversion or fast loops with that little code, surely
how hard can it possibly be to try every 57 character valid powershell program
and that applies even moreso to APL and J answers for things at 10-15 characters
but given how big the search space is, easily 50^57 is it a wonder that (some) humans can hone in on code that works in such a short time?
every Pi-spigot on rosettacode.org/wiki/Pi is enormous except J, and that's because J has it as a builtin. Most of them seem to be ports of each other's Rabinowitz spigot or Machin(?)'s algorithm.
@Shaggy Well, given the language is restricted to GoL, you'd probably have to make a Japt interpreter in GoL, then write Tetris in Japt to "technically be a Japt answer" :P
@Shaggy "Drunk? It's only Tuesday!" he says, sipping a beer
@RedwolfPrograms Yeah, I can see that in the review history. When I refresh my review queues page, or check the review queues dropdown for the toolbar, it says that there's nothing to review (yet the edit is still pending). Weird
@rak1507 I have a 51 there (powershell) and primo has a 48. my method does not translate well into Python; is there a shorter loop than for i in range(foo):?
Seeing as ETH hasn't been seen in nearly 2 years, I've half a mind to celebrate by creating a new JS-based golfing lang. The other half of my mind, though, knows feck all about language design!