Given a UTF-16 string, test its endianness.
Rules:
As long as the input is in UTF-16 without BOM, its type doesn't matter. In C++ on Windows, it can be std::wstring or std::u16string. In Haskell, it can be [Int16] or [Word16].
The endianness is tested by noncharacters. If the input contains a ...
LOOP is a programming language designed by Uwe Schöning, along with GOTO and WHILE. The only operations supported in the language are assignment, addition and looping.
The key property of the LOOP language is that the functions it can compute are exactly the primitive recursive functions.
== Features ==
Each primitive recursive function is LOOP-computable and vice versa.In contrast to GOTO programs and WHILE programs, LOOP programs always terminate. Therefore, the set of functions computable by LOOP-programs is a proper subset of computable functions (and thus a subset of the computable by WHILE...
"What is the most complex language" oh boy, probably gonna be something suuuper complex "can compute the exact time complexity for any program" oh, probably something super simple.
I suspect it might be possible in a version of LOOP with only addition but no subtraction.
The issue with subtraction is that it's possible with have one variable of magnitude O(something big) and another variable with magnitude O(same big thing) but still have the difference between the variables be O(small).
Here's a paper where they talk some about forming an upper bound but that "The complexity problem for Ln is: given a program P in Ln determine whether Tp is bounded by f,_l (k) for any integer k. Theorem 6. For each n > 3, the complexity problem for Ln is effectively undecidable. "
The LOOP language can compute exactly the primitive recursive functions. (According to PPCG's slightly arbitrary rules, anything less powerful isn't considered much of a language at all.)
Well with the LOOP language, it's essentially a question of how does the count of basic operations (starting a loop iteration, an addition, or an assignment) scale as the input numbers to the program scale.
In any case, I think it suffices to require the language to be executable by a TM. Oracles can do them in constant time, yes, but that's not "executable by a TM".
@El'endiaStarman I'm not sure what you mean by this?
@PhiNotPi This certainly makes sense, but once we get to more abstract edge cases, for example making each computable function a basic operation, I feel like we need a concrete definition.
And since you don't care about multiplicative factors when determining time complexity, figuring out the time complexity boils down to... if I double some of the input variables, how many more times do the bodies of the innermost loops have to be run?
@SriotchilismO'Zaic Phi's question was "what is the most complex language with computable time complexity for all programs?" and it's easy to require that such a language must be possible to implement with a Turing machine. An Oracle explicitly can do more than a Turing machine, and so are disallowed. Even if you restrict what the Oracle can compute, it's still not implementable with a TM because the TM does not have a magical oracle to ask.
I don't know if we need to get this abstract? Unless we want to talk about computers that operate wildly differently than everyday computers, which I wasn't planning to get into. Because I think time complexity seems well-enough defined by saying addition/assignments are the basic unit operations.
Well if we do say time complexity is in terms of the equivalent Turing machine then there is no most complex model and my proof does work.
I think that we can show that the addition, subtraction, assignment definition of complexity is equivalent to the Turing machine definition.
The proof goes like this: Let us say that we have a model M which is the most complex model that can compute its own complexity. Let us take the set of functions computable by a Turing machine but not M (this must not be empty since it is weaker than a TM) and choose an arbitrary function from the list, f. Let us then make a new model M' which is identical to M except that it is augmented with a new atom which computes f.
This new model is more complex, since M could not compute f, but can still compute its own complexity, since the complexity of f is computable.
This is a contradiction since we started by saying M was the most powerful model that could compute its own time complexity and M' is more powerful, thus no most powerful language can exist.
21, 21, 23, 20, 5, 25, 31, 24, ?
Inspired by this Puzzle, given an integer \$n>0\$ , print out the following sequence until you reach a non-Integer (spoilered, in case you want to solve the puzzle yourself first)
TestCases:
Input and Output may be taken in any reasonable format, standard l...
Does anyone here know a simple GUI library for python? I want to do something that allows you to display images and draw on them - but I'm not familiar with building GUIs in python. I also considered doing the GUI in HTML/JS but again I have no experience with building a python webserver:)
well gimp is probably way to powerfull for what I need
I maybe should have specified: I really only need to draw one color (black/white) with the mouse, maybe adjust the radius of the "brush" or something like that, which wouldn't be too difficult to implement anyway
I was thinking of posing a fastest-code challenge around oeis.org/A161169 . But to make it more interesting I am dividing by the max possible and the code only has to output correct to three decimals places. Like this bpaste.net/show/Ygsg
@JohnDvorak sure! It just has to output the right answers up to 3 decimal places
I am wondering two things
a) what the output should be? I mean outputting all the values for k in range(int(n*(n-1)/2+1)) is quite a lot and b) if I should just give a score being the speed relative to the python code to make it easier for people to judge for themselves
I've not completely read through all the mess of the past week because I've been dealing with my own troubles closer to home (look up Indonesia parliament protests) and at time of writing I'm at work, but I want to thank Dennis deeply for his years of service, first and foremost, and thank the other mods for theirs and their continued support despite this shitstorm.
Second and thirdmost, the Discord server is open, if a bit dead, and the CGCC gaming Discord server is also open and less dead.
Fourthmost, I haven't seen all the discussion around Axtell and its hiatus but if there's any way I can help with development now that I have a more stable situation post-university, I'd love to help. I know we have unresolved issues with what this sort of community migration/reboot/backup would entail, but frankly now seems like a good time to start hashing out those issues and continuing to develop a "backup" plan
Compute A161169, approximately and quickly
Input: Two values n and k.
Output: T(n,k)/n! rounded to three decimal places. T(n,k) is defined by OEIS sequence A161169.
questions
For fastest-code, what should the input and output be?
@Adám thanks for your comment on my sandbox question. The thing I am not clear about is what the input and output should be exactly. I mean to be a fastest-code competition I think I need to say somethign like "the largest n,k you can reach in 10 seconds"
@Anush For fastest code questions, you need very detailed specifications on how the speed of the code will be measured. For example, if its on your machine, specs should be included (i.e see here)
This is essentially the inverse of Generate a US License Plate
Challenge: Given a string that matches one of the below license plate formats, output all possible states that match that formatting. In the below table 0 stands for a single digit 0 through 9 inclusive, and A stands for a single let...
@flawr and @ngn: TNBDE ostensibly has backups in the form of automated database dumps, but it should have every single non-deleted message, possibly excepting the previous one or two hours.
@El'endiaStarman no. i request a batch of many messages, starting from the current time backwards, i look at the earliest message in the batch, and request again using before: in the new query, and repeat
{"event_type":1,"time_stamp":1570015148,"content":"which reminds me, has anyone ever tried to back up tnb\u0026#39;s chat log?","user_id":136283,"user_name":"ngn","room_id":240,"message_id":51932959},
{"event_type":1,"time_stamp":1570008088,"content":"@flawr \u003ca href=\"https://en.wikipedia.org/wiki/GIMP\" rel=\"nofollow noopener noreferrer\"\u003egimp\u003c/a\u003e not good enough?","user_id":136283,"user_name":"ngn","room_id":240,"message_id":51931665,"parent_id":51931496,"message_edits":1,"show_parent":true},
i was a bit worried about flooding the server or getting banned, so i spaced the requests a few 10s of milliseconds apart, but that seems to have been unnecessary
Cool. I'm just trying to think of anything I have that you don't. Hmm...what about the Markdown contents? I.e. this message will have <em> or something similar in the content field. But the Markdown contents will have asterisks.
Eh, I most definitely got rate-limited when I was scraping the transcript. Granted, I was also fetching each message individually as well (for the timestamp).
Yeah. Making my scraper robust to SE rate-limiting and memory limits on the remote server I'm using was by far the hardest part. Probably took 3x as much time as everything else put together.
Fortunately, that robustness did pay off; I haven't had to touch TNBDE in literal years and it's still chugging along.
Reason I ask is that if we built a chat platform as well (which is itself a monumental task), then we could import TNB's chat history into that. And I'd want stars and up(/down?) votes on messages. Right now, stars get used for both "this is important" and "I agree with this".
....and for lulzy reasons, but let's not encourage those.
@El'endiaStarman I definitely agree with up/down votes on messages. There have been quite a few messages I've wanted to show my disagreement with without having to say anything
@DJMcMayhem A couple of my coworkers made a Slack bot that counts reactions and gives rewards to people that get enough/most of them. Need them to be non-anonymous for that. That said, I do think it'd probably also be good to have anonymous up/down votes or whatever (or agree/disagree, etc).
very off topic, but I'm teaching for a program at my college where high schoolers come to take classes on literally anything - does anyone have any suggestions for programming-related things that are cool but also accessible to a significant portion of high schoolers?
@Doorknob If you use a simple enough library, I'm sure some game dev would appeal to lots of them. Game dev is a great way to get introduced to programming since making shapes move on a screen is way more exciting than printing text
According to this meta post we can never recreate old challenges. Of course not, its a duplicate. Makes sense to me. No problems.
Except this challenge can no longer be answered with a language newer than the challenge, even though the requirement that "languages be newer than the challenge" is ...
CMC: given a list L and an integer n where 0 <= n < 2**len(L), return a list that has the first element if n & 1, the second element if n & 2, the third element if n & 4, and so on.
CMC: Given a list, return an all-zero list of same length, but with the positions of first occurrences of each unique element set to the count of that element. E.g. [3,1,4,1,5,9,2,6,5,3,5,8,9,7,9] → [2,2,1,0,3,3,1,1,0,0,0,1,0,1,0]
@Pavel We have Dyalog on Pi. The problem isn't the interpreter itself — it already runs on Android — we need an IDE that is suited for a small touchscreen.
@Pavel I'm with you. That's what I've been saying should be the first Dyalog APL for Android: a powerful calculator app. But then we have to deal with (multi-line) function editing, and what happens if a function hits an error etc.