21 May 2011 Comments Off

UAlbarta CS Code Repository

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

Source: http://webdocs.cs.ualberta.ca/~contest/code/

4 October 2010 Comments Off

C++ Tutorials

These tutorials explain the C++ language from its basics up to the newest features of ANSI-C++, including basic concepts such as arrays or classes and advanced concepts such as polymorphism or templates.

[ Download the entire tutorial as a PDF file ]

Instructions for use
Basics of C++:
Structure of a program
Variables. Data Types.
Basic Input/Output
Control Structures:
Control Structures
Functions (I)
Functions (II)
Compound Data Types:
Character Sequences
Dynamic Memory
Data Structures
Other Data Types
Object Oriented Programming:
Classes (I)
Classes (II)
Friendship and inheritance
Advanced Concepts:
Type Casting
Preprocessor directives
C++ Standard Library:
Input/Output with files
29 August 2010 Comments Off

10487 – Closest Sum

#include <stdio.h>
int main()
int n, i, q, c, sz, idx, idx2, t1, t2, elteres, ce = 0;
if(!n) break;
printf("Case %d:\n",++ce);
int set[n], i = 0, q = 0;
sz = n;

elteres = 2147483647;
for(idx = 0; idx < sz; idx++)
for(idx2 = idx + 1; idx2 < sz; idx2++)
if(  abs((set[idx] + set[idx2]) - c) < elteres  )
elteres = abs((set[idx] + set[idx2]) - c);
t1 = set[idx];
t2 = set[idx2];
printf("Closest sum to %d is %d.\n",c,t1+t2);
return 0;
13 August 2010 Comments Off

Programming Competition Skills Workshop by Bill Smart

Overview: Welcome to CSE 232: Programming Skills Workshop! To fully understand the intended purpose of this course, it’s important to be aware of the ACM’s annual ICPC (International Collegiate Programming Competition; Wikipedia). The Washington University ACM has determined that we should make it our goal to win, and if not to win then to get the most out of this opportunity as possible. This class is a means to that end. We wish to train in a collaborative manner, by studying essential algorithms, problem solving skills, coding techniques, and strategy necessary to compete successfully in the ICPC. Unfortunately, not all participants of the class will be able to compete (registration has been limited in past years to 3 teams of 3 students each, at most, from each university). However, in designing this class we have aimed to distill from the oceans of related material specifically that content which we believe to be most useful and applicable to anyone in the field of computer science. Thus, while the formal goal of this class is to prepare you for the ICPC, the real value lies in our belief that the skills developed herein will benefit you in all of your pursuits as a student of computer science*.

Mini-Competitions: There will be approximately 3 small, in-house competitions held throughout the semester. All interested students, staff, and faculty are invited to attend. These competitions serve to provide a realistic practice for prospective competitors, as well as help students decide who should go to the ICPC. Also, there will be free food and it’s a great chance to practice your coding skills, learn new algorithms, and to meet other CS students. If you’re in the class, it’s a part of your grade, too. See Competitons Page.

Topics: Some topics we’d like to cover, broken up by category are listed below. Note:We will most likely not manage to cover all of these. Our hope is to at least touch on the majority of the topics listed below, and give you the tools and inspiration to learn the rest on your own, as needed. A more formal syllabus is available below with a more accurate list of topics to be covered this semester during class time. This list is more to provide a general feel for the kinds of things we’ll touch on and why they are important.

– Base conversion, string to digit, digit to string, overflows, epsilons, properties of polynomials, logs, sequences, primes, number theory, GCD, LCM, modular arithmetics, combinatorics, etc.
* All of these are important to be familiar with (and you probably already are); they’re likely to show up in several problems tangentially to the main algorithm.
Backtracking/Brute Force:
– Permutations, combinations, heuristic ideas, knowing when to use it
* Sometimes it really is the only way, and sometimes coder time really is worth many than execution time.
Data Structures:
– Graph representations, priority queues, lists, maps, etc.
* The emphasis will mostly be on how to write these quickly or use ones in the Java library, take CSE 241 for a deeper introduction to these if you haven’t seen them before. Their importance is pretty obvious, but at times making the parsing -> data representation -> data processing transition can be tricky anyway.
– Dijkstra, max/min flow, spanning trees, BFS/DFS, modeling problems as graphs.
* Translating seemingly unrelated problems into graph problems can provide easy solutions for a lot of problems. We want you to be able to recognize when to think “graph” and to know what to do with the graph once you’ve made that realization (common algorithms).
Dynamic Programming
* Possibly the scariest topic in this course, but also a source of surprisingly efficient algorithms when used properly. Take CSE 441T for a proper introduction to this domain of algorithms; our intent here is to provide a quick overview of what it means and how to use it, mostly in simpler cases.
Computation Geometry:
– Grids, intersections, convex hulls, sweep lines, useful equations
* Take CSE 546 if you really want to learn this stuff. We do intend to show you the basics though and give you some food for thought, and probably a couple algorithms and data structures to snack on.
Competition Strategy
* Because we want to win the ICPC


4 July 2010 Comments Off

C- is alphanumeric

#include <ctype.h>
#include <stdio.h>

int main(void)
char ch;

printf(". to exit:");
for(;;) {
ch = getc(stdin);
if(ch == '.')
printf("%c is alphanumeric\n", ch);

return 0;

Tags: ,