140 likes | 254 Views
MEETING’S CANCELLED. (Late) April Fools. PotW Solution - Stelia. BufferedReader ff = new BufferedReader ( new InputStreamReader ( System . in )) ; int n = Integer . parseInt ( ff. readLine () . trim ()) ; int [][] points = new int [ n ][ 2 ] ; String [] l ;
E N D
MEETING’S CANCELLED (Late) April Fools
PotW Solution - Stelia BufferedReaderff=newBufferedReader(newInputStreamReader(System.in)); intn =Integer.parseInt(ff.readLine().trim()); int[][] points =newint[n][2]; String[] l; for(inti=0;i< n;i++){ l =ff.readLine().trim().split(" "); points[i][0]=Integer.parseInt(l[0]); points[i][1]=Integer.parseInt(l[1]); } intmin =Integer.MAX_VALUE, low =0, up =0; for(inti=0;i< n -1;i++){ for(int j =i+1; j < n; j++){ intx = points[i][0]- points[j][0], y = points[i][1]- points[j][1]; intsqrDist= x * x + y *y; if(sqrDist< min) { min =sqrDist; low =i; up = j; } } } System.out.println(points[low][0]+" "+ points[low][1]); System.out.println(points[up][0]+" "+ points[up][1]);
Stuff to pay attention to • USACO • US Open is this coming weekend! (4/6 - 4/9) • 5 hours, 10 points PotW credit, mandatory for those hoping to get into USACO camp • ProCo • May 26 • Registration link can be found at http://proco.stanford.edu, as well as rules, directions, and practice problems
Esoteric Programming Languages >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>>++++++++[<++++>-] <.>>>++++++++++[<+++++++++>-]<---.<<<<.+++.------.--------.>>+.
What is an Esoteric Programming Language? • Also known as esolangs • A programming language designed to experiment with weird ideas, to be hard to program in, or as a joke, rather than for practical use • Usually no intention of the language being adopted for mainstream programming; usability rarely a high priority • First known deliberate esolang is INTERCAL, designed in 1972 to be as different as possible from existing programming languages
Turing Completeness • A term referring to the capabilities of a language • “Turing complete” means that the language can be used to simulate a Turing machine • Can theoretically emulate any computer (the practicality of doing so may vary) • Any Turing-complete system can model any other Turing-complete system • True Turing-completeness cannot be reached by physical computers since it requires infinite memory and infinite lifetime • Esolangs may or may not be Turing-complete • “Turing tarpit” = language that aims for Turing-completeness with minimal language elements; result is flexible but impractical language
HQ9+ • “Joke” language • Four instructions: • H: Print “Hello, world!” • Q: Print the program’s source code • 9: Print lyrics of “99 Bottles of Beer” • +: Increment the accumulator (an instruction as useless as it sounds) • Example program: HQ+QH++ • Output: Hello, world! HQ+QH++HQ+QH++Hello, world!
Brain**** • Minimalist, arguably the most famous esolang • Eight commands:
Brain**** (cont.) • Operates on array of memory cells each initially set to zero, pointer initially pointing to first memory cell • Hello world program: • >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>>++++++++[<++++>-] <.>>>++++++++++[<+++++++++>-]<---.<<<<.+++.------.--------.>>+. • Print Fibonacci numbers (runs until terminated): • >++++++++++>+>+[ [+++++[>++++++++<-]>.<++++++[>--------<-]+<<<]>.>>[ [-]<[>+<-]>>[<<+>+>-]<[>+<-[>+<-[>+<-[>+<-[>+<-[>+<- [>+<-[>+<-[>+<-[>[-]>+>+<<<-[>+<-]]]]]]]]]]]+>>> ]<<< ]
Stack-based Programming • Equivalent to postfix, or Reverse Polish notation • E.g. "3 4 - print" • 3 is pushed onto stack first • 4 is pushed next • '-' is encountered, causing 3 and 4 to be popped, and 3 - 4 = -1 to be pushed • 'print' is encountered, causing -1 to be popped and printed • Examples: Whitespace, Forth, Factor, Befunge • Can be somewhat useful for its simplicity and concision • Factor is one of the most well-developed
Befunge • Esoteric Language • Stack-based • 2-Dimensional code • Flow controlled by arrows. • Examples: • Print (n*n+n)/2&::*+2/.@ • Print first n natural numbers, in reverse order. & v -1.:_@#:<
Java (jk) (actually not jk) (no really, jk) . . . Learn more about esoteric programming languages at http://esolangs.org!
PotW - Inception • Write a Befunge program that prints out a Brain**** program that prints out a HQ9+ program that prints out “Hello, world” • Worth 30 points. The shortest version will receive 5 bonus points. • As an easier version, for 15 points, write a Brain**** program that prints out a HQ9+ program. • For access to compilers, use http://codeforces.com/problemset/customtestWe will be using the same system, so if your code works on it, it should easily get the points.Note that all of these programming languages work with ASCII values for representing characters.
Don’t Jack the sign-in sheets >:[ (Meeting adjourned)