Skip to main content
Updating based on Andbdrew's comment
Source Link
Briguy37
  • 2.6k
  • 15
  • 23

Javascript

Here's the basic format of all the solutions. This case returns true if a>b and false otherwise:

function greaterThan(a,b){
    c=a;//Copy a
    while(true){
        if(b==a){
            return false;
        }
        if(b==c){
            return true;
        }
        a++;//Approaches b if a<b
        c--;//Approaches b if a>b
    }
}

Warning: Since we didn't need to support the A==B case, the next 3 solutions will lock up for those inputs. Thus, don't fill in equal or empty numbers at the prompts in the test fiddles, unless of course you like pushing red buttons that say "Do NOT push!!!"

149 chars - Fiddle: Conforms EXACTLY to specs ;)

for(A=B='A',C='B',a=c=prompt(A),b=prompt(C);b!=c++||(B=C),b!=a--||(A=C),A==B;);alert("Integer "+B+" is Greater than "+A+".\n\n\nRules : No Brainfuck.")

74 chars - Fiddle: Prompts user for 2 numbers, alerts '-1' if 1st<2nd, '1' if 2nd>1st:

for(A=0,a=c=prompt(),b=prompt();b!=c++||(A=-1),b!=a--||(A=1),!A;);alert(A)

54 chars - Fiddle: Function that takes 2 parameters and returns true if A > B, false if BA < AB, and, of course, locks up if A==B.

function a(a,b){for(c=a;b!=++a&&b!=--c;);return b!=a;}

Javascript

Here's the basic format of all the solutions. This case returns true if a>b and false otherwise:

function greaterThan(a,b){
    c=a;//Copy a
    while(true){
        if(b==a){
            return false;
        }
        if(b==c){
            return true;
        }
        a++;//Approaches b if a<b
        c--;//Approaches b if a>b
    }
}

Warning: Since we didn't need to support the A==B case, the next 3 solutions will lock up for those inputs. Thus, don't fill in equal or empty numbers at the prompts in the test fiddles, unless of course you like pushing red buttons that say "Do NOT push!!!"

149 chars - Fiddle: Conforms EXACTLY to specs ;)

for(A=B='A',C='B',a=c=prompt(A),b=prompt(C);b!=c++||(B=C),b!=a--||(A=C),A==B;);alert("Integer "+B+" is Greater than "+A+".\n\n\nRules : No Brainfuck.")

74 chars - Fiddle: Prompts user for 2 numbers, alerts '-1' if 1st<2nd, '1' if 2nd>1st:

for(A=0,a=c=prompt(),b=prompt();b!=c++||(A=-1),b!=a--||(A=1),!A;);alert(A)

54 chars - Fiddle: Function that takes 2 parameters and returns true if A > B, false if B < A, and, of course, locks up if A==B.

function a(a,b){for(c=a;b!=++a&&b!=--c;);return b!=a;}

Javascript

Here's the basic format of all the solutions. This case returns true if a>b and false otherwise:

function greaterThan(a,b){
    c=a;//Copy a
    while(true){
        if(b==a){
            return false;
        }
        if(b==c){
            return true;
        }
        a++;//Approaches b if a<b
        c--;//Approaches b if a>b
    }
}

Warning: Since we didn't need to support the A==B case, the next 3 solutions will lock up for those inputs. Thus, don't fill in equal or empty numbers at the prompts in the test fiddles, unless of course you like pushing red buttons that say "Do NOT push!!!"

149 chars - Fiddle: Conforms EXACTLY to specs ;)

for(A=B='A',C='B',a=c=prompt(A),b=prompt(C);b!=c++||(B=C),b!=a--||(A=C),A==B;);alert("Integer "+B+" is Greater than "+A+".\n\n\nRules : No Brainfuck.")

74 chars - Fiddle: Prompts user for 2 numbers, alerts '-1' if 1st<2nd, '1' if 2nd>1st:

for(A=0,a=c=prompt(),b=prompt();b!=c++||(A=-1),b!=a--||(A=1),!A;);alert(A)

54 chars - Fiddle: Function that takes 2 parameters and returns true if A > B, false if A < B, and, of course, locks up if A==B.

function a(a,b){for(c=a;b!=++a&&b!=--c;);return b!=a;}
Added format for solutions
Source Link
Briguy37
  • 2.6k
  • 15
  • 23

Javascript

Here's the basic format of all the solutions. This case returns true if a>b and false otherwise:

function greaterThan(a,b){
    c=a;//Copy a
    while(true){
        if(b==a){
            return false;
        }
        if(b==c){
            return true;
        }
        a++;//Approaches b if a<b
        c--;//Approaches b if a>b
    }
}

Warning: Since we didn't need to support the A==B case, allthe next 3 solutions will lock up for those inputs. Thus, don't fill in equal or empty numbers at the prompts in the test fiddles, unless of course you like pushing red buttons that say "Do NOT push!!!"

149 chars - Fiddle: Conforms EXACTLY to specs ;)

for(A=B='A',C='B',a=c=prompt(A),b=prompt(C);b!=c++||(B=C),b!=a--||(A=C),A==B;);alert("Integer "+B+" is Greater than "+A+".\n\n\nRules : No Brainfuck.")

74 chars - Fiddle: Prompts user for 2 numbers, alerts '-1' if 1st<2nd, '1' if 2nd>1st:

for(A=0,a=c=prompt(),b=prompt();b!=c++||(A=-1),b!=a--||(A=1),!A;);alert(A)

54 chars - Fiddle: Function that takes 2 parameters and returns true if A > B, false if B < A, and, of course, locks up if A==B.

function a(a,b){for(c=a;b!=++a&&b!=--c;);return b!=a;}

Javascript

Warning: Since we didn't need to support the A==B case, all solutions will lock up for those inputs. Thus, don't fill in equal or empty numbers at the prompts in the test fiddles, unless of course you like pushing red buttons that say "Do NOT push!!!"

149 chars - Fiddle: Conforms EXACTLY to specs ;)

for(A=B='A',C='B',a=c=prompt(A),b=prompt(C);b!=c++||(B=C),b!=a--||(A=C),A==B;);alert("Integer "+B+" is Greater than "+A+".\n\n\nRules : No Brainfuck.")

74 chars - Fiddle: Prompts user for 2 numbers, alerts '-1' if 1st<2nd, '1' if 2nd>1st:

for(A=0,a=c=prompt(),b=prompt();b!=c++||(A=-1),b!=a--||(A=1),!A;);alert(A)

54 chars - Fiddle: Function that takes 2 parameters and returns true if A > B, false if B < A, and, of course, locks up if A==B.

function a(a,b){for(c=a;b!=++a&&b!=--c;);return b!=a;}

Javascript

Here's the basic format of all the solutions. This case returns true if a>b and false otherwise:

function greaterThan(a,b){
    c=a;//Copy a
    while(true){
        if(b==a){
            return false;
        }
        if(b==c){
            return true;
        }
        a++;//Approaches b if a<b
        c--;//Approaches b if a>b
    }
}

Warning: Since we didn't need to support the A==B case, the next 3 solutions will lock up for those inputs. Thus, don't fill in equal or empty numbers at the prompts in the test fiddles, unless of course you like pushing red buttons that say "Do NOT push!!!"

149 chars - Fiddle: Conforms EXACTLY to specs ;)

for(A=B='A',C='B',a=c=prompt(A),b=prompt(C);b!=c++||(B=C),b!=a--||(A=C),A==B;);alert("Integer "+B+" is Greater than "+A+".\n\n\nRules : No Brainfuck.")

74 chars - Fiddle: Prompts user for 2 numbers, alerts '-1' if 1st<2nd, '1' if 2nd>1st:

for(A=0,a=c=prompt(),b=prompt();b!=c++||(A=-1),b!=a--||(A=1),!A;);alert(A)

54 chars - Fiddle: Function that takes 2 parameters and returns true if A > B, false if B < A, and, of course, locks up if A==B.

function a(a,b){for(c=a;b!=++a&&b!=--c;);return b!=a;}
added 2 characters in body
Source Link
Briguy37
  • 2.6k
  • 15
  • 23

Javascript

Warning: Since we didn't need to support the A==BA==B case, all solutions will lock up for those inputs. Thus, don't fill in equal or empty numbers at the prompts in the test fiddles, unless of course you like pushing red buttons that say "Do NOT push!!!"

149 chars - Fiddle: Conforms EXACTLY to specs ;)

for(A=B='A',C='B',a=c=prompt(A),b=prompt(C);b!=c++||(B=C),b!=a--||(A=C),A==B;);alert("Integer "+B+" is Greater than "+A+".\n\n\nRules : No Brainfuck.")

74 chars - Fiddle: Prompts user for 2 numbers, alerts '-1' if 1st<2nd, '1' if 2nd>1st:

for(A=0,a=c=prompt(),b=prompt();b!=c++||(A=-1),b!=a--||(A=1),!A;);alert(A)

54 chars - Fiddle: Function that takes 2 parameters and returns true if A > B, false if B < A, and, of course, locks up if A==B.

function a(a,b){for(c=a;b!=++a&&b!=--c;);return b!=a;}

Javascript

Warning: Since we didn't need to support the A==B case, all solutions will lock up for those inputs. Thus, don't fill in equal or empty numbers at the prompts in the test fiddles, unless of course you like pushing red buttons that say "Do NOT push!!!"

149 chars - Fiddle: Conforms EXACTLY to specs ;)

for(A=B='A',C='B',a=c=prompt(A),b=prompt(C);b!=c++||(B=C),b!=a--||(A=C),A==B;);alert("Integer "+B+" is Greater than "+A+".\n\n\nRules : No Brainfuck.")

74 chars - Fiddle: Prompts user for 2 numbers, alerts '-1' if 1st<2nd, '1' if 2nd>1st:

for(A=0,a=c=prompt(),b=prompt();b!=c++||(A=-1),b!=a--||(A=1),!A;);alert(A)

54 chars - Fiddle: Function that takes 2 parameters and returns true if A > B, false if B < A, and, of course, locks up if A==B.

function a(a,b){for(c=a;b!=++a&&b!=--c;);return b!=a;}

Javascript

Warning: Since we didn't need to support the A==B case, all solutions will lock up for those inputs. Thus, don't fill in equal or empty numbers at the prompts in the test fiddles, unless of course you like pushing red buttons that say "Do NOT push!!!"

149 chars - Fiddle: Conforms EXACTLY to specs ;)

for(A=B='A',C='B',a=c=prompt(A),b=prompt(C);b!=c++||(B=C),b!=a--||(A=C),A==B;);alert("Integer "+B+" is Greater than "+A+".\n\n\nRules : No Brainfuck.")

74 chars - Fiddle: Prompts user for 2 numbers, alerts '-1' if 1st<2nd, '1' if 2nd>1st:

for(A=0,a=c=prompt(),b=prompt();b!=c++||(A=-1),b!=a--||(A=1),!A;);alert(A)

54 chars - Fiddle: Function that takes 2 parameters and returns true if A > B, false if B < A, and, of course, locks up if A==B.

function a(a,b){for(c=a;b!=++a&&b!=--c;);return b!=a;}
Source Link
Briguy37
  • 2.6k
  • 15
  • 23
Loading