HKOI Programming HKOI Training Team (Intermediate) 2005-01-15 Alan, Tam Siu Lung Unu, Tse Chi Yung.

Slides:



Advertisements
Similar presentations
Advanced Programming 15 Feb The “OI” Programming Process Reading the problem statement Thinking Coding + Compiling Testing + Debugging Finalizing.
Advertisements

Contest format 5 hours, around 8-12 problems One computer running (likely)Linux, plus printer 3 people on one machine No cell phones, calculators, USB.
Intro to USACO Strategy
Programming Types of Testing.
An Introduction to Programming Concepts and OI-programming …from abstract theory to dirty tricks…
Introduction to C Programming
Debugging Techniques1. 2 Introduction Bugs How to debug Using of debugger provided by the IDE Exception Handling Techniques.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Chapter 2: Input, Processing, and Output
Introduction to a Programming Environment
Guide To UNIX Using Linux Third Edition
Introduction to C Programming
Group practice in problem design and problem solving
Fortran- Subprograms Chapters 6, 7 in your Fortran book.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
An Introduction to Programming Concepts and OI-programming …from abstract theory to dirty tricks…
General Programming Introduction to Computing Science and Programming I.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved For Loops October 16, 2013 Slides by Evan Gallagher.
Program Development Life Cycle (PDLC)
CS Fall 2007 Dr. Barbara Boucher Owens. CS 2 Text –Main, Michael. Data Structures & Other Objects in Java Third Edition Objectives –Master building.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
OI-style programming Gary Wong For any questions, please ask via MSN:
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Making Good Code AKA: So, You Wrote Some Code. Now What? Ray Haggerty July 23, 2015.
ENEE150 – 0102 ANDREW GOFFIN Testing and Debugging.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Introduction to Programming
HKOI 2005 Training Introduction to Algorithms Alan, Tam Siu Lung.
Overview of c++ Objectives 1. Understanding the use of the following elements in a c++ program variables constants assignment input output 2. Writing a.
Reactive and Output-Only HKOI Training Team 2006 Liu Chi Man (cx) 11 Feb 2006.
Python Let’s get started!.
Think Possibility 1 Iterative Constructs ITERATION / LOOPS C provides three loop structures: the for-loop, the while-loop, and the do-while-loop. Each.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
The Hashemite University Computer Engineering Department
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Efficiently Solving Computer Programming Problems Doncho Minkov Telerik Corporation Technical Trainer.
Python 1 SIGCS 1 Intro to Python March 7, 2012 Presented by Pamela A Moore & Zenia C Bahorski 1.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Bill Tucker Austin Community College COSC 1315
A variable is a name for a value stored in memory.
Chapter 7 User-Defined Methods.
Chapter 2: Input, Processing, and Output
Lecture – 2 on Data structures
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Print slides for students reference
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Objective of This Course
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Programming Fundamentals (750113) Ch1. Problem Solving
Optimization 薛智文 (textbook ch# 9) 薛智文 96 Spring.
Chapter 2: Input, Processing, and Output
Unit 3: Variables in Java
Primary School Computing
Chapter 1: Creating a Program.
Presentation transcript:

HKOI Programming HKOI Training Team (Intermediate) Alan, Tam Siu Lung Unu, Tse Chi Yung

What you should learn from this lesson How to solve a problem How to code faster How to test your program How to score more

Today’s flow Competition Rules Problem Solving Coding Testing Tricks

Competition Rules The winner is determined by – Fastest program? – Amount of time used in coding? – Number of tasks solved? – Highest score

Scoring Black-box Testing Marks will be given if a program passes a certain test case A test case is passed if the output – matches the expected one, or – satisfies certain criteria No referral to source code

The “OI” Programming Process Choosing a problem Reading the problem Thinking Coding Testing Finalizing the program

Reading the problem Usually, a task consists of – Title – Problem Description – Constraints – Input/Output Specification – Sample Input/Output – Scoring

Reading the problem Constraints – Range of variables – Execution time NEVER make assumptions yourself – Ask whenever you are confused Read EVERY word Make sure you understand before going on

Thinking Classify the problem – Graph? Mathematics? Data Processing? … Compare with some past problems – Any similarity? For complex problems, divide the problem into smaller sub-problems

Thinking Draw diagrams Consider special cases Is the problem too simple? – Be suspicious, you may have overlooked something Still no idea? Give it up… Try again later

Designing the solution Some points to consider – Execution Time (Time Complexity) – Amount of memory used (Space Complexity) – How to store data? (Data Structure) – Difficulty in coding

Coding Coding is just a small part in the competition Less coding time means more time for thinking (which is more important) FYI, usually Unu completes a program in 15 minutes How to perform problem reduction faster?

Characteristics of OI programs Simple Input/Output Assumption: Data input format always matches specification Short programs (usually < 100 lines)

Common practices in OI-coding No comments needed Short variable names (usually 1-2 chars) Less procedures / functions Use of break, continue and goto Hardcoding (Not recommended)

Common practices in OI-coding Use a slightly larger array than needed Pascal users: use longint instead of integer Avoid real numbers (sometimes not possible) Avoid long and complex expressions Save and Compile frequently

Testing Sample Input/Output “A problem has sample output for two reasons: 1. To make you understand what the correct output format is 2. To make you believe that your incorrect solution has solved the problem correctly ”

Testing Create some simple input yourself (by hand) Boundary cases “Large” input – Test for execution time and integer overflow Tricky cases

Debugging Print values of important variables to screen and/or files Print messages to screen and/or files Use debugger – FreePascal IDE debugger – GDB

Finalizing Check I/O filename Check output format – Any trailing spaces? Correct source/executable name? Is the executable updated?

Tricks Quick and dirty ways to get marks Usually, 10-20% of total marks are allocated to simple test cases Write programs that handles these cases ONLY Use only when you have totally no idea on a task or time is running out

Tricks “No solution” Sample Input/Output Special cases Hardcoding Stop the program before execution time runs out

Demonstration (of sloppy skills) Define the value of a character be: ‘A’=1, ‘B’=2, …, ‘Z’=26 Given N strings of capital letters, sort them according to the average value of all characters. If average value of 2 strings are equal, the one which comes earlier in the input should be ranked earlier. Input: (“TOM”, “JANET”, “JOHN”) Output: (JOHN”, “TOM”, “JANET”)