125 Ad spot 125 Ad spot

ACMSolver or Art of Programming? 24 X 7 Updates

From 2002 ACMSolver is campaigning for free programming knowledge!

26 October 2013 Comments Off

How to String Tokenize in C++?

I found a way coded by Shohag of UBC.

void first_method(string str, string delim)
	int posCurr = 0;
	int posFind = str.find_first_of(delim, posCurr);

	while( posFind != string::npos){
		string temp = str.substr(posCurr, posFind-posCurr);
		posCurr = posFind + 1;
		posFind = str.find_first_of(delim, posCurr);

		if(temp.length()) cout << temp << endl;

But quick and easy way of tokenizing is to use istringstream

void second_method(string str, char ch)
	istringstream strStrm(str);
	string temp = "";

	while(getline(strStrm, temp, ch)){
		cout << temp << endl;
4 July 2013 Comments Off

Bag data structures (collected)

Here we will consider the implementation of an ADT which we call the Bag ADT. This container class will contain entries of type Item. We will implement the container class using pre-allocated partially filled array.

#ifndef BAG_H

#define BAG_H

#include <iostream.h>

#include <assert.h>  //if we want to use “assert” function.

#include <stdlib.h>//if we want to use “size_t”

class Bag



static const int CAPACITY = 10; // This is the max # of Items “data” can hold.

typedef int Item; // if we want, we could change int to char or float or any such type.


Bag ( ) { used = 0; }

//Modification member functions

bool insert ( const Item& myItem);

bool remove ( const Item& myItem);

void operator += (const Bag& addend);

//constant member function.

size_t size ( ) const { return used;}


size_t used;

Item data [CAPACITY];


// non-member function.

Bag operator + (const Bag& b1, const Bag& b2);


Let’s look at the ADT in more detail.

- The Bag class contains a member called data, which is an array of Items.

- The size of the “data” array is defined using a static const called CAPACITY defined inside the Bag class definition.

- We use another member of the Bag class called “used” to indicate how many Items the “data” array currently holds.

- Invariant of the Bag ADT: The member variable “used” is an int in the range 0 through CAPACITY-1. If the “data” array does not contain any Items, then “used” = 0. If the “data” array does contain Items, those Items are contained within the indices 0 through “used”-1. We do not care what is contained in the indices starting from “used” up through CAPACITY-1.

- The insert member function takes as argument a const reference to an Item to be inserted into the Bag object.If there is space for the item to be inserted, the function inserts it and returns true. Else, it returns false.

- The remove member function takes as argument a const reference to an item, the first copy of which would be removed from the Bag instance, if the item is present in it. It returns true in such a case. Else, it returns false.

- The size member function returns the number of Items currently held by the Bag instance.

- We shall look at the 2 overloaded operators later.

Tags: , ,
4 July 2013 Comments Off

Stanford ACM ICPC Local Contests

2011 2011 Stanford Local Programming Contest
2010 2010 Stanford Local Programming Contest
2009 2009 Stanford Local Programming Contest
2008 2008 Stanford Local Programming Contest
2007 2007 Stanford Local Programming Contest
2006 2006 Stanford Local Programming Contest
2005 2005 Stanford Local Programming Contest
2004 2004 Stanford Local Programming Contest
2003 2003 Stanford Local Programming Contest
2002 2002 Stanford Local Programming Contest
2001 2001 Stanford Local Programming Contest
2000 2000 Stanford Local Programming Contest
1999 1999 Stanford Local Programming Contest
1998 1998 Stanford Local Programming Contest
1997 1997 Stanford Local Programming Contest
1996 1996 Stanford Local Programming Contest
5 June 2013 Comments Off

UAlberta programming club code archive

[DIR] Parent Directory -
[DIR] 2D_Geometry/ 30-Apr-2010 15:08 -
[DIR] 3D_Geometry/ 23-Feb-2004 15:23 -
[DIR] Archive/ 25-May-2012 13:33 -
[DIR] Arithmetic/ 26-Oct-2005 10:44 -
[DIR] C++/ 26-Oct-2005 11:15 -
[DIR] Combinatorics/ 23-Feb-2004 15:23 -
[DIR] Data_Struct/ 23-Feb-2004 15:23 -
[DIR] Dynamic/ 23-Feb-2004 15:23 -
[DIR] Generators/ 23-Feb-2004 15:23 -
[DIR] Graph_Theory/ 13-Jan-2006 13:39 -
[DIR] Java/ 23-Feb-2004 15:23 -
[TXT] Makefile 10-Nov-2003 17:14 69
[DIR] Misc/ 26-Oct-2005 10:34 -
[DIR] Num_theory/ 26-Aug-2008 11:13 -
[DIR] OLD/ 23-Feb-2004 15:23 -
[DIR] Old/ 14-Mar-2003 20:26 -
[DIR] Parsing/ 23-Feb-2004 15:23 -
[DIR] Search/ 23-Feb-2004 15:23 -
[TXT] index.txt 13-Nov-2003 13:36 7.6K
[TXT] masterlist.txt 26-Aug-2008 11:15 12K
[DIR] misc/ 25-Nov-2005 14:51 -
[TXT] oldfiles.txt 19-Mar-2003 17:32 3.9K
[TXT] tables.txt 21-Jan-2003 16:43 3.9K
[TXT] todo.txt 13-Jan-2006 13:41 304
[TXT] updatelist.txt 13-Jan-2006 13:40 6.4K
Tags: , ,
5 June 2013 Comments Off

ACM ICPC World Finals 2013

The 2013 World Finals will be held in St. Petersburg, Russia.

The ACM International Collegiate Programming Contest (ICPC) provides college students with opportunities to interact with students from other universities and to sharpen and demonstrate their problem-solving, programming, and teamwork skills. The contest provides a platform for ACM, industry, and academia to encourage and focus public attention on the next generation of computing professionals as they pursue excellence.

ACM ICPC World Finals 2013 is organized under the auspices of the National Research University of Information Technologies, Mechanics and Optics. The University ITMO, being the most important research university in Russia, is an important component of Russian innovation economy. It nurtures both a culture of new venture creation and an infrastructure that will support many new ventures.

The contest is a two-tiered competition among teams of students representing institutions of higher education. The highest scoring team is the World Champion and will receive the World Champion Cup and plaques. The World Champion team will be awarded $12,000.

The primary purpose of the University ITMO is the creation, dissemination, preservation, and application of knowledge in such fields as optics, information science and equipment engineering. To fulfill this mission, the University focuses on priority directions of development in science, technology and engineering. Support of the Contset reflects the mission of our University: we prepare students to take an active role in any team, and work in competitive conditions paying continuing attention to formation and development of outstanding academic and educational schools.

Source: http://en.ifmo.ru/index.php?option=com_content&view=article&id=1859:acm-icpc-world-finals-2013&catid=166&Itemid=404

Tags: ,
26 March 2013 Comments Off

Algolist.net a nice website for algorithms.

On Algolist.net you will find articles on the subjects of data structures, algorithms and programming concepts. Each and every article is supplemented with code snippets in both C++ and Java, so you can turn to the practice right after reading a tutorial. For the very beginners we developed articles about how to install a development environment and to write simple applications.