![]() |
|
[Anti-Golfing] Hello World - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Coding (https://sinister.li/Forum-Coding--71) +--- Thread: [Anti-Golfing] Hello World (/Thread-Anti-Golfing-Hello-World) |
[Anti-Golfing] Hello World - Eclipse - 08-23-2015 So, I tried this before, but no one bit. Round two. The aim is to print Code: Hello, World!Scores will be calculated using a Byte Counter and program complexity (judged by us). Code: (no_of_bytes/2)*complexitySpoiler: Leaderboard
Points may change based on complexity judgement and algorithm. 1) @Shebang - 1443.8 ((7219/2)*0.4) 2) @lux - 775.95 ((2217/2)*0.7) 3) @Master Antrax - 0.555 ((111/2)*0.01) The winner will be awarded 25 NSP. Donate to @SyntaxPot to add to our prize pool. RE: [Anti-Golfing] Hello World - lux - 08-23-2015 Code: // Manually defining the unicode alphabet in an array.
var alpha = ["\u0041", "\u0042", "\u0043", "\u0044", "\u0045", "\u0046", "\u0047", "\u0048", "\u0049", "\u004A", "\u004B", "\u004C", "\u004D", "\u004E", "\u004F", "\u0050", "\u0051", "\u0052", "\u0053", "\u0054", "\u0055", "\u0056", "\u0057", "\u0058", "\u0059", "\u005A"];
// Manually definine special characters in an array of unicode, spac = \u0020
var special = ["\u0020", "\u0021", "\u0022", "\u0023", "\u0024", "\u0025", "\u0026", "\u0027", "\u0028", "\u0029"];
//Assinging letters as variables to the index of the unicodes.
var h = alpha.indexOf('\u0048');
var e = alpha.indexOf('\u0045');
var l = alpha.indexOf('\u004C');
var o = alpha.indexOf('\u004F');
var w = alpha.indexOf('\u0057');
var r = alpha.indexOf('\u0052');
var d = alpha.indexOf('\u0044');
var sp = special.indexOf("\u0020");
var exp = special.indexOf("\u0021");
//Creating a prototype to bind 'console.log' to 'logThisOutYeahMate'
var logThisOutYeahMate = Function.prototype.bind.call(console.log, console);
// A sequence of if statements to see if the unicode character exists. If it exists it'll return a numerical value
// Of the position in the array. Luckily A isn't used, as it's position would be 0, resulting in a 'false' and not
// allowing the if statement to run
if (alpha.indexOf('\u0048')) {
if (alpha.indexOf('\u00485')) {
if (alpha.indexOf('\u004C')) {
if (alpha.indexOf('\u004C')) {
if (alpha.indexOf('\u004F')) {
// Oh look, here's an anomaly... The position of '\u0020' in the array 'special' is 0, which is equivalent to
// false. So we'll just check if it equals the Numeric 0, which is true.
if (special.indexOf('\u0020') === 0) {
if (alpha.indexOf('\u0057')) {
if (alpha.indexOf('\u004F')) {
if (alpha.indexOf('\u0052')) {
if (alpha.indexOf('\u004C')) {
if (alpha.indexOf('\u0044')) {
// Creates a function that takes the argument 'doTheThingWhenTheThingIsDone'
function f(doTheThingWhenTheThingIsDone) {
// Checks if the variable 'doTheThingWhenTheThingIsDone' is equal to the unicode string of
// 'The thing to be done'
if (doTheThingWhenTheThingIsDone == '\u0054\u0068\u0065\u0020\u0074\u0068\u0069\u006e\u0067\u0020\u0074\u006f\u0020\u0062\u0065\u0020\u0064\u006f\u006e\u0065') {
// Calls the bound logThisOutYeahMate function previously defined, and applies it to the
// the console.
logThisOutYeahMate.apply(console, [alpha[h].toUpperCase() + alpha[e].toLowerCase() + alpha[l].toLowerCase() + alpha[l].toLowerCase() + alpha[o].toLowerCase() + special[sp].toLowerCase() + alpha[w].toLowerCase() + alpha[o].toLowerCase() + alpha[r].toLowerCase() + alpha[l].toLowerCase() + alpha[d].toLowerCase() + special[exp].toLowerCase()]);
// We call each unicode character from the array 'alpha' by parsing it the variables we
// previously defined by checking the indexOf
// And we make sure these are all either UPPER-CASE, or lower-case
}
}
// We call the function, and set the argument 'doTheThingWhenTheThingIsDone' to equal the unicode string
// equivalent to 'The thing to be done'
f(doTheThingWhenTheThingIsDone = '\u0054\u0068\u0065\u0020\u0074\u0068\u0069\u006e\u0067\u0020\u0074\u006f\u0020\u0062\u0065\u0020\u0064\u006f\u006e\u0065');
}
}
}
}
}
}
}
}
}
}
}Gotta' make sure those letters exist. RE: [Anti-Golfing] Hello World - Eclipse - 08-23-2015 (08-23-2015, 03:04 PM)Lux Wrote: Oh, and I forgot to mention in the OP that you should include pseudocode or a simple explanation as to what your code is doing. RE: [Anti-Golfing] Hello World - lux - 08-23-2015 (08-23-2015, 03:26 PM)eclipse Wrote: Oh, and I forgot to mention in the OP that you should include pseudocode or a simple explanation as to what your code is doing. Eugh. Fine. Time to get commenting RE: [Anti-Golfing] Hello World - Shebang - 08-23-2015 I'm working on a Brainfuck solution.. this might be a while. RE: [Anti-Golfing] Hello World - lux - 08-23-2015 (08-23-2015, 03:26 PM)eclipse Wrote: Oh, and I forgot to mention in the OP that you should include pseudocode or a simple explanation as to what your code is doing. Updated. Byte count does not include pseudocode. RE: [Anti-Golfing] Hello World - Master Antrax - 08-23-2015 Here is a brainfuck code for this: Code: ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.You can compile it here: http://copy.sh/brainfuck/ Byte Count: 111 Bytes RE: [Anti-Golfing] Hello World - Shebang - 08-23-2015 Not sure if this is valid, but whatever. It's a nested Brainfuck program! 7,219 Bytes Code: ++++[->++++++++<]>.................+++++++++++..++[->++<]>+.++[--->++<]>.+[--->++<]>+..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+<]>+....--[->+++<]>+.++[--->++<]>.+[--->++<]>+..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.>++++++++++.[->+++<]>++................+++++++++++...+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+.-----------.....+++++++++++..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[->+++++++++<]>.--[----->+<]>.[->+++++<]>-..>++++++++++.[->+++<]>++...............+++++++++++.......++[->++<]>+.++[--->++<]>.--[---->+++<]>.[--->++<]>++......--[-->+++<]>.......[--->++++<]>.[---->+++<]>.+[->++<]>+.>++++++++++.[->+++<]>++..............+++++++++++..++[->++<]>+.++[--->++<]>.+[--->++<]>+..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+<]>+.......--[->+++<]>+.++[--->++<]>.+[--->++<]>+.....+[----->+<]>.[---->+++<]>.+[->++<]>+.>++++++++++.[->+++<]>++.............-[->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+.....+[----->+<]>.[---->+++<]>.[--->++<]>++........-[->+++<]>.[--->++<]>.+[--->++<]>+.+++.--[----->+<]>.[->+++++<]>-.....>++++++++++.[->+++<]>++............+++++++++++......++[->++<]>+.++[--->++<]>.--[---->+++<]>..[--->++<]>++.........--[-->+++<]>........[--->++++<]>.[---->+++<]>.>++++++++++.[->+++<]>++...........-[->+++<]>.[--->++<]>.--[---->+++<]>.[--->++++<]>.[->+++++<]>-..++[->++<]>+.++[--->++<]>.+[--->++<]>+..-----------..........--[->++<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+...+[----->+<]>.>++++++++++.[->+++<]>++..........--[-->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+...+[----->+<]>.[---->+++<]>.[--->++<]>++...........-[->+++<]>.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+...+[----->+<]>.[---->+++<]>.+[->++<]>+.>++++++++++.[->+++<]>++.........-[->++<]>.+[--->++<]>+.........-----------............+++++++++++.....+++.--[----->+<]>.[->+++++<]>-...>++++++++++.[->+++<]>++........+++++++++++...++[->++<]>+.++[--->++<]>.--[---->+++<]>.....[--->++<]>++.............--[-->+++<]>..........>++++++++++.[->+++<]>++.......--[-->+++<]>...[--->++++<]>.[---->+++<]>.+[->++<]>+.-[-->+<]>---..++[->++<]>+.++[--->++<]>.[-->+<]>+..............+++++++++++..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+..>++++++++++.[->+++<]>++.......+++++++++++.+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+...+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+...+[----->+<]>.[-->+<]>++....--[-->+++<]>.+[->++<]>+.[--->++<]>.[->+++++++++<]>.--[----->+<]>.[->+++++<]>-.....>++++++++++.[->+++<]>++.......+++++++++++.++[->++<]>+.++[--->++<]>.--[---->+++<]>.................[--->++<]>++....--[-->+++<]>.[--->++++<]>.[---->+++<]>.+[->++<]>+.-[-->+<]>---...++[->++<]>+.++[--->++<]>.+[--->++<]>+.>++++++++++.[->+++<]>++.......+++++++++++....................-----------....+++++++++++..........>++++++++++.[->+++<]>++.................+++++++++++......+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+<]>+....[-->+++<]>--.--[----->+<]>.[->+++++<]>-........>++++++++++.[->+++<]>++................+++++++++++...++[->++<]>+.++[--->++<]>.--[---->+++<]>.....[--->++<]>++.....--[-->+++<]>.....[--->++++<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.--[---->+++<]>.>++++++++++.[->+++<]>++...............--[->++<]>.[->+++++<]>-..++[->++<]>+.++[--->++<]>.+[--->++<]>+..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->+<]>+......-[->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+.......>++++++++++.[->+++<]>++..............+++++++++++....+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[->+++++++++<]>.--[----->+<]>.[-->+<]>++.......+++++++++++..........>++++++++++.[->+++<]>++.............+++++++++++.++[->++<]>+.++[--->++<]>.--[---->+++<]>....[--->++++<]>.[---->+++<]>.+[->++<]>+.[--->+<]>+........+++++++++++..++[->++<]>+.++[--->++<]>.+[--->++<]>+..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.>++++++++++.[->+++<]>++............--[->+++<]>+.++[--->++<]>.+[--->++<]>+..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.[-->+<]>+.........+++++++++++..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+..-----------..>-[--->+<]>--.[--->+<]>--.+++..+++++++.-[---->+<]>++.++++[->++<]>+.-[->++++<]>.---[->++++<]>-.++.+[->+++<]>+.++++++++.-[++>---<]>+.[->+++<]>+.--[--->+<]>-.[---->+<]>+++.[->++<]>+.>-[--->+<]>--.--[->++++<]>-.++++++..-[->++++<]>.[->++<]>+.--[----->+<]>-.++.[---->+<]>+++.---[->++<]>.--[->++++++<]>.>++++++++++.[->+++<]>++...........--[->++<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[->+++++++++<]>.--[----->+<]>.[->+++++<]>-....-----------..........+++++++++++....++[->++<]>+.++[--->++<]>.--[---->+++<]>....>++++++++++.[->+++<]>++..........--[->++<]>.[---->+++<]>.+[->++<]>+.-[-->+<]>---...++[->++<]>+.++[--->++<]>.+[--->++<]>+..-----------...........+++++++++++...........................+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[->+++++++++<]>.--[----->+<]>.[->+++++<]>-.........>++++++++++.[->+++<]>++.........--[->+++<]>+.++[--->++<]>.--[---->+++<]>........[--->++<]>++............--[-->+++<]>..[--->++++<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.--[---->+++<]>...[--->++++<]>.[->+++++<]>-...++[->++<]>+.++[--->++<]>.+[--->++<]>+...........................>++++++++++.[->+++<]>++........+++++++++++..........-----------.............+++++++++++..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[->+++++++++<]>.--[----->+<]>.[->+++++<]>-...........++[->++<]>+.++[--->++<]>.--[---->+++<]>..........[--->++++<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.--[---->+++<]>.[--->++++<]>.[->+++++<]>-..++[->++<]>+.++[--->++<]>.+[--->++<]>+.>++++++++++.[->+++<]>++.......+++++++++++..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+...-----------.............+++++++++++.+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+.....+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.--[---->+++<]>......+.--[----->+<]>.[->+++++<]>-......++[->++<]>+.++[--->++<]>.--[---->+++<]>..........>++++++++++..-[->+++++<]>.........[--->++++<]>.[---->+++<]>.+[->++<]>+.-[-->+<]>---..++[->++<]>+.++[--->++<]>.+[--->++<]>+..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+...+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+...+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+...+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[->+++++++++<]>.--[----->+<]>.[->+++++<]>-......++[->++<]>+.++[--->++<]>.--[---->+++<]>..................[--->++++<]>.[---->+++<]>.+[->++<]>+.-[-->+<]>---.>++++++++++.+[->++++<]>-.++[->++<]>+.++[--->++<]>.+[--->++<]>+..+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+.....+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[-->+++<]>--.++[--->++<]>.+[--->++<]>+.....+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.[->+++++++++<]>.--[----->+<]>.[->+++++<]>-..........++[->++<]>+.++[--->++<]>.--[---->+++<]>..........[--->++++<]>.[---->+++<]>.+[->++<]>+.-[-->+<]>---...++[->++<]>+.++[--->++<]>.+[--->++<]>+..........+[----->+<]>.[---->+++<]>.+[->++<]>+.[--->++<]>.+[--->++<]>+...+++.This outputs the following (leading spaces on the first line were replaced with a special character so format wasn't messed up): Code: ++[>++<-]> [>++<-]>[>
+++<-]>[>+ ++<-]>.<++
+++++++[>- -------<-]
++[>++<-]> [>+++++<-]
>[>+++++<- ]>+.<+++++
++++++[>-- --------<-
]>-<++[>++ <-]>[>+++<
-]>[>+++<- ]>[>+++<-]
>+++++++++ +++++.<+++
+++[>----- ----------
---<-]++[> ++<-]>[>++
+<-]>[>+++<-]>[>+++< -]>.<+++++
+[>----------------- -<-]+++[>+
++++++++++++++++++++ ++++++++++
++++++<-]> .<++++++++
+++[>----- -----<-]>-
<++[>++<-] >[>+++++++
++++<-]>.< ++++++++++
+[>----<-] ++[>++<-]>
[>++<-]>[> ++<-]>[>++ Sorry I suck at ASCII Art :P
<-]>.<++++ ++++[>----
<-]+++[>++ +++++++++++++++++++++++++++<-]>.<+++++++++
[>-------- --<-]>---<+++[>+++++++++++++++++++++++++++
++++++++++ ++<-]>.<+++++++++++[>----------<-]>-<++[>+
++<-]>[>+++ +<-]>[>+++++<-]>------.<++++++[>----------
---------<-]++[>++<-]>[>+++<-]>[>+++<-]>[>+++<-]>.<++++++[>------------------<-]+
+[>++<-]>[>+++++<-]>[>+++++<-]>.<++++++++++[>----------<-]+++[>++++++++++<-]>+++.Which outputs, obviously: Code: Hello, World!Spoiler: ExplanationCode: ++[>++<-]>[>++<-]>[>+++<-]>[>+++<-]>. # Prints "H"
<+++++++++[>--------<-] # resets the value to 0
++[>++<-]>[>+++++<-]>[>+++++<-]>+. # Prints "e"
<+++++++++++[>----------<-]>-< # resets the value to 0
++[>++<-]>[>+++<-]>[>+++<-]>[>+++<-]>++++++++++++++. # Prints "l"
<++++++[>------------------<-] # resets the value to 0
++[>++<-]>[>+++<-]>[>+++<-]>[>+++<-]>. # Prints "l"
<++++++[>------------------<-] # resets the value to 0
+++[>+++++++++++++++++++++++++++++++++++++<-]>. # Prints "o"
<+++++++++++[>----------<-]>-< # resets the value to 0
++[>++<-]>[>+++++++++++<-]>. # Prints a comma
<+++++++++++[>----<-] # resets the value to 0
++[>++<-]>[>++<-]>[>++<-]>[>++<-]>. # Prints " "
<++++++++[>----<-] # resets the value to 0
+++[>+++++++++++++++++++++++++++++<-]>. # Prints "W"
<+++++++++[>----------<-]>---< # resets the value to 0
+++[>+++++++++++++++++++++++++++++++++++++++<-]>. # Prints "o"
<+++++++++++[>----------<-]>-< # resets the value to 0
++[>+++<-]>[>++++<-]>[>+++++<-]>------. # Prints "r"
<++++++[>-------------------<-] # resets the value to 0
++[>++<-]>[>+++<-]>[>+++<-]>[>+++<-]>. # Prints "l"
<++++++[>------------------<-] # resets the value to 0
++[>++<-]>[>+++++<-]>[>+++++<-]>. # Prints "d"
<++++++++++[>----------<-] # resets the value to 0
+++[>++++++++++<-]>+++. # Prints "!"This is a great demonstration of how NOT to program in Brainfuck ![]() (08-23-2015, 04:22 PM)Master Antrax Wrote: Here is a brainfuck code for this: The purpose of the challenge is not just to print it, but to have the longest and most complex code!
RE: [Anti-Golfing] Hello World - Master Antrax - 08-23-2015 @Shebang Oh sorry I thought it was to have the smallest xD
RE: [Anti-Golfing] Hello World - Eclipse - 08-28-2015 @Shebang is the winner and has been awarded 25 NSP. Feel free to still attempt the challenge if you wish. |