Skip to content

Instantly share code, notes, and snippets.

@Tosainu
Last active August 29, 2015 14:10
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 Tosainu/fcd43348eaf5ca99e406 to your computer and use it in GitHub Desktop.
Save Tosainu/fcd43348eaf5ca99e406 to your computer and use it in GitHub Desktop.
g++ -std=c++11 -Wall -Wextra `pkg-config ruby-2.1 --cflags --libs` fizzbuzz.cc
#include <iostream>
#include <ruby.h>
auto main() -> int {
ruby_init();
ruby_init_loadpath();
int status;
rb_eval_string_protect(R"(
1.upto(100) do |x|
puts "#{x} : #{
x % 15 == 0 ? " fizzbuzz"
: x % 5 == 0 ? " buzz"
: x % 3 == 0 ? " fizz"
: ''
}"
end
)", &status);
ruby_finalize();
return status;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment