C++ in Competitive Programming: I/O

Growing up

Welcome back to my series about Competitive Programming. Here is the introduction in case you missed it.

In this post I’ll explain some common idioms to deal with input and output.

In C++ a simple task like reading an integer from the standard input can be done in different ways: using streams, C functions or OS-dependant calls. The streams model offers a pretty high level interface, but it is generally slower than using native operating system calls. However, in different cases, it is acceptable.

I have solved a lot of challenges and very rarely I had to switch to C functions (e.g. scanf) or turn off the synchronization between C++ streams and standard C streams after each input/output operation (by using std::ios_base::sync_with_stdio). Most of the time the I/O is not the point of the exercise then we can use the convenient streams model. This point seems irrelevant but it brings about simplification, enabling us to write not only simpler but also safer idioms. We’ll…

View original post 1,640 more words

Featured Image -- 2165

The 50 Startups That Launched At Y Combinator Summer 2015 Demo Day 1

TechCrunch

Hardware took the spotlight at today’s Y Combinator Demo Day, reflecting a major shift of the accelerator beyond the cliche mobile app startup. Out of the 50 companies from the Summer 2015 batch that demoed on the record today, 20 featured hardware. What was formally the Demo Day lunchroom has become an expo hall for all manners of robots and gadgets.

Tomorrow, another 50 or so startups will present. Soon, we’ll have our selections made for our favorites. But for now, here’s a look at all 50 that strutted the stage today:

TeaBOT — An automated beverage vendor

TeaBOT is a robot that makes grab’n’go tea. You enter up to three types of its dozen teas, pay via iPad or credit card, and the bot automatically mixes you a hot cup of tea. The company says the bots can earn $100,000 a year. The startup licenses the TeaBOTs to retailers and colleges, and…

View original post 4,314 more words

Featured Image -- 2161

The Mystery Money Creating The Unicorn Herd

TechCrunch

[tc_contributor_byline slug=”jeff-grabow”]

Varied explanations for the growing herd of unicorns — and predictions of their imminent demise — abound. But all can agree: Those who invest in unicorns are chasing returns they can’t get elsewhere. And while venture capital is widely perceived to be fueling the unicorns’ growth, a closer look reveals that not all venture capital is really venture capital.

Data on VC fundraising shows a long-term decline in capital to VC funds, a trend I covered here. If less money goes in, less is available to be deployed.

image009 Declining fundraising in the U.S. since 2007. 2009 marks the fewest funds raised in 16 years. 2009 was the low point in terms of dollars raised since 2003.

In 2014, Dow Jones reported that the amount of venture capital invested in the United States soared to $52 billion, from $35 billion in 2013, an increase of almost 50 percent…

View original post 757 more words

Featured Image -- 2154

How Amazon Could Drive Blended Reality Into The Living Room

TechCrunch

[tc_dropcap]A[/tc_dropcap]mazon has been amassing computer vision expertise for a long time. And continues to do so. A LinkedIn search for computer vision jobs at the company currently returns more than 50 posts — mostly split across research and software engineering roles. But is there more than meets the eye to the ecommerce giant’s interest in technologies that can sense the world around them?

Amazon’s nascent drone delivery program, Prime Air, is one clear driver to hire scientists with a grounding in machine learning and computer vision, since drones need to navigate in real world environments. And if you’re chasing a dream of autonomous delivery drones, as Amazon is, then accurate object detection and dynamic collision avoidance are essential.

Likewise there’s Amazon’s thus far ill-fated foray into smartphones, with last year’s debut Fire Phone. The handset’s flagship feature was a 3D interface that uses data from four front-facing cameras to generate three dimensional effects on screen…

View original post 3,014 more words

Objects

howtosurvivecomputerscienceincollege

Java is an object orientated programming language (so is c++ and python) which means that the programming is centered around using classes and methods to create objects, and then using those objects in your code. I will take two posts to explain objects, the first will be how to create objects, and the second will be to show all of the different functionality that objects have.

An object is something that has different states and behaviors for example a bear has states such as color, type, ..ect and a bear has behaviors such as growling, eating, sleeping. You create an object by creating an instance of the class that the object is defined in.

public class Bear {

private String color;

public Bear(int age, String type) {

this.age = age;

this.type = type;

}

void growling() {  }

void eating() {  }

void sleeping() {   }

}

so this…

View original post 258 more words

Featured Image -- 2151

Meet the French startup set to revolutionize the Internet of things

Fortune

This fall a new kind of wireless network will launch in a metropolis near you. This network won’t connect to phones or tablets. Instead it will provide the wireless links necessary to connect devices, appliances and sensors that make up the Internet of things (IoT).

The company building the network is called Sigfox, and it’s based in Europe (Toulouse, France, to be exact) where it’s already set up networks in France, Spain, the U.K., and five other countries. Sigfox-powered sensors are being slapped on fire hydrants (to monitor water pressure), embedded in home alarms (to alert the authorities when they’re tripped), and even buried in the dirt (to monitor the soil density of farmland). This year, however, it’s moving to its largest country to date, the U.S., where it plans to build networks covering the ten largest cities.

Wireless connectivity that covers a wide swath of land is nothing…

View original post 545 more words

How Shazam Works

Free Won't

There is a cool service called Shazam, which take a short sample of music, and identifies the song.  There are couple ways to use it, but one of the more convenient is to install their free app onto an iPhone.  Just hit the “tag now” button, hold the phone’s mic up to a speaker, and it will usually identify the song and provide artist information, as well as a link to purchase the album.

What is so remarkable about the service, is that it works on very obscure songs and will do so even with extraneous background noise.  I’ve gotten it to work sitting down in a crowded coffee shop and pizzeria.

So I was curious how it worked, and luckily there is a paper written by one of the developers explaining just that.  Of course they leave out some of the details, but the basic idea is…

View original post 620 more words