Please Disable Ad-Block To View This Website.

If you block ads, this site can not survive!

Ads are very minimal for registered users. If you don't have an account please register now!

DOWNLOAD
 Full Scripts
 Addons
 Snippets
 DLLs
 MTS Themes
 Tutorials
 Misc.
 File Queue
 Download mIRC
INTERACT
 Screenshots
 Challenge
 Top Downloads
 Submit Form
 Forums

SEARCH
Site Search

FRIENDS
Link to us!
PhotoShelf

Top Challenge Entrants

  # User Points
  1 jaytea 587
  2 [Znork] 303
  3 urza 297
  4 Ag2X 288
  5 dr_Eamer 255
  6 Albie 199
  7 Chessnut 197
  8 A Noniem 194
  9 zzattack 186
  10 Kol 185
  11 m910q 168
  12 Sephiroth 115
  13 patje 114
  14 Auron956 114
  15 chid 110
  16 Ohad2121 92
  17 SkorpSSS 87
  18 DixrouE 84
  19 Suchorski 83
  20 ^Vampire^ 74
Challenge:Smallest $ishappy number
Start:August 9th 2009
End:August 15th 2009
Description:

In this challenge you are asked to create an alias that will return if a given number is "happy" or not.

Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers.


Your alias should return 1 if the number is happy or 0 if unhappy. Always assume the correct input is passed to the alias i.e. a integer number >= 0. A number up to and including 1000 will be tested.

Example:

Lets take for example the number 7. First of all we square the number:

7^2 = 49


Then we square each single digit in the answer and add them together;

4^2 + 9^2 = 97


We keep repeating:

9^2 + 7^2 = 130
1^2 + 3^2 + 0^2 = 10
1^2 + 0^2 = 1 we have reached 1 therefore 7 is a happy number

Now lets take a look at an unhappy number 4:

4^2 = 16
1^2 + 6^2 = 37
3^2 + 7^2 = 58
3^2 + 7^2 = 89
8^2 + 9^2 = 145
1^2 + 4^2 + 5^2 = 42
4^2 + 2^2 = 20
2^2 + 0^2 = 4 --> we are back where we started and will now continue going in a loop.


Therefore 4 is not a happy number.

$ishappy(0) = 0
$ishappy(1) = 1
$ishappy(338) = 1
$ishappy(491) = 0


Rules:

  • Alias name must be 'ishappy'
  • No dlls, coms, sockets
  • One submission per user.
  • Script must give correct results after consecutive runs.


  • Testing conditions:

  • Alias will be run on mIRC v6.35 and loaded into the remotes section.
  • Your code will be taken for EXACTLY as-is.
  • Alias will be run on a mIRC with no variables set - a clean mIRC.