Discuss Scratch

technoboy10
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

Introduction to Code Golf
Welcome to (probably) the first AT code golf! I've gotten permission from the ST to try code golf out in the ATs, so please don't spam or do anything that would revoke our ability to do code golf here!


What is code golf anyway?

The Wikipedia definition of code golf is
A type of recreational computer programming competition in which participants strive to achieve the shortest possible code that implements a certain algorithm.


Can I use (insert programming language here)?

Mostly any language is OK for code golfing, but please don't use languages with swear words in the name or in the code (even if you asterisk the title). This is simply to make sure that we can continue golfing without getting in trouble with the ST.


How do I submit an answer?

Here's a template.
<language name> – <length of program> (length is usually in characters, but for Scratch submissions blocks might work better)
insert your code here
explanation of program here

Show me the challenge already!

OK, but you'll have to wait until I type it up.

Last edited by technoboy10 (April 28, 2015 12:45:14)

technoboy10
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

Challenge
The top-voted challenge on Stack Overflow's Code Golf is “Produce the number 2014 without any numbers in your source code”. In honor of Scratch, create code that produces the number 2007 without any numbers in your source code!

RULES AND SCORING
  • Follow all rules in the first post
  • You may not use any numbers in your code.
  • Your code should print/alert/log 2007.
  • Solutions must not rely on preexisting conditions in the code/project environment (this includes the date).
  • Submissions will be scored on code length in letters, unless your submission is in a graphical language like Scratch or Snap!
  • If using graphical languages, submissions will be scored on number of characters to reproduce in scratchblocks2.
  • If you're a cool person, write how your code works in your submission post.
  • Keep chat down if possible - leave room for submissions (but feel free to ask for clarification)

Check out this for help with making new code golf topics. Feel free to use the initial post for any code golf topics you create.


The competition will end on May 9th. Lowest score wins!

Last edited by technoboy10 (April 27, 2015 01:56:30)

cwkgavin367
Scratcher
100+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

reserved post
cwkgavin367
Scratcher
100+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

if i used brain it would be easy
cwkgavin367
Scratcher
100+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

cwkgavin367 wrote:

if i used brain it would be easy
but it has a badword in its name
Thepuzzlegame
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

cwkgavin367 wrote:

cwkgavin367 wrote:

if i used brain it would be easy
but it has a badword in its name
Why are you replying to yourself?
technoboy10
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

cwkgavin367 wrote:

cwkgavin367 wrote:

if i used brain it would be easy
but it has a badword in its name
Yup, so don't use it.
Thepuzzlegame
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

JavaScript – 19 characters
alert(btoa("ÛM;"));
ÛM; is 2007 decoded using base-64. This code uses JavaScript's built in function btoa to encode the string back to 2007.
(I would have done this the more logical way and decoded MjAwNw== however I wanted to save a little extra character space.

Last edited by Thepuzzlegame (April 23, 2015 01:49:39)

blob8108
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

Including visual languages is interesting. How do you compare them with text languages?

And is “number of blocks” a sufficient constraint? How does the following
repeat (2007)
change [foo v] by [1]
end
say (foo)
compare with this?
change [foo v] by [2000]
say ((foo) + (7))

EDIT: typo

Last edited by blob8108 (April 23, 2015 01:26:17)

technoboy10
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

blob8108 wrote:

Including visual languages is interesting. How do you compare them with text languages?

And is “number of blocks” a sufficient constraint? How does the following
repeat (2007)
change [foo v] by [1]
end
say (foo)
compare with this?
change [foo v] by [2000]
say ((foo) + (7))

EDIT: typo
I clarified the rules - 2, 0, and 7 can't be in your solution.
technoboy10
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

~-~! (No Comment) - 37 characters
'=~~,~~~,~~~~~:@'+~~:@':@':@'+~~~~~~~
No Comment is a language joefarebrother and I made up a while ago. “:” is basically the semicolon, “@…” prints the unicode character represented by whatever the ‘…’ expression is, ‘,’ is multiplication, and tildes are unary numbers. (cheating a bit with ~~ but no comment was too much fun to code in to pass up )
NoMod-Programming
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

technoboy10 wrote:

blob8108 wrote:

Including visual languages is interesting. How do you compare them with text languages?

And is “number of blocks” a sufficient constraint? How does the following
repeat (2007)
change [foo v] by [1]
end
say (foo)
compare with this?
change [foo v] by [2000]
say ((foo) + (7))

EDIT: typo
I clarified the rules - 2, 0, and 7 can't be in your solution.
How about
say ((1999) + (8))
#lol
openSesame36
New Scratcher
4 posts

[CLOSED] Produce the number 2007 without any numbers in your source code

<C++> - <57 characters>

global int x;
int main()
{
x+=1999;
x+=8;
cout<<x<<endl;
}

A C++ global variable is automatically set to 0. I just add two numbers that equal 2007 without using those digits. Then I display with a simple cout statement.
ohaiderstudios
Scratcher
3 posts

[CLOSED] Produce the number 2007 without any numbers in your source code

Python - 9 Characters

6553%4546

Last edited by ohaiderstudios (April 23, 2015 01:58:23)

technoboy10
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

NoMod-Programming wrote:

technoboy10 wrote:

blob8108 wrote:

Including visual languages is interesting. How do you compare them with text languages?

And is “number of blocks” a sufficient constraint? How does the following
repeat (2007)
change [foo v] by [1]
end
say (foo)
compare with this?
change [foo v] by [2000]
say ((foo) + (7))

EDIT: typo
I clarified the rules - 2, 0, and 7 can't be in your solution.
How about
say ((1999) + (8))
#lol
Wait just realized that *no* numbers may be in your solution as per the rules.
NoMod-Programming
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

Shortest code not using 2,0, or 7:
JS:
return(1999 + 8)

Last edited by NoMod-Programming (April 23, 2015 01:59:25)

technoboy10
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

Just to clarify,


YOUR SOLUTION MAY NOT CONTAIN ANY NUMBERS IN IT

Thanks!
NoMod-Programming
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

technoboy10 wrote:

Just to clarify,


YOUR SOLUTION MAY NOT CONTAIN ANY NUMBERS IN IT

Thanks!
Ooh… Aww
openSesame36
New Scratcher
4 posts

[CLOSED] Produce the number 2007 without any numbers in your source code

technoboy10 wrote:

Just to clarify,


YOUR SOLUTION MAY NOT CONTAIN ANY NUMBERS IN IT

Thanks!
But other than your contrived No Comment code, what other languages use no numbers to display numbers? Even if you use the Unicode numbers in your code (50, 48, 48, 55) that still doesn't abide by your rules because a) it has a 0 and b) it has numbers period.

How??
blob8108
Scratcher
1000+ posts

[CLOSED] Produce the number 2007 without any numbers in your source code

Are we allowed 1, at least?

EDIT: wait nvm

Last edited by blob8108 (April 23, 2015 02:08:56)

Powered by DjangoBB