r/dailyprogrammer • • Apr 22 '12

Announcing flair!

Hi! I'm oskar_s, and I'm your new friendly moderator! I have a bunch of fun problems lined up that I'm looking forward to posting (starting tomorrow) which I think you'll really enjoy (though please also go to /r/dailyprogrammer_ideas to suggest new ones!)

However, as my first act of... moderatorship?... I'd like to make an announcement: programming language flair! That's right: brand yourself with the programming language of your choice, whether it be Python, Perl, C, C++, Java, Haskell or any other weird language I can't think of right now (I'm partial to Python, myself). Or maybe you're the kind of nutcase that wishes everyone to know that you solve all the problems with like Prolog or J or something. Now you can!

Until we get a more convenient system set up, comment in this thread with which flair you'd like, and we'll set it up for ya (or you can just message us). If you can't commit to one programming language, it's fine to pick two or more.

Finally: if you're really feeling starved for programming challenges, here's a simple one: if you replace "F" with 4, "L" with 5, "A" with 6, "I" with 1 and "R" with 3, the word "FLAIR" becomes 45613, which is a prime. In how many ways can you replace the letters in the word FLAIR with numbers and get a prime? (note: no two different letters can be assigned to the same number!)

This little challenge is purely optional, you get the flair either way ;)

Have fun!

Edit: if I don't get to you right away, I'm probably away from the computer or sleeping or something, but I'll get to you sooner or later.

36 Upvotes

218 comments sorted by

3

u/mythril225 Apr 22 '12 edited Apr 22 '12

2934

God, it's been awhile since i've last used haskell, but here you go: code

EDIT: also, id like to have java as my flair

9

u/oskar_s Apr 22 '12 edited Apr 22 '12

UserFlairs.getInstance().addUserFlair(User.byName("mythril225"), FlairFactory.createFlair("Java"))

Done, Java-style!

→ More replies (2)

3

u/luxgladius Apr 23 '12

You can flair me as Perl and here's a Perl solution:

P.S. Congrats on your appointment.

Perl

my @solution;
my @prime = (2);
sub isPrime
{
    my $x = shift;
    my $s = sqrt($x);
    while($prime[-1] < $s)
    {
        my $i = $prime[-1]+1;
        while(!isPrime($i)) {++$i;}
        push @prime, $i;
    }
    for(my $i = 0; $i < @prime && $prime[$i] <= $s; ++$i)
    {
        return 0 if $x % $prime[$i] == 0;
    }
    return 1;
}
TEST: for my $candidate (1234 .. 98765)
{
    my @digit = split //, sprintf('%05d',$candidate);
    my @seen;
    $seen[$_]++ && next TEST for @digit;
    push @solution, sprintf('%05d', $candidate) if isPrime($candidate);
}
print 0+@solution . " solutions: ";
print "@solution\n";

Output: 2924 solutions

→ More replies (2)

2

u/Menagruth Apr 22 '12

Can I have a C flair?

Thanks and good luck!

→ More replies (1)

2

u/[deleted] Apr 22 '12

Can I get a Pascal flair please?

3

u/oskar_s Apr 22 '12

Old school, I like it!

→ More replies (1)

2

u/Koldof Apr 22 '12

I can't decide between a C++ or a python flair. Tell you what, surprise me.

4

u/oskar_s Apr 22 '12

I was tempted to do something mean like "Poopyface", but I thought better of it :)

→ More replies (2)

2

u/[deleted] Apr 22 '12
    f =. 3 : '((-:~.) (5#10) #: y) *. (y >: 10^4)'
    # (#~f"0) i.&.(_1&p:) 10^5
==> 2529

No flair for me, I switch languages a lot. J here, but Ruby/C/Haskell elsewhere. Maybe you can get me a "Various" tag.

→ More replies (14)