Since this is an era when many people are concerned about ‘fairness’ and ‘social justice,’ what is your ‘fair share’ of what someone else has worked for?

— Thomas Sowell

Commercials That Don’t Fit the NFL Audience

 
Verizon ad

These Verizon and Sprint commercials I see on NFL telecasts, where beta male milquetoasts dispense advice on cell phones, seem misdirected toward what I imagine to be the pro football-watching demographic.

Also off target: the Dove for Men commercials where metrosexuals meet up to lament the demoisturizing effects of their skin care products.

Profanity in Book Titles

 

Powell’s Books emailed a list of self-care titles aimed at making readers happier and healthier and saner.

A surprisingly high (to me) percentage of the titles — 3 out of 25 (12 percent) — contain the word “fuck.” One title includes the word “shit” but it’s also one of the titles that uses “fuck” so I’m not going to double-count it.

Is this a new publishing industry strategy to reawaken people’s interest in reading? Personally I don’t care for it . . .

Competitive Programming: TopCoder – Marketing

 

[Link to problem]

Problem Statement

You work for a very large company that markets many different products. In some cases, one product you market competes with another. To help deal with this situation you have split the intended consumers into two groups, namely Adults and Teenagers. If your company markets 2 products that compete with each other, selling one to Adults and the other to Teenagers will help maximize profits. Given a list of the products that compete with each other, you are going to determine whether all can be marketed such that no pair of competing products are both sold to Teenagers or both sold to Adults. If such an arrangement is not feasible your method will return -1. Otherwise, it should return the number of possible ways of marketing all of the products.

The products will be given in a compete whose kth element describes product k. The kth element will be a single-space delimited list of integers. These integers will refer to the products that the kth product competes with. For example:

compete = {"1 4",
            "2",
            "3",
            "0",
	    ""}

The example above shows product 0 competes with 1 and 4, product 1 competes with 2, product 2 competes with 3, and product 3 competes with 0. Note, competition is symmetric so product 1 competing with product 2 means product 2 competes with product 1 as well.

Ways to market:

  1. 0 to Teenagers, 1 to Adults, 2 to Teenagers, 3 to Adults, and 4 to Adults
  2. 0 to Adults, 1 to Teenagers, 2 to Adults, 3 to Teenagers, and 4 to Teenagers

Your method would return 2.

Definition

Class: Marketing

Method: howMany

Parameters: String[]

Returns: long

Method signature: long howMany(String[] compete)

Constraints

  • compete will contain between 1 and 30 elements, inclusive.
  • Each element of compete will have between 0 and 50 characters, inclusive.
  • Each element of compete will be a single space delimited sequence of integers such that:
    • All of the integers are unique.
    • Each integer contains no extra leading zeros.
    • Each integer is between 0 and k-1 inclusive where k is the number of elements in compete.
  • No element of compete contains leading or trailing whitespace.
  • Element i of compete will not contain the value i.
  • If i occurs in the jth element of compete, j will not occur in the ith element of compete.

Examples

{"1 4","2","3","0",""}
Returns: 2
The example from above
{"1","2","0"}
Returns: -1
Product 0 cannot be marketed with product 1 or 2. Product 1 cannot be marketed with product 2.
There is no way to achieve a viable marketing scheme.
{"1","2","3","0","0 5","1"}
Returns: 2
{"","","","","","","","","","", "","","","","","","","","","", "","","","","","","","","",""}
Returns: 1073741824
{"1","2","3","0","5","6","4"}
Returns: -1

Solution below . . .

Read more

2018: The Year in Books

 

These are the books I read in 2018, roughly in the order listed. The ratings are mine. They don’t represent a consensus of opinion.

Books of the Year: Middlemarch by George Eliot (fiction), Lincoln in the Bardo by George Sanders (contemporary fiction) and Factfulness: Ten Reasons We’re Wrong About the World–and Why Things Are Better Than You Think by Hans Rosling (non-fiction).

How Our Careers Affect Our Children

 

Mothers spending time on themselves — on relaxation and self-care — and not so much on housework, was associated with positive outcomes for children. It’s not just a matter of mothers being at home versus at work, it’s what they do when they’re at home with their non-work time. If mothers were not with their children so they could take care of themselves, there was no ill effect on their children.  But to the extent that mothers were engaged in housework, children were more likely to be beset by behavior problems.

— “How Our Careers Affect Our Children”, Harvard Business Review

We’re studying the effects of working mothers, mothers spending time on themselves, mothers engaged in housework . . . I wonder what is the effect of mothers actually spending time with their children?

Competitive Programming: UVa 612 – DNA Sorting

 

[Link to problem]

One measure of “unsortedness” in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequence DAABEC, this measure is 5, since D is greater than four letters to its right and E is greater than one letter to its right. This measure is called the number of inversions in the sequence. The sequence AACEDGG has only one inversion (E and D) — it is nearly sorted — while the sequence ZWQM has 6 inversions (it is as unsorted as can be — exactly the reverse of sorted).

You are responsible for cataloging a sequence of DNA strings (sequences containing only the four letters A, C, G, and T). However, you want to catalog them, not in alphabetical order, but rather in order of “sortedness,” from “most sorted” to “least sorted.” All the strings are of the same length.

Input

The first line of the input is an integer M, then a blank line followed by M datasets. There is a blank line between datasets.

The first line of each dataset contains two integers: a positive integer n (0 < n <= 50) giving the length of the strings; and a positive integer m (0 < m <= 100) giving the number of strings. These are followed by m lines, each containing a string of length n.

Output

For each dataset, output the list of input strings, arranged from “most sorted” to “least sorted.” If two or more strings are equally sorted, list them in the same order they are in the input file.

