Two O's, then four O's, then two O's again?
1
Name:
Bob (Twin Peaks)
2014-11-14 2:58
This for loop prints: XOOOOXOOOOXOOOOXOOOO for(int i=1;i<=4;i++){ System.out.print("X"); for(int j=1;j<=4;j++){ System.out.print("O"); } } Using ONLY "for" (no if, while, etc.), print statements, and modifying the logic of the loops, how can I make the loops print: XOOXOOOOXOOOOXOO Where the O's after the first and last X's are HALF the amount of O's printed between the inner X's?
2
Name:
Anonymous
2014-11-14 4:07
System.out.print("X"); for(int i=1;i<=4;i++){ System.out.print("O"); System.out.print("O"); System.out.print("X"); System.out.print("O"); System.out.print("O"); }
3
Name:
Bob (Twin Peaks)
2014-11-14 4:11
>>2 Can it be done without repeating code?
4
Name:
Anonymous
2014-11-14 4:30
or likefor(int i=1;i<=2;i++){ System.out.print("XOO"); } for(int j=1;j<=2;j++){ System.out.print("OOXOO"); }
i think i know what you mean but the loops don't seem to like it
5
Name:
Anonymous
2014-11-14 4:47
X OO X OO OO X OO OO X OO for(int i=1;i<=4;i++){ System.out.print("X"); for(int j=5-i; j<=i; j++){ // j=4,3,2,1, j<=1,2,3,4, k=0,0,2,4 System.out.print("O"); } for(int j=i; j<=5-i; j++){ // j = 1,2,3,4, j<=4,3,2,1, k=4,2,0,0 System.out.print("O"); } } output X OOOO X OO X OO X OOOO
6
Name:
Anonymous
2014-11-14 4:59
mapping for 1,2,3,4 -> 2,4,4,2 ? 5 - [3,1,abs(-1, -3)] ?
7
Name:
Anonymous
2014-11-14 5:24
or [0,2,2,2] + [2,2,2,0]for(int i=1; i<=4; i++){ System.out.print("X"); for(int j=i; j>1; j--){ //iffy for(j=j; j>-4; j-=4){ System.out.print("O"); } } for(int j=i; j<4; j++){ //again for(j=j; j<=7; j+=4){ System.out.print("O"); } } }
8
Name:
Bob (Twin Peaks)
2014-11-14 5:30
>>7 I'm going to study this and use it tomorrow. I hope my professor doesn't see this post. =)
9
Name:
Anonymous
2014-11-14 5:47
for (int i=0; i<1; i++) System.out.print("XOOXOOOOXOOOOXOO");
10
Name:
Anonymous
2014-11-14 9:00
for(int i=1;i<=4;i++){ System.out.print("X"); for(int j=i%3;j<=2+(((i+(((i-1) >> 1)+1))*(i+(((i-1) >> 1)+1))*(i+(((i-1) >> 1)+1)))%4);j++){ System.out.print("O"); }}
11
Name:
Anonymous
2014-11-14 9:51
12
Name:
Anonymous
2014-11-14 14:33
Your board got linked in one of /g/'s programming threads.
13
Name:
Anonymous
2014-11-14 15:10
How do you pronounce xoxo
? 1. Χοχο! (Greek, like ho ho) 2. Ksokso 3. Hugs and kisses (fucking faggot ) 4. Zozo
14
Name:
Anonymous
2014-11-14 16:51
>>12 And you browse /g/ because you are a fucking /g/ro and come here just to shit this place up, right?
15
Name:
Anonymous
2014-11-14 18:41
16
Name:
Anonymous
2014-11-14 19:45
>>1 map (flip take (repeat 'O') >>> (['X'] ++)) >>> concat >>> print $ [2, 4, 4, 2]
17
Name:
Anonymous
2014-11-14 22:08
>>3 Yeah
System.out.print("XOOXOOOOXOOOOXOO")
18
Name:
Anonymous
2014-11-14 22:09
>>16 "oh look at me >>> I'm haskal >>> I can $ do flip take"
list(2,4,4,2) map(o, "X" .. "O" repeated(o)) join println
19
Name:
Anonymous
2014-11-14 23:19
(progn (format t "x") (loop repeat 5 do (format t "ooxoo")) (format t "x~%"))
20
Name:
Cudder
!MhMRSATORI
2014-11-15 2:40
WTF is this, amateur hour?for(int i=1;i<=4;i++){ System.out.print("X"); for(int j=3-(i&2);j<=4;j++){ System.out.print("O"); } }
21
Name:
Anonymous
2014-11-15 7:53
>>20 can you make it do [2,4,3,1]?
22
Name:
Anonymous
2014-11-15 8:30
>>20 You're the amateur here if you still mutate i's and j's in loops by hand. Go scrub some toilets if you like manual labor so much. Programming is not for you.
23
Name:
Anonymous
2014-11-15 9:41
>>22 POP QUIZ! How many bytes in a long mode GDT entry?
Nigger.
I wrote my own assembler and compiler. Who's smarter?
Obviouly, I'm smarter than you. Shat-up.
You gonna tell me it doesn't work, that it doesn't boot? How's your logic
skills, sherlock?
Nigger.
24
Name:
Anonymous
2014-11-15 9:51
>>23 bytes What do bytes have to do with programming, you stupid nigger toiletscrubber?
I wrote my own assembler and compiler. Who's smarter? I am. Because I don't waste my time on rewriting low-level toilet-scrubbery that has already been created for me by professional janitors.
25
Name:
Anonymous
2014-11-15 10:00
>>23 uh, 8?
the compiler?
Sure, why not? uhm, i'm not sherlock, and they're okay i guess ^^
26
Name:
Anonymous
2014-11-15 13:59
27
Name:
Anonymous
2014-11-15 16:21
>>26 How many satellites are running haskal code?
28
Name:
Anonymous
2014-11-15 17:10
>>27 Miranda (a satellate of
Uranus ) is running Miranda, and that's Haskell 0.9.
29
Name:
Anonymous
2014-11-15 17:11
30
Name:
Anonymous
2014-11-15 17:41
>>29 so you're saying... haskal my anus?
31
Name:
Anonymous
2014-11-17 3:40
,&'X';<@('X',$&'O')@>;/2 4 4 2
I'm certain there's a shorter way but I haven't figured out what it is.
32
Name:
Anonymous
2014-11-17 7:16
printf("XOOOOXOOOOXOOOOXOOOO")
33
Name:
Anonymous
2014-11-18 9:01
34
Name:
Anonymous
2014-11-18 12:41
Do some CS classes really have braindead exercises like this?
35
Name:
Anonymous
2014-11-18 14:40
>>34 I know, right? If you're taking a CS class you should already be a competent programmer. Blowing entire semesters on teaching people to program is a waste of precious taxpayer dollars.
Newer Posts