Created
August 25, 2014 23:09
-
-
Save bkerley/7c879857aa1078fd3caa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
gcc -o idunno idunno.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
long long first, second; | |
puts("enter two integers"); | |
scanf("%lld %lld", &first, &second); | |
printf("%d\n", first + second); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def idunno(a, b) | |
out = nil | |
IO.popen './idunno', 'r+' do |io| | |
io.puts a | |
io.puts b | |
read = io.gets | |
read = io.gets | |
out = read.to_i | |
end | |
end | |
describe 'idunno' do | |
describe 'addition' do | |
it 'adds 2 and 2 to make 4' do | |
expect(idunno(2, 2)).to eq 4 | |
end | |
it 'adds 2 and 3 to make 5' do | |
expect(idunno(2, 3)).to eq 5 | |
end | |
100.times do | |
n1 = rand 2**31 | |
n2 = rand 2**31 | |
sum = n1 + n2 | |
it "adds #{n1} and #{n2} to make #{sum}" do | |
expect(idunno(n1, n2)).to eq sum | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment