Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #22122 > unrolled thread
| Started by | keijaf2011@gmail.com |
|---|---|
| First post | 2013-02-05 11:19 -0800 |
| Last post | 2013-02-06 11:24 -0800 |
| Articles | 20 on this page of 44 — 11 participants |
Back to article view | Back to comp.lang.java.programmer
compare several boolean matrix’s keijaf2011@gmail.com - 2013-02-05 11:19 -0800
Re: compare several boolean matrix’s Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-02-05 15:47 -0500
Re: compare several boolean matrixs Roedy Green <see_website@mindprod.com.invalid> - 2013-02-05 16:26 -0800
Re: compare several boolean matrix’s Arne Vajhøj <arne@vajhoej.dk> - 2013-02-05 19:43 -0500
Re: compare several boolean matrix’s Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-05 21:09 -0400
Re: compare several boolean matrix’s Arne Vajhøj <arne@vajhoej.dk> - 2013-02-05 19:40 -0500
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-05 23:21 -0800
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-06 03:23 -0800
Re: compare several boolean matrix’s Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-06 07:55 -0400
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-06 04:11 -0800
Re: compare several boolean matrix’s Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-06 08:24 -0400
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-06 06:00 -0800
Re: compare several boolean matrix’s lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-06 14:00 +0000
Re: compare several boolean matrix’s Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 16:18 -0500
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-06 06:35 -0800
Re: compare several boolean matrix’s Patricia Shanahan <pats@acm.org> - 2013-02-06 07:49 -0800
Re: compare several boolean matrix’s lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-06 16:13 +0000
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-06 08:01 -0800
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-06 08:20 -0800
Re: compare several boolean matrix’s lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-06 16:33 +0000
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-06 08:42 -0800
Re: compare several boolean matrix’s Lars Enderin <lars.enderin@telia.com> - 2013-02-06 18:09 +0100
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-06 09:14 -0800
Re: compare several boolean matrix’s Lars Enderin <lars.enderin@telia.com> - 2013-02-06 18:29 +0100
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-06 09:40 -0800
Re: compare several boolean matrix’s lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-06 17:19 +0000
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-06 09:29 -0800
Re: compare several boolean matrix’s lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-06 18:18 +0000
Re: compare several boolean matrix’s Lars Enderin <lars.enderin@telia.com> - 2013-02-06 19:57 +0100
Re: compare several boolean matrix’s lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-06 19:02 +0000
Re: compare several boolean matrixs T®oll <spooksRus@derbyshire-crania.org> - 2013-02-06 21:01 +0000
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-08 11:21 -0800
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-08 11:31 -0800
Re: compare several boolean matrix’s lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-08 19:49 +0000
Re: compare several boolean matrix’s Keivan Jafari <keijaf2011@gmail.com> - 2013-02-08 12:24 -0800
Re: compare several boolean matrix’s Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 23:30 -0500
Re: compare several boolean matrix’s Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 23:32 -0500
Re: compare several boolean matrix’s lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-09 08:39 +0000
Re: compare several boolean matrix’s Lew <lewbloch@gmail.com> - 2013-02-09 11:18 -0800
Re: compare several boolean matrix’s Arne Vajhøj <arne@vajhoej.dk> - 2013-02-09 19:25 -0500
Re: compare several boolean matrix’s Lew <lewbloch@gmail.com> - 2013-02-09 23:36 -0800
Re: compare several boolean matrix’s Arne Vajhøj <arne@vajhoej.dk> - 2013-02-10 13:54 -0500
Re: compare several boolean matrix’s Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 16:30 -0500
Re: compare several boolean matrix’s Patricia Shanahan <pats@acm.org> - 2013-02-06 11:24 -0800
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
| From | Keivan Jafari <keijaf2011@gmail.com> |
|---|---|
| Date | 2013-02-06 08:42 -0800 |
| Message-ID | <ad3775e4-d087-4d07-ab95-ab62db3f35fb@googlegroups.com> |
| In reply to | #22122 |
Den tisdagen den 5:e februari 2013 kl. 20:19:58 UTC+1 skrev Keivan Jafari: > Hi there, > > > > Is there any way to compare several boolean matrix’s(25 matrix’s) and pick up a final valid matrix of those 25. > > > > The elements in the valid matrix will be, an example: > > > > If matrix M(0) to M(5) element(21) have value false > > > > And if matrix M(6) to M(24) element(21) have value true, Then most probably the value of element 21 is true, since much more matrix’s shows that that element 21 value is true > > > > Java code will be mostly appreciated > > > > Best regards/ > > > > Keivan tankyou. yes maybe!
[toc] | [prev] | [next] | [standalone]
| From | Lars Enderin <lars.enderin@telia.com> |
|---|---|
| Date | 2013-02-06 18:09 +0100 |
| Message-ID | <51128E30.6000909@telia.com> |
| In reply to | #22170 |
2013-02-06 17:42, Keivan Jafari skrev: > tankyou. > yes maybe! > What post does your reply refer to? Google Groups is a bad interface to Usenet, granted, but you should not make all your posts replies to your first post. Please reply to the post you are commenting on! (And the plural of matrix is matrices.) -- Lars Enderin
[toc] | [prev] | [next] | [standalone]
| From | Keivan Jafari <keijaf2011@gmail.com> |
|---|---|
| Date | 2013-02-06 09:14 -0800 |
| Message-ID | <3f00213e-fec7-4633-bc96-1051d0346360@googlegroups.com> |
| In reply to | #22171 |
Den onsdagen den 6:e februari 2013 kl. 18:09:04 UTC+1 skrev Lars Enderin: > 2013-02-06 17:42, Keivan Jafari skrev: > > > tankyou. > > > yes maybe! > > > > > > > What post does your reply refer to? > > Google Groups is a bad interface to Usenet, granted, but you should not > > make all your posts replies to your first post. Please reply to the post > > you are commenting on! > > (And the plural of matrix is matrices.) > > > > -- > > Lars Enderin sorry! I'm new. My reply was for lipska the kat
[toc] | [prev] | [next] | [standalone]
| From | Lars Enderin <lars.enderin@telia.com> |
|---|---|
| Date | 2013-02-06 18:29 +0100 |
| Message-ID | <51129303.2070701@telia.com> |
| In reply to | #22172 |
2013-02-06 18:14, Keivan Jafari skrev: > sorry! I'm new. > My reply was for lipska the kat > I see that you are new (and that you probably are posting from Sweden, like me). You did reply to me correctly, so you do know how to do it. It helps to keep message threads consistent. A traditional news client may have a little trouble otherwise. -- Lars Enderin
[toc] | [prev] | [next] | [standalone]
| From | Keivan Jafari <keijaf2011@gmail.com> |
|---|---|
| Date | 2013-02-06 09:40 -0800 |
| Message-ID | <158e132e-13c8-4b9e-8249-19ed6378c27b@googlegroups.com> |
| In reply to | #22175 |
Den onsdagen den 6:e februari 2013 kl. 18:29:39 UTC+1 skrev Lars Enderin: > 2013-02-06 18:14, Keivan Jafari skrev: > > > sorry! I'm new. > > > My reply was for lipska the kat > > > > > > > I see that you are new (and that you probably are posting from Sweden, > > like me). You did reply to me correctly, so you do know how to do it. It > > helps to keep message threads consistent. A traditional news client may > > have a little trouble otherwise. > > > > -- > > Lars Enderin Ok! Now, I go to the match between Argantina and Sweden.
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-02-06 17:19 +0000 |
| Message-ID | <cq2dnVlRd-tdDY_MnZ2dnUVZ8jidnZ2d@bt.com> |
| In reply to | #22170 |
On 06/02/13 16:42, Keivan Jafari wrote: > Den tisdagen den 5:e februari 2013 kl. 20:19:58 UTC+1 skrev Keivan Jafari: >> Hi there, >> [snip] > yes maybe! Oh dear, I don't think your professor will be too pleased will he/she Have you used Java before ? lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Keivan Jafari <keijaf2011@gmail.com> |
|---|---|
| Date | 2013-02-06 09:29 -0800 |
| Message-ID | <d1322f9a-2c40-4b0e-9e41-f490d18b1f67@googlegroups.com> |
| In reply to | #22173 |
Den onsdagen den 6:e februari 2013 kl. 18:19:58 UTC+1 skrev lipska the kat: > On 06/02/13 16:42, Keivan Jafari wrote: > > > Den tisdagen den 5:e februari 2013 kl. 20:19:58 UTC+1 skrev Keivan Jafari: > > >> Hi there, > > >> > > > > [snip] > > > > > yes maybe! > > > > Oh dear, I don't think your professor will be too pleased will he/she > > > > Have you used Java before ? > > > > lipska > > > > -- > > Lipska the Kat©: Troll hunter, sandbox destroyer > > and farscape dreamer of Aeryn Sun I'm too old and busy! Please stick to the problem, take it as a challenge!
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-02-06 18:18 +0000 |
| Message-ID | <bvqdnV6WTp7CA4_MnZ2dnUVZ8sadnZ2d@bt.com> |
| In reply to | #22174 |
On 06/02/13 17:29, Keivan Jafari wrote: > Den onsdagen den 6:e februari 2013 kl. 18:19:58 UTC+1 skrev lipska the kat: >> On 06/02/13 16:42, Keivan Jafari wrote: [snip] > I'm too old and busy! > Please stick to the problem, take it as a challenge! What is it with you Scandinavian types ? I'll give you the benefit of the doubt this one time only. http://pastebin.com/iNpSxjJd This is a starting point only. There is no error handling minimal comments and lots of assumptions made. Eric Sosman also gave you an outline solution upthread. I have provided you with a simple working solution that you can build upon. The result matrix is filled with the '1 counts' at each position The rest is up to you. lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Lars Enderin <lars.enderin@telia.com> |
|---|---|
| Date | 2013-02-06 19:57 +0100 |
| Message-ID | <5112A7AE.7050500@telia.com> |
| In reply to | #22177 |
2013-02-06 19:18, lipska the kat skrev: > On 06/02/13 17:29, Keivan Jafari wrote: >> Den onsdagen den 6:e februari 2013 kl. 18:19:58 UTC+1 skrev lipska the >> kat: >>> On 06/02/13 16:42, Keivan Jafari wrote: > > [snip] > >> I'm too old and busy! >> Please stick to the problem, take it as a challenge! > > What is it with you Scandinavian types ? > I warned him privately about your possible reaction. Keivan's name is not Scandinavian, although he lives near Stockholm. I have no idea how long he's been living in Sweden, maybe his whole life, but his roots are probably somewhere in the Middle East. -- Lars Enderin
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-02-06 19:02 +0000 |
| Message-ID | <Rb6dnd40FNgxNY_MnZ2dnUVZ8gydnZ2d@bt.com> |
| In reply to | #22178 |
On 06/02/13 18:57, Lars Enderin wrote: > 2013-02-06 19:18, lipska the kat skrev: >> On 06/02/13 17:29, Keivan Jafari wrote: >>> Den onsdagen den 6:e februari 2013 kl. 18:19:58 UTC+1 skrev lipska the >>> kat: >>>> On 06/02/13 16:42, Keivan Jafari wrote: >> >> [snip] >> >>> I'm too old and busy! >>> Please stick to the problem, take it as a challenge! >> >> What is it with you Scandinavian types ? >> > > I warned him privately about your possible reaction. > Keivan's name is not Scandinavian, although he lives near Stockholm. I > have no idea how long he's been living in Sweden, maybe his whole life, > but his roots are probably somewhere in the Middle East. > You warned him did you ... oh dear, my reputation precedes me :-( Thank you (I think). lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | T®oll <spooksRus@derbyshire-crania.org> |
|---|---|
| Date | 2013-02-06 21:01 +0000 |
| Subject | Re: compare several boolean matrixs |
| Message-ID | <keugb5$5ot$1@speranza.aioe.org> |
| In reply to | #22179 |
lipska the kat <"nospam at neversurrender dot co dot uk"> blew smoke: /clipT >You warned him did you ... oh dear, my reputation precedes me :-( > you betcha sweet bippy it does, asshole. >Thank you (I think). > be sure; http://preview.tinyurl.com/b3ygsjt or wrapped URL http://groups.google.com/groups/search?as_q=seamus+derbyshire+kook+twisted&as_ epq=&as_oq=&as_eq=&num=100&scoring=&lr=&as_sitesearch=&as_qdr=&as_mind =1&as_minm=1&as_miny=2013&as_maxd=1&as_maxm=1&as_maxy=2013&as_ ugroup=&as_usubject=&as_uauthors=&safe=off >lips stuck to Lews ass sig corrected for all to know, lamer.
[toc] | [prev] | [next] | [standalone]
| From | Keivan Jafari <keijaf2011@gmail.com> |
|---|---|
| Date | 2013-02-08 11:21 -0800 |
| Message-ID | <d0e4ed65-85cd-416f-8339-aff4fa943ea5@googlegroups.com> |
| In reply to | #22177 |
Den onsdagen den 6:e februari 2013 kl. 19:18:04 UTC+1 skrev lipska the kat: > On 06/02/13 17:29, Keivan Jafari wrote: > > > Den onsdagen den 6:e februari 2013 kl. 18:19:58 UTC+1 skrev lipska the kat: > > >> On 06/02/13 16:42, Keivan Jafari wrote: > > > > [snip] > > > > > I'm too old and busy! > > > Please stick to the problem, take it as a challenge! > > > > What is it with you Scandinavian types ? > > > > I'll give you the benefit of the doubt this one time only. > > > > http://pastebin.com/iNpSxjJd > > > > This is a starting point only. There is no error handling > > minimal comments and lots of assumptions made. > > > > Eric Sosman also gave you an outline solution upthread. > > > > I have provided you with a simple working solution that you can build > > upon. The result matrix is filled with the '1 counts' at each position > > > > The rest is up to you. > > > > lipska > > > > -- > > Lipska the Kat�: Troll hunter, sandbox destroyer > > and farscape dreamer of Aeryn Sun Tanks man! I'm trying to create new revolutionary android application allots things to think about. I will remember your help. Sometimes you have so little time! Br/ Keivan
[toc] | [prev] | [next] | [standalone]
| From | Keivan Jafari <keijaf2011@gmail.com> |
|---|---|
| Date | 2013-02-08 11:31 -0800 |
| Message-ID | <b23f5206-3054-4cbd-a091-e9d63f5107a8@googlegroups.com> |
| In reply to | #22205 |
Den fredagen den 8:e februari 2013 kl. 20:21:39 UTC+1 skrev Keivan Jafari: > Den onsdagen den 6:e februari 2013 kl. 19:18:04 UTC+1 skrev lipska the kat: > > > On 06/02/13 17:29, Keivan Jafari wrote: > > > > > > > Den onsdagen den 6:e februari 2013 kl. 18:19:58 UTC+1 skrev lipska the kat: > > > > > > >> On 06/02/13 16:42, Keivan Jafari wrote: > > > > > > > > > > > > [snip] > > > > > > > > > > > > > I'm too old and busy! > > > > > > > Please stick to the problem, take it as a challenge! > > > > > > > > > > > > What is it with you Scandinavian types ? > > > > > > > > > > > > I'll give you the benefit of the doubt this one time only. > > > > > > > > > > > > http://pastebin.com/iNpSxjJd > > > > > > > > > > > > This is a starting point only. There is no error handling > > > > > > minimal comments and lots of assumptions made. > > > > > > > > > > > > Eric Sosman also gave you an outline solution upthread. > > > > > > > > > > > > I have provided you with a simple working solution that you can build > > > > > > upon. The result matrix is filled with the '1 counts' at each position > > > > > > > > > > > > The rest is up to you. > > > > > > > > > > > > lipska > > > > > > > > > > > > -- > > > > > > Lipska the Kat�: Troll hunter, sandbox destroyer > > > > > > and farscape dreamer of Aeryn Sun > > Tanks man! > > I'm trying to create new revolutionary android application allots things to think about. > > I will remember your help. > > Sometimes you have so little time! > > > > Br/ > > Keivan got the help! tanks alots to "lipska the kat"
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-02-08 19:49 +0000 |
| Message-ID | <P7ydnXXp988ty4jMnZ2dnUVZ7radnZ2d@bt.com> |
| In reply to | #22206 |
On 08/02/13 19:31, Keivan Jafari wrote: > Den fredagen den 8:e februari 2013 kl. 20:21:39 UTC+1 skrev Keivan Jafari: >> Den onsdagen den 6:e februari 2013 kl. 19:18:04 UTC+1 skrev lipska the kat: >> >>> On 06/02/13 17:29, Keivan Jafari wrote: [snip] >> >> Sometimes you have so little time! Indeed Because you bothered to respond here's one that works with boolean values http://pastebin.com/ay5hCBuZ lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Keivan Jafari <keijaf2011@gmail.com> |
|---|---|
| Date | 2013-02-08 12:24 -0800 |
| Message-ID | <ad38cedf-771a-417c-afea-115754c7aeb8@googlegroups.com> |
| In reply to | #22207 |
Den fredagen den 8:e februari 2013 kl. 20:49:01 UTC+1 skrev lipska the kat: > On 08/02/13 19:31, Keivan Jafari wrote: > > > Den fredagen den 8:e februari 2013 kl. 20:21:39 UTC+1 skrev Keivan Jafari: > > >> Den onsdagen den 6:e februari 2013 kl. 19:18:04 UTC+1 skrev lipska the kat: > > >> > > >>> On 06/02/13 17:29, Keivan Jafari wrote: > > > > [snip] > > > > >> > > >> Sometimes you have so little time! > > > > Indeed > > > > Because you bothered to respond here's one that works with boolean values > > > > http://pastebin.com/ay5hCBuZ > > > > lipska > > > > -- > > Lipska the Kat©: Troll hunter, sandbox destroyer > > and farscape dreamer of Aeryn Sun I take my hatt for you "lipska" this is my last post.
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 23:30 -0500 |
| Message-ID | <5115d0e4$0$283$14726298@news.sunsite.dk> |
| In reply to | #22207 |
On 2/8/2013 2:49 PM, lipska the kat wrote: > On 08/02/13 19:31, Keivan Jafari wrote: >> Den fredagen den 8:e februari 2013 kl. 20:21:39 UTC+1 skrev Keivan >> Jafari: >>> Den onsdagen den 6:e februari 2013 kl. 19:18:04 UTC+1 skrev lipska >>> the kat: >>> >>>> On 06/02/13 17:29, Keivan Jafari wrote: > > [snip] > >>> >>> Sometimes you have so little time! > > Indeed > > Because you bothered to respond here's one that works with boolean values > > http://pastebin.com/ay5hCBuZ The code is not too big to post here. Arne
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 23:32 -0500 |
| Message-ID | <5115d160$0$283$14726298@news.sunsite.dk> |
| In reply to | #22239 |
On 2/8/2013 11:30 PM, Arne Vajhøj wrote:
> On 2/8/2013 2:49 PM, lipska the kat wrote:
>> On 08/02/13 19:31, Keivan Jafari wrote:
>>> Den fredagen den 8:e februari 2013 kl. 20:21:39 UTC+1 skrev Keivan
>>> Jafari:
>>>> Den onsdagen den 6:e februari 2013 kl. 19:18:04 UTC+1 skrev lipska
>>>> the kat:
>>>>
>>>>> On 06/02/13 17:29, Keivan Jafari wrote:
>>
>> [snip]
>>
>>>>
>>>> Sometimes you have so little time!
>>
>> Indeed
>>
>> Because you bothered to respond here's one that works with boolean values
>>
>> http://pastebin.com/ay5hCBuZ
>
> The code is not too big to post here.
And the code is OK.
I would have done a few things differently, but ...
Arne
====
public class MatrixSummarize {
public static boolean[][] summarize(boolean[][][] matrices) {
assert matrices.length % 2 == 1 : "Number of matrices must be odd";
int majority = (matrices.length + 1) / 2;
boolean[][] result = new
boolean[matrices[0].length][matrices[0][0].length];
for(int i = 0; i < result.length; i++) {
for(int j = 0; j < result[i].length; j++) {
int ntrue = 0;
for(int k = 0; k < matrices.length; k++) {
if(matrices[k][i][j]) ntrue++;
if(ntrue >= majority) {
result[i][j] = true;
break;
} else if(k + 1 - ntrue >= majority) {
break;
}
}
}
}
return result;
}
public static void print(boolean[][] result) {
for(int i = 0; i < result.length; i++) {
for(int j = 0; j < result[i].length; j++) {
System.out.printf(" %-5b", result[i][j]);
}
System.out.println();
}
}
public static void main(String[] args){
boolean [][] matrix1 = {
{ true, true, false },
{ true, false, true },
{false, true, false }
};
boolean [][] matrix2 = {
{ false, true, false },
{ true, false, false },
{ false, true, false }
};
boolean [][] matrix3 = {
{ true, false, true },
{ true, false, false },
{ false, true, false }
};
boolean[][][] matrices = { matrix1, matrix2, matrix3 };
boolean[][] result = summarize(matrices);
print(result);
}
}
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-02-09 08:39 +0000 |
| Message-ID | <qImdnY6difSulovMnZ2dnUVZ8sKdnZ2d@bt.com> |
| In reply to | #22240 |
On 09/02/13 04:32, Arne Vajhøj wrote: > On 2/8/2013 11:30 PM, Arne Vajhøj wrote: >> On 2/8/2013 2:49 PM, lipska the kat wrote: >>> On 08/02/13 19:31, Keivan Jafari wrote: >>>> Den fredagen den 8:e februari 2013 kl. 20:21:39 UTC+1 skrev Keivan <snip> > And the code is OK. > > I would have done a few things differently, but ... Well your code is OK but I think mine would be slightly more understandable to a beginner. The assumptions were an attempt to get the OP to think about some of the issues. I do agree that a revolutionary app will be a challenge. Do you think the OP will share royalties with the residents of cljp ? lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2013-02-09 11:18 -0800 |
| Message-ID | <21496893-281c-4f0a-803a-0466acce96f4@googlegroups.com> |
| In reply to | #22240 |
Arne Vajhøj wrote:
> I would have done a few things differently, but ...
>
> public class MatrixSummarize {
> public static boolean[][] summarize(boolean[][][] matrices) {
> assert matrices.length % 2 == 1 : "Number of matrices must be odd";
Nitpicks: Some details that separate pedagogy from production.
Arne's code is very good, and proper for instruction. However, if it were
to serve in production there is more to do.
This is an improper use of 'assert' because there is no code to
enforce the invariant. Properly, there should be argument-checking prior to
the assertion so that it represents an actual invariant.
There's no check for a null argument. One could assert non-nullity after
the check.
By dropping the 'assert' in here like this, Arne has presented a secret
challenge to fill in the gaps, as anyone schooled in the use of 'assert'
might have noticed.
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-09 19:25 -0500 |
| Message-ID | <5116e8ec$0$288$14726298@news.sunsite.dk> |
| In reply to | #22255 |
On 2/9/2013 2:18 PM, Lew wrote:
> Arne Vajhøj wrote:
>> I would have done a few things differently, but ...
>>
>> public class MatrixSummarize {
>> public static boolean[][] summarize(boolean[][][] matrices) {
>> assert matrices.length % 2 == 1 : "Number of matrices must be odd";
>
> Nitpicks: Some details that separate pedagogy from production.
>
> Arne's code is very good, and proper for instruction. However, if it were
> to serve in production there is more to do.
>
> This is an improper use of 'assert' because there is no code to
> enforce the invariant. Properly, there should be argument-checking prior to
> the assertion so that it represents an actual invariant.
>
> There's no check for a null argument. One could assert non-nullity after
> the check.
>
> By dropping the 'assert' in here like this, Arne has presented a secret
> challenge to fill in the gaps, as anyone schooled in the use of 'assert'
> might have noticed.
I am not that advanced.
Passing null, passing arrays with wrong dimensions etc. will all
give various exceptions.
The odd number requirement will not give an exception if violated.
So I flipped a coin (virtually) between an if throw new
RuntimeException and the assert. Assert won.
Arne
[toc] | [prev] | [next] | [standalone]
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
Back to top | Article view | comp.lang.java.programmer
csiph-web