Print a blank line between consecutive test cases.

Time limit: 3.000 seconds

Sample Input

1
10 6
AACATGAAGG
TTTTGGCCAA
TTTGGCCAAA
GATCAGATTT
CCCGGGGGGA
ATCGATGCAT

Sample Output

CCCGGGGGGA
AACATGAAGG
GATCAGATTT
ATCGATGCAT
TTTTGGCCAA
TTTGGCCAAA

Solution below . . .

Read more

Student Loan Debt Sets Record

 

U.S. Student Loan Debt Sets Record, Doubling Since Recession — Bloomberg

What happened to parents saving up to pay for college? Is that not a thing anymore?

I don’t find it morally defensible to encourage a kid to incorporate academics into his or her life from an early age, to emphasize the importance of education, then when the kid is admitted to college to say “Congratulations, here’s your student loan application. Have fun paying that off till you’re 60.”

More Christmas Songs That Should Be Banned

 
Perry Como Christmas Album

A pair of hop-a-long boots and a pistol that shoots
Is the wish of Barney and Ben
Dolls that’ll talk and will go for a walk
Is the hope of Janice and Jen

— “It’s Beginning to Look a Lot Like Christmas”

Baby dolls for little girls and guns for little boys?! Continuing to segregate and advertise toys based on gender just works to perpetuate nasty sexist stereotypes, plus it severely limits the development of all young people.

Be sure to engage in a conversation about sexism with your friends and families over the holidays!

Sailing to Byzantium

 

That is no country for old men. The young
In one another’s arms, birds in the trees
– Those dying generations – at their song,
The salmon-falls, the mackerel-crowded seas,
Fish, flesh, or fowl, commend all summer long
Whatever is begotten, born, and dies.
Caught in that sensual music all neglect
Monuments of unageing intellect.

An aged man is but a paltry thing,
A tattered coat upon a stick, unless
Soul clap its hands and sing, and louder sing
For every tatter in its mortal dress,
Nor is there singing school but studying
Monuments of its own magnificence;
And therefore I have sailed the seas and come
To the holy city of Byzantium.

O sages standing in God’s holy fire
As in the gold mosaic of a wall,
Come from the holy fire, perne in a gyre,
And be the singing-masters of my soul.
Consume my heart away; sick with desire
And fastened to a dying animal
It knows not what it is; and gather me
Into the artifice of eternity.

Once out of nature I shall never take
My bodily form from any natural thing,
But such a form as Grecian goldsmiths make
Of hammered gold and gold enamelling
To keep a drowsy Emperor awake;
Or set upon a golden bough to sing
To lords and ladies of Byzantium
Of what is past, or passing, or to come.

— William Butler Yeats, “Sailing to Byzantium”

The Time for Song and Frivolity is Over!

 
Carolers

A colleague went to see his son’s Christmas pageant, a day care thing where the kids try to sing “Jingle Bells.” 

He says once his older daughter got to kindergarten, the school didn’t do singing Christmas shows anymore . . .

THIS IS KINDERGARTEN! THE TIME FOR SONG AND FRIVOLITY IS OVER! DO YOU HEAR YOUR PARENTS GOING AROUND SINGING ALL THE TIME? THAT’S WHAT GROWING UP IS ALL ABOUT! ALL JOYOUS ACTIVITIES ARE SURRENDERED OR STRIPPED AWAY FROM YOU!

Are You Sure?

 
Are you sure?

I was closing out of Remote Desktop Connection Manager and got the popup shown here.

Am I sure? To the extent that we can really be sure about anything, then yes I’m sure.

Why is the No option selected as the default? Is there an assumption that I’m flying by the seat of my pants, acting randomly and without certitude? 

That I’m not a confident person? That I lack the courage of my convictions?

See You in Hell

 

Satan

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

Many are outraged that President Trump didn’t recite the Apostle’s Creed at the Bush funeral.

Most of the outraged wouldn’t know the Apostle’s Creed from Apollo Creed. But they’re outraged because they were told that they should be.

See you in Hell!

Teaching Computer Science: What is a Computer Science Integration Specialist?

 

Sheena Vaidyanathan, a computer science integration specialist at Los Altos School District in California, says that states, school districts and boards of education have not prioritized computer science education the way they should. Even if not every child will grow up to work as a computer scientist, she thinks everyone should at least get exposure to how computers work.

A couple of things I don’t understand there . . . one is why everyone needs to know “how computers work.” They work on electricity, that’s about all I know about it.

Actually, I know a little more than that, but there’s no reason that everyone should know “how computers work,” any more than everyone should know how phones work, or how cars work, or how refrigerators work.

You can use things without knowing how they work.

I do think everyone can benefit from understanding how programmers think, which is based in part on knowing how computers work, but if you know that computers do exactly what you tell them to do — no more and no less — that’s about all you need to know.

The other thing I don’t understand is what is a “computer science integration specialist”? I had to look up a job description:

  • Consult with each school leader or their designees to gather information about program needs, objectives, functions, features, and data metric requirements. Research need and create plans for computer science/technical personnel and other resources required for implementations for each school.
  • Analyze, define, and document all relevant requirements for the teaching and learning of computer science, including but not limited to the impact on courses of study, streams of data and data capture, logical processes, computer lab or other learning environment requirements. Write and maintain specifications and document relevant workflows.
  • Perform (department management approved) intervention(s) on the identified gaps by implementing existing or developing new appropriate interventions or programs to help create cultures or conditions of success in which computer science programs can flourish.

It goes on and on like that, but after reading the whole thing, I find myself no wiser as to how a person in this role is helping students learn computer science.

Money is available for this but not for hiring teachers with actual computer science education or experience?

Thus spoke The Programmer.