Jump to content

Coder


bullet-401

Recommended Posts

Yeah, this is really obscure...

 

FOR Y = 10 TO 1 STEP -1

 

Otherwise BASIC will always assume you want to increment by 1.  So, Y = 10, then next loop, Y = 11, which exceeds the bounds....I'm pretty sure it always runs through the loop at least once.  Add that STEP -1 though.  It's like the y-- operator.

Your my hero!

 

Yep you guys were right N=4 X=11 Y=0 Sigh I fail at my own game.

 

NOFX got the answer first so have at the next one!

Link to comment
Share on other sites

here was my version of the code in VB (that got me my above answer)

 

Dim x As Integer = 0
       Dim y As Integer = 10
       Dim n As Integer = 0

       Do While x <= 10
           Do While y > 0
               x += 1
               If ((x > 5) And (y > 1)) Then
                   n += 1
                   TextBox1.Text &= "x=" & x & " y=" & y & " n=" & n & vbCrLf
               End If
               y -= 1
               TextBox1.Text &= "x=" & x & " y=" & y & " n=" & n & vbCrLf
           Loop
           x += 1
           TextBox1.Text &= "x=" & x & " y=" & y & " n=" & n & vbCrLf
       Loop

Link to comment
Share on other sites

can I request that we make a rule that you must attempt to solve in your head? I mean sure we're talking honor system here, but where's the fun if we all just go plug the code into a program?

Link to comment
Share on other sites

Oh man that VB code is going to drive me insane! How could Bill Gates like that crap? I shall pee on his grave.

AHAHAHA!

you mean cause it's readable and actually somewhat understandable?

I CAN code in c-based languages...but I choose not to because I like to be able to read my code easily.

Link to comment
Share on other sites

I got one for ya fellers

 

VB.Net Code:
Dim i As Integer = 1
       Dim y As Integer = 5
       Dim alpb As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
       Dim alpa As String = "1234567890"
       Dim HoldAnswer As String

       Do While i < 10
           Dim alph As String = alpa
           Do While alph.Length > 4
               HoldAnswer &= alpb.Substring(i, y)
               alph = alph.Substring(0, alph.Length - 2)
           Loop
           i += 3
           y += (i - 2)
       Loop

C# Code:
int i = 1;
 	int y = 5;
 	string alpb = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
 	string alpa = "1234567890";
 	string HoldAnswer = "";

 	do
 	{
   string alph = alpa;
   do
   {
   	HoldAnswer += alpb.Substring(i, y);
   	alph = alph.Substring(0, alph.Length - 2);
   } while(alph.Length > 4);
   i += 3;
   y += (i - 2);
 	} while(i < 10);

 

What will "HoldAnswer" be?

 

*edit*

I'm solving in my head to (yes I have already seen the answer, but believe me...it's not something I can memorize)

Link to comment
Share on other sites

heh, worked out a bit easier than I thought it would when doing it in your head.

 

my answer:

 

i = 1

y = 5

HoldAnswer = "BCDEFBCDEFBCDEF"

 

i = 4

y = 7

HoldAnswer = "BCDEFBCDEFBCDEFDEFGHIJDEFGHIJDEFGHIJ"

 

i = 7

y = 12

HoldAnswer = "BCDEFBCDEFBCDEFDEFGHIJDEFGHIJDEFGHIJHIJKLMNOPQRSHIJKLMNOPQRSHIJKLMNOPQRS"

 

*edit*

DOH! I'm off by one letter.

Link to comment
Share on other sites

Member
(edited)

woot assembler

 

lets see who can get this baby

 

.begin 

.org 2048

 

a_start .equ 3000

ld [length], %r1

ld [address], %r2

andcc %r3, %r0, %r3

 

loop: andcc %r1, %r1, %r0

be done

addcc %r1, -4, %r1

addcc %r1, %r2, %r4

ld %r4, %r5

ba loop

addcc %r15, 4, %r15

done: jmpl %r15 + 4 , %r0

 

length: 40

address: a_start

 

.org a_start

 

a:  25

  -10

  33

  -5

  7

  9

  -2

  20

  -24

  1

 

.end

Edited by NOFX
Link to comment
Share on other sites

Member
(edited)

heh I could rewrite a more modernized version

 

temp[] = new array;

int temp = 0;;

int i =0;

 

temp[0] = 25;

temp[1] = -10;

temp[2] = 33;

temp[3] = -5;

temp[4] = 7

temp[5] = 9;

temp[6] = -2;

temp[7] = 20;

temp[8] = -24;

temp[9] = 1;

 

while(i<10, i++)

{

 

temp2 = temp + temp2;

}

 

print temp2;

 

ahhh much easier to read than the other, but your comp has to do a gazillion more proceses to produce the same answer.

Edited by NOFX
Link to comment
Share on other sites

×
×
  • Create New...