Okay, a small, easy test for you:
Write a program that prints number 1 to 100. But, for multiples of 7 print "Satoshi" instead of the number and for the multiples of 8 print "Nakamoto". For numbers that are multiples of both 7 and 8 print "SatoshiNakamoto".
Haha, ok
In C
#include <stdio.h>
#include <string.h>
// gcc s.c ; ./a.out ;
int main() {
int n=0;
char r[100];
for(n=1 ; n<=100 ; n++){
// clear r
memset(r,0,100);
if(n % 7 == 0) {
strcat(r,"Satoshi");
};
if(n % 8 == 0) {
strcat(r,"Nakamoto");
};
if(strlen(r) == 0) {
sprintf(r,"%d",n);
};
printf("%s\n",r);
}
return 0;
}
In Python
#!/usr/bin/env python
# python s.py
import sys
for n in xrange(1,100+1):
replacement = ""
if n % 7 == 0:
replacement += "Satoshi"
if n % 8 == 0:
replacement += "Nakamoto"
if len(replacement) > 0:
print replacement
else:
print n
In Perl
#!/usr/bin/env perl
use strict;
use warnings;
# perl s.pl
for(1..100) {
my $str_to_print = "";
if($_ % 7 == 0) {
$str_to_print .= "Satoshi";
};
if($_ % 8 == 0) {
$str_to_print .= "Nakamoto";
};
if(length($str_to_print)==0) {
$str_to_print = $_;
};
print "$str_to_print\n";
}
In Elisp
;; emacs --batch -l ./s.el 2>/dev/null
(dolist (n (number-sequence 1 100))
(setq string-to-print nil)
(when (eq (mod n 7) 0) (setq string-to-print (concat string-to-print "Satoshi")))
(when (eq (mod n 8) 0) (setq string-to-print (concat string-to-print "Nakamoto")))
(when (eq (length string-to-print) 0) (setq string-to-print (number-to-string n)))
;; (insert (concat string-to-print "\n"))
(princ (concat string-to-print "\n")))
In Bash
#!/bin/bash
# bash s.sh
for n in $(seq 1 100); do
to_print=""
if [[ $(($n % 7)) -eq 0 ]]; then
to_print=$to_print"Satoshi"
fi
if [[ $(($n % 8)) -eq 0 ]]; then
to_print=$to_print"Nakamoto"
fi
len=$(echo -n $to_print | wc -c)
if [[ $len -eq 0 ]]; then
to_print="$n"
fi
echo $to_print
done
What other languages should I write this in ?
Any other challenges ?
I'd like to thank those who reached out to me so far
That was nice.
You still have the chance to work with me on a part-time project.
Use your chance, it's a great opportunity. If you pass on the best programmer in the known universe,
who will you choose? A newbie? Will you choose a weak programmer, an amateur for your project ?
Why would you do that ? Why would you choose an amateur ?!
Choose the best programmer in the whole known(and unknown) universe ! That's me
I am the best, and you have the biggest opportunity of your lifetime right now to work with me !
The most wise, the most skilled, the best organized, the most productive, the most handsome, the most marketable,
the smartest, the most intelligent, by far the best programmer in the whole known(and unknown) universe !
I'm absolutely the best there is.
I'm super-smart, I'm the best.