14
1
I am too bored and want a challenge to solve. But I do not see any interesting challenges, and I am too lazy to search for one. Can you (Well, technically your code) suggest me one?
I/O
Input: None.
Output: A link to a random open(i.e. non-closed) challenge("Challenge" excludes tips!) on PPCG. You may not link to an answer in a challenge, Just a challenge. (I didn't ask for an interesting answer!)
Examples
Valid:
http://codegolf.stackexchange.com/questions/93288/make-me-a-mooncake
http://codegolf.stackexchange.com/questions/113796/raise-a-single-number
http://codegolf.stackexchange.com/questions/113898
Invalid:
http://codegolf.stackexchange.com/questions/78152/tips-for-golfing-in-matl (tips question)
http://codegolf.stackexchange.com/questions/113896/josephus-problem (closed)
http://codegolf.stackexchange.com/questions/84260/add-two-numbers/84365#84365 (linked to answer)
Can we output
http://codegolf.stackexchange.com/questions/93288/
instead ofhttp://codegolf.stackexchange.com/questions/93288/make-me-a-mooncake
(note the lack of challenge name). – user41805 – 2017-03-26T11:53:25.080@Kritixi Lithos Sure, that works. – Matthew Roh – 2017-03-26T11:54:23.647
Not all tips questions have the word "tips" in their name. See this one for example. Is that allowed or did you mean to remove challenges in the "tips" tag?
– seshoumara – 2017-03-26T12:11:44.580@seshoumara The latter, that's also the reason I typed 'tips' as a tag. – Matthew Roh – 2017-03-26T12:12:41.383
There are about 6k questions fulfilling your criteria on PPCG. Do all need to have a chance of being picked by random, or can I pick at random from the first 50 results I get from a search link? – seshoumara – 2017-03-26T12:21:49.020
@seshoumara the former option. – Matthew Roh – 2017-03-26T12:24:03.010
@SIGSEGV I believe there is no way to choose a random question from every open question asked. – Okx – 2017-03-27T09:31:15.457
@Okx Use your brain.. (Hint: every question and answer has an unique id) – Matthew Roh – 2017-03-27T09:32:51.383
Thanks. Also, can we only give [tag:code-golf] questions? The SE API needs either a tagged parameter or an intitle parameter. – Okx – 2017-03-27T09:34:40.050
@Okx Huh? I do not understand what you mean. I believe you can put newlines in code-golf too. – Matthew Roh – 2017-03-27T09:37:27.347
@SIGSEGV I mean questions with the tag [tag:code-golf] – Okx – 2017-03-27T09:38:00.670
@Okx you could generate the post id first, then see if it's valid. That way your problem is solved. – Matthew Roh – 2017-03-27T09:39:35.100
Let us continue this discussion in chat.
– Okx – 2017-03-27T09:40:56.137I am going to answer with SEDE! – Christopher – 2017-03-27T15:53:39.357
@DownChristopher Sure, Why not! – Matthew Roh – 2017-03-27T15:57:18.760
Actually one problem is it won't be a url but a id for the question. Would that be invalid? (I think so) – Christopher – 2017-03-27T15:58:57.230