Here's a #toyprogrammingchallenge requiring a bit of algebra.
For any four non-collinear points A, B, C, and D in three-dimensional space, there is a unique hyperbolic paraboloid H containing the lines AB, BC, CD, and AD (that is, every point on any of these lines is also on the surface of H). Write a program that accepts Cartesian coordinate triplets representing A, B, C, and D and prints an equation in x, y, and z that is satisfied if and only if <x, y, z> is a point on H.
Your program's output may differ from the examples but should be optimised for human readability. Combine like terms, omit terms equal to zero and avoid unnecessary factors (e.g. prefer "x = y" to "2x + 0 = 4y - 2y" even though both describe the same surface).
Example 1 input:
<0, 1, -1>; <1, 0, 1>; <0, -1, -1>; <-1, 0, 1>
Example 1 output:
z = x² - y²
Example 2 input:
<1, 1, 1>; <1, 0, -1>; <-1, 1, -1>; <-1, 0, 1>
Example 2 output:
2y = xz + 1
Example 3 input:
<0, 1, 1>; <0, 1, -1>; <0, -1, -1>; <0, -1, 1>
Example 3 output:
x = 0
I see in Mastodon's API there is a call to dismiss a specific notification. Is there a way to do this from the web frontend?
Electoral math, CW for length (3108 characters hidden)
Canada just had a parliamentary election yesterday. Seat breakdown is as follows, per the CBC:
Bloc Quebecois 32
New Democrat 24
There will almost certainly be a minority government, led by the centre-left Liberals and supported by one or more of the further-left Bloc, NDP, and Greens.
The Liberal party achieved this result despite winning zero seats in the less populous western provinces outside of the Vancouver and Winnipeg metropolitan areas, and I'm starting to see people repeat the claim that a US-style electoral college would stop city voters from "ruling over" rural voters. I'm skeptical of this argument when Americans cite it as a Divine wisdom encapsulated in the Constitution, so I got the preliminary data from Elections Canada and simulated an electoral college.
First, I supposed each province and territory had a number of electors equal to the number of seats it currently gets in the House of Commons, and awarded all its electors to the winner of the popular vote within its boundaries (the Liberals came away with NL, PE, NS, NB, QC, ON, YT, and NT, while the Conservatives prevailed in MB, SK, AB, and BC; the New Democrats won only NU). The seat totals end up as follows:
New Democrat 1
Essentially, what happens is that the Liberals get a massive boost from narrow wins in very populous provinces, while the Conservatives already own most of the seats in the western provinces, so coming away with *all* of them doesn't come close to balancing things out. The Bloc came a close second in Quebec but end up with nothing to show for it and the NDP's scattered support doesn't pay off.
Canada, however, has a complicated formula for allocating seats to each province, which no longer matches up well with population distribution because some regions have grown faster than others. So I simulated it again with US-style rules where electors are distributed among provinces according to current population, while territories get zero (Canada doesn't have elected senators, so I set each province's minimum at one elector rather than three as in the States). Turns out not to make a big difference:
This masks some interesting stuff going on behind the scenes - Atlantic Canada is overrepresented, losing eleven electors across four provinces, while Ontario is underrepresented and picks up ten when this is corrected. Because these are all Liberal victories anyway, the net effect is only a loss of one (the other two correspond to the territories no longer being eligible for electors, which are mainly redistributed to western provinces).
This should be evidence against the idea that importing electoral features from the US will make Canada's political landscape more like that of America. Using either scheme, allocating a whole province at a time really changes things, but not in a way that helps strengthen rural Canada's voice. Every other party loses seats to the Liberals, which pushes them from a minority government to a very lopsided majority.
Here is a #toyprogrammingchallenge which corresponds to the general case of a problem I ran up against recently.
Given a positive integer K and a directed graph G with weighted edges, return a new graph H satisfying all the following conditions, if such a graph exists:
1. G and H contain exactly the same set of vertices.
2. H contains only edges in G, but G may contain edges not in H.
3. A path exists in H of length at most K between each pair of vertices in each direction.
4. No edge can be removed from H while still satisfying condition 3.
Where more than one graph exists satsifying these conditions, return the one with the least total weight. You may assume G does not contain edges with negative weights.
Here is an example G, each triplet representing the <start, end, weight> of an edge:
<1, 2, 40>
<1, 3, 12>
<1, 4, 50>
<2, 1, 84>
<2, 3, 19>
<2, 4, 69>
<3, 1, 25>
<3, 2, 78>
<3, 4, 93>
<4, 1, 75>
<4, 2, 36>
<4, 3, 96>
Your program should produce the following H given the above G and K = 2:
<1, 2, 40>
<1, 4, 50>
<2, 1, 84>
<2, 3, 19>
<3, 1, 25>
<4, 2, 36>
@freemo there are two people who i used to follow, who aren't being followed by me any more, who still follow me, and who haven't blocked me.
when i visit their profile from within our instance i'm given the option to cancel a follow request??
Freedom of speech and the Web. Rest CW'd for length (4850 chars hidden)
About two days ago, @freemo made a well-considered proposal to create a collective among Fediverse instances, for the purpose of enforcing respect for one another's freedom of speech. It doesn't quite line up with my idea of free speech, however, and I decided to publish my thoughts on the matter to solicit feedback. Just as "your right to swing your arm leaves off where my right not to have my nose struck begins," so too one person's right to speak leaves off where another's right not to repeat his words begins.
When you access a webpage, your browser sends a request to the server on which that website is hosted. In the simplest case, this request is essentially a formalised way of saying, "Hey, [server], please send me [page]." If things go according to plan, the server responds with the named page. You can set this up yourself: type up some text, share it using a tool like SimpleHTTPServer, and load it in a browser.
But you don't, strictly speaking, *need* to run a server to send the content in response to client requests. You could, for instance, run netcat listening on an appropriate port, and manually type in whatever you wanted as the content of the webpage. Of course, this would get very tedious if you had to type it in more than once or twice, but it does cause the browser to display the content.
It should be evident that typing the response directly back to the listener is an instance of speech, the same way it is to answer a question on the telephone or by a printed letter. In this case, it's very clear who the speaker is - if the reply is based on information obtained from a third party, or even if it's a direct quote of a third party, the role of speaker still remains with the person actually making the reply by typing it up, by speaking it into the handset, or by putting pen to paper.
Note that the freedom of speech allows one person to decline to quote another as well. If Alice asks Bob, "What did Carol say about me?" that freedom allows him to say, "It doesn't bear repeating," or even lie and say, "Nothing at all." It is not a violation of Carol's freedom of speech for Bob to do so, even if Bob knows full well what Carol said about Alice, even if Carol made her remarks directly to Bob, and even if Carol wanted Bob to pass the remarks on to Alice.
Let's return to the idea of manually typing out your HTTP responses. Suppose, for instance, you have a comment section on the page you want to show the user - why would you be obliged to type out a given comment, simply because the commenter wants you to pass it on to your site's visitor? Clearly, as you're the speaker, your freedom of speech is still in operation as in the above scenario, and it protects your decision to decline to do so.
Consider an old-fashioned printing press, which works by pressing an inked design against a sheet of paper. When that paper is retrieved from the machine, it may have some words on it - but the printing press itself is not the speaker of those words. It is the operator of the press - who carved the design, or constructed it from movable type or some other means - who is responsible for their content. The press itself is merely a tool that enables him to produce many copies of the same words more rapidly than he could by handwriting them repeatedly.
Likewise, a webserver is just a tool that saves the site owner from having to repeatedly type the same response to each HTTP request he gets. This is just a program running on a machine somewhere, which itself doesn't have the degree of autonomy necessary to enjoy freedom of speech. The program's speech cannot be "free" in any meaningful sense, because it is completely controlled by the person with the capability to determine how it works, whether by altering the program itself or by modifying the content files it sends.
This is how federation works among Mastodon and related technology. Each instance is normally responsible for passing along the content produced by others, but silencing, suspending, and banning allow the operator of each website to specify policies under which his machine should not repeat that content. This control makes the operator the speaker to whom freedom of speech applies, even though he neither authored the content nor manually transmitted it to the client. His free speech rights, far from compelling him to never use these tools, are in fact what allows him to exercise his discretion to do so.
Although they use tools to distribute content more efficiently, the human operators remain the speakers, and it is to them that the freedom of speech applies. Machines themselves don't have such a freedom protecting them from our decisions to modify the content they emit, and if others offer comments, it is no infringement of their freedom when we decline to repeat their words.
As we make clear in out ToS we dont block other instances but we DO censor. We believe in free speech in the sense that you wont get blocked for simply holding an unpopular opinion. But anyone who attacks others, insults them, or acts aggressive towards others are, and have been banned. We do NOT tolerate racism.
As others have pointed out, none of our users are hateful or racist. On the few cases that happened it resulted in a ban.
I generally suggest people ban instances based on what they do or do not tolerate from their users, rather than some ideological response to some key words in a description.
If anyone in this thread actually knows of an example of any user on QOTO not living up to what I described please let me know, we will take care of them.
QOTO: Question Others to Teach Ourselves. A STEM-oriented instance.
No hate, No censorship. Be kind, be respectful
We federate with all servers: we don't block any servers.