|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Abureesh)
|
العزيز الدين عثمان... يا زول انتا رجعتا السودان خلاص؟؟؟ أخوي ماشي ماليزيا...على العموم شكراً على الترحا...
العزيز يوسف حسن... مشكور يا كريم على اهداء الجائزة... وكده أخوك قاصي لمحمد عثمان خصوصاً أنو جاي قري مننا...
العزيز محمد... هناك من ارسل لي رسالة ولمحتوى الموضوع انشرها لك ولفائدة المتاعين...
Quote: Dear Anwar, Can you please forward this email to Abureesh on sudaneseonline.com? I believe he gave the price for the unique sum function game without any correct answer. 1. none of the winning contestant provided anything close to a working code 2. the first place winner suggest two things, either a polynomial arrangement, where each number is multiplied by its location coefficient as a first solution or using orthogonal vectors as coefficients to grantee the uniqueness of the sum. His second suggestion is better, but have the real problem of defining these orthogonal vectors without having a predefined multi-dimensional space defined in place. That is why he conveniently suggested to Abureesh the use of Matlab, which has the multi-direction vector space already defined. The problem here is that this is mount to cheating the game, as the game said you have to use VB or other similar programming languages. My solution below involves the simple shift-right process to accommodate number of the full size and the numbers don't have to only be in the range of (0 and 9) as supported by all the solutions on the discussion thread. This will lead to a true solution only dependant on the size of the input variables and the output is a normal larger sized long integer that is well defined in the programming language of choice. note that in my solution the inputs can be anything that fits in an unsigned 8 bit variable, you can simply use any number between (0 and 254), while the out put i used is unsigned 46 bit variable. The solution I am providing is more implementable in a regular programing language and the code is also provided, which none of the other contestants has provided. Too bad the game has ended without a correct answer. Thanks, Muhannad Elzaki
---------- Forwarded message ---------- From: Muhannad Elzaki Date: Sep 21, 2007 4:04 PM Subject: Unique Sum Function To: sudanorg
Salam Abureesh, I saw your programing problem on sudaneseonline.com, but since I don't have a sudaneseonline.com account, I would rather email you the my suggested solution. I just hope you check this email account often. If you have another email account that you would rather be contacted on, then please let me know. The program is written in pseudo C language, so please note that: u8 is unsigned 8 bit variable and u64 is unsigned 64 bit variable. Here is your unique_sum() function with the a, b, c, d,e,f parameters: u64 unique_sum(u8 a, u8 b, u8 c, u8 d, u8 e, u8 f) { u8 in[6]; u64 sum = 0; in[0] = a; in[1] = b; in[2] = c; in[3] = d; in[4] = e; in[5] = f; for(u8 i = 0; i < 5; i++) sum = (u64)(in[i] >> (i*(size(u8))); return sum; }
Here is a more complete program with main() and a modified version of the unique_sum() function, where I prefer to pass the values as an array instead of individual parameters:
#define ARRAY_SIZE 6 u8 total[ARRAY_SIZE];
u64 unique_sum(u8* in) { u64 sum = 0; for(u8 i = 0; i sum = (u64)(in[i] >> (i*(size(u8))); return sum; }
void main(void) { total[0] = a; total[1] = b; total[2] = c; total[3] = d; total[4] = e; total[5] = f; print( unique_sum(total)); }
I didn't have the time to run and debug the code, as I am still at work and only had few minutes break to scribe it.
Thanks,
Muhannad Elzaki
|
يلا انا مستني الجائزة ...شكلها هي زاتها لغز لأنو عنوان موضوع اعلان الجائزة ما عارفو وين!!!
مودتي واتمنى ان اسمع منك قرياً لما تجي هونغ كونغ
أنور
|
|
|
|
|
|
|
العنوان |
الكاتب |
Date |
Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-20-07, 08:44 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-21-07, 03:35 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | يحي ابن عوف | 09-21-07, 03:41 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Ashrinkale | 09-21-07, 04:17 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-21-07, 04:42 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | smart_ana2001 | 09-21-07, 06:58 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-21-07, 09:01 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Mamoun Ahmed | 09-21-07, 09:51 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | aosman | 09-21-07, 10:53 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | aosman | 09-21-07, 11:06 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-21-07, 11:45 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | aosman | 09-21-07, 12:52 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | aosman | 09-21-07, 12:59 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | مريم بنت الحسين | 09-21-07, 01:53 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-21-07, 03:31 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | aosman | 09-21-07, 03:39 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-21-07, 04:54 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Biraima M Adam | 09-21-07, 05:31 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-21-07, 05:49 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Biraima M Adam | 09-21-07, 10:04 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Biraima M Adam | 09-21-07, 10:16 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | AnwarKing | 09-21-07, 11:20 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-22-07, 01:53 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Biraima M Adam | 09-22-07, 01:59 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-22-07, 02:09 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-22-07, 02:14 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Yousef Hassan | 09-22-07, 04:58 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Yousef Hassan | 09-22-07, 05:02 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-22-07, 07:58 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Yousef Hassan | 09-22-07, 03:10 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | aosman | 09-22-07, 08:22 AM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Abureesh | 09-22-07, 03:32 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Yousef Hassan | 09-22-07, 04:35 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | AnwarKing | 09-22-07, 05:33 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Yousef Hassan | 09-22-07, 06:24 PM |
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 | Yousef Hassan | 09-22-07, 06:36 PM |
|
|
|