I Am Not Proud
on 01.02.16
Occasionally I'll do a CodeWars problem, and one thing I like about the site is that it'll show you everyone else's answer after you've successfully complete a problem, and you can learn some cool tricks that way. But you have to swallow your pride first. Here's the problem:
The examples below show you how to write function accum:
Examples:
accum("abcd") --> "A-Bb-Ccc-Dddd"
accum("RqaEzty") --> "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"
accum("cwAt") --> "C-Ww-Aaa-Tttt"
The parameter of accum is a string which includes only letters from a..z and A..Z.
Feel free to try it in your preferred language. I did it in Javascript.
I kept searching for an elegant mathematical solution to capitalizing only the first letter of each fragment, but my math sucks and finally I said fuck it, I just want to see other answers, so I kludged it. (And of course the formatting gets screwed up here.)
function accum(s) {
var wordArray = []
s = s.toLowerCase()
for (var i = 0; i < s.length; i++){
for (var j = 0; j < i+1; j++){
wordArray.push(s[i])
}
if (i < s.length-1)
wordArray.push('-')
}
wordArray[0] = wordArray[0].toUpperCase()
for (var k = 0; k < wordArray.length-1; k++){
if(wordArray[k] === '-'){
wordArray[k+1] = wordArray[k+1].toUpperCase()
}
}
return wordArray.join('')
}
And here's the most popular answer.
function accum(s) {
return s.split('').map((x,index) => x.toUpperCase()+Array(index+1).join(x.toLowerCase())).join('-');
}
Very clever, asshole.
Secret Shame
on 01.01.16
College-educated Republicans are embarrassed to admit they heart Trump:
The experiment confirmed that "voters are about six points more likely to support Trump when they're taking the poll online then when they're talking to a live interviewer," said Dropp.
The most telling part of the experiment, however, was that not all types of people responded the same way. Among blue-collar Republicans, who have formed the core of Trump's support, the polls were about the same regardless of method. But among college-educated Republicans, a significant difference appeared, with Trump scoring 9 points better in the online poll.
The most likely explanation for that education gap, Dropp and his colleagues believe, is a well-known problem known as social-desirability bias -- the tendency of people to not want to confess unpopular views to a pollster.
At least they learned something in college (that you will be judged harshly for certain views).
If Unfogged Were A Person, It Would Be Going Through Puberty
on 12.31.15
My older kid is an early January baby, so each new year also brings a birthday, and we now have a more concrete sense of change and passing time. The great child psychologist and sports columnist Bill Simmons somewhere noted how around the age of five kids' stories start to make sense and you can begin interacting with them more like real people. As my son is about to turn five, that seems to be holding up, although for him it's not stories, but eye-rolling sarcasm. They spent a day at my mom's, where they know I've directed their screen time to be limited, and when I picked them up I asked, "What did you guys do today?"
"Watched movies all day."
Little bastard. Couldn't be more proud.
In a couple of weeks, I'm starting a "coding bootcamp," which will run for three months, so I'll be somewhere between scarce and entirely absent. A happy new year, with health and glad tidings, to all.
It's the end of the year*
on 12.31.15
I went hunting for predictions from last year. I found this prediction from 2010 about the year 2015, this and this call from Ogged for a master-prediction website to aggregate and track the success of predictions, and Drum's predictions from last year.
Or, I was debating a resolutions thread. I did a great job on my 2014 resolution, which was to meticulously document the fluoride fight in Heebieville. The pro-cavity side won.
*I didn't really want to tack on (as we know it) to the title, but it's probably so ingrained in the cultural gestalt that you'll be earwormed anyway.
Diversions
on 12.30.15
On a lighter note, some iOS games I've been enjoying lately.
--Table Tennis Touch. Superb graphics, good gameplay (starts easy, gets pretty hard, but can be beaten with some obsessiveness). The multiplayer is a lot of fun, but there aren't nearly enough players.
--Rop. A spatial puzzle game. Match a pattern by pinning a rope to particular nodes. A calm, meditative sort of affair. (Also for Android.)
--Blek. A different spatial puzzle game. Can I describe the gameplay in a sentence? Drag your finger to create a line that will repeat itself and move in the direction of your creating, with the goal of touching points on the screen. Either more or less fun because you have to solve the mental puzzle and create the line properly.
CPD
on 12.30.15
On being detained by the Chicago Police Department:
Fortunately -- no thanks to CPD -- nobody got shot. It eventually took more than 10 individual cops on the scene to determine that I was in fact just minding my own business. Meanwhile (naturally) spectators were gathering on the riverwalk and above from the walkway. If you ever find yourself in this situation, this is the part where you see people taking pictures with their phones, and imagine your face on Reddit.
Once they were convinced I wasn't a "terrorist," (his word, not mine) the cop who cuffed me said they had a report of an individual with a gun, and that I had been tracked by video surveillance for nearly a half mile before they jumped me.
Then he asked what I was doing on Michigan Avenue, revealing that they didn't even have the right person: I had walked on Wabash all the way from my office, at Huron. I hadn't been on Michigan Avenue since lunchtime. He asked where I had been 30 minutes earlier: In my office. Sitting at my desk.
The whole piece makes the CPD sound full of trigger-happy crazies.
Via E. Messily
Let Us Not Hack
on 12.30.15
People, the Tamir Rice shooting was inexcusable, Loehmann should have never been on the street, and the grand jury was a genuine travesty of justice, BUT, if I hear one more person say "it's an open-carry state!" I might have to become inspired by ISIS. The 911 caller, the same one who says Rice is probably a kid and the gun is probably fake, also says that he's pointing the gun and "scaring the shit out of people." You can't do that, even in an open-carry jurisdiction.
hunka hunka smoldering wrestling
on 12.29.15
A lurker encouraged me to post this: What amount of naked male touching is permissable before it becomes veiwed as homosexual?
I encouraged myself to post this: hunks and kittens!