For a long time I have been following the Codegolf tasks, which are published daily on https://codegolf.stackexchange.com. Now I want to make Codegolf better known on Steemit. For this purpose I will start a Codegolf Challenge.
Wait what is Codegolf?
The goal of every code golfer is to write a program that is as short as possible and implements a specific algorithm. There are special codegolf languages that allow to solve tasks with extremely short code. However, these are often very difficult to read. One of these languages is GolfScript.
Codegolf is an art form!
Task
My task for you is to write a program that outputs "YES" for any input X (X > 0 & x < 2000), if the number is a harshard prime and otherwise "NO".
A Harshad number is a number that can be divided by the sum of its digits.
E. g. is 18 is divisible by 1+8 (=9) and is therefore a Harshad number. In this case, however, we are only interested in these numbers, which are both a prime number and a Harshad number.
Rules
Entries are accepted in any language you like. You have 7 days to publish your code as a comment or in an article. If you publish the code in an article, please post a comment with a link to your article below.
The author of the shortest program (in bytes) gets 2SBD as a small price =)
Great initiative! I don't know if I'll have time to submit an entry, but I'm keeping this entry in my bookmarks to see if I can find time this week :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Quick question: are you measuring "program length" in how much size the file takes in plain text, or taking into account binary size, memory usage or any other parameters? Just to be sure what parameter I'm trying to optimize ^^"
Also, if you measure text, are tabs/spaces counted?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I will measure the text size in bytes =) So if you use tabs you can save some bytes!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I found time after all and even did it in GolfScript for maximum saving XD.
Here's my entry. I ended up doing a bit of a wall of text explaining my reasoning, but you can find the answer at the beginning if you don't want to read my ramblings XD
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Nice solution =D
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit