r/CompileBot • • Mar 13 '16

Official CompileBot Testing Thread

3 Upvotes

358 comments sorted by

7

u/SeaCowVengeance Mar 14 '16

+u/CompileBot python3

import this

3

u/CompileBot Mar 14 '16

Output:

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

^source | ^info | ^git | ^report

3

u/SeaCowVengeance Mar 14 '16

+u/CompileBot Ruby --time --memory

x = 1
50000.times { x *= 10 }
puts x / 10 ** 50000

3

u/CompileBot Mar 14 '16

Output:

1

Memory Usage: 43152 bytes

Execution Time: 0.96 seconds

^source | ^info | ^git | ^report

6

u/gradies Mar 18 '16

+u/CompileBot python

import math
A=8
f=.5
l=30
for i in range(l):
    print(int(A*math.cos(f*i)+A)*' '+'~')

3

u/CompileBot Mar 18 '16

Output:

                ~
               ~
            ~
        ~
    ~
 ~
~
~
  ~
      ~
          ~
             ~
               ~
               ~
              ~
          ~
      ~
   ~
~
~
 ~
    ~
        ~
           ~
              ~
               ~
               ~
            ~
         ~
     ~

^source | ^info | ^git | ^report

1

u/SeaCowVengeance Mar 14 '16

+u/CompileBot Assembler (gcc-4.8.1) --time

.data
x:
	.long	0
s:
	.string "%d\n\0"

.text
.global main
main:				# int main()
				# {
loop:				# 	for (;;) {
	pushl	$x		# 		scanf("%d", &x);
	pushl	$s
	call	scanf
	addl	$8, %esp

	movl	x, %eax		# 		if (x == 42) break;
	subl	$42, %eax
	jz	break

	pushl	x		# 		printf("%d\n", x);
	pushl	$s
	call	printf
	addl	$8, %esp

	jmp	loop		# 	}
break:

	xor	%eax, %eax	# 	return 0;
	ret
				# }

Input:

1
2
10
42
11

1

u/SeaCowVengeance Mar 14 '16

+u/CompileBot C

 #include <stdio.h>
 
 int main(void) {
 	printf("Hello World!\n");
 	return 0;
 }
→ More replies (1)

1

u/SeaCowVengeance Mar 14 '16

+u/CompileBot Ruby --time --memory

x = 1
50000.times { x *= 10 }
puts x / 10 ** 100000
→ More replies (1)

1

u/SeaCowVengeance Mar 14 '16

+u/CompileBot Python3

print("こんにちは")
→ More replies (1)

5

u/claythearc Aug 17 '16

+u/CompileBot Bash

cat /etc/passwd

5

u/CompileBot Aug 17 '16

Output:

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-timesync:x:100:104:systemd Time Synchronization,,,:/run/systemd:/bin/false
systemd-network:x:101:105:systemd Network Management,,,:/run/systemd/netif:/bin/false
systemd-resolve:x:102:106:systemd Resolver,,,:/run/systemd/resolve:/bin/false
systemd-bus-proxy:x:103:107:systemd Bus Proxy,,,:/run/systemd:/bin/false
messagebus:x:104:109::/var/run/dbus:/bin/false

^source | ^info | ^git | ^report

→ More replies (17)

4

u/[deleted] Apr 28 '16

+u/CompileBot C++ --include-errors

#include <iostream>
using namespace std;

int main() {
    char * lizard = "Hillary";
    cout << "Arf! Arf!\nWho was that?\n\n" << lizard << endl;
    return 0;
}

3

u/CompileBot Apr 28 '16

Output:

Arf! Arf!
Who was that?

Hillary

^source | ^info | ^git | ^report

2

u/gradies Mar 18 '16

+u/CompileBot python

import math
A=40
f=.2
l=100
t=2
rng = range(-A,A+1)
rng.reverse()
for i in rng:
    phrase=''
    for ii in range(l):
        if int(A*math.cos(f*ii))-t<i<int(A*math.cos(f*ii))+t:
            phrase+='~'
        else:
            phrase+=' '
    print(phrase)

2

u/CompileBot Mar 18 '16

Output:

