{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-06T14:01:22.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-06T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":2186,"title":"GJam 2012 Qualifier: Tongues","description":"This Challenge is a Warm-Up for \u003chttp://code.google.com/codejam/schedule.html Google Code Jam 2014\u003e Qualifying round coming up on April 11, 2014. Registration starts March 11, 2014. The Google site has many practice cases with input validation check.\r\n\r\nThis Challenge is \u003chttp://code.google.com/codejam/contest/1460488/dashboard Tongues from 2012 Qualifier\u003e, an alphabet substitution. The \"Googlerese\" needs to be translated back to normal. Normal to G samples are  'a' -\u003e 'y', 'o' -\u003e 'e', and 'z' -\u003e 'q'. This means that \"a zoo\" will become \"y qee\" in G. \r\n\r\nAdditional samples of G to Normal to determine translation are:\r\n\r\n  ejp mysljylc kd kxveddknmc re jsicpdrysi\r\n  rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd\r\n  de kr kd eoya kw aej tysr re ujdr lkgc jv\r\n  to:\r\n  our language is impossible to understand\r\n  there are twenty six factorial possibilities\r\n  so it is okay if you want to just give up\r\n\r\n*Input:* str  of G\r\n\r\n*Output:* str of translated letters\r\n\r\n*Google Code Jam Notes:*\r\nThe contest entry format is very strict and requires a little practice with fprintf. The data formats are 1980 vintage FORTRAN based. The usage of fgetl, fscanf, and dlmread may be used based upon data set. My preference is to read the Data set into a cell array and then loop over the processing as a function call with a line of output per call. I plan to post sets of input read and output write models.\r\n\r\n\r\n\r\n\r\n  ","description_html":"\u003cp\u003eThis Challenge is a Warm-Up for \u003ca href = \"http://code.google.com/codejam/schedule.html\"\u003eGoogle Code Jam 2014\u003c/a\u003e Qualifying round coming up on April 11, 2014. Registration starts March 11, 2014. The Google site has many practice cases with input validation check.\u003c/p\u003e\u003cp\u003eThis Challenge is \u003ca href = \"http://code.google.com/codejam/contest/1460488/dashboard\"\u003eTongues from 2012 Qualifier\u003c/a\u003e, an alphabet substitution. The \"Googlerese\" needs to be translated back to normal. Normal to G samples are  'a' -\u0026gt; 'y', 'o' -\u0026gt; 'e', and 'z' -\u0026gt; 'q'. This means that \"a zoo\" will become \"y qee\" in G.\u003c/p\u003e\u003cp\u003eAdditional samples of G to Normal to determine translation are:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eejp mysljylc kd kxveddknmc re jsicpdrysi\r\nrbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd\r\nde kr kd eoya kw aej tysr re ujdr lkgc jv\r\nto:\r\nour language is impossible to understand\r\nthere are twenty six factorial possibilities\r\nso it is okay if you want to just give up\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e str  of G\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e str of translated letters\u003c/p\u003e\u003cp\u003e\u003cb\u003eGoogle Code Jam Notes:\u003c/b\u003e\r\nThe contest entry format is very strict and requires a little practice with fprintf. The data formats are 1980 vintage FORTRAN based. The usage of fgetl, fscanf, and dlmread may be used based upon data set. My preference is to read the Data set into a cell array and then loop over the processing as a function call with a line of output per call. I plan to post sets of input read and output write models.\u003c/p\u003e","function_template":"function str = Tongues(sin)\r\n  str=sin;\r\nend","test_suite":"%%\r\nsin='ejp mysljylc kd kxveddknmc re jsicpdrysi';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'our language is impossible to understand'))\r\n%%\r\nsin='rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'there are twenty six factorial possibilities'))\r\n%%\r\nsin='de kr kd eoya kw aej tysr re ujdr lkgc jv';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'so it is okay if you want to just give up'))\r\n%%\r\nsin='hello i am the google code jam test data';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'xoggk d yl wxo vkkvgo ekso uyl wonw sywy'))\r\n%%\r\nsin='how are you';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'xkf yto akj'))\r\n%%\r\nsin='aynny iynny aynny iynny aynny iynny aynny iynny aynny iynny aynny iynny aynny iynny aynny ieeeeeeeee';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'yabba dabba yabba dabba yabba dabba yabba dabba yabba dabba yabba dabba yabba dabba yabba dooooooooo'))\r\n%%\r\nsin='y n f i c w l b k u o m x s e v z p d r j g a t h a q set k oset xa ynfd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'a b c d e f g h i j k l m n o p q r s t u v y w x y z now i know my abcs'))\r\n%%\r\nsin='schr rkxc tesr aej dksl tkrb xc';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'next time wont you sing with me'))\r\n%%\r\nsin='wep rbedc tbe dvcyo ks y resljc ie ser dvcyo re erbcp vcevmc';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'for those who speak in a tongue do not speak to other people'))\r\n%%\r\nsin='seneia jsicpdrysid rbcx dksfc rbca ypc dvcyoksl xadrcpkcd ks rbc dvkpkr';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'nobody understands them since they are speaking mysteries in the spirit'))\r\n%%\r\nsin='rbkd kd de chfkrksl k bygc re le rbc nyrbpeex';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'this is so exciting i have to go the bathroom'))\r\n%%\r\nsin='kr tyd rbc ncdr ew rkxcd kr tyd rbc nmjpdr ew rkxcd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'it was the best of times it was the blurst of times'))\r\n%%\r\nsin='mcr mkvd ie tbyr bysid ie';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'let lips do what hands do'))\r\n%%\r\nsin='rbkd bcpc kd ljsveticp yfrkgyrci rtcsra dcgcs fymkncp wjmm yjre se okfonyfo sykmrbpetksl xyabcx';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'this here is gunpowder activated twenty seven caliber full auto no kickback nailthrowing mayhem'))\r\n%%\r\nsin='k bygc ncdrci wpjkr dvkoc ysi xees set k dbymm ncdr aej rbc lja';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'i have bested fruit spike and moon now i shall best you the guy'))\r\n%%\r\nsin='eb byk kx ks jp fexvjrcp cyrksl aejp fbccqnjplcpd ysi leelmcpcdksl aejp rchrq';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'oh hai im in ur computer eating your cheezburgers and googleresing your textz'))\r\n%%\r\nsin='ys cac wep ys cac ysi y vklces wep y vklces';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'an eye for an eye and a pigeon for a pigeon'))\r\n%%\r\nsin='ymm aejp nydc ypc ncmesl re cppep rbc dveesa nypi';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'all your base are belong to error the spoony bard'))\r\n%%\r\nsin='aej vkddci eww rbc fbkfocs myia';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'you pissed off the chicken lady'))\r\n%%\r\nsin='set kd rbc djxxcp ew ejp myfo ew ikdfesrcsr';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'now is the summer of our lack of discontent'))\r\n%%\r\nsin='na rbc vpkfoksl ew xa rbjxnd dexcrbksl tkfoci rbkd tya fexcd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'by the pricking of my thumbs something wicked this way comes'))\r\n%%\r\nsin='ks y tepmi ew ikpctemgcd ysi mkesd dexcrkxcd rbc pypcdr fpcyrjpc kd y wpkcsi';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'in a world of direwolves and lions sometimes the rarest creature is a friend'))\r\n%%\r\nsin='lpccrksld fbccdc vevdkfmc rbc sjxncp aej bygc ikymci kd fjppcsrma ejr ew vepofbevd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'greetings cheese popsicle the number you have dialed is currently out of porkchops'))\r\n%%\r\nsin='tba ie vpelpyxxcpd ymtyad xkh jv bymmetccs ysi fbpkdrxyd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'why do programmers always mix up halloween and christmas'))\r\n%%\r\nsin='kx fexxysicp dbcvypi ysi rbkd kd xa wygepkrc vpenmcx es rbc leelmc feic uyx';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'im commander shepard and this is my favorite problem on the google code jam'))\r\n%%\r\nsin='w ew rte czjymd w ew esc czjymd esc';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'f of two equals f of one equals one'))\r\n%%\r\nsin='wep k ncrtccs rbpcc ysi s w ew k czjymd w ew k xksjd esc vmjd w ew k xksjd rte';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'for i between three and n f of i equals f of i minus one plus f of i minus two'))\r\n%%\r\nsin='bet ypc aej bemiksl jv ncfyjdc kx y veryre';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'how are you holding up because im a potato'))\r\n%%\r\nsin='ip qykjd ip qykjd ip qykjd ip qykjd eeeeeeeeeeeeb ip qykjd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'dr zaius dr zaius dr zaius dr zaius ooooooooooooh dr zaius'))\r\n%%\r\nsin='tbeeeeeeeeeeeeeeeeeeeyyyyyyyyy k oset f vmjd vmjd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'whoooooooooooooooooooaaaaaaaaa i know c plus plus'))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":19,"test_suite_updated_at":"2014-02-16T18:14:55.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-02-16T18:04:01.000Z","updated_at":"2026-01-28T10:40:23.000Z","published_at":"2014-02-16T18:11:52.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is a Warm-Up for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://code.google.com/codejam/schedule.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGoogle Code Jam 2014\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e Qualifying round coming up on April 11, 2014. Registration starts March 11, 2014. The Google site has many practice cases with input validation check.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://code.google.com/codejam/contest/1460488/dashboard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eTongues from 2012 Qualifier\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, an alphabet substitution. The \\\"Googlerese\\\" needs to be translated back to normal. Normal to G samples are 'a' -\u0026gt; 'y', 'o' -\u0026gt; 'e', and 'z' -\u0026gt; 'q'. This means that \\\"a zoo\\\" will become \\\"y qee\\\" in G.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAdditional samples of G to Normal to determine translation are:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ejp mysljylc kd kxveddknmc re jsicpdrysi\\nrbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd\\nde kr kd eoya kw aej tysr re ujdr lkgc jv\\nto:\\nour language is impossible to understand\\nthere are twenty six factorial possibilities\\nso it is okay if you want to just give up]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e str of G\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e str of translated letters\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eGoogle Code Jam Notes:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e The contest entry format is very strict and requires a little practice with fprintf. The data formats are 1980 vintage FORTRAN based. The usage of fgetl, fscanf, and dlmread may be used based upon data set. My preference is to read the Data set into a cell array and then loop over the processing as a function call with a line of output per call. I plan to post sets of input read and output write models.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2291,"title":"GJam 2014 Qualifier: Deceitful War (Small)","description":"This Challenge is derived from \u003chttp://code.google.com/codejam/contest/2974486/dashboard#s=p3 GJam 2014 Qualifier Deceitful War\u003e.\r\n\r\nMy condensed summary of the problem statement.\r\n\r\nGiven two players, A and B, they are each given N masses. All masses are unique. Player A plays first on each comparison and states a Mass. Player B then plays a Mass. The player with the higher mass wins a point after they are compared on a scale. These masses then disappear. This repeats for all N masses. There are no constraints on the order of pieces played.\r\n\r\nUnsurprisingly when A truthfully states masses player B consistently wins.\r\n\r\nPlayer A, discouraged, decides to cheat. After the masses are provided player A asks B get A a drink and while B is away A looks at B's masses. Player A now plays pieces but does not necessarily honestly state the mass values. All scale comparisons must be valid based on B's strategy and A's stated mass. Player A now achieves more wins.\r\n\r\nPart one is determine the best possible score for A when playing deceitfully.\r\n\r\nPart two is determine the best possible score if player A did not look and is honest.\r\n\r\n*Examples:*\r\n\r\n  A: 0.5 0.1 0.9  B 0.6 0.4 0.3  Deceitful Wins 2, Optimal Honest 1\r\n  \r\n  A 0.186 0.389 0.907 0.832 0.959 0.557 0.300 0.992 0.899\r\n  B 0.916 0.728 0.271 0.520 0.700 0.521 0.215 0.341 0.458\r\n  Deceitful A Wins 8\r\n  Optimal Honest A Wins 4\r\n\r\n*Input:* A,B vectors of length N (Small has N\u003c=10, Large(future challenge N\u003c=1000)\r\n\r\n*Output:* Deceitful Wins, Optimal Honest Wins\r\n\r\n\r\n\r\n\r\n\r\n*Note:*\r\n\r\nIn the contest period there were 30 Matlab solutions, of which I was not one as I glitched on the easy Deceitful algorithm thinking my Honest algorithm was in error. \u003chttp://www.go-hero.net/jam/14/solutions/0/4/MATLAB GJam Deceitful Solutions\u003e. My post contest full GJam is in the test suite. About 11000 out of 28000 entrants solved this puzzle.","description_html":"\u003cp\u003eThis Challenge is derived from \u003ca href = \"http://code.google.com/codejam/contest/2974486/dashboard#s=p3\"\u003eGJam 2014 Qualifier Deceitful War\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eMy condensed summary of the problem statement.\u003c/p\u003e\u003cp\u003eGiven two players, A and B, they are each given N masses. All masses are unique. Player A plays first on each comparison and states a Mass. Player B then plays a Mass. The player with the higher mass wins a point after they are compared on a scale. These masses then disappear. This repeats for all N masses. There are no constraints on the order of pieces played.\u003c/p\u003e\u003cp\u003eUnsurprisingly when A truthfully states masses player B consistently wins.\u003c/p\u003e\u003cp\u003ePlayer A, discouraged, decides to cheat. After the masses are provided player A asks B get A a drink and while B is away A looks at B's masses. Player A now plays pieces but does not necessarily honestly state the mass values. All scale comparisons must be valid based on B's strategy and A's stated mass. Player A now achieves more wins.\u003c/p\u003e\u003cp\u003ePart one is determine the best possible score for A when playing deceitfully.\u003c/p\u003e\u003cp\u003ePart two is determine the best possible score if player A did not look and is honest.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExamples:\u003c/b\u003e\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eA: 0.5 0.1 0.9  B 0.6 0.4 0.3  Deceitful Wins 2, Optimal Honest 1\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eA 0.186 0.389 0.907 0.832 0.959 0.557 0.300 0.992 0.899\r\nB 0.916 0.728 0.271 0.520 0.700 0.521 0.215 0.341 0.458\r\nDeceitful A Wins 8\r\nOptimal Honest A Wins 4\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e A,B vectors of length N (Small has N\u0026lt;=10, Large(future challenge N\u0026lt;=1000)\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e Deceitful Wins, Optimal Honest Wins\u003c/p\u003e\u003cp\u003e\u003cb\u003eNote:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eIn the contest period there were 30 Matlab solutions, of which I was not one as I glitched on the easy Deceitful algorithm thinking my Honest algorithm was in error. \u003ca href = \"http://www.go-hero.net/jam/14/solutions/0/4/MATLAB\"\u003eGJam Deceitful Solutions\u003c/a\u003e. My post contest full GJam is in the test suite. About 11000 out of 28000 entrants solved this puzzle.\u003c/p\u003e","function_template":"function W = War(m)\r\n% W=[Deceitful Wins, Optimal Honest Wins]\r\n  W=[0 0];\r\nend","test_suite":"%%\r\nm=[0.270000 0.550000 0.910000 0.330000 0.520000 0.300000 ;0.850000 0.450000 0.060000 0.240000 0.120000 0.880000 ];\r\nWexp=[5 3];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.164000 0.255000 0.009000 0.445000 0.209000 0.100000 0.391000 0.536000 0.027000 0.118000 ;0.673000 0.782000 0.582000 0.882000 0.591000 0.855000 0.745000 0.955000 0.991000 0.600000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.800000 0.480000 0.760000 0.680000 0.160000 0.640000 0.360000 ;0.200000 0.440000 0.960000 0.280000 0.880000 0.520000 0.120000 ];\r\nWexp=[5 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.170000 0.100000 0.120000 0.200000 0.540000 0.150000 ;0.490000 0.070000 0.240000 0.680000 0.610000 0.340000 ];\r\nWexp=[2 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.780000 0.770000 0.900000 0.810000 0.880000 0.840000 0.600000 0.730000 0.930000 0.990000 ;0.270000 0.150000 0.260000 0.510000 0.570000 0.310000 0.170000 0.140000 0.400000 0.040000 ];\r\nWexp=[10 10];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.320000 0.820000 0.350000 0.770000 0.020000 0.550000 0.040000 0.990000 0.610000 0.190000 ;0.730000 0.530000 0.750000 0.800000 0.670000 0.870000 0.330000 0.250000 0.080000 0.680000 ];\r\nWexp=[7 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.510000 0.100000 0.380000 0.050000 0.210000 0.130000 0.440000 0.180000 ;0.560000 0.920000 0.540000 0.900000 0.670000 0.790000 0.820000 0.970000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.420000 ;0.080000 ];\r\nWexp=[1 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.690000 0.310000 0.540000 0.230000 0.710000 0.030000 0.490000 0.600000 0.510000 0.860000 ;0.830000 0.340000 0.370000 0.740000 0.430000 0.200000 0.090000 0.170000 0.910000 0.400000 ];\r\nWexp=[8 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.300000 0.920000 0.710000 0.130000 0.230000 0.620000 0.140000 0.260000 0.360000 0.310000 ;0.440000 0.010000 0.640000 0.350000 0.820000 0.550000 0.780000 0.790000 0.060000 0.570000 ];\r\nWexp=[6 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.504000 0.218000 0.479000 0.101000 0.050000 0.445000 0.471000 0.084000 0.034000 0.008000 ;0.992000 0.546000 0.647000 0.849000 0.891000 0.739000 0.765000 0.555000 0.613000 0.748000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.570000 0.470000 0.640000 0.550000 0.060000 0.430000 0.040000 0.280000 0.130000 0.510000 ;0.700000 0.740000 0.770000 0.810000 0.870000 0.790000 0.940000 0.910000 0.850000 0.660000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.200000 0.020000 0.510000 0.120000 0.220000 0.250000 0.100000 0.490000 0.530000 0.350000 ;0.800000 0.960000 0.760000 0.820000 0.710000 0.570000 0.940000 0.690000 0.900000 0.550000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.260000 0.030000 0.360000 0.410000 0.330000 0.430000 0.540000 0.300000 0.280000 0.100000 ;0.770000 0.910000 0.700000 0.550000 0.590000 0.780000 0.650000 0.860000 0.750000 0.990000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.920000 0.370000 0.900000 0.200000 0.150000 0.020000 0.530000 0.860000 0.250000 0.190000 ;0.170000 0.980000 0.140000 0.680000 0.830000 0.470000 0.950000 0.340000 0.880000 0.540000 ];\r\nWexp=[7 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.510000 0.020000 0.490000 0.280000 0.080000 0.830000 0.170000 0.140000 0.850000 ;0.420000 0.650000 0.950000 0.890000 0.030000 0.580000 0.380000 0.060000 0.370000 ];\r\nWexp=[6 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.670000 0.050000 0.590000 0.330000 0.820000 0.030000 0.740000 0.560000 0.950000 0.620000 ;0.210000 0.380000 0.770000 0.080000 0.260000 0.640000 0.460000 0.790000 0.310000 0.410000 ];\r\nWexp=[8 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.840000 0.800000 0.420000 0.580000 0.670000 0.070000 0.360000 ;0.690000 0.870000 0.310000 0.600000 0.760000 0.200000 0.380000 ];\r\nWexp=[6 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.450000 0.380000 0.280000 0.590000 0.620000 0.230000 0.810000 ;0.320000 0.190000 0.680000 0.140000 0.090000 0.940000 0.170000 ];\r\nWexp=[6 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.207000 0.288000 0.180000 0.595000 0.748000 0.459000 0.802000 0.387000 0.027000 0.090000 ;0.450000 0.982000 0.694000 0.613000 0.486000 0.423000 0.685000 0.847000 0.432000 0.604000 ];\r\nWexp=[4 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.750000 0.970000 0.820000 0.840000 0.680000 0.780000 0.730000 0.270000 0.220000 0.150000 ;0.130000 0.920000 0.390000 0.320000 0.230000 0.080000 0.800000 0.330000 0.720000 0.590000 ];\r\nWexp=[10 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.260000 0.140000 0.600000 0.950000 0.160000 0.650000 0.580000 0.910000 0.230000 0.020000 ;0.120000 0.510000 0.530000 0.280000 0.350000 0.070000 0.400000 0.930000 0.490000 0.090000 ];\r\nWexp=[8 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.545000 0.527000 0.500000 0.727000 0.018000 0.400000 0.191000 0.982000 0.409000 0.591000 ;0.945000 0.745000 0.355000 0.673000 0.045000 0.118000 0.682000 0.827000 0.645000 0.482000 ];\r\nWexp=[6 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.930000 0.980000 0.470000 0.810000 0.830000 0.460000 0.510000 0.540000 ;0.490000 0.640000 0.170000 0.290000 0.140000 0.440000 0.590000 0.760000 ];\r\nWexp=[8 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.580000 ;0.330000 ];\r\nWexp=[1 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.640000 0.820000 0.700000 0.480000 0.520000 0.610000 0.060000 0.240000 0.300000 ;0.550000 0.450000 0.090000 0.030000 0.850000 0.670000 0.760000 0.360000 0.790000 ];\r\nWexp=[7 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.800000 ;0.900000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.340000 0.100000 0.040000 0.110000 0.650000 0.250000 0.570000 0.480000 0.150000 0.800000 ;0.550000 0.020000 0.920000 0.080000 0.700000 0.360000 0.910000 0.710000 0.820000 0.850000 ];\r\nWexp=[5 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.340000 0.890000 0.060000 0.090000 0.750000 0.730000 0.810000 0.950000 0.660000 0.390000 ;0.530000 0.970000 0.610000 0.670000 0.690000 0.380000 0.590000 0.300000 0.720000 0.110000 ];\r\nWexp=[8 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.870000 0.600000 0.860000 0.830000 0.680000 0.810000 0.700000 0.920000 0.760000 ;0.170000 0.510000 0.330000 0.050000 0.240000 0.030000 0.410000 0.480000 0.520000 ];\r\nWexp=[9 9];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.940000 0.720000 0.810000 0.220000 0.280000 0.530000 0.440000 0.160000 0.880000 0.970000 ;0.120000 0.030000 0.470000 0.560000 0.380000 0.340000 0.690000 0.090000 0.250000 0.750000 ];\r\nWexp=[10 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.410000 0.360000 0.230000 0.140000 0.180000 0.050000 0.500000 0.270000 0.090000 0.450000 ;0.680000 0.950000 0.910000 0.860000 0.730000 0.550000 0.590000 0.820000 0.640000 0.770000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.278000 0.852000 0.370000 0.824000 0.389000 0.704000 0.546000 0.204000 0.296000 0.056000 ;0.833000 0.315000 0.991000 0.028000 0.907000 0.630000 0.361000 0.037000 0.065000 0.954000 ];\r\nWexp=[7 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.713000 0.657000 0.778000 0.435000 0.565000 0.870000 0.963000 0.343000 0.481000 0.593000 ;0.287000 0.333000 0.454000 0.130000 0.370000 0.759000 0.176000 0.611000 0.231000 0.398000 ];\r\nWexp=[10 6];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.590000 0.750000 0.650000 0.900000 0.740000 0.880000 0.850000 ;0.400000 0.070000 0.540000 0.380000 0.570000 0.150000 0.490000 ];\r\nWexp=[7 7];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.110000 0.920000 0.540000 0.840000 0.380000 0.770000 0.900000 0.490000 0.870000 0.750000 ;0.620000 0.480000 0.330000 0.440000 0.890000 0.130000 0.430000 0.080000 0.340000 0.560000 ];\r\nWexp=[10 5];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.480000 0.650000 0.770000 0.690000 0.720000 0.560000 0.660000 0.550000 0.510000 0.730000 ;0.310000 0.440000 0.300000 0.060000 0.200000 0.420000 0.030000 0.070000 0.110000 0.140000 ];\r\nWexp=[10 10];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.900000 0.680000 0.600000 0.800000 ;0.350000 0.050000 0.170000 0.880000 ];\r\nWexp=[4 3];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.730000 0.910000 0.450000 0.640000 0.090000 ;0.550000 0.360000 0.270000 0.820000 0.180000 ];\r\nWexp=[4 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.530000 0.740000 0.410000 0.320000 0.820000 0.970000 0.620000 0.500000 0.710000 0.090000 ;0.180000 0.760000 0.380000 0.150000 0.470000 0.210000 0.560000 0.120000 0.590000 0.440000 ];\r\nWexp=[9 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.487000 0.092000 0.714000 0.160000 0.504000 0.277000 0.479000 0.605000 0.462000 0.832000 ;0.210000 0.824000 0.118000 0.387000 0.664000 0.874000 0.445000 0.739000 0.546000 0.017000 ];\r\nWexp=[8 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.100000 ;0.400000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.688000 0.872000 0.615000 0.477000 0.734000 0.624000 0.394000 0.532000 0.954000 0.817000 ;0.193000 0.119000 0.349000 0.073000 0.037000 0.009000 0.128000 0.303000 0.046000 0.064000 ];\r\nWexp=[10 10];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.910000 0.550000 0.300000 0.570000 0.920000 0.400000 0.450000 0.150000 0.110000 0.190000 ;0.090000 0.790000 0.890000 0.740000 0.850000 0.940000 0.340000 0.380000 0.720000 0.260000 ];\r\nWexp=[6 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.723000 0.639000 0.824000 0.697000 0.840000 0.882000 0.437000 0.782000 0.588000 0.218000 ;0.345000 0.151000 0.067000 0.849000 0.815000 0.235000 0.521000 0.765000 0.950000 0.681000 ];\r\nWexp=[9 3];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.200000 0.150000 0.350000 0.090000 0.110000 0.330000 0.220000 ;0.390000 0.460000 0.850000 0.700000 0.570000 0.610000 0.500000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.850000 0.790000 0.550000 0.380000 0.300000 0.400000 0.770000 0.740000 0.320000 0.570000 ;0.260000 0.210000 0.110000 0.130000 0.020000 0.040000 0.230000 0.190000 0.090000 0.060000 ];\r\nWexp=[10 10];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.961000 0.330000 0.010000 0.816000 0.583000 0.913000 0.893000 0.951000 0.126000 0.398000 ;0.767000 0.029000 0.262000 0.641000 0.175000 0.544000 0.359000 0.932000 0.680000 0.476000 ];\r\nWexp=[9 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.300000 ;0.700000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.240000 0.050000 0.190000 0.110000 0.920000 0.590000 0.730000 0.380000 0.780000 0.950000 ;0.860000 0.700000 0.430000 0.620000 0.220000 0.540000 0.410000 0.890000 0.680000 0.490000 ];\r\nWexp=[6 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\n% function GJam_Qual_2014d\r\n% % \r\n% %War\r\n% fn='D-small-attempt0.in';\r\n% %fn='D-large.in';\r\n% [data] = read_file(fn); % \r\n% \r\n% fidG = fopen('D-small-output.out', 'w');\r\n% %fidG = fopen('D-large-output001.out', 'w');\r\n% tic\r\n% \r\n% for i=1:size(data,2) % Cell array has N rows of cases\r\n% % m=sort(data{i},2);\r\n%  m=data{i};\r\n%  dw = dWar(m) ;% \r\n%  w = War(m) ;%  \r\n%  \r\n%    fprintf('Case #%i: %i %i\\n',i,dw,w);\r\n%    fprintf(fidG,'Case #%i: %i %i\\n',i,dw,w);\r\n%     \r\n% end\r\n% toc\r\n% \r\n% fclose(fidG);\r\n% \r\n% end\r\n% \r\n% function dw=dWar(m)\r\n% % Post contest\r\n% % Lie to burn opponent best pieces\r\n%  N=sort(m(1,:));\r\n%  K=sort(m(2,:));\r\n%  \r\n%  dw=0;\r\n%  for i=1:length(N)\r\n%   if N(i)\u003eK(1) % Lie to above to beat lowest\r\n%    dw=dw+1;\r\n%    K=K(2:end);\r\n%   else % Lie to just below best\r\n%    K=K(1:end-1);\r\n%   end\r\n%  end\r\n%  \r\n% end\r\n% \r\n% function w=War(m)\r\n% % Optimal truthful strategy\r\n% % Best lucky sequence\r\n%  w=0;\r\n% \r\n%  Nm=sort(m(1,:));\r\n%  Km=sort(m(2,:));\r\n%  \r\n%  Nmz=[Nm' ones(size(Nm,2),1)];\r\n%  Kmz=[Km' zeros(size(Km,2),1)];\r\n%  z=[Nmz;Kmz]; \r\n%  z=sortrows(z,-1);\r\n%  \r\n%  while ~isempty(z)\r\n%   ptr1=find(z(:,2)==1,1,'last');\r\n%   ptr0=find(z(1:ptr1,2)==0,1,'last');\r\n%   if isempty(ptr0)\r\n%    % score\r\n%    w=w+1;\r\n%    z(ptr1,:)=[];\r\n%    ptr0=find(z(:,2)==0,1,'last');\r\n%    z(ptr0,:)=[];  \r\n%   else\r\n%    z(ptr1,:)=[];\r\n%    z(ptr0,:)=[];  \r\n%   end\r\n%  end \r\n%  % Create worst Ken/B Scenario\r\n%  \r\n% end\r\n% \r\n% \r\n% function [d] = read_file(fn)\r\n% % Read whole array then parse\r\n% % dlmread valid for numeric arrays\r\n%  m=dlmread(fn);\r\n%  m(1,:)=[];\r\n%  for i=1:size(m,1)/3\r\n%   d{i}=m(3*i-1:3*i,1:m(3*i-2,1));\r\n%  end\r\n%  \r\n% end % read_file\r\n% Data Set file\r\n%4\r\n%1\r\n%0.5\r\n%0.6\r\n%2\r\n%0.7 0.2\r\n%0.8 0.3\r\n%3\r\n%0.5 0.1 0.9\r\n%0.6 0.4 0.3\r\n%9\r\n%0.186 0.389 0.907 0.832 0.959 0.557 0.300 0.992 0.899\r\n%0.916 0.728 0.271 0.520 0.700 0.521 0.215 0.341 0.458\r\n\r\n\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":8,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-04-19T14:08:56.000Z","updated_at":"2014-04-19T15:00:47.000Z","published_at":"2014-04-19T15:00:47.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is derived from\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://code.google.com/codejam/contest/2974486/dashboard#s=p3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGJam 2014 Qualifier Deceitful War\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMy condensed summary of the problem statement.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two players, A and B, they are each given N masses. All masses are unique. Player A plays first on each comparison and states a Mass. Player B then plays a Mass. The player with the higher mass wins a point after they are compared on a scale. These masses then disappear. This repeats for all N masses. There are no constraints on the order of pieces played.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eUnsurprisingly when A truthfully states masses player B consistently wins.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePlayer A, discouraged, decides to cheat. After the masses are provided player A asks B get A a drink and while B is away A looks at B's masses. Player A now plays pieces but does not necessarily honestly state the mass values. All scale comparisons must be valid based on B's strategy and A's stated mass. Player A now achieves more wins.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePart one is determine the best possible score for A when playing deceitfully.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePart two is determine the best possible score if player A did not look and is honest.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[A: 0.5 0.1 0.9  B 0.6 0.4 0.3  Deceitful Wins 2, Optimal Honest 1\\n\\nA 0.186 0.389 0.907 0.832 0.959 0.557 0.300 0.992 0.899\\nB 0.916 0.728 0.271 0.520 0.700 0.521 0.215 0.341 0.458\\nDeceitful A Wins 8\\nOptimal Honest A Wins 4]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e A,B vectors of length N (Small has N\u0026lt;=10, Large(future challenge N\u0026lt;=1000)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Deceitful Wins, Optimal Honest Wins\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn the contest period there were 30 Matlab solutions, of which I was not one as I glitched on the easy Deceitful algorithm thinking my Honest algorithm was in error.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.go-hero.net/jam/14/solutions/0/4/MATLAB\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGJam Deceitful Solutions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. My post contest full GJam is in the test suite. About 11000 out of 28000 entrants solved this puzzle.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":2186,"title":"GJam 2012 Qualifier: Tongues","description":"This Challenge is a Warm-Up for \u003chttp://code.google.com/codejam/schedule.html Google Code Jam 2014\u003e Qualifying round coming up on April 11, 2014. Registration starts March 11, 2014. The Google site has many practice cases with input validation check.\r\n\r\nThis Challenge is \u003chttp://code.google.com/codejam/contest/1460488/dashboard Tongues from 2012 Qualifier\u003e, an alphabet substitution. The \"Googlerese\" needs to be translated back to normal. Normal to G samples are  'a' -\u003e 'y', 'o' -\u003e 'e', and 'z' -\u003e 'q'. This means that \"a zoo\" will become \"y qee\" in G. \r\n\r\nAdditional samples of G to Normal to determine translation are:\r\n\r\n  ejp mysljylc kd kxveddknmc re jsicpdrysi\r\n  rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd\r\n  de kr kd eoya kw aej tysr re ujdr lkgc jv\r\n  to:\r\n  our language is impossible to understand\r\n  there are twenty six factorial possibilities\r\n  so it is okay if you want to just give up\r\n\r\n*Input:* str  of G\r\n\r\n*Output:* str of translated letters\r\n\r\n*Google Code Jam Notes:*\r\nThe contest entry format is very strict and requires a little practice with fprintf. The data formats are 1980 vintage FORTRAN based. The usage of fgetl, fscanf, and dlmread may be used based upon data set. My preference is to read the Data set into a cell array and then loop over the processing as a function call with a line of output per call. I plan to post sets of input read and output write models.\r\n\r\n\r\n\r\n\r\n  ","description_html":"\u003cp\u003eThis Challenge is a Warm-Up for \u003ca href = \"http://code.google.com/codejam/schedule.html\"\u003eGoogle Code Jam 2014\u003c/a\u003e Qualifying round coming up on April 11, 2014. Registration starts March 11, 2014. The Google site has many practice cases with input validation check.\u003c/p\u003e\u003cp\u003eThis Challenge is \u003ca href = \"http://code.google.com/codejam/contest/1460488/dashboard\"\u003eTongues from 2012 Qualifier\u003c/a\u003e, an alphabet substitution. The \"Googlerese\" needs to be translated back to normal. Normal to G samples are  'a' -\u0026gt; 'y', 'o' -\u0026gt; 'e', and 'z' -\u0026gt; 'q'. This means that \"a zoo\" will become \"y qee\" in G.\u003c/p\u003e\u003cp\u003eAdditional samples of G to Normal to determine translation are:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eejp mysljylc kd kxveddknmc re jsicpdrysi\r\nrbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd\r\nde kr kd eoya kw aej tysr re ujdr lkgc jv\r\nto:\r\nour language is impossible to understand\r\nthere are twenty six factorial possibilities\r\nso it is okay if you want to just give up\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e str  of G\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e str of translated letters\u003c/p\u003e\u003cp\u003e\u003cb\u003eGoogle Code Jam Notes:\u003c/b\u003e\r\nThe contest entry format is very strict and requires a little practice with fprintf. The data formats are 1980 vintage FORTRAN based. The usage of fgetl, fscanf, and dlmread may be used based upon data set. My preference is to read the Data set into a cell array and then loop over the processing as a function call with a line of output per call. I plan to post sets of input read and output write models.\u003c/p\u003e","function_template":"function str = Tongues(sin)\r\n  str=sin;\r\nend","test_suite":"%%\r\nsin='ejp mysljylc kd kxveddknmc re jsicpdrysi';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'our language is impossible to understand'))\r\n%%\r\nsin='rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'there are twenty six factorial possibilities'))\r\n%%\r\nsin='de kr kd eoya kw aej tysr re ujdr lkgc jv';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'so it is okay if you want to just give up'))\r\n%%\r\nsin='hello i am the google code jam test data';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'xoggk d yl wxo vkkvgo ekso uyl wonw sywy'))\r\n%%\r\nsin='how are you';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'xkf yto akj'))\r\n%%\r\nsin='aynny iynny aynny iynny aynny iynny aynny iynny aynny iynny aynny iynny aynny iynny aynny ieeeeeeeee';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'yabba dabba yabba dabba yabba dabba yabba dabba yabba dabba yabba dabba yabba dabba yabba dooooooooo'))\r\n%%\r\nsin='y n f i c w l b k u o m x s e v z p d r j g a t h a q set k oset xa ynfd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'a b c d e f g h i j k l m n o p q r s t u v y w x y z now i know my abcs'))\r\n%%\r\nsin='schr rkxc tesr aej dksl tkrb xc';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'next time wont you sing with me'))\r\n%%\r\nsin='wep rbedc tbe dvcyo ks y resljc ie ser dvcyo re erbcp vcevmc';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'for those who speak in a tongue do not speak to other people'))\r\n%%\r\nsin='seneia jsicpdrysid rbcx dksfc rbca ypc dvcyoksl xadrcpkcd ks rbc dvkpkr';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'nobody understands them since they are speaking mysteries in the spirit'))\r\n%%\r\nsin='rbkd kd de chfkrksl k bygc re le rbc nyrbpeex';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'this is so exciting i have to go the bathroom'))\r\n%%\r\nsin='kr tyd rbc ncdr ew rkxcd kr tyd rbc nmjpdr ew rkxcd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'it was the best of times it was the blurst of times'))\r\n%%\r\nsin='mcr mkvd ie tbyr bysid ie';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'let lips do what hands do'))\r\n%%\r\nsin='rbkd bcpc kd ljsveticp yfrkgyrci rtcsra dcgcs fymkncp wjmm yjre se okfonyfo sykmrbpetksl xyabcx';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'this here is gunpowder activated twenty seven caliber full auto no kickback nailthrowing mayhem'))\r\n%%\r\nsin='k bygc ncdrci wpjkr dvkoc ysi xees set k dbymm ncdr aej rbc lja';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'i have bested fruit spike and moon now i shall best you the guy'))\r\n%%\r\nsin='eb byk kx ks jp fexvjrcp cyrksl aejp fbccqnjplcpd ysi leelmcpcdksl aejp rchrq';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'oh hai im in ur computer eating your cheezburgers and googleresing your textz'))\r\n%%\r\nsin='ys cac wep ys cac ysi y vklces wep y vklces';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'an eye for an eye and a pigeon for a pigeon'))\r\n%%\r\nsin='ymm aejp nydc ypc ncmesl re cppep rbc dveesa nypi';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'all your base are belong to error the spoony bard'))\r\n%%\r\nsin='aej vkddci eww rbc fbkfocs myia';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'you pissed off the chicken lady'))\r\n%%\r\nsin='set kd rbc djxxcp ew ejp myfo ew ikdfesrcsr';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'now is the summer of our lack of discontent'))\r\n%%\r\nsin='na rbc vpkfoksl ew xa rbjxnd dexcrbksl tkfoci rbkd tya fexcd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'by the pricking of my thumbs something wicked this way comes'))\r\n%%\r\nsin='ks y tepmi ew ikpctemgcd ysi mkesd dexcrkxcd rbc pypcdr fpcyrjpc kd y wpkcsi';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'in a world of direwolves and lions sometimes the rarest creature is a friend'))\r\n%%\r\nsin='lpccrksld fbccdc vevdkfmc rbc sjxncp aej bygc ikymci kd fjppcsrma ejr ew vepofbevd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'greetings cheese popsicle the number you have dialed is currently out of porkchops'))\r\n%%\r\nsin='tba ie vpelpyxxcpd ymtyad xkh jv bymmetccs ysi fbpkdrxyd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'why do programmers always mix up halloween and christmas'))\r\n%%\r\nsin='kx fexxysicp dbcvypi ysi rbkd kd xa wygepkrc vpenmcx es rbc leelmc feic uyx';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'im commander shepard and this is my favorite problem on the google code jam'))\r\n%%\r\nsin='w ew rte czjymd w ew esc czjymd esc';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'f of two equals f of one equals one'))\r\n%%\r\nsin='wep k ncrtccs rbpcc ysi s w ew k czjymd w ew k xksjd esc vmjd w ew k xksjd rte';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'for i between three and n f of i equals f of i minus one plus f of i minus two'))\r\n%%\r\nsin='bet ypc aej bemiksl jv ncfyjdc kx y veryre';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'how are you holding up because im a potato'))\r\n%%\r\nsin='ip qykjd ip qykjd ip qykjd ip qykjd eeeeeeeeeeeeb ip qykjd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'dr zaius dr zaius dr zaius dr zaius ooooooooooooh dr zaius'))\r\n%%\r\nsin='tbeeeeeeeeeeeeeeeeeeeyyyyyyyyy k oset f vmjd vmjd';\r\nstr=Tongues(sin);\r\nassert(strcmp(str,'whoooooooooooooooooooaaaaaaaaa i know c plus plus'))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":19,"test_suite_updated_at":"2014-02-16T18:14:55.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-02-16T18:04:01.000Z","updated_at":"2026-01-28T10:40:23.000Z","published_at":"2014-02-16T18:11:52.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is a Warm-Up for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://code.google.com/codejam/schedule.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGoogle Code Jam 2014\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e Qualifying round coming up on April 11, 2014. Registration starts March 11, 2014. The Google site has many practice cases with input validation check.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://code.google.com/codejam/contest/1460488/dashboard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eTongues from 2012 Qualifier\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, an alphabet substitution. The \\\"Googlerese\\\" needs to be translated back to normal. Normal to G samples are 'a' -\u0026gt; 'y', 'o' -\u0026gt; 'e', and 'z' -\u0026gt; 'q'. This means that \\\"a zoo\\\" will become \\\"y qee\\\" in G.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAdditional samples of G to Normal to determine translation are:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ejp mysljylc kd kxveddknmc re jsicpdrysi\\nrbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd\\nde kr kd eoya kw aej tysr re ujdr lkgc jv\\nto:\\nour language is impossible to understand\\nthere are twenty six factorial possibilities\\nso it is okay if you want to just give up]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e str of G\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e str of translated letters\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eGoogle Code Jam Notes:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e The contest entry format is very strict and requires a little practice with fprintf. The data formats are 1980 vintage FORTRAN based. The usage of fgetl, fscanf, and dlmread may be used based upon data set. My preference is to read the Data set into a cell array and then loop over the processing as a function call with a line of output per call. I plan to post sets of input read and output write models.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2291,"title":"GJam 2014 Qualifier: Deceitful War (Small)","description":"This Challenge is derived from \u003chttp://code.google.com/codejam/contest/2974486/dashboard#s=p3 GJam 2014 Qualifier Deceitful War\u003e.\r\n\r\nMy condensed summary of the problem statement.\r\n\r\nGiven two players, A and B, they are each given N masses. All masses are unique. Player A plays first on each comparison and states a Mass. Player B then plays a Mass. The player with the higher mass wins a point after they are compared on a scale. These masses then disappear. This repeats for all N masses. There are no constraints on the order of pieces played.\r\n\r\nUnsurprisingly when A truthfully states masses player B consistently wins.\r\n\r\nPlayer A, discouraged, decides to cheat. After the masses are provided player A asks B get A a drink and while B is away A looks at B's masses. Player A now plays pieces but does not necessarily honestly state the mass values. All scale comparisons must be valid based on B's strategy and A's stated mass. Player A now achieves more wins.\r\n\r\nPart one is determine the best possible score for A when playing deceitfully.\r\n\r\nPart two is determine the best possible score if player A did not look and is honest.\r\n\r\n*Examples:*\r\n\r\n  A: 0.5 0.1 0.9  B 0.6 0.4 0.3  Deceitful Wins 2, Optimal Honest 1\r\n  \r\n  A 0.186 0.389 0.907 0.832 0.959 0.557 0.300 0.992 0.899\r\n  B 0.916 0.728 0.271 0.520 0.700 0.521 0.215 0.341 0.458\r\n  Deceitful A Wins 8\r\n  Optimal Honest A Wins 4\r\n\r\n*Input:* A,B vectors of length N (Small has N\u003c=10, Large(future challenge N\u003c=1000)\r\n\r\n*Output:* Deceitful Wins, Optimal Honest Wins\r\n\r\n\r\n\r\n\r\n\r\n*Note:*\r\n\r\nIn the contest period there were 30 Matlab solutions, of which I was not one as I glitched on the easy Deceitful algorithm thinking my Honest algorithm was in error. \u003chttp://www.go-hero.net/jam/14/solutions/0/4/MATLAB GJam Deceitful Solutions\u003e. My post contest full GJam is in the test suite. About 11000 out of 28000 entrants solved this puzzle.","description_html":"\u003cp\u003eThis Challenge is derived from \u003ca href = \"http://code.google.com/codejam/contest/2974486/dashboard#s=p3\"\u003eGJam 2014 Qualifier Deceitful War\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eMy condensed summary of the problem statement.\u003c/p\u003e\u003cp\u003eGiven two players, A and B, they are each given N masses. All masses are unique. Player A plays first on each comparison and states a Mass. Player B then plays a Mass. The player with the higher mass wins a point after they are compared on a scale. These masses then disappear. This repeats for all N masses. There are no constraints on the order of pieces played.\u003c/p\u003e\u003cp\u003eUnsurprisingly when A truthfully states masses player B consistently wins.\u003c/p\u003e\u003cp\u003ePlayer A, discouraged, decides to cheat. After the masses are provided player A asks B get A a drink and while B is away A looks at B's masses. Player A now plays pieces but does not necessarily honestly state the mass values. All scale comparisons must be valid based on B's strategy and A's stated mass. Player A now achieves more wins.\u003c/p\u003e\u003cp\u003ePart one is determine the best possible score for A when playing deceitfully.\u003c/p\u003e\u003cp\u003ePart two is determine the best possible score if player A did not look and is honest.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExamples:\u003c/b\u003e\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eA: 0.5 0.1 0.9  B 0.6 0.4 0.3  Deceitful Wins 2, Optimal Honest 1\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eA 0.186 0.389 0.907 0.832 0.959 0.557 0.300 0.992 0.899\r\nB 0.916 0.728 0.271 0.520 0.700 0.521 0.215 0.341 0.458\r\nDeceitful A Wins 8\r\nOptimal Honest A Wins 4\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e A,B vectors of length N (Small has N\u0026lt;=10, Large(future challenge N\u0026lt;=1000)\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e Deceitful Wins, Optimal Honest Wins\u003c/p\u003e\u003cp\u003e\u003cb\u003eNote:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eIn the contest period there were 30 Matlab solutions, of which I was not one as I glitched on the easy Deceitful algorithm thinking my Honest algorithm was in error. \u003ca href = \"http://www.go-hero.net/jam/14/solutions/0/4/MATLAB\"\u003eGJam Deceitful Solutions\u003c/a\u003e. My post contest full GJam is in the test suite. About 11000 out of 28000 entrants solved this puzzle.\u003c/p\u003e","function_template":"function W = War(m)\r\n% W=[Deceitful Wins, Optimal Honest Wins]\r\n  W=[0 0];\r\nend","test_suite":"%%\r\nm=[0.270000 0.550000 0.910000 0.330000 0.520000 0.300000 ;0.850000 0.450000 0.060000 0.240000 0.120000 0.880000 ];\r\nWexp=[5 3];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.164000 0.255000 0.009000 0.445000 0.209000 0.100000 0.391000 0.536000 0.027000 0.118000 ;0.673000 0.782000 0.582000 0.882000 0.591000 0.855000 0.745000 0.955000 0.991000 0.600000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.800000 0.480000 0.760000 0.680000 0.160000 0.640000 0.360000 ;0.200000 0.440000 0.960000 0.280000 0.880000 0.520000 0.120000 ];\r\nWexp=[5 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.170000 0.100000 0.120000 0.200000 0.540000 0.150000 ;0.490000 0.070000 0.240000 0.680000 0.610000 0.340000 ];\r\nWexp=[2 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.780000 0.770000 0.900000 0.810000 0.880000 0.840000 0.600000 0.730000 0.930000 0.990000 ;0.270000 0.150000 0.260000 0.510000 0.570000 0.310000 0.170000 0.140000 0.400000 0.040000 ];\r\nWexp=[10 10];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.320000 0.820000 0.350000 0.770000 0.020000 0.550000 0.040000 0.990000 0.610000 0.190000 ;0.730000 0.530000 0.750000 0.800000 0.670000 0.870000 0.330000 0.250000 0.080000 0.680000 ];\r\nWexp=[7 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.510000 0.100000 0.380000 0.050000 0.210000 0.130000 0.440000 0.180000 ;0.560000 0.920000 0.540000 0.900000 0.670000 0.790000 0.820000 0.970000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.420000 ;0.080000 ];\r\nWexp=[1 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.690000 0.310000 0.540000 0.230000 0.710000 0.030000 0.490000 0.600000 0.510000 0.860000 ;0.830000 0.340000 0.370000 0.740000 0.430000 0.200000 0.090000 0.170000 0.910000 0.400000 ];\r\nWexp=[8 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.300000 0.920000 0.710000 0.130000 0.230000 0.620000 0.140000 0.260000 0.360000 0.310000 ;0.440000 0.010000 0.640000 0.350000 0.820000 0.550000 0.780000 0.790000 0.060000 0.570000 ];\r\nWexp=[6 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.504000 0.218000 0.479000 0.101000 0.050000 0.445000 0.471000 0.084000 0.034000 0.008000 ;0.992000 0.546000 0.647000 0.849000 0.891000 0.739000 0.765000 0.555000 0.613000 0.748000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.570000 0.470000 0.640000 0.550000 0.060000 0.430000 0.040000 0.280000 0.130000 0.510000 ;0.700000 0.740000 0.770000 0.810000 0.870000 0.790000 0.940000 0.910000 0.850000 0.660000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.200000 0.020000 0.510000 0.120000 0.220000 0.250000 0.100000 0.490000 0.530000 0.350000 ;0.800000 0.960000 0.760000 0.820000 0.710000 0.570000 0.940000 0.690000 0.900000 0.550000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.260000 0.030000 0.360000 0.410000 0.330000 0.430000 0.540000 0.300000 0.280000 0.100000 ;0.770000 0.910000 0.700000 0.550000 0.590000 0.780000 0.650000 0.860000 0.750000 0.990000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.920000 0.370000 0.900000 0.200000 0.150000 0.020000 0.530000 0.860000 0.250000 0.190000 ;0.170000 0.980000 0.140000 0.680000 0.830000 0.470000 0.950000 0.340000 0.880000 0.540000 ];\r\nWexp=[7 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.510000 0.020000 0.490000 0.280000 0.080000 0.830000 0.170000 0.140000 0.850000 ;0.420000 0.650000 0.950000 0.890000 0.030000 0.580000 0.380000 0.060000 0.370000 ];\r\nWexp=[6 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.670000 0.050000 0.590000 0.330000 0.820000 0.030000 0.740000 0.560000 0.950000 0.620000 ;0.210000 0.380000 0.770000 0.080000 0.260000 0.640000 0.460000 0.790000 0.310000 0.410000 ];\r\nWexp=[8 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.840000 0.800000 0.420000 0.580000 0.670000 0.070000 0.360000 ;0.690000 0.870000 0.310000 0.600000 0.760000 0.200000 0.380000 ];\r\nWexp=[6 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.450000 0.380000 0.280000 0.590000 0.620000 0.230000 0.810000 ;0.320000 0.190000 0.680000 0.140000 0.090000 0.940000 0.170000 ];\r\nWexp=[6 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.207000 0.288000 0.180000 0.595000 0.748000 0.459000 0.802000 0.387000 0.027000 0.090000 ;0.450000 0.982000 0.694000 0.613000 0.486000 0.423000 0.685000 0.847000 0.432000 0.604000 ];\r\nWexp=[4 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.750000 0.970000 0.820000 0.840000 0.680000 0.780000 0.730000 0.270000 0.220000 0.150000 ;0.130000 0.920000 0.390000 0.320000 0.230000 0.080000 0.800000 0.330000 0.720000 0.590000 ];\r\nWexp=[10 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.260000 0.140000 0.600000 0.950000 0.160000 0.650000 0.580000 0.910000 0.230000 0.020000 ;0.120000 0.510000 0.530000 0.280000 0.350000 0.070000 0.400000 0.930000 0.490000 0.090000 ];\r\nWexp=[8 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.545000 0.527000 0.500000 0.727000 0.018000 0.400000 0.191000 0.982000 0.409000 0.591000 ;0.945000 0.745000 0.355000 0.673000 0.045000 0.118000 0.682000 0.827000 0.645000 0.482000 ];\r\nWexp=[6 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.930000 0.980000 0.470000 0.810000 0.830000 0.460000 0.510000 0.540000 ;0.490000 0.640000 0.170000 0.290000 0.140000 0.440000 0.590000 0.760000 ];\r\nWexp=[8 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.580000 ;0.330000 ];\r\nWexp=[1 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.640000 0.820000 0.700000 0.480000 0.520000 0.610000 0.060000 0.240000 0.300000 ;0.550000 0.450000 0.090000 0.030000 0.850000 0.670000 0.760000 0.360000 0.790000 ];\r\nWexp=[7 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.800000 ;0.900000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.340000 0.100000 0.040000 0.110000 0.650000 0.250000 0.570000 0.480000 0.150000 0.800000 ;0.550000 0.020000 0.920000 0.080000 0.700000 0.360000 0.910000 0.710000 0.820000 0.850000 ];\r\nWexp=[5 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.340000 0.890000 0.060000 0.090000 0.750000 0.730000 0.810000 0.950000 0.660000 0.390000 ;0.530000 0.970000 0.610000 0.670000 0.690000 0.380000 0.590000 0.300000 0.720000 0.110000 ];\r\nWexp=[8 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.870000 0.600000 0.860000 0.830000 0.680000 0.810000 0.700000 0.920000 0.760000 ;0.170000 0.510000 0.330000 0.050000 0.240000 0.030000 0.410000 0.480000 0.520000 ];\r\nWexp=[9 9];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.940000 0.720000 0.810000 0.220000 0.280000 0.530000 0.440000 0.160000 0.880000 0.970000 ;0.120000 0.030000 0.470000 0.560000 0.380000 0.340000 0.690000 0.090000 0.250000 0.750000 ];\r\nWexp=[10 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.410000 0.360000 0.230000 0.140000 0.180000 0.050000 0.500000 0.270000 0.090000 0.450000 ;0.680000 0.950000 0.910000 0.860000 0.730000 0.550000 0.590000 0.820000 0.640000 0.770000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.278000 0.852000 0.370000 0.824000 0.389000 0.704000 0.546000 0.204000 0.296000 0.056000 ;0.833000 0.315000 0.991000 0.028000 0.907000 0.630000 0.361000 0.037000 0.065000 0.954000 ];\r\nWexp=[7 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.713000 0.657000 0.778000 0.435000 0.565000 0.870000 0.963000 0.343000 0.481000 0.593000 ;0.287000 0.333000 0.454000 0.130000 0.370000 0.759000 0.176000 0.611000 0.231000 0.398000 ];\r\nWexp=[10 6];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.590000 0.750000 0.650000 0.900000 0.740000 0.880000 0.850000 ;0.400000 0.070000 0.540000 0.380000 0.570000 0.150000 0.490000 ];\r\nWexp=[7 7];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.110000 0.920000 0.540000 0.840000 0.380000 0.770000 0.900000 0.490000 0.870000 0.750000 ;0.620000 0.480000 0.330000 0.440000 0.890000 0.130000 0.430000 0.080000 0.340000 0.560000 ];\r\nWexp=[10 5];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.480000 0.650000 0.770000 0.690000 0.720000 0.560000 0.660000 0.550000 0.510000 0.730000 ;0.310000 0.440000 0.300000 0.060000 0.200000 0.420000 0.030000 0.070000 0.110000 0.140000 ];\r\nWexp=[10 10];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.900000 0.680000 0.600000 0.800000 ;0.350000 0.050000 0.170000 0.880000 ];\r\nWexp=[4 3];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.730000 0.910000 0.450000 0.640000 0.090000 ;0.550000 0.360000 0.270000 0.820000 0.180000 ];\r\nWexp=[4 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.530000 0.740000 0.410000 0.320000 0.820000 0.970000 0.620000 0.500000 0.710000 0.090000 ;0.180000 0.760000 0.380000 0.150000 0.470000 0.210000 0.560000 0.120000 0.590000 0.440000 ];\r\nWexp=[9 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.487000 0.092000 0.714000 0.160000 0.504000 0.277000 0.479000 0.605000 0.462000 0.832000 ;0.210000 0.824000 0.118000 0.387000 0.664000 0.874000 0.445000 0.739000 0.546000 0.017000 ];\r\nWexp=[8 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.100000 ;0.400000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.688000 0.872000 0.615000 0.477000 0.734000 0.624000 0.394000 0.532000 0.954000 0.817000 ;0.193000 0.119000 0.349000 0.073000 0.037000 0.009000 0.128000 0.303000 0.046000 0.064000 ];\r\nWexp=[10 10];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.910000 0.550000 0.300000 0.570000 0.920000 0.400000 0.450000 0.150000 0.110000 0.190000 ;0.090000 0.790000 0.890000 0.740000 0.850000 0.940000 0.340000 0.380000 0.720000 0.260000 ];\r\nWexp=[6 1];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.723000 0.639000 0.824000 0.697000 0.840000 0.882000 0.437000 0.782000 0.588000 0.218000 ;0.345000 0.151000 0.067000 0.849000 0.815000 0.235000 0.521000 0.765000 0.950000 0.681000 ];\r\nWexp=[9 3];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.200000 0.150000 0.350000 0.090000 0.110000 0.330000 0.220000 ;0.390000 0.460000 0.850000 0.700000 0.570000 0.610000 0.500000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.850000 0.790000 0.550000 0.380000 0.300000 0.400000 0.770000 0.740000 0.320000 0.570000 ;0.260000 0.210000 0.110000 0.130000 0.020000 0.040000 0.230000 0.190000 0.090000 0.060000 ];\r\nWexp=[10 10];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.961000 0.330000 0.010000 0.816000 0.583000 0.913000 0.893000 0.951000 0.126000 0.398000 ;0.767000 0.029000 0.262000 0.641000 0.175000 0.544000 0.359000 0.932000 0.680000 0.476000 ];\r\nWexp=[9 4];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.300000 ;0.700000 ];\r\nWexp=[0 0];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\nm=[0.240000 0.050000 0.190000 0.110000 0.920000 0.590000 0.730000 0.380000 0.780000 0.950000 ;0.860000 0.700000 0.430000 0.620000 0.220000 0.540000 0.410000 0.890000 0.680000 0.490000 ];\r\nWexp=[6 2];\r\nW=War(m);\r\nassert(isequal(Wexp,W))\r\n%%\r\n% function GJam_Qual_2014d\r\n% % \r\n% %War\r\n% fn='D-small-attempt0.in';\r\n% %fn='D-large.in';\r\n% [data] = read_file(fn); % \r\n% \r\n% fidG = fopen('D-small-output.out', 'w');\r\n% %fidG = fopen('D-large-output001.out', 'w');\r\n% tic\r\n% \r\n% for i=1:size(data,2) % Cell array has N rows of cases\r\n% % m=sort(data{i},2);\r\n%  m=data{i};\r\n%  dw = dWar(m) ;% \r\n%  w = War(m) ;%  \r\n%  \r\n%    fprintf('Case #%i: %i %i\\n',i,dw,w);\r\n%    fprintf(fidG,'Case #%i: %i %i\\n',i,dw,w);\r\n%     \r\n% end\r\n% toc\r\n% \r\n% fclose(fidG);\r\n% \r\n% end\r\n% \r\n% function dw=dWar(m)\r\n% % Post contest\r\n% % Lie to burn opponent best pieces\r\n%  N=sort(m(1,:));\r\n%  K=sort(m(2,:));\r\n%  \r\n%  dw=0;\r\n%  for i=1:length(N)\r\n%   if N(i)\u003eK(1) % Lie to above to beat lowest\r\n%    dw=dw+1;\r\n%    K=K(2:end);\r\n%   else % Lie to just below best\r\n%    K=K(1:end-1);\r\n%   end\r\n%  end\r\n%  \r\n% end\r\n% \r\n% function w=War(m)\r\n% % Optimal truthful strategy\r\n% % Best lucky sequence\r\n%  w=0;\r\n% \r\n%  Nm=sort(m(1,:));\r\n%  Km=sort(m(2,:));\r\n%  \r\n%  Nmz=[Nm' ones(size(Nm,2),1)];\r\n%  Kmz=[Km' zeros(size(Km,2),1)];\r\n%  z=[Nmz;Kmz]; \r\n%  z=sortrows(z,-1);\r\n%  \r\n%  while ~isempty(z)\r\n%   ptr1=find(z(:,2)==1,1,'last');\r\n%   ptr0=find(z(1:ptr1,2)==0,1,'last');\r\n%   if isempty(ptr0)\r\n%    % score\r\n%    w=w+1;\r\n%    z(ptr1,:)=[];\r\n%    ptr0=find(z(:,2)==0,1,'last');\r\n%    z(ptr0,:)=[];  \r\n%   else\r\n%    z(ptr1,:)=[];\r\n%    z(ptr0,:)=[];  \r\n%   end\r\n%  end \r\n%  % Create worst Ken/B Scenario\r\n%  \r\n% end\r\n% \r\n% \r\n% function [d] = read_file(fn)\r\n% % Read whole array then parse\r\n% % dlmread valid for numeric arrays\r\n%  m=dlmread(fn);\r\n%  m(1,:)=[];\r\n%  for i=1:size(m,1)/3\r\n%   d{i}=m(3*i-1:3*i,1:m(3*i-2,1));\r\n%  end\r\n%  \r\n% end % read_file\r\n% Data Set file\r\n%4\r\n%1\r\n%0.5\r\n%0.6\r\n%2\r\n%0.7 0.2\r\n%0.8 0.3\r\n%3\r\n%0.5 0.1 0.9\r\n%0.6 0.4 0.3\r\n%9\r\n%0.186 0.389 0.907 0.832 0.959 0.557 0.300 0.992 0.899\r\n%0.916 0.728 0.271 0.520 0.700 0.521 0.215 0.341 0.458\r\n\r\n\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":8,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-04-19T14:08:56.000Z","updated_at":"2014-04-19T15:00:47.000Z","published_at":"2014-04-19T15:00:47.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is derived from\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://code.google.com/codejam/contest/2974486/dashboard#s=p3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGJam 2014 Qualifier Deceitful War\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMy condensed summary of the problem statement.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two players, A and B, they are each given N masses. All masses are unique. Player A plays first on each comparison and states a Mass. Player B then plays a Mass. The player with the higher mass wins a point after they are compared on a scale. These masses then disappear. This repeats for all N masses. There are no constraints on the order of pieces played.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eUnsurprisingly when A truthfully states masses player B consistently wins.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePlayer A, discouraged, decides to cheat. After the masses are provided player A asks B get A a drink and while B is away A looks at B's masses. Player A now plays pieces but does not necessarily honestly state the mass values. All scale comparisons must be valid based on B's strategy and A's stated mass. Player A now achieves more wins.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePart one is determine the best possible score for A when playing deceitfully.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePart two is determine the best possible score if player A did not look and is honest.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[A: 0.5 0.1 0.9  B 0.6 0.4 0.3  Deceitful Wins 2, Optimal Honest 1\\n\\nA 0.186 0.389 0.907 0.832 0.959 0.557 0.300 0.992 0.899\\nB 0.916 0.728 0.271 0.520 0.700 0.521 0.215 0.341 0.458\\nDeceitful A Wins 8\\nOptimal Honest A Wins 4]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e A,B vectors of length N (Small has N\u0026lt;=10, Large(future challenge N\u0026lt;=1000)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Deceitful Wins, Optimal Honest Wins\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn the contest period there were 30 Matlab solutions, of which I was not one as I glitched on the easy Deceitful algorithm thinking my Honest algorithm was in error.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.go-hero.net/jam/14/solutions/0/4/MATLAB\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGJam Deceitful Solutions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. My post contest full GJam is in the test suite. About 11000 out of 28000 entrants solved this puzzle.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"qualifier\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"qualifier\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"qualifier\"","","\"","qualifier","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f64f0cc6af8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f64f0cc69b8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f64f0cc37b8\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f64f0cc6d78\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f64f0cc6cd8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f64f0cc6c38\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f64f0cc6b98\u003e":"tag:\"qualifier\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f64f0cc6b98\u003e":"tag:\"qualifier\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"qualifier\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"qualifier\"","","\"","qualifier","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f64f0cc6af8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f64f0cc69b8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f64f0cc37b8\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f64f0cc6d78\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f64f0cc6cd8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f64f0cc6c38\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f64f0cc6b98\u003e":"tag:\"qualifier\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f64f0cc6b98\u003e":"tag:\"qualifier\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":2186,"difficulty_rating":"easy-medium"},{"id":2291,"difficulty_rating":"unrated"}]}}