EppsNet Archive: Programming

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 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 . # .… 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. 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 Read more →

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… Read more →

Teaching Computer Science: How to Get Top-Notch Teachers in the Classroom

I read something every day where educators and/or elected officials are talking about the importance for our kids, our country, our future, etc., of teaching computer science, the sticking point being an extreme shortage of qualified teachers. A person entering the workforce with a computer science degree is unlikely to go into teaching because of the opportunity cost: they can earn a lot more money as a software engineer. The likelihood of getting a mid-career tech industry professional to switch into teaching is even lower. Teacher salaries are based in large part on years of service. A mid-career person switching into teaching is not going to get a mid-career teacher’s salary, they are going to get a first-year teacher’s salary. So here’s the idea: Give CS professionals the opportunity to apply their years in industry to years of service as a teacher. It’s still a pay cut going from software… Read more →

Teaching Computer Science: The Phones Aren’t Helping You

I’m volunteering a couple mornings a week at a local high school, helping out with computer science classes. The way the classes are taught, via an online curriculum, provides a great temptation to kids to get off-task, which they do, usually by entertaining themselves with their phones. They get off-task in other ways too — web surfing, doing homework for other classes — but the main distractor is the phones . . .   “As I mentioned before, I worked with another CS class a couple years ago. No phones allowed in the classroom. “I remember one day the assistant principal was in class observing . . . a student had a phone out, looking at it . . . he was holding it under the table so no one could see it, but this guy, the assistant principal, he did see it. “Oh man, did he hit the roof!… Read more →

Teaching Computer Science: When You Need Help, Ask For Help

I’m volunteering a couple mornings a week at a local high school, helping out with computer science classes. It’s a mixed class . . . most of the students are taking AP Computer Science Principles, and about 10 kids just recently started a second-semester Visual Basic class. The VB kids were pretty inquisitive at first but started to get discouraged . . . in my opinion because of the way the material is presented to them via an online curriculum. The current approach to teaching computer science in American schools, because of the shortage of (I almost said “lack of”) qualified teachers is to use packaged courses delivered to students online. My observation is students assume that because they’ve been put in front of a computer full of lessons, they’re expected to be able to read and understand the material and complete the assignments on their own with no help.… Read more →

Teaching Computer Science: Asking for Help

I’m volunteering a couple mornings a week at a local high school, helping out with computer science classes. This morning, in AP Computer Science Principles, the teacher went through an explanation of the hexadecimal number system, then gave an in-class assignment for students to convert their cell phone number to hexadecimal. Not in two parts, 3 digits and 4 digits, but as a 7-digit number. It seemed pretty obvious from the interaction and the body language and the looks on their faces that a lot of students didn’t get it, but in a class of 25 students, only one student asked for help. Until the teacher finished with that student and asked “Does anyone else need help?” and eight more students immediately raised their hand. I asked the teacher, “Can I address the class for a minute?”   “First off, doing a 7-digit hex conversion is not easy. I know… Read more →

Teaching Computer Science: It’s Not Easy to Teach a Subject in Which You Have No Training

A recent issue of Science has an article on the pipeline for computer science teachers . . . The first sentence says, “It’s not easy to teach a subject in which you have no training.” That could be the whole article, really. That’s about all you need to know about the current state of computer science instruction: It’s not easy to teach a subject in which you have no training. Cameron Wilson, chief operating officer and president of the Code.org Advocacy Coalition, is quoted as saying, “It’s really hard to convince a computer science professional to give up a job that pays up to three times more to pursue teaching. And I don’t think we should.” Wilson’s opinion that computer science classes should not be taught by someone who actually knows something about computer science is probably influenced by the fact that Code.org is one of the leading providers of… Read more →

More Words and Phrases I’m Sick Unto Death Of

Although I can’t claim never to have said these things myself, if I had a dollar for every time I’ve heard someone say either a) “It was working fine 10 minutes ago,” or b) “It works okay on my machine,” I would be comfortably retired by now. Thus spoke The Programmer. Read more →

What Does a Programmer Do?

I was asked to give a talk last week to a high school computer science class on “What Does a Programmer Do?” (I’m indebted to Jim McCarthy for the “lords and ladies of logic” section.)   Programming is problem solving. At the highest level, the problem that programmers solve is that people want to be able to do things with computers that they can’t do. And by computers, I don’t mean just the kind of computers you have on the desks here, I mean phones, watches, cars . . . more and more different kinds of devices are running software. So one good thing about being a programmer is that pretty much every field of endeavor now uses software and data. You can work at a tech company like Microsoft or Google or Twitter or Facebook, but you can also work in healthcare, finance, education, sports . . . you… Read more →

I’m a Winner!

I’ve been doing the daily challenges at CodeFights for quite a while and yesterday’s challenge is the first time I got first place! (CodeFights ranks solutions by fewest number of characters, with solution time as the tiebreaker.) Read more →

AP Computer Science Revisited

I got a LinkedIn invitation today from a student I taught in an AP Computer Science class a couple of years ago. She’s now a computer science major at UCSB. Several of the kids from that class are now in college as computer science majors. Some of them would have been computer science majors anyway, without the class — they came in already having programming interest and experience — but this young lady was not in that group. She was quiet in class but when I worked with her one on one, she asked a lot of questions. She asked them quietly but she asked. And when I told her to do something a certain way she always asked why. She only has four connections at this time so I appreciate her thinking of me. 🙂 Read more →

Learn to Code

I’m a programmer . . . Job searches for me go like this: I’m old, I have to compete with people half my age, but I’ve worked in Orange County since forever so I know some people, and I can write good code in interviews, which the majority of programmers who show up for interviews can’t. I was out of work on January 5. It’s now January 24. I have three job offers and picked the one I like best. Moral of the story: Learn to code, kids . . . Thus spoke The Programmer. Read more →

See You in Hell

[See You in Hell is a feature by our guest blogger, Satan — PE] Along with pleas for money, almost 100 percent of the cardboard signs I see being held by people on freeway off-ramps and the like include the phrase “God Bless You.” There seems to be a correlation between belief in God and begging for money on off-ramps. Notice that you never see Satanists begging for money. Why don’t they pray for the money? Maybe they did pray and God told them to make a cardboard sign? I tell my acolytes if they need money, learn to code. See you in Hell . . . Read more →

Programmer or Parolee?

Our office building is next door to a probation field office . . . I have a game I play in the parking lot each morning: Programmer or Parolee. I spot someone, guess if he’s here for a programming challenge or a meeting with his parole officer, then wait to see if he shows up in our office. If a methed-out skinhead comes in for a programming challenge, I lose today’s game. Read more →

Teaching Prisoners to Code: What Could Go Wrong?

What could go wrong here? Criminal minds + coding skills = ??? One of my favorite Mr. Boffo cartoons shows a gang of robbers in a bank in the Old West . . . one of the robbers says to another, “Someday this will all be done by computer.” What an inspiring program to solve a big and growing U.S. problem. Posted by Code.org on Sunday, February 21, 2016 Read more →

The Ceiling Seems Very Low

I don’t know if this is good news or bad news. It would help to know what “trains” means but I read the article and it doesn’t say. Reporters need to be more inquisitive. Can someone with no knowledge of computer science or programming be “trained” to teach computer science or programming? What would that entail? How long would it take? Can someone who’s never played an instrument or listened to a piece of music be “trained” to teach a music class? Can someone who’s never picked up a drawing pencil or visited a museum be “trained” to teach an art class? Can someone who doesn’t speak Spanish be “trained” to teach a Spanish class? The ceiling on any of these approaches seems very low compared to hiring actual programmers, musicians, artists and Spanish speakers . . . Thus spoke The Programmer. Read more →

Hey Guys, I Wrote a Book!

It’s called Thus Spoke the Programmer: A Fictional Memoir. (Don’t be put off by the title if you’re not a programmer. It’s guaranteed to delight both technical and non-technical readers alike. 🙂 ) If you’re interested in having a look at it, you have a couple of options: Leanpub, a PWYW (pay what you want) platform, which means if you want to read the book for free, you can download it and read it for free. Amazon, available in paperback or Kindle format (not free). Read more →

« Previous PageNext Page »