Skip to content

Instantly share code, notes, and snippets.

@DeclanHoare
Last active November 20, 2020 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeclanHoare/02d40f7afa98a82ab350f82623a5e901 to your computer and use it in GitHub Desktop.
Save DeclanHoare/02d40f7afa98a82ab350f82623a5e901 to your computer and use it in GitHub Desktop.
99bottles polyglot take 2 (C, C++, HolyC, C#, HTML (with Javascript), Python 2.7 and 3)
#if U64_MIN //\
"""
#endif
/* """
from __future__ import print_function
def printf(fmt, *args):
print(fmt % args, end = "")
return 1
"""
<script type="text/javascript">
var ourtext = "";
function printf(fmt, number)
{
let ln = fmt.replace("%d", number);
ourtext += ln.replace("\n", "<br />");
console.log(ln);
}
function display()
{
document.body.innerHTML = ourtext;
}
</script>
<noscript><h1>JavaScript is required.</h1></noscript>
<body onload="display()">
<!--
*/
#if I64_MAX
/**/#define printf Print
I64 i;
#else
#if __LINE__
extern
#if __cplusplus
"C"
#endif
int printf(const char* format, ...);
int main(int argc, char** argv)
#else
public static class Application
{
private static void printf(string format, int number = 0)
{
System.Console.Write(format.Replace("%d", number.ToString()));
}
public static void Main(string[] args)
#endif
{
int i;
#endif
/*--><script type="text/javascript">
var i;
//"""; 1 // 1 # */
i = 99;
while (1 == 1) // 1:
{
printf("%d bottles of beer on the wall,\n", i) // 1 }; """
; // """
printf("%d bottles of beer.\n", i);
printf("If one of those bottles should happen to fall\n");
i = i - 1;
if (i == 1) // 1:
break;
printf("there'd be %d bottles of beer on the wall.\n", i) // 1; { """
; // """
}
printf("there'd be 1 bottle of beer on the wall.\n");
printf("1 bottle of beer on the wall,\n");
printf("1 bottle of beer,\n");
printf("and if that one bottle should happen to fall\n");
printf("there'd be no more bottles of beer on the wall.\n") // 1; """
;
//</script>
//<!--
#if !I64_MAX
#if __LINE__
return 0;
#endif
}
#if !__LINE__
}
#endif
#endif
/*
-->
</body>
*///"""
#if U64_MIN //\
"""
#endif
/* """
from __future__ import print_function
def printf(fmt, *args):
print(fmt % args, end = "")
return 1
"""
<script type="text/javascript">
var ourtext = "";
function printf(fmt, number)
{
let ln = fmt.replace("%d", number);
ourtext += ln.replace("\n", "<br />");
console.log(ln);
}
function display()
{
document.body.innerHTML = ourtext;
}
</script>
<noscript><h1>JavaScript is required.</h1></noscript>
<body onload="display()">
<!--
*/
#if I64_MAX
/**/#define printf Print
I64 i;
#else
#if __LINE__
extern
#if __cplusplus
"C"
#endif
int printf(const char* format, ...);
int main(int argc, char** argv)
#else
public static class Application
{
private static void printf(string format, int number = 0)
{
System.Console.Write(format.Replace("%d", number.ToString()));
}
public static void Main(string[] args)
#endif
{
int i;
#endif
/*--><script type="text/javascript">
var i;
//"""; 1 // 1 # */
i = 99;
while (1 == 1) // 1:
{
printf("%d bottles of beer on the wall,\n", i) // 1 }; """
; // """
printf("%d bottles of beer.\n", i);
printf("If one of those bottles should happen to fall\n");
i = i - 1;
if (i == 1) // 1:
break;
printf("there'd be %d bottles of beer on the wall.\n", i) // 1; { """
; // """
}
printf("there'd be 1 bottle of beer on the wall.\n");
printf("1 bottle of beer on the wall,\n");
printf("1 bottle of beer,\n");
printf("and if that one bottle should happen to fall\n");
printf("there'd be no more bottles of beer on the wall.\n") // 1; """
;
//</script>
//<!--
#if !I64_MAX
#if __LINE__
return 0;
#endif
}
#if !__LINE__
}
#endif
#endif
/*
-->
</body>
*///"""
#if U64_MIN //\
"""
#endif
/* """
from __future__ import print_function
def printf(fmt, *args):
print(fmt % args, end = "")
return 1
"""
<script type="text/javascript">
var ourtext = "";
function printf(fmt, number)
{
let ln = fmt.replace("%d", number);
ourtext += ln.replace("\n", "<br />");
console.log(ln);
}
function display()
{
document.body.innerHTML = ourtext;
}
</script>
<noscript><h1>JavaScript is required.</h1></noscript>
<body onload="display()">
<!--
*/
#if I64_MAX
/**/#define printf Print
I64 i;
#else
#if __LINE__
extern
#if __cplusplus
"C"
#endif
int printf(const char* format, ...);
int main(int argc, char** argv)
#else
public static class Application
{
private static void printf(string format, int number = 0)
{
System.Console.Write(format.Replace("%d", number.ToString()));
}
public static void Main(string[] args)
#endif
{
int i;
#endif
/*--><script type="text/javascript">
var i;
//"""; 1 // 1 # */
i = 99;
while (1 == 1) // 1:
{
printf("%d bottles of beer on the wall,\n", i) // 1 }; """
; // """
printf("%d bottles of beer.\n", i);
printf("If one of those bottles should happen to fall\n");
i = i - 1;
if (i == 1) // 1:
break;
printf("there'd be %d bottles of beer on the wall.\n", i) // 1; { """
; // """
}
printf("there'd be 1 bottle of beer on the wall.\n");
printf("1 bottle of beer on the wall,\n");
printf("1 bottle of beer,\n");
printf("and if that one bottle should happen to fall\n");
printf("there'd be no more bottles of beer on the wall.\n") // 1; """
;
//</script>
//<!--
#if !I64_MAX
#if __LINE__
return 0;
#endif
}
#if !__LINE__
}
#endif
#endif
/*
-->
</body>
*///"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment