Alfie Evans, 2016-2018

 

Thank god this could never happen here in the US . . . at least until Bernie Sanders is inaugurated.

RIP Alfie Evans

Generic LinkedIn Recommendation

 

LinkedIn icon

Feel free to use it:

When you meet him, he will act upon you, whether you know it or not.

What he says or does may seem inconsistent or even incomprehensible to you. But it has its meaning. He does not live entirely in your world.

His intuition is that of the rightly guided, and he always works in accordance with the Right Way.

He may discomfit you. That will be intended and necessary.

He may seem to return good for evil, or evil for good. But what he is really doing is known only to the Few.

You may hear that some men oppose him. You will find that few men really do.

He is modest and allows you to find out what you have to find out slowly.

When you first meet him, he may seem to be very different from you. He is not. He may seem to be very much like you. He is not.

See You in Hell

 
Satan

[See You in Hell is a feature by our guest blogger, Satan — PE]

A woman was sucked out the window of a Southwest Airlines plane . . . not a black woman, fortunately, so Southwest won’t have to shut down for racial bias training.

In other news, David Hogg is telling his Twitter followers to boycott the BlackRock and Vanguard investment firms.

“David Hogg’s Twitter followers” . . . might be a good name for an improv group.

See you in Hell!

Competitive Programming: POJ 1426 – Find The Multiple

 

Description

Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corresponding m containing no more than 100 decimal digits.

Input

The input file may contain multiple test cases. Each line contains a value of n (1 <= n <= 200). A line containing a zero terminates the input.

Output

For each value of n in the input print a line containing the corresponding value of m. The decimal representation of m must not contain more than 100 digits. If there are multiple solutions for a given value of n, any one of them is acceptable.

Sample Input

2
6
19
0

Sample Output

10
100100100100100100
111111111111111111

Link to problem

Solution below . . .

Read more

Passenger Sucked Out of Plane Window: Another Reason I Prefer to Just Stay Home

 

Southwest passenger died after broken plane window nearly sucked her outCNN

You are now free to move about the country!

Thanks, but I’d prefer to move about the country from inside the plane . . .

Competitive Programming: POJ 2084 – Game of Connections

 

Description

This is a small but ancient game. You are supposed to write down the numbers 1, 2, 3, . . . , 2n – 1, 2n consecutively in clockwise order on the ground to form a circle, and then, to draw some straight line segments to connect them into number pairs. Every number must be connected to exactly one another. And, no two segments are allowed to intersect.

It’s still a simple game, isn’t it? But after you’ve written down the 2n numbers, can you tell me in how many different ways can you connect the numbers into pairs? Life is harder, right?

Input

Each line of the input file will be a single positive number n, except the last line, which is a number -1. You may assume that 1 <= n <= 100.

Output

For each n, print in a single line the number of ways to connect the 2n numbers into pairs.

Sample Input

2
3
-1

Sample Output

2
5

Link to problem

Solution below . . .

Read more

Competitive Programming: USACO Big Barn

 

Farmer John wants to place a big square barn on his square farm. He hates to cut down trees on his farm and wants to find a location for his barn that enables him to build it only on land that is already clear of trees. For our purposes, his land is divided into N x N parcels. The input contains a list of parcels that contain trees. Your job is to determine and report the largest possible square barn that can be placed on his land without having to clear away trees. The barn sides must be parallel to the horizontal or vertical axis.

EXAMPLE

Consider the following grid of Farmer John’s land where ‘.’ represents a parcel with no trees and ‘#’ represents a parcel with trees:

          1 2 3 4 5 6 7 8
        1 . . . . . . . .
        2 . # . . . # . .
        3 . . . . . . . .
        4 . . . . . . . .
        5 . . . . . . . .
        6 . . # . . . . .
        7 . . . . . . . .
        8 . . . . . . . .

The largest barn is 5 x 5 and can be placed in either of two locations in the lower right part of the grid.

PROGRAM NAME: bigbrn

INPUT FORMAT

Line 1: Two integers: N (1 <= N <= 1000), the number of parcels on a side, and T (1 <= T <= 10,000) the number of parcels with trees
Lines 2..T+1: Two integers (1 <= each integer <= N), the row and column of a tree parcel

SAMPLE INPUT (file bigbrn.in)

8 3
2 2
2 6
6 3

OUTPUT FORMAT

The output file should consist of exactly one line, the maximum side length of John’s barn.

SAMPLE OUTPUT (file bigbrn.out)

5

Solution below . . .

Read more

Competitive Programming: POJ 1654 – Area

 

Description

Consider an infinite full binary search tree (see the figure below), the numbers in the nodes are 1, 2, 3, …. In a subtree whose root node is X, we can get the minimum number in this subtree by repeating going down the left node until the last level, and we can also find the maximum number by going down the right node. Now you are given some queries as “What are the minimum and maximum numbers in the subtree whose root node is X?” Please try to find answers for the queries.

BST

Input

In the input, the first line contains an integer N, which represents the number of queries. In the next N lines, each contains a number representing a subtree with root number X (1 <= X <= 231 – 1).

