home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Programming Contest / MacHack Contest.sit / MacHack Contest / Problems Folder / Problem 01 - Mode Sort / Solution.cp < prev    next >
MacBinary  |  1998-06-18  |  2.0 KB  |  [TEXT/CWIE]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert MS-DOS Code Page Info (other/dosCodePage) ext Unsupported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Thu Jun 18 12:48:45 1998, modified Thu Jun 18 12:48:45 1998, creator 'CWIE', type ASCII, 1401 bytes "Solution.cp" , at 0x5f9 410 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[CWIE]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0b 53 6f 6c 75 74 69 | 6f 6e 2e 63 70 00 00 00 |..Soluti|on.cp...|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 43 57 49 | 45 00 00 00 00 00 00 00 |.TEXTCWI|E.......|
|00000050| 00 00 00 00 00 05 79 00 | 00 01 9a b1 ae f5 6d b1 |......y.|......m.|
|00000060| ae f5 6d 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |..m.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 c5 74 00 00 |........|.....t..|
|00000080| 2f 2a 0d 50 72 6f 62 6c | 65 6d 20 30 31 20 2d 20 |/*.Probl|em 01 - |
|00000090| 4d 6f 64 65 20 53 6f 72 | 74 0d 0d 54 68 69 73 20 |Mode Sor|t..This |
|000000a0| 70 72 6f 62 6c 65 6d 20 | 69 73 20 74 6f 20 73 6f |problem |is to so|
|000000b0| 72 74 20 61 6e 20 69 6e | 70 75 74 20 73 74 72 69 |rt an in|put stri|
|000000c0| 6e 67 20 6f 66 20 4e 20 | 63 68 61 72 61 63 74 65 |ng of N |characte|
|000000d0| 72 73 2c 20 4e 3c 31 30 | 30 30 30 30 30 2c 20 62 |rs, N<10|00000, b|
|000000e0| 61 73 65 64 20 6f 6e 0d | 74 68 65 20 6e 75 6d 62 |ased on.|the numb|
|000000f0| 65 72 20 6f 66 20 74 69 | 6d 65 73 20 61 20 63 68 |er of ti|mes a ch|
|00000100| 61 72 61 63 74 65 72 20 | 6f 63 63 75 72 73 20 69 |aracter |occurs i|
|00000110| 6e 20 74 68 65 20 69 6e | 70 75 74 2e 20 20 54 68 |n the in|put. Th|
|00000120| 65 20 6d 6f 73 74 20 66 | 72 65 71 75 65 6e 74 6c |e most f|requentl|
|00000130| 79 0d 6f 63 63 75 72 72 | 69 6e 67 20 63 68 61 72 |y.occurr|ing char|
|00000140| 61 63 74 65 72 20 73 68 | 6f 75 6c 64 20 62 65 20 |acter sh|ould be |
|00000150| 73 6f 72 74 65 64 20 74 | 6f 20 74 68 65 20 66 72 |sorted t|o the fr|
|00000160| 6f 6e 74 20 6f 66 20 74 | 68 65 20 73 74 72 69 6e |ont of t|he strin|
|00000170| 67 2c 20 66 6f 6c 6c 6f | 77 65 64 20 62 79 0d 74 |g, follo|wed by.t|
|00000180| 68 65 20 6e 65 78 74 20 | 6d 6f 73 74 20 66 72 65 |he next |most fre|
|00000190| 71 75 65 6e 74 6c 79 20 | 6f 63 63 75 72 72 69 6e |quently |occurrin|
|000001a0| 67 20 63 68 61 72 61 63 | 74 65 72 2c 20 65 74 63 |g charac|ter, etc|
|000001b0| 2e 20 20 46 6f 72 20 63 | 68 61 72 61 63 74 65 72 |. For c|haracter|
|000001c0| 73 20 6f 63 63 75 72 72 | 69 6e 67 0d 74 68 65 20 |s occurr|ing.the |
|000001d0| 73 61 6d 65 20 6e 75 6d | 62 65 72 20 6f 66 20 74 |same num|ber of t|
|000001e0| 69 6d 65 73 2c 20 74 68 | 65 20 63 68 61 72 61 63 |imes, th|e charac|
|000001f0| 74 65 72 20 74 68 61 74 | 20 6f 63 63 75 72 73 20 |ter that| occurs |
|00000200| 66 69 72 73 74 20 69 6e | 20 74 68 65 20 69 6e 70 |first in| the inp|
|00000210| 75 74 20 73 68 6f 75 6c | 64 0d 62 65 20 73 6f 72 |ut shoul|d.be sor|
|00000220| 74 65 64 20 74 6f 20 74 | 68 65 20 66 72 6f 6e 74 |ted to t|he front|
|00000230| 2e 0d 0d 48 65 61 64 65 | 72 20 73 70 65 63 69 66 |...Heade|r specif|
|00000240| 69 63 61 74 69 6f 6e 0d | 0d 70 61 73 63 61 6c 20 |ication.|.pascal |
|00000250| 4f 53 45 72 72 20 4d 6f | 64 65 53 6f 72 74 28 20 |OSErr Mo|deSort( |
|00000260| 63 6f 6e 73 74 20 46 53 | 53 70 65 63 2a 20 69 6e |const FS|Spec* in|
|00000270| 66 69 6c 65 2c 20 63 6f | 6e 73 74 20 46 53 53 70 |file, co|nst FSSp|
|00000280| 65 63 2a 20 6f 75 74 66 | 69 6c 65 20 29 3b 0d 0d |ec* outf|ile );..|
|00000290| 49 6e 70 75 74 20 73 70 | 65 63 69 66 69 63 61 74 |Input sp|ecificat|
|000002a0| 69 6f 6e 0d 0d 54 68 65 | 20 69 6e 66 69 6c 65 20 |ion..The| infile |
|000002b0| 69 6e 70 75 74 20 66 69 | 6c 65 20 63 6f 6e 74 61 |input fi|le conta|
|000002c0| 69 6e 73 20 74 68 65 20 | 63 68 61 72 61 63 74 65 |ins the |characte|
|000002d0| 72 73 2e 20 20 49 6e 70 | 75 74 20 63 68 61 72 61 |rs. Inp|ut chara|
|000002e0| 63 74 65 72 73 20 6f 74 | 68 65 72 20 74 68 61 6e |cters ot|her than|
|000002f0| 0d 74 68 6f 73 65 20 70 | 72 69 6e 74 61 62 6c 65 |.those p|rintable|
|00000300| 20 6c 6f 77 20 61 73 63 | 69 69 20 63 68 61 72 61 | low asc|ii chara|
|00000310| 63 74 65 72 73 20 63 2c | 20 30 78 32 30 3c 63 3c |cters c,| 0x20<c<|
|00000320| 30 78 37 66 2c 20 6d 75 | 73 74 20 62 65 20 69 67 |0x7f, mu|st be ig|
|00000330| 6e 6f 72 65 64 2e 0d 0d | 4f 75 74 70 75 74 20 73 |nored...|Output s|
|00000340| 70 65 63 69 66 69 63 61 | 74 69 6f 6e 0d 0d 54 68 |pecifica|tion..Th|
|00000350| 65 20 6f 75 74 66 69 6c | 65 20 6d 75 73 74 20 62 |e outfil|e must b|
|00000360| 65 20 63 72 65 61 74 65 | 64 20 61 6e 64 20 74 68 |e create|d and th|
|00000370| 65 6e 20 66 69 6c 6c 65 | 64 20 77 69 74 68 20 74 |en fille|d with t|
|00000380| 68 65 20 73 6f 72 74 65 | 64 20 63 68 61 72 61 63 |he sorte|d charac|
|00000390| 74 65 72 73 2e 20 20 49 | 74 27 73 0d 66 69 6e 61 |ters. I|t's.fina|
|000003a0| 6c 20 6c 65 6e 67 74 68 | 20 73 68 6f 75 6c 64 20 |l length| should |
|000003b0| 62 65 20 65 78 61 63 74 | 6c 79 20 74 68 65 20 73 |be exact|ly the s|
|000003c0| 61 6d 65 20 61 73 20 74 | 68 65 20 63 6f 75 6e 74 |ame as t|he count|
|000003d0| 20 6f 66 20 63 68 61 72 | 61 63 74 65 72 73 20 69 | of char|acters i|
|000003e0| 6e 20 74 68 65 0d 61 6c | 6c 6f 77 65 64 20 72 61 |n the.al|lowed ra|
|000003f0| 6e 67 65 20 28 30 78 32 | 30 3c 63 3c 30 78 37 66 |nge (0x2|0<c<0x7f|
|00000400| 29 20 28 77 68 69 63 68 | 20 6d 61 79 20 62 65 20 |) (which| may be |
|00000410| 73 68 6f 72 74 65 72 20 | 74 68 61 6e 20 74 68 65 |shorter |than the|
|00000420| 20 69 6e 66 69 6c 65 20 | 66 69 6c 65 20 6c 65 6e | infile |file len|
|00000430| 67 74 68 29 2e 0d 0d 53 | 61 6d 70 6c 65 20 69 6e |gth)...S|ample in|
|00000440| 70 75 74 0d 0d 61 62 63 | 64 65 66 67 68 61 62 62 |put..abc|defghabb|
|00000450| 63 63 63 64 64 64 65 65 | 65 0d 6f 72 0d 30 31 32 |cccdddee|e.or.012|
|00000460| 33 34 35 36 37 38 39 31 | 31 32 33 34 35 36 37 38 |34567891|12345678|
|00000470| 39 32 31 32 33 34 35 36 | 37 38 39 33 31 32 33 34 |92123456|78931234|
|00000480| 35 36 37 38 39 34 31 32 | 33 34 35 36 37 38 39 35 |56789412|34567895|
|00000490| 31 32 33 34 35 36 37 38 | 39 36 31 32 33 34 35 36 |12345678|96123456|
|000004a0| 37 38 39 37 31 32 33 34 | 35 36 37 38 39 31 0d 0d |78971234|567891..|
|000004b0| 53 61 6d 70 6c 65 20 6f | 75 74 70 75 74 0d 0d 63 |Sample o|utput..c|
|000004c0| 63 63 63 64 64 64 64 65 | 65 65 65 62 62 62 61 61 |cccdddde|eeebbbaa|
|000004d0| 66 67 68 0d 6f 72 0d 31 | 31 31 31 31 31 31 31 31 |fgh.or.1|11111111|
|000004e0| 31 32 32 32 32 32 32 32 | 32 32 33 33 33 33 33 33 |12222222|22333333|
|000004f0| 33 33 33 34 34 34 34 34 | 34 34 34 34 35 35 35 35 |33344444|44445555|
|00000500| 35 35 35 35 35 36 36 36 | 36 36 36 36 36 36 37 37 |55555666|66666677|
|00000510| 37 37 37 37 37 37 37 38 | 38 38 38 38 38 38 38 39 |77777778|88888889|
|00000520| 39 39 39 39 39 39 39 30 | 0d 2a 2f 0d 0d 23 69 6e |99999990|.*/..#in|
|00000530| 63 6c 75 64 65 20 22 53 | 6f 6c 75 74 69 6f 6e 2e |clude "S|olution.|
|00000540| 68 22 0d 0d 2f 2f 20 46 | 69 6c 6c 20 69 6e 20 79 |h"..// F|ill in y|
|00000550| 6f 75 72 20 73 6f 6c 75 | 74 69 6f 6e 20 61 6e 64 |our solu|tion and|
|00000560| 20 74 68 65 6e 20 73 75 | 62 6d 69 74 20 74 68 69 | then su|bmit thi|
|00000570| 73 20 66 6f 6c 64 65 72 | 0d 0d 2f 2f 20 54 65 61 |s folder|..// Tea|
|00000580| 6d 20 4e 61 6d 65 3a 20 | 46 49 4c 4c 20 49 4e 20 |m Name: |FILL IN |
|00000590| 59 4f 55 52 20 54 45 41 | 4d 20 4e 41 4d 45 21 0d |YOUR TEA|M NAME!.|
|000005a0| 0d 70 61 73 63 61 6c 20 | 4f 53 45 72 72 20 4d 6f |.pascal |OSErr Mo|
|000005b0| 64 65 53 6f 72 74 28 20 | 63 6f 6e 73 74 20 46 53 |deSort( |const FS|
|000005c0| 53 70 65 63 2a 20 69 6e | 66 69 6c 65 2c 20 63 6f |Spec* in|file, co|
|000005d0| 6e 73 74 20 46 53 53 70 | 65 63 2a 20 6f 75 74 66 |nst FSSp|ec* outf|
|000005e0| 69 6c 65 20 29 0d 7b 0d | 09 72 65 74 75 72 6e 20 |ile ).{.|.return |
|000005f0| 6e 6f 45 72 72 3b 0d 7d | 0d 00 00 00 00 00 00 00 |noErr;.}|........|
|00000600| 00 00 01 00 00 00 01 54 | 00 00 00 54 00 00 00 46 |.......T|...T...F|
|00000610| 2b 30 38 30 30 31 35 3a | 35 35 3a 33 32 20 31 39 |+080015:|55:32 19|
|00000620| 39 38 00 00 00 00 00 00 | 00 00 b1 78 6a 77 00 00 |98......|...xjw..|
|00000630| 0b 53 6f 6c 75 74 69 6f | 6e 2e 63 70 61 63 48 61 |.Solutio|n.cpacHa|
|00000640| 63 6b 20 43 6f 6e 74 65 | 73 74 31 2e 73 69 74 69 |ck Conte|st1.siti|
|00000650| 02 4a 50 61 72 74 53 49 | 54 21 00 00 00 00 00 00 |.JPartSI|T!......|
|00000660| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000670| 00 00 b1 b0 40 8c 00 00 | 00 00 00 00 01 9a 00 00 |....@...|........|
|00000680| 00 00 29 bc 7f 92 00 00 | 00 00 20 52 65 3a 20 46 |..).....|.. Re: F|
|00000690| 6f 6c 64 65 72 20 48 69 | 65 72 61 72 63 68 79 20 |older Hi|erarchy |
|000006a0| 44 75 70 6c 69 63 61 74 | 69 6f 6e 0d 00 00 00 00 |Duplicat|ion.....|
|000006b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000006c0| 00 00 00 00 00 00 00 00 | 00 04 36 35 37 a4 00 00 |........|..657...|
|000006d0| 00 00 00 00 00 00 00 00 | 00 01 be ab 00 00 05 f2 |........|........|
|000006e0| 00 00 02 90 02 07 31 32 | 2f 35 2f 39 38 34 30 30 |......12|/5/98400|
|000006f0| 30 32 31 3a 30 31 3a 35 | 36 20 31 39 39 38 00 00 |021:01:5|6 1998..|
|00000700| 00 00 00 48 00 0a 47 65 | 6e 65 76 61 00 00 00 00 |...H..Ge|neva....|
|00000710| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000720| 00 00 00 00 00 00 00 02 | 00 02 00 28 00 0a 01 c2 |........|...(....|
|00000730| 02 80 00 28 00 0a 01 c2 | 02 80 b1 ae ad 72 00 00 |...(....|.....r..|
|00000740| 05 79 00 00 05 79 00 00 | 03 1c 01 00 00 00 00 04 |.y...y..|........|
|00000750| 00 01 00 01 00 00 01 00 | 00 00 01 54 00 00 00 54 |........|...T...T|
|00000760| 00 00 00 46 00 ce 0d f8 | 26 32 00 00 00 1c 00 46 |...F....|&2.....F|
|00000770| 00 01 4d 50 53 52 00 00 | 00 12 4d 57 42 42 00 00 |..MPSR..|..MWBB..|
|00000780| 00 1e 03 ed ff ff 00 00 | 00 00 00 00 00 00 03 f0 |........|........|
|00000790| ff ff 00 00 00 4c 00 00 | 00 00 00 00 00 00 00 00 |.....L..|........|
|000007a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+