Python

for i in range(401):
    print "%s\t%s" % (max(min(i, 200-i), i-200), max(max(100-i, 0), i-200))

On Wed, Nov 30, 2011 at 5:26 AM, Steven Hao <[email protected]> wrote:

> Here is my smaller solution
> public static void main(String[] args) {
>
> System.out.print("0\t0\n1\t9\n2\t8\n3\t7\n4\t6\n5\t5\n6\t4\n7\t3\n8\t2\n9\t1\n10\t0\n11\t9\n12\t8\n13\t7\n14\t6\n15\t5\n16\t4\n17\t3\n18\t2\n19\t1\n20\t0\n21\t9\n22\t8\n23\t7\n24\t6\n25\t5\n26\t4\n27\t3\n28\t2\n29\t1\n30\t0\n31\t9\n32\t8\n33\t7\n34\t6\n35\t5\n36\t4\n37\t3\n38\t2\n39\t1\n40\t0\n41\t9\n42\t8\n43\t7\n44\t6\n45\t5\n46\t4\n47\t3\n48\t2\n49\t1\n50\t0\n51\t9\n52\t8\n53\t7\n54\t6\n55\t5\n56\t4\n57\t3\n58\t2\n59\t1\n60\t0\n61\t9\n62\t8\n63\t7\n64\t6\n65\t5\n66\t4\n67\t3\n68\t2\n69\t1\n70\t0\n71\t9\n72\t8\n73\t7\n74\t6\n75\t5\n76\t4\n77\t3\n78\t2\n79\t1\n80\t0\n81\t9\n82\t8\n83\t7\n84\t6\n85\t5\n86\t4\n87\t3\n88\t2\n89\t1\n90\t0\n91\t9\n92\t8\n93\t7\n94\t6\n95\t5\n96\t4\n97\t3\n98\t2\n99\t1\n100\t0\n99\t0\n98\t0\n97\t0\n96\t0\n95\t0\n94\t0\n93\t0\n92\t0\n91\t0\n90\t0\n89\t0\n88\t0\n87\t0\n86\t0\n85\t0\n84\t0\n83\t0\n82\t0\n81\t0\n80\t0\n79\t0\n78\t0\n77\t0\n76\t0\n75\t0\n74\t0\n73\t0\n72\t0\n71\t0\n70\t0\n69\t0\n68\t0\n67\t0\n66\t0\n65\t0\n64\t0\n63\t0\n62\t0\n61\t0\n60\t0\n59\t0\n58\t0\n57\t0\n56\t0\n55\t0\n54\t0\n53\t0\n52\t0\n51\t0\n50\t0\n49\t0\n48\t0\n47\t0\n46\t0\n45\t0\n44\t0\n43\t0\n42\t0\n41\t0\n40\t0\n39\t0\n38\t0\n37\t0\n36\t0\n35\t0\n34\t0\n33\t0\n32\t0\n31\t0\n30\t0\n29\t0\n28\t0\n27\t0\n26\t0\n25\t0\n24\t0\n23\t0\n22\t0\n21\t0\n20\t0\n19\t0\n18\t0\n17\t0\n16\t0\n15\t0\n14\t0\n13\t0\n12\t0\n11\t0\n10\t0\n9\t0\n8\t0\n7\t0\n6\t0\n5\t0\n4\t0\n3\t0\n2\t0\n1\t0\n0\t0\n1\t1\n2\t2\n3\t3\n4\t4\n5\t5\n6\t6\n7\t7\n8\t8\n9\t9\n10\t0\n11\t1\n12\t2\n13\t3\n14\t4\n15\t5\n16\t6\n17\t7\n18\t8\n19\t9\n20\t0\n21\t1\n22\t2\n23\t3\n24\t4\n25\t5\n26\t6\n27\t7\n28\t8\n29\t9\n30\t0\n31\t1\n32\t2\n33\t3\n34\t4\n35\t5\n36\t6\n37\t7\n38\t8\n39\t9\n40\t0\n41\t1\n42\t2\n43\t3\n44\t4\n45\t5\n46\t6\n47\t7\n48\t8\n49\t9\n50\t0\n51\t1\n52\t2\n53\t3\n54\t4\n55\t5\n56\t6\n57\t7\n58\t8\n59\t9\n60\t0\n61\t1\n62\t2\n63\t3\n64\t4\n65\t5\n66\t6\n67\t7\n68\t8\n69\t9\n70\t0\n71\t1\n72\t2\n73\t3\n74\t4\n75\t5\n76\t6\n77\t7\n78\t8\n79\t9\n80\t0\n81\t1\n82\t2\n83\t3\n84\t4\n85\t5\n86\t6\n87\t7\n88\t8\n89\t9\n90\t0\n91\t1\n92\t2\n93\t3\n94\t4\n95\t5\n96\t6\n97\t7\n98\t8\n99\t9\n100\t0\n101\t1\n102\t2\n103\t3\n104\t4\n105\t5\n106\t6\n107\t7\n108\t8\n109\t9\n110\t0\n111\t1\n112\t2\n113\t3\n114\t4\n115\t5\n116\t6\n117\t7\n118\t8\n119\t9\n120\t0\n121\t1\n122\t2\n123\t3\n124\t4\n125\t5\n126\t6\n127\t7\n128\t8\n129\t9\n130\t0\n131\t1\n132\t2\n133\t3\n134\t4\n135\t5\n136\t6\n137\t7\n138\t8\n139\t9\n140\t0\n141\t1\n142\t2\n143\t3\n144\t4\n145\t5\n146\t6\n147\t7\n148\t8\n149\t9\n150\t0\n151\t1\n152\t2\n153\t3\n154\t4\n155\t5\n156\t6\n157\t7\n158\t8\n159\t9\n160\t0\n161\t1\n162\t2\n163\t3\n164\t4\n165\t5\n166\t6\n167\t7\n168\t8\n169\t9\n170\t0\n171\t1\n172\t2\n173\t3\n174\t4\n175\t5\n176\t6\n177\t7\n178\t8\n179\t9\n180\t0\n181\t1\n182\t2\n183\t3\n184\t4\n185\t5\n186\t6\n187\t7\n188\t8\n189\t9\n190\t0\n191\t1\n192\t2\n193\t3\n194\t4\n195\t5\n196\t6\n197\t7\n198\t8\n199\t9\n200\t0\n");
> }
> no loops required.
>
>
> On Thu, Nov 24, 2011 at 10:38 AM, Nikhil <[email protected]>wrote:
>
>> question is to print this pattern
>>
>> 0       100
>> 1       99
>> 2       98
>> 3       97
>> 4       96
>> 5       95
>> 6       94
>> 7       93
>> 8       92
>> 9       91
>> 10      90
>> 11      89
>> 12      88
>> 13      87
>> 14      86
>> 15      85
>> 16      84
>> 17      83
>> 18      82
>> 19      81
>> 20      80
>> 21      79
>> 22      78
>> 23      77
>> 24      76
>> 25      75
>> 26      74
>> 27      73
>> 28      72
>> 29      71
>> 30      70
>> 31      69
>> 32      68
>> 33      67
>> 34      66
>> 35      65
>> 36      64
>> 37      63
>> 38      62
>> 39      61
>> 40      60
>> 41      59
>> 42      58
>> 43      57
>> 44      56
>> 45      55
>> 46      54
>> 47      53
>> 48      52
>> 49      51
>> 50      50
>> 51      49
>> 52      48
>> 53      47
>> 54      46
>> 55      45
>> 56      44
>> 57      43
>> 58      42
>> 59      41
>> 60      40
>> 61      39
>> 62      38
>> 63      37
>> 64      36
>> 65      35
>> 66      34
>> 67      33
>> 68      32
>> 69      31
>> 70      30
>> 71      29
>> 72      28
>> 73      27
>> 74      26
>> 75      25
>> 76      24
>> 77      23
>> 78      22
>> 79      21
>> 80      20
>> 81      19
>> 82      18
>> 83      17
>> 84      16
>> 85      15
>> 86      14
>> 87      13
>> 88      12
>> 89      11
>> 90      10
>> 91      9
>> 92      8
>> 93      7
>> 94      6
>> 95      5
>> 96      4
>> 97      3
>> 98      2
>> 99      1
>> 100     0
>> 99      0
>> 98      0
>> 97      0
>> 96      0
>> 95      0
>> 94      0
>> 93      0
>> 92      0
>> 91      0
>> 90      0
>> 89      0
>> 88      0
>> 87      0
>> 86      0
>> 85      0
>> 84      0
>> 83      0
>> 82      0
>> 81      0
>> 80      0
>> 79      0
>> 78      0
>> 77      0
>> 76      0
>> 75      0
>> 74      0
>> 73      0
>> 72      0
>> 71      0
>> 70      0
>> 69      0
>> 68      0
>> 67      0
>> 66      0
>> 65      0
>> 64      0
>> 63      0
>> 62      0
>> 61      0
>> 60      0
>> 59      0
>> 58      0
>> 57      0
>> 56      0
>> 55      0
>> 54      0
>> 53      0
>> 52      0
>> 51      0
>> 50      0
>> 49      0
>> 48      0
>> 47      0
>> 46      0
>> 45      0
>> 44      0
>> 43      0
>> 42      0
>> 41      0
>> 40      0
>> 39      0
>> 38      0
>> 37      0
>> 36      0
>> 35      0
>> 34      0
>> 33      0
>> 32      0
>> 31      0
>> 30      0
>> 29      0
>> 28      0
>> 27      0
>> 26      0
>> 25      0
>> 24      0
>> 23      0
>> 22      0
>> 21      0
>> 20      0
>> 19      0
>> 18      0
>> 17      0
>> 16      0
>> 15      0
>> 14      0
>> 13      0
>> 12      0
>> 11      0
>> 10      0
>> 9       0
>> 8       0
>> 7       0
>> 6       0
>> 5       0
>> 4       0
>> 3       0
>> 2       0
>> 1       0
>> 0       0
>> 1       1
>> 2       2
>> 3       3
>> 4       4
>> 5       5
>> 6       6
>> 7       7
>> 8       8
>> 9       9
>> 10      10
>> 11      11
>> 12      12
>> 13      13
>> 14      14
>> 15      15
>> 16      16
>> 17      17
>> 18      18
>> 19      19
>> 20      20
>> 21      21
>> 22      22
>> 23      23
>> 24      24
>> 25      25
>> 26      26
>> 27      27
>> 28      28
>> 29      29
>> 30      30
>> 31      31
>> 32      32
>> 33      33
>> 34      34
>> 35      35
>> 36      36
>> 37      37
>> 38      38
>> 39      39
>> 40      40
>> 41      41
>> 42      42
>> 43      43
>> 44      44
>> 45      45
>> 46      46
>> 47      47
>> 48      48
>> 49      49
>> 50      50
>> 51      51
>> 52      52
>> 53      53
>> 54      54
>> 55      55
>> 56      56
>> 57      57
>> 58      58
>> 59      59
>> 60      60
>> 61      61
>> 62      62
>> 63      63
>> 64      64
>> 65      65
>> 66      66
>> 67      67
>> 68      68
>> 69      69
>> 70      70
>> 71      71
>> 72      72
>> 73      73
>> 74      74
>> 75      75
>> 76      76
>> 77      77
>> 78      78
>> 79      79
>> 80      80
>> 81      81
>> 82      82
>> 83      83
>> 84      84
>> 85      85
>> 86      86
>> 87      87
>> 88      88
>> 89      89
>> 90      90
>> 91      91
>> 92      92
>> 93      93
>> 94      94
>> 95      95
>> 96      96
>> 97      97
>> 98      98
>> 99      99
>> 100     100
>> 101     101
>> 102     102
>> 103     103
>> 104     104
>> 105     105
>> 106     106
>> 107     107
>> 108     108
>> 109     109
>> 110     110
>> 111     111
>> 112     112
>> 113     113
>> 114     114
>> 115     115
>> 116     116
>> 117     117
>> 118     118
>> 119     119
>> 120     120
>> 121     121
>> 122     122
>> 123     123
>> 124     124
>> 125     125
>> 126     126
>> 127     127
>> 128     128
>> 129     129
>> 130     130
>> 131     131
>> 132     132
>> 133     133
>> 134     134
>> 135     135
>> 136     136
>> 137     137
>> 138     138
>> 139     139
>> 140     140
>> 141     141
>> 142     142
>> 143     143
>> 144     144
>> 145     145
>> 146     146
>> 147     147
>> 148     148
>> 149     149
>> 150     150
>> 151     151
>> 152     152
>> 153     153
>> 154     154
>> 155     155
>> 156     156
>> 157     157
>> 158     158
>> 159     159
>> 160     160
>> 161     161
>> 162     162
>> 163     163
>> 164     164
>> 165     165
>> 166     166
>> 167     167
>> 168     168
>> 169     169
>> 170     170
>> 171     171
>> 172     172
>> 173     173
>> 174     174
>> 175     175
>> 176     176
>> 177     177
>> 178     178
>> 179     179
>> 180     180
>> 181     181
>> 182     182
>> 183     183
>> 184     184
>> 185     185
>> 186     186
>> 187     187
>> 188     188
>> 189     189
>> 190     190
>> 191     191
>> 192     192
>> 193     193
>> 194     194
>> 195     195
>> 196     196
>> 197     197
>> 198     198
>> 199     199
>> 200     200
>>
>>
>>
>> My solution is :
>>
>> public static void main(String[] args)
>>    {
>>        int k=0;
>>        for(int i=0;i<=300 ; )
>>        {
>>            if(k==0 && i<100)
>>            {
>>                System.out.println(i+"\t"+(100-i) );
>>                i++;
>>            }
>>            else
>>                if(k==0 && i==100)
>>                {
>>                    System.out.println(i+"\t0");
>>                    k=1;
>>                    i--;
>>                }
>>            else
>>                if(k==1 && i>0)
>>                {
>>                    System.out.println(i+"\t0");
>>                    i--;
>>                }
>>            else
>>                    if(k==1 && i==0 )
>>                    {
>>                        System.out.println(i+"\t"+i);
>>                        i++;
>>                        k=2;
>>                    }
>>            else
>>                if(k==2)
>>                {
>>                    System.out.println(i+"\t"+i);
>>                    i++;
>>                }
>>
>>        }
>>    }
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Code Jam" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-code?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to