Output

There are N lines in total, the i-th of which contains the answer for the i-th query.

Sample Input

2
8
10

Sample Output

1 15
9 11

Link to problem

import java.util.Scanner;

/*
There's a pattern with the lowest-order set bit of the numbers:
  - For leaf-node numbers, the lowest order set bit is 1.
  - Go up one level and the lowest order set bit is 2.
  - Go up one more level and the lowest order set bit is 4.
  - Etc.

That said, we can take advantage of Bit Hack #7 from 
http://www.catonmat.net/blog/low-level-bit-hacks-you-absolutely-must-know/
to isolate the lowest-order set bit.

Each node will have one less than that number of nodes in each subtree.
 */

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		while (N-- > 0) {
			int x = sc.nextInt();
			int diff = (x & (-x)) -1;
			System.out.println((x - diff) + " " + (x + diff));
		}

		sc.close();
	}
}

You Will Know Whether it Has All Been True

 

How does a life flash before one’s eyes
At the end? How is there time for so much time?
You pick up the book and hold it, knowing
Long since the failed romance, the strained
Marriage, the messenger, the mistake,
Knowing it all at once, as if looking through
A lighted dormer on the dark crest of a barn.
You know who is inside, and who has always been
At the other edge of the wood. She is waiting
For no one in particular. It could be you.
If you can discover which tree she has become,
You will know whether it has all been true.

— J.D. McClatchy, “Wolf’s Trees”

Diversity in Tech Efforts Self-Defeating?

 
Inclusion in Tech summit
Tash Wilder, Mimi Fox Melton, Damien Hooper-Campbell, and Tracy Chou [left to right] at The Atlantic’s Inclusion in Tech summit. (Photo: Tekla S. Perry)

Panelists at the Inclusion in Tech summit lamented that we can’t tell if tech is doing better on diversity because the data stinks.

My advice would be don’t worry about it. A lot of the noise around diversity in technology is self-defeating. If you’re a member of an underrepresented group, all you hear is that technology fields are hostile and awful and unwelcoming, you won’t be treated fairly, etc.

And you wonder why certain groups are underrepresented? You’ve answered your own question. Why would anyone who wants to have a happy life pursue a career beset by unfairness and hardship? Why not instead be a meeting planner or a flight attendant?

Asians are overrepresented in technology jobs but that’s a relatively recent development in the history of these fields. I don’t remember, when this transition from underrepresented to overrepresented was happening, hearing a lot about how technology fields were hostile to Asians. I don’t remember conferences being convened for the express purpose of complaining about the unfairness of it all.

Maybe it was happening and I just missed it, but either way, there’s a model for going from underrepresented to fairly represented or even overrepresented, and the model is accept the reality of your starting point, don’t complain, don’t get discouraged by listening to other people complain, do the work you need to do to accomplish what you want to accomplish.

Thus spoke The Programmer.

Competitive Programming: POJ 2242 – The Circumference of the Circle

 

Description

To calculate the circumference of a circle seems to be an easy task – provided you know its diameter. But what if you don’t?

You are given the cartesian coordinates of three non-collinear points in the plane.
Your job is to calculate the circumference of the unique circle that intersects all three points.

Input

The input will contain one or more test cases. Each test case consists of one line containing six real numbers x1,y1,x2,y2,x3,y3, representing the coordinates of the three points. The diameter of the circle determined by the three points will never exceed a million. Input is terminated by end of file.

Output

For each test case, print one line containing one real number telling the circumference of the circle determined by the three points. The circumference is to be printed accurately rounded to two decimals. The value of pi is approximately 3.141592653589793.

Sample Input

0.0 -0.5 0.5 0.0 0.0 0.5
0.0 0.0 0.0 1.0 1.0 1.0
5.0 5.0 5.0 7.0 4.0 6.0
0.0 0.0 -1.0 7.0 7.0 7.0
50.0 50.0 50.0 70.0 40.0 60.0
0.0 0.0 10.0 0.0 20.0 1.0
0.0 -500000.0 500000.0 0.0 0.0 500000.0

Sample Output

3.14
4.44
6.28
31.42
62.83
632.24
3141592.65

Link to problem

Solution below . . .

Read more

The More We Rely on Technology . . .

 

No Internet Today

We had a brief network outage at the office, during which Mr. Frick walked over to Mr. Frack’s desk and said, “The network’s down. We can’t do the screen share,” i.e., they can’t see each other’s computer screen over the network because it’s down.

I was waiting for one of them — Frick or Frack — to say “Let’s just sit together in front of the one computer here like they used to in olden days” but neither of them ever did . . .

Foot of Pride

 

Billy Sunday

Yeah, from the stage they’ll be tryin’ to get water outta rocks
A whore will pass the hat, collect a hundred grand and say thanks
They like to take all this money from sin, build big universities to study in
Sing “Amazing Grace” all the way to the Swiss banks

Well, there ain’t no goin’ back when your foot of pride come down
Ain’t no goin’ back

— Bob Dylan, “Foot of Pride”