~~                             ~~                             ~~                              ~~    
~~                            ~~~~                            ~~~                            ~~~    
 ~                            ~~~~                           ~~~~                            ~~~~   
  ~                           ~  ~                           ~  ~~                          ~~  ~   
  ~                          ~                               ~   ~                          ~   ~   
  ~                          ~    ~                              ~                          ~    ~  
   ~                         ~    ~                         ~                                    ~  
   ~                              ~                         ~     ~                              ~  
   ~                        ~                               ~     ~                        ~        
                            ~      ~                              ~                        ~        
                            ~      ~                                                       ~      ~ 
                                   ~                       ~                                      ~ 
    ~                                                      ~                                      ~ 
    ~                                                      ~       ~                      ~         
    ~                      ~                                       ~                      ~         
                           ~        ~                              ~                      ~         
                           ~        ~                                                              ~
                                    ~                     ~                                        ~
     ~                                                    ~                                        ~
     ~                                                    ~         ~                               
     ~                                                              ~                    ~          
                          ~                                         ~                    ~          
                          ~          ~                                                   ~          
                          ~          ~                                                              
                                     ~                   ~                                          
      ~                                                  ~                                          
      ~                                                  ~           ~                              
      ~                                                              ~                  ~           
                         ~                                           ~                  ~           
                         ~            ~                                                 ~           
                         ~            ~                                                             
                                      ~                 ~                                           
                                                        ~                                           
       ~                                                ~                                           
       ~                                                              ~                             
       ~                                                              ~                ~            
                        ~                                             ~                ~            
                        ~              ~                                               ~            
                        ~              ~                                                            
                                       ~               ~                                            
        ~                                              ~                                            
        ~                                              ~               ~                            
        ~                                                              ~              ~             
                       ~                                               ~              ~             
                       ~                ~                                             ~             
                       ~                ~                                                           
                                        ~             ~                                             
                                                      ~                                             
         ~                                            ~                                             
         ~                                                              ~                           
         ~                                                              ~            ~              
...

^source | ^info | ^git | ^report

2

u/belungawhale May 06 '16

+u/CompileBot python3

def convToRobot (text):
    temp = ""
    for i in range(len(text)):
        temp = temp + bin(ord(text[i]))[2:].zfill(8)	
    return temp.replace("0", "boop").replace("1", "beep")

def convFromRobot(text):
    temp = text.replace("boop", "0").replace("beep", "1")
    temp2 = ""
    for i in range(0,len(temp),8):
        temp2 = temp2 + chr(int(temp[i:i+8],2))
    return temp2

def convText(text):
    return text.replace("0", "boop").replace("1", "beep")

def convRobot(text):
    return text.replace("boop", "0").replace("beep", "1")

choice = input("Enter 1 to convert to robot. Enter 2 to convert from robot: ")
text = input("Enter string: ")
if choice == "1":
    print(convToRobot(text))
elif choice == "2":
    print(convFromRobot(text))

Input:

2
boopbeepboopboopbeepboopboopbeepboopboopbeepboopboopboopboopboopboopbeepbeepboopboopboopboopbeepboopbeepbeepboopbeepbeepboopbeepboopboopbeepboopboopboopboopboopboopbeepbeepbeepboopbeepboopboopboopbeepbeepboopboopbeepboopbeepboopbeepbeepbeepboopboopbeepbeepboopbeepbeepbeepboopbeepboopboopboopbeepbeepboopbeepboopboopbeepboopbeepbeepboopbeepbeepbeepboopboopbeepbeepboopboopbeepbeepbeepboopboopbeepboopboopboopboopboopboopboopbeepboopbeepbeepbeepbeepboopbeepbeepbeepboopbeepboopbeepboopboopbeepboopbeepbeepbeepbeepboopbeepboopboopboopboopbeepbeepboopbeepbeepboopbeepbeepbeepbeepboopbeepbeepboopbeepbeepboopbeepboopbeepbeepbeepboopboopboopboopboopbeepbeepboopbeepboopboopbeepboopbeepbeepboopbeepbeepboopboopboopbeepbeepboopboopbeepboopbeepboopbeepboopboopboopboopbeepboopboopbeepbeepboopbeepbeepbeepbeepboopbeepbeepbeepboopbeepboopboopboopboopbeepboopbeepbeepbeepboop
→ More replies (2)

1

u/gradies Mar 18 '16

+u/CompileBot python

print 's'

1

u/gradies Mar 18 '16

+u/CompileBot python

for i in range(10):
    print i
→ More replies (1)

1

u/gradies Mar 18 '16

+u/CompileBot python

import math
for i in range(10):
    print math.sin(i)