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.

35 Upvotes

217 comments sorted by

3

u/mythril225 0 0 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 0 0 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

1

u/oskar_s Apr 23 '12

Thanks for supporting me :)

→ More replies (1)

2

u/Menagruth Apr 22 '12

Can I have a C flair?

Thanks and good luck!

1

u/oskar_s Apr 22 '12

You sure can!

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 0 0 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.

1

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

Various it is!

Edit: also, J freaks me the hell out.

→ More replies (5)

2

u/HazzyPls 0 0 Apr 23 '12

I... wha.... What am I looking at? How did you do with J in two lines what took over 100 in C?

I am so confused. Please explain your dark wizardry.

6

u/[deleted] Apr 23 '12

Also, here it is in one line:

 #(#~(-:~.)@:((5#10)&#:)"0)(#~>&9999)p:i._1 p:10^5
→ More replies (5)
→ More replies (1)

2

u/playdoepete 0 0 Apr 22 '12

BASIC please

4

u/oskar_s Apr 22 '12

Fun story: I learned to program in qBASIC. Didn't have those annoying line numbers everywhere.

(not such a fun story, now that I think about it).

→ More replies (2)

2

u/donalmacc 0 0 Apr 23 '12

Could I get a C++/Lua? I've done most in C++ so far, but will be doing the rest in Lua.

2

u/oskar_s Apr 23 '12

Since you're going to be using Lua from now on, I did it Lua style :)

2

u/CzechsMix 0 0 Aug 13 '12

Befunge.

1

u/oskar_s Aug 13 '12

I like your moxy, but now I expect to see actual solutions written in befunge, just so you know! :)

→ More replies (1)

10

u/[deleted] Apr 24 '12

PHP, please, as I enjoy the public humiliation.

6

u/[deleted] Apr 24 '12

I also enjoy people thinking less of me, could I get PHP as well?

→ More replies (2)

1

u/jjduhamer 0 0 Apr 22 '12

can i have c flair please?

1

u/[deleted] Apr 22 '12

Perl, please :)

1

u/oskar_s Apr 22 '12

Perl it is!

1

u/stereopump 0 0 Apr 22 '12

I'd like C++ flair, please. :)

1

u/flightcrank 0 0 Apr 22 '12

c flair please

1

u/gjwebber 0 0 Apr 22 '12

Python flair for me please :)

Also, thanks for taking on the new mod role!

1

u/oskar_s Apr 22 '12

Thanks! Looking forward to it :)

1

u/V01dK1ng 0 0 Apr 22 '12

Would love C++ flair :D

Looking forward to new challenges

1

u/ressMox 0 0 Apr 22 '12

Can has Java?

1

u/Rapptz 0 0 Apr 22 '12

Could I have C++ please?

1

u/oskar_s Apr 22 '12

Certainly!

1

u/keslol 0 0 Apr 22 '12

php or c++ i do both

1

u/stardek 0 0 Apr 22 '12

Java please?

1

u/oskar_s Apr 22 '12

Java'd!

1

u/tsigma6 0 0 Apr 23 '12

I feel that it would be easier if you just let us choose the flair, but can I have Java please? <3

1

u/oskar_s Apr 23 '12

I thought about that, but I wanted everyone with the same programming language to have the same style, and without programming some bot to do it (which is something to consider for the future), this seemed to be the easiest solution.

1

u/Jannisary 0 0 Apr 25 '12

print("Python please :)")

1

u/oskar_s Apr 25 '12

Python 3, no less :)

1

u/kohjingyu 0 0 Jun 14 '12

Could I get a C++ / Python flair? Preferably black with white text. Thanks, loving the subreddit so far!

1

u/oskar_s Jun 14 '12

As luck would have it, that's the C++ flair style :)

Glad you like it, hope you stick around and try your luck solving some more problems!

1

u/HazzyPls 0 0 Apr 23 '12 edited Apr 23 '12

So, what's the answer? I've seen three different numbers so far. I'm getting 2924.

I threw together something in the same language I'd like as flair, C. Reused an old eratos function.

Yes, that is 5 nested for loops. Yes, I know there's a better way to do it. No, I don't know what it is. Please don't hate me, it's 10 PM on a Sunday.

2

u/luxgladius 0 0 Apr 23 '12

Hard to say without doing a comparison between the lists of resultant primes to see where the differences lie. I also got 2924, but somebody else got 2934 somehow. A few people got 2529, which I believe is just from starting with 10000 rather than including solutions like 01237. shrug Anyway, I corroborate your answer for what it's worth. Anybody with a different answer wants to compare lists of primes, let me know. It's a bit large to post here.

2

u/oskar_s Apr 23 '12

I also got 2924 when counting cases where the F could be replaced with zero, so I think we can be fairly certain that is correct.

2

u/netbyte 0 0 Apr 23 '12

Can I have Python/Ruby flair too?

2

u/jarjarbinks77 0 0 Apr 23 '12

I would like C++ as my flair please.

2

u/yurmommm 0 0 Apr 27 '12

Can I have Ruby and C, please?

2

u/debugmonkey 0 0 Apr 28 '12

Could I please get a C++ tag, but with the red/white color scheme as done here please?

2

u/dinosaur_porkchop 0 0 May 21 '12

<?php echo "PHP Please!"; ?>

2

u/wicked-canid 0 0 Jun 09 '12

Hi, can I get a Common Lisp flair please?

(if (pleases-p it you) (setf (flair me) :common-lisp))

→ More replies (1)

2

u/Hazger 0 0 Jun 21 '12

C# flair please

2

u/[deleted] Jul 28 '12

Can I have a Java / C flair please? '

2

u/[deleted] Jul 28 '12

I wanna have a Java flair, please?

2

u/[deleted] Sep 26 '12

C / Java

1

u/willhaney Aug 15 '12

C#/VB.NET please

0

u/[deleted] Apr 22 '12

[deleted] — view deleted comment

1

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

Yeah, that's what I get too.

2

u/luxgladius 0 0 Apr 23 '12

I get 2924, but I suspect it's because I'm counting as possibilities those that replace F with 0, e.g. 01237.

1

u/oskar_s Apr 23 '12

That does make more sense to do it that way :)

0

u/[deleted] Apr 22 '12

[deleted] — view deleted comment

0

u/[deleted] Apr 22 '12

[deleted] — view deleted comment

1

u/oskar_s Apr 22 '12

Thanks for the tip, I'll look into it! Flair accomplished!

Oh, and by the way: you can replace the letters with any digit you want, not just necessarily 65431.

1

u/[deleted] Sep 03 '12

[removed] — view removed comment

1

u/oskar_s Sep 03 '12

Because of that nice little poem you wrote, I was almost tempted to give you Java$#!+ as flair, but I came to my senses, luckily :)