Google Code Jam 2012 Qualification Round Problem A : Speaking In Tongues
Masih ingat dengan kontes pemrograman yang diadakan Google? Ya, Google Code Jam 2012 resmi dimulai pada tanggal 13 April 2012 yang lalu dengan ditandai mulainya Qualification Round. Bagi yang tidak tahu apa itu Google Code Jam, silahkan terlebih dahulu membaca artikel ini
Satu per satu kita akan membahas semua soal dari tiap – tiap babak. Untuk yang pertama, mari kita telaah pertanyaan dari Qualification Round Problem A. Bagi yang penasaran ingin memecahkan soal – soal Qualification Round dengan usaha sendiri, silahkan kunjungi website ini
Problem
We have come up with the best possible language here at Google, called Googlerese. To translate text into Googlerese, we take any message and replace each English letter with another English letter. This mapping is one-to-one and onto, which means that the same input letter always gets replaced with the same output letter, and different input letters always get replaced with different output letters. A letter may be replaced by itself. Spaces are left as-is.
For example (and here is a hint!), our awesome translation algorithm includes the following three mappings: ‘a’ -> ‘y’, ‘o’ -> ‘e’, and ‘z’ -> ‘q’. This means that “a zoo” will become “y qee”.
Googlerese is based on the best possible replacement mapping, and we will never change it. It will always be the same. In every test case. We will not tell you the rest of our mapping because that would make the problem too easy, but there are a few examples below that may help.
Given some text in Googlerese, can you translate it to back to normal text?
Solving this problem
Usually, Google Code Jam problems have 1 Small input and 1 Large input. This problem has only 1 Small input. Once you have solved the Small input, you have finished solving this problem.
Input
The first line of the input gives the number of test cases, T. T test cases follow, one per line.
Each line consists of a string G in Googlerese, made up of one or more words containing the letters ‘a’ – ‘z’. There will be exactly one space (‘ ‘) character between consecutive words and no spaces at the beginning or at the end of any line.
Output
For each test case, output one line containing “Case #X: S” where X is the case number and S is the string that becomes G in Googlerese.
Limits
1 ≤ T ≤ 30.
G contains at most 100 characters.
None of the text is guaranteed to be valid English.
Sample
Input
3
ejp mysljylc kd kxveddknmc re jsicpdrysi
rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd
de kr kd eoya kw aej tysr re ujdr lkgc jv
________________________________________
Output
Case #1: our language is impossible to understand
Case #2: there are twenty six factorial possibilities
Case #3: so it is okay if you want to just give up
Secara garis besar, kita diminta untuk membuat sebuah program untuk menterjemahkan kalimat Googlerese ke dalam bahasa yang dapat dimengerti manusia dimana setiap huruf dalam bahasa Googlerese secara unik hanya dapat diterjemahkan ke dalam satu huruf (bahasa inggris dalam kasus ini)
Solving
Dalam babak qualification round, problem A ini bisa dikatakan sebagai “bonus problem” dari Google. Mengapa demikian? Ini tidak terlepas dari “kebaikan hati” Google memberikan pemecahan secara implisit dari sample case yang diberikan
Dari paragraf kedua problem :
For example (and here is a hint!), our awesome translation algorithm includes the following three mappings: ‘a’ -> ‘y’, ‘o’ -> ‘e’, and ‘z’ -> ‘q’. This means that “a zoo” will become “y qee”.
dapat diketahui bahwa huruf a dirubah menjadi huruf y, huruf o dirubah menjadi huruf e, dan huruf z dirubah menjadi huruf q.
Jika dibuatkan tabelnya, maka akan menjadi :
Selanjutnya, dari sample case #1 tertulis :
ejp mysljylc kd kxveddknmc re jsicpdrysi
dapat diartikan menjadi :
our language is impossible to understand
sehingga tabelnya menjadi :
Berikutnya, dari case #2 tertulis :
rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd
dapat diartikan menjadi :
there are twenty six factorial possibilities
sehingga tabelnya menjadi :
Dan yang terakhir, di case #3 tertulis :
de kr kd eoya kw aej tysr re ujdr lkgc jv
dapat diartikan menjadi :
so it is okay if you want to just give up
sehingga tabelnya menjadi :
Perlu dicermati di sini bahwa di hint pertama, huruf O ditranslasikan menjadi huruf E, sedangkan di case #3, huruf O ditranslasikan menjadi huruf K. Entah karena ada kesalahan dari pihak Google atau memang sengaja dibuat untuk membingungkan kontestan, namun dari case #1 dan #2 jelas ditunjukkan bahwa huruf E didapatkan dari enkripsi huruf C, jadi kita putuskan huuruf O ditranslasikan menjadi huruf K. Dan yang terakhir, huruf Q mendapat sisanya, yaitu huruf Z. Jadi, tabel akhir untuk problem A ini adalah :
Setelah kita telusuri jalan pemecahan program tersebut, langkah berikutnya akan menjadi lebih mudah. Kita tinggal menuangkan tabel di atas ke dalam bahasa pemrograman. Google tidak membatasi penggunaan bahasa pemrograman dalam kontes ini. Jadi meskipun Anda pecinta bahasa C, C++, C#, Java, atau bahkan Pascal sekalipun, asalkan output yang dikeluarkan benar, maka program Anda akan lolos. Selamat mengerjakan!
Related Posts
Category: Event, International Event












Comments (1)
Trackback URL | Comments RSS Feed
Sites That Link to this Post