Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Two O's, then four O's, then two O's again?

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?

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");
}

Name: Bob (Twin Peaks) 2014-11-14 4:11

>>2

Can it be done without repeating code?

Name: Anonymous 2014-11-14 4:30

or like
for(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

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

Name: Anonymous 2014-11-14 4:59

mapping for 1,2,3,4 -> 2,4,4,2 ?

5 - [3,1,abs(-1, -3)] ?

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");
}
}
}

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. =)

Name: Anonymous 2014-11-14 5:47

for (int i=0; i<1; i++)
System.out.print("XOOXOOOOXOOOOXOO");

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");
}}

Name: Anonymous 2014-11-14 9:51

>>1
Kill yourself, retard

Name: Anonymous 2014-11-14 14:33

Your board got linked in one of /g/'s programming threads.

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

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?

Name: Anonymous 2014-11-14 18:41

>>13
チュッ

Name: Anonymous 2014-11-14 19:45

>>1
map (flip take (repeat 'O') >>> (['X'] ++)) >>> concat >>> print $ [2, 4, 4, 2]

Name: Anonymous 2014-11-14 22:08

>>3
Yeah

System.out.print("XOOXOOOOXOOOOXOO")

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

Name: Anonymous 2014-11-14 23:19

(progn
(format t "x")
(loop repeat 5 do (format t "ooxoo"))
(format t "x~%"))

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");
}
}

Name: Anonymous 2014-11-15 7:53

>>20
can you make it do [2,4,3,1]?

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.

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.

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.

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 ^^

Name: Anonymous 2014-11-15 13:59

>>18
Io is useless.

Name: Anonymous 2014-11-15 16:21

>>26
How many satellites are running haskal code?

Name: Anonymous 2014-11-15 17:10

>>27
Miranda (a satellate of Uranus) is running Miranda, and that's Haskell 0.9.

Name: Anonymous 2014-11-15 17:11

>>28
* satellite

Name: Anonymous 2014-11-15 17:41

>>29
so you're saying... haskal my anus?

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.

Name: Anonymous 2014-11-17 7:16

printf("XOOOOXOOOOXOOOOXOOOO")

Name: Anonymous 2014-11-18 9:01

>>31
XOOXOOOOXOOOOXOO

Name: Anonymous 2014-11-18 12:41

Do some CS classes really have braindead exercises like this?

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.

Don't change these.
Name: Email:
Entire Thread Thread List