Function لوجـه الله - يفضل كتابتهـا ب VB6.0

Function لوجـه الله - يفضل كتابتهـا ب VB6.0


09-20-2007, 08:44 PM


  » http://sudaneseonline.com/cgi-bin/sdb/2bb.cgi?seq=msg&board=120&msg=1190317483&rn=22


Post: #1
Title: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-20-2007, 08:44 PM
Parent: #0

عندى 5 متغيرات.. a, b, c, d and f

داير مجموعهـم فى أى وقت.. بحيث a+b+c+d+f <> b+a+c+f+d، بمعنى لو غيرت ترتيب
الجمـع تتغيـر النتيجـة أيضـا.
الذى يستطيـع إيجاد الحل الصحيـح له جائـزة قيمـة، ويكون مستعـدا للتنازل عن
حق إستعمال الفنكشن.

وبالله التوفيق..

Post: #2
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-21-2007, 03:35 AM
Parent: #1

vb6 كود مقبول، أو برضو ممكن تكون معادلة عاديـة

Post: #3
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: يحي ابن عوف
Date: 09-21-2007, 03:41 AM
Parent: #2


Post: #4
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Ashrinkale
Date: 09-21-2007, 04:17 AM
Parent: #3

Salam Abureesh
Ramadhan Kareem
Do you mean a+b+c+d+f != d+a+c+b+f

Thanks

Post: #5
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-21-2007, 04:42 AM
Parent: #4

الأخ Ashrinkale

الف مرحبـا وشكـرا على الإهتمام والمشـاركـة.

ما بالضـرورة الجمـع أو الـ negation (!).. ممكن تجمع أو تطرح أو تضرب
أو تقسـم، بأى طريقـة.. المهـم المطلوب هـو رقـم وحيـد يمثل مجموعة
المتغيـرات..
A unique number that represents the group of the variables at any time.. not necessarily the
arithmatic summation of the variables

مثال أفترض المتغيرات ِa, b and c، ثم فى لحظـة كانت هـذه قيمهـا:
a = 7
b = 5
c = 2

by simple addition, a+b+c = b+c+a = c+a+b = ... = 14

but I don't want this

the requirnment is

a+b+c should not equal to b+c+a or any other arrangement AT ALL TIMES

بالتوفيق

Post: #6
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: smart_ana2001
Date: 09-21-2007, 06:58 AM
Parent: #5

الاستاذ Abureesh
رمضان كريم
دى غلبتنى كلو كلو...
الكود خليه .....بالورقه و القلم مستحيله
و اشمعنى VB6.0 ؟؟؟؟ هل دى جانب من الفزوره ؟؟ يعنى ممكن اكتبو ب VB.Net ؟؟؟

Post: #7
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-21-2007, 09:01 AM
Parent: #6

Quote: smart_ana2001


smart_ana2001

شكــرا ومرحبـا،

VB6.0, dot net, c++,.. anything

المهم المعادلـة وشرح الألغوريثم

عندى بروجكت بالفى بى 6 مشيت فيه كتير، عشـان كدا لو اتكتبت بلغة تانيـة حأترجمها.

لكن سيبك من اللغات، بس ادونا المعادلـة.. كتابة الكود ما مشكلـة

Post: #8
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Mamoun Ahmed
Date: 09-21-2007, 09:51 AM
Parent: #1

ابو الريش
مرة كنت بقرا عن تاريخ الرياضيات
صادفتني حاجة شبيه ليها
وبسموها الارقام المتحابة
كتحليل للعلاقات الغير متناهية لهذه الارقام
وانو المكتشف منها لايتجاوز اصابع اليد عددا
وقد بدأت مع الخوارزمي ولازالت تبحث
في بيركلي..


يبدو اني ما افدتك بي شي

Post: #9
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: aosman
Date: 09-21-2007, 10:53 AM
Parent: #1


الأخ أبوالريش

رمضان كريم.
بعد غيبة طويلة من المنبر أجبرتني مشكلة على الكتابة مرة ثانية.






Since you haven't imposed any restrictions to the proposed solution of your problem, I suggest for you
1. to assign string data type for your variables, e.g.
Dim a, b, c as String
2. The addition of strings is interpreted as concatenation in most of programming languages (if not all of them)
3. After the addition you can convert the type of the result from string to integer or whatever data type you like

For example:

if a = "1" and b = "2" then a + b is not equal to b + a
a + b yields "12" and b + a yields "21" and when you convert them to integers you get 12 and 21

I hope that this algorithm will offer you some help.

with my best wishes and regards



Post: #10
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: aosman
Date: 09-21-2007, 11:06 AM
Parent: #1



Here is the Visual Basic code

Dim a As String = "4"
Dim b As Integer = "6"
Dim c As String = "5"
Dim d As Integer = "3"
Dim f As String = "2"


Dim result1 As Integer = a + b + c + d + f

Dim result2 As Integer = a + b + c + f + d


Post: #11
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-21-2007, 11:45 AM
Parent: #10

الأخ العزيز عثمان،

الف مرحب وشكرا على المساهمـة.

Quote: Here is the Visual Basic code

Dim a As String = "4"
Dim b As Integer = "6"
Dim c As String = "5"
Dim d As Integer = "3"
Dim f As String = "2"


Dim result1 As Integer = a + b + c + d + f

Dim result2 As Integer = a + b + c + f + d


ياخى لك ان تعاتبنى ما شئت، فقـد نسيت أن أستبعـد حل (الرصـة) لأنى
حاولته من قبل، ووجدت أنه عندما تكون قيم المتغيرات كبيرة، فإن الرقم
الناتج عن (الرص) سيكون طويلاً جـدا..

بالرغم من أنى لم أفهـم كيف تجمـع integer مع string بدون ما يديك تايب مسماتش.
انا عملت كل المتغيرات استرنق فى الأول، وبعد أن رصيتهـا حولت النتيجة لعدد،
المهم دا ما الموضوع.

معليش أرجو أن تعيـد الكـرة مـرة أخرى..

تستطيع إضافـة أو طرح أرقام أو الضرب فى عوامل، فإن المقصـود ليس هـو
نتيجـة الجمـع بقدر ما هـو ال uniqueness للرقم النهائى، ودقـة التمثيل بقدر
الإمكان.

شكـرا ليك مـرة أخرى، وعلى أى حال انت دخلت فى زون الجائزة، وربمـا
نلت الجائزة الثانيـة لو لم يقفز شخصان أخران.

Post: #12
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: aosman
Date: 09-21-2007, 12:52 PM
Parent: #1

Quote: بالرغم من أنى لم أفهـم كيف تجمـع integer مع string بدون ما يديك تايب مسماتش.
انا عملت كل المتغيرات استرنق فى الأول، وبعد أن رصيتهـا حولت النتيجة لعدد،
المهم دا ما الموضوع.



يمكن أستخدام الفنكشن Val لتحويل ال string الي integer مثلا

Dim value1 as Integer = Val (a + b + c) this will do it without giving any error

الأخ ابو الريش

على حسب صيغة سؤالك في البداية فالحل الذي طرحته لك هو سليم مية المية, واذا أستمريت في أعادة صياغة السؤال بعد كل حل فلا يمكن لنا الوصول الي حل.
وتأكد أن لم تضع حد معين للأرقام التي سوف تجمعهم وتركتهم مفتوحة فيصعب أيجاد أرقام فردية صغيرة لتمثيل حاصل الجمع والطرح والض

مثال: اذا أخذنا ستة أرقام فردية وحاولنا جمعهم أثنين أثنين نجد ان هنالك 5 * 4 * 3 * 2 = 120 طريقة لجمعهم

الرجاء شرح المشكلة بتفصيل أكثر دقة

Post: #13
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: aosman
Date: 09-21-2007, 12:59 PM
Parent: #1


Dear Abureesh,

If the last number is very big you can convert the numbers to hexadecimal number before or after addition

Post: #14
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: مريم بنت الحسين
Date: 09-21-2007, 01:53 PM
Parent: #1

lovely...I'lll think about it...

I just want to know what's the prize?

Post: #15
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-21-2007, 03:31 PM
Parent: #14

Quote: Dim a As String = "4"
Dim b As Integer = "6"
Dim c As String = "5"
Dim d As Integer = "3"
Dim f As String = "2"


يا عثمان ياخ دا كان مصدر تعليقى، موش لأنو ما عارف احول القيم المختلفـة!

ليه أديت المتغيرات دى واحدين استرنق وواحدين إنتيجر.

عملت a استرنق و b انتقر عى أى أساس.. طبعا ممكن تحولهم زى ما عاوز لكن
حتخسـر خطوة برمجـة زيادة.. حتى لو استعملت function val()1 فالخطوات الزائدة
ستكون موجودة وترهق البروسسـور بالرغـم من أنهـا شفافـة بالنسبـة ليك.. أنت
تفتكر انهـا خطوة واحدة.. لكن دى طريقة الفى بى..

والســؤال الأسـاسى:
عملت a و c استرنق و b و d انتقر عى أى أساس يا عثمان؟


بعدين موضوع الكونكاتينيشن دا صرفنا النظر عنه من أول محاولاتى لحل للمشكلة زى ما
قلت.. وهسى أصرف النظر عن الكود برضـو.. ركز على المعادلـة بس..

مـرة أخرى، المشكلـة هى:

المطلوب إيجاد قيمة تعبر عن حصيلـة قيـم المتغيرات بحيث لا تتكرر عند تبادل
مواقع القيـم فى كتابـة المعادلـة.
لا يمكن اتباع الحل الخطى بوضع تلك القيم بجانب بعضهـا لتكون سلسلـة.

Post: #16
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: aosman
Date: 09-21-2007, 03:39 PM
Parent: #1


الأخ ابوالريش
عفوا كل المتغيرات String حصل خطأ في الكتابة

Post: #17
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-21-2007, 04:54 PM
Parent: #16

Quote: الأخ ابوالريش
عفوا كل المتغيرات String حصل خطأ في الكتابة


الأخ عثمان،

مافى مشكلـة، وما زلت مرشحـا للجائزة الثانيـة.


الأخت مريــم،
سلام ورمضان مبارك..

الجائزة قيمـة جـدا، وتعتمـد على ذكاء الحل..
just put as much intelligance in the solution as you can, and the result
will be good

Post: #18
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Biraima M Adam
Date: 09-21-2007, 05:31 PM
Parent: #17


المهندس أبوالريش
هات الحل:
نجعل قيم الأرقام بالحساب الرقمى

a = 0
b = 1
c = 1

أجمع
a+b+c = 011
b+a+c = 101
b+c+a = 110

هذا يعنى أن:
a+b+c = 3
b+a+c = 5
b+c+a = 6

وعلى هذا الأساس
a+b+c != b+a+c != b+c+a

ولو محتاج للبرنامج سوف أكتبه لك بلغة Java

تحياتى

بريمة

Post: #19
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-21-2007, 05:49 PM
Parent: #18

Quote:
المهندس أبوالريش
هات الحل:
نجعل قيم الأرقام بالحساب الرقمى

a = 0
b = 1
c = 1

أجمع
a+b+c = 011
b+a+c = 101
b+c+a = 110

هذا يعنى أن:
a+b+c = 3
b+a+c = 5
b+c+a = 6

وعلى هذا الأساس
a+b+c != b+a+c != b+c+a

ولو محتاج للبرنامج سوف أكتبه لك بلغة Java

تحياتى

بريمة



بريمـة،

الظاهـر رمضان مسخن عندكم..

ياخى إقتراحك دا إلا تقدمو للحكومـة عشـان تحل بيه مشكلـة دارفـور!!


تقول:
Quote: أجمع
a+b+c = 011
b+a+c = 101
b+c+a = 110

هذا يعنى أن:
a+b+c = 3
b+a+c = 5
b+c+a = 6


لا أجمـع أنت يا أخى..

a+b+c
b+a+c
b+c+a

دى كلهـا حتديك 3 لأنك ذكرت أنك بتستعمل أرقام وليس string.. يعنى حل الأخ عثمان
زاتو لكن لخبطتو..
فى حالـة المتغيـر يكون رقـم تانى الجمع هو الجمع والنتيجـة 3 بصـرف النظر
عن نظام الحساب المتبع (هكس، باينرى، ديسيمال، أوكتال...الخ)

أصحى يا بريش.

Post: #20
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Biraima M Adam
Date: 09-21-2007, 10:04 PM
Parent: #19


طيب محاولة أخرى
نفترض أن المعطيات فى شكل متوالية
ونفترض:
a != b !=c
ومن ثم المتوالئة الأولى لا تساوى المتوالية الثانية أى جمع المتوالية الأولى لا يساوى حاصل جمع المتوالية الثانية :

a b c != b a c

وهذا يعنى عندما تضع a فى البداية هى أصغر من الرقم الذى يليها وهكذا

وعندما نضع b فى البداية فهى أصغر من a

يلا جيب الجائزة بدون كلام!

بريمة

Post: #21
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Biraima M Adam
Date: 09-21-2007, 10:16 PM
Parent: #19


Quote: دى كلهـا حتديك 3 لأنك ذكرت أنك بتستعمل أرقام وليس string.. يعنى حل الأخ عثمان
زاتو لكن لخبطتو..
فى حالـة المتغيـر يكون رقـم تانى الجمع هو الجمع والنتيجـة 3 بصـرف النظر
عن نظام الحساب المتبع (هكس، باينرى، ديسيمال، أوكتال...الخ)

أصحى يا بريش.

ياصحبى أنت ذاتك مهود .. حاصل الجمع يساوى 2


أصحى يا بريش!!!

بريمة

Post: #22
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: AnwarKing
Date: 09-21-2007, 11:20 PM
Parent: #1

محمد عثمان... عودا حميدا لسودانيز و
رمضان كريم

................
عرفتا الحل ولا لسة؟

Binary Addition results are different
Convert multiple times

ولا شنو؟

الدين عثمان....مشتاقين يارجل... أخي الاصغر جاييكم قريب بهناك...

Post: #23
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-22-2007, 01:53 AM

Quote: طيب محاولة أخرى
نفترض أن المعطيات فى شكل متوالية
ونفترض:
a != b !=c
ومن ثم المتوالئة الأولى لا تساوى المتوالية الثانية أى جمع المتوالية الأولى لا يساوى حاصل جمع المتوالية الثانية :


أولا شكـرا على التنبيـه بأنى إتجريت ورا الغلط بتاعك حين جمعت 1+1 = 3

بعدين نظام التوالى دا الترابى زاتو خلاه..

ثم كيف تفترض على كيفك انو a <> b.. و أى متغير من ديل له الحق الكامل انو
يعادل متغير اخر.. بل قد تكون لحظة فيها كل المتغيرات متسـاوية.
و نصيحة ليك وليومك، حتى لو فرضنـا انو جهة ما طلبت منك حل لمشكلة، فعليك أن
تقدم حلا عامـا وليس خاصـا، حتى لو كانت المشكلة خاصـة وفيها إفتراضك هذا..
دى نصيحة أخويـة سـاكت.

Post: #24
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Biraima M Adam
Date: 09-22-2007, 01:59 AM
Parent: #23


أبوالريش
Quote: أولا شكـرا على التنبيـه بأنى إتجريت ورا الغلط بتاعك حين جمعت 1+1 = 3
أنت كنت الغلطان ..
أنا أتيت 011 وهى تعادل 3 وكذلك 101 وهى تعادل 5 و 110 وهى تعادل 6. وأنت جبت 3 من وين ما عارف! أنت بس ما عايز تعطينى الجائزة

الحل الأخير صحيح بغض النظر أنه خاص .. وهل المسألة المطروحة مسألة عامة!

جيب الجايزة يا زول

بريمة

Post: #25
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-22-2007, 02:09 AM
Parent: #24

Quote:
a = 0
b = 1
c = 1

أجمع
a+b+c = 011


بريمـة،

موش انت الجمعت a+b+c = 011 اللى هى 3؟
بتغالط مالك لو قلت اتجريت ورا غلطك؟

Post: #26
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-22-2007, 02:14 AM
Parent: #25

الأخ أنور دفع الله،

سلام ورمضان كريم..

الأسبوع الجاى حأكون فى HK إن شـاء الله.

المشكلة لسـه ما إتحلت.. براك شايف ناس بريمة الواحد يفترض إفتراض
خاطئ وطوالى يقوم بنمرة تلاتة!

Post: #27
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Yousef Hassan
Date: 09-22-2007, 04:58 AM
Parent: #26

I have an idea hopefully will solve your problem. You can use a model that will pre-multiply each number with a coefficient (spread code like) according to their index:

x1*a1 + x2*a2 + …+ xn*an

You can write a function that takes a1, a2, …, an as arguments and return the unique sum according to their order.

If this serves what you are looking for send my gift to Anwarking el 3rees

Post: #28
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Yousef Hassan
Date: 09-22-2007, 05:02 AM
Parent: #26

I have an idea hopefully will solve your problem. You can use a model that will pre-multiply each number with a coefficient (spread code like) according to their index

x1*a1 + x2*a2 + …+ xn*an

You can write a function that takes a1, a2, …, an as arguments and return the unique sum according to their order. If this serves what you are looking for send my gift to Anwarking el 3rees

Post: #29
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-22-2007, 07:58 AM
Parent: #28

الأخ يوسف،
شكـرا والف مرحبـا

إجابتك أقرب للصـواب من كل الإجابات الموجودة حتى الأن.. ولقـد أطلعت أخ عزيز
عند زيارته لنا الشهـر الماضى على نفس الحل (تضرب المتغيـر فى رقم موقعه)
ولكنه قال أن هناك بعض الحالات التى سـوف يشترك فيها متغيران أو أكثر.
دعنى أتحقق من هـذه أولا، ولكنك بهـذا أزحت عثمان من المنافسـة على الجائزة
الثانيـة (على الأقل).

Post: #31
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Yousef Hassan
Date: 09-22-2007, 03:10 PM
Parent: #29

You can multiply your 1x5 vector by a 5x5 orthogonal matrix that will yield different 1x5 vector if the numbers or their order changes, now you grantee you have different set of numbers every time regardless of the original one then you can pre multiply them with their index or any other 1x5 vector (use independent vector to avoid the sum being 0).
Do you use Matlab? It's easier to exercise this in Matlab. If so I can send you script to do that so you can try different combinations of numbers and see if it works.

Post: #30
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: aosman
Date: 09-22-2007, 08:22 AM
Parent: #1


الأخ العزيز أنو كنج

نشكرك على الأستقبال وأخوك ألف ألف مرحب بيهو, أخوك جاي السودان؟

Post: #32
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Abureesh
Date: 09-22-2007, 03:32 PM
Parent: #30

Quote: Do you use Matlab? It's easier to exercise this in Matlab


Dear Yousif

thanks again, and I will try to implement this in FFT (Fast Fourier Transform)1

دى لازم نحسبهـا طايرة يا يوسف.. ومبروك الجائـزة بالمناسبـة.. أعلنت النتيجـة
فى بوست أخـر.

Post: #33
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Yousef Hassan
Date: 09-22-2007, 04:35 PM
Parent: #32

Thank you for the challenge. Good luck

Post: #34
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: AnwarKing
Date: 09-22-2007, 05:33 PM
Parent: #1

العزيز الدين عثمان...
يا زول انتا رجعتا السودان خلاص؟؟؟
أخوي ماشي ماليزيا...على العموم شكراً على الترحا...

العزيز يوسف حسن...
مشكور يا كريم على اهداء الجائزة... وكده أخوك قاصي لمحمد عثمان خصوصاً أنو جاي قري مننا...

العزيز محمد...
هناك من ارسل لي رسالة ولمحتوى الموضوع انشرها لك ولفائدة المتاعين...

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


يلا انا مستني الجائزة ...شكلها هي زاتها لغز لأنو عنوان موضوع اعلان الجائزة ما عارفو وين!!!

مودتي واتمنى ان اسمع منك قرياً لما تجي هونغ كونغ


أنور

Post: #35
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Yousef Hassan
Date: 09-22-2007, 06:24 PM
Parent: #34

Muhannad Elzaki,

what is the difference between your solution and my first proposed solution? right shift by i is nothing but divid by 2^i. which you already said it doesn't work.

Orthogonal vectors are not a rocket scince to compute Gram-Schmidt algorithm can be used.

I suggested Matlab for the ease of prototyping and by the way you can convert Matlab code into C code when you make sure the design works.

you can e mail me at [email protected] if you dissagree and I will post it here.

Post: #36
Title: Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0
Author: Yousef Hassan
Date: 09-22-2007, 06:36 PM
Parent: #35

AnwarKing,

Quote: مشكور يا كريم على اهداء الجائزة... وكده أخوك قاصي لمحمد عثمان خصوصاً أنو جاي قري مننا...


I meant send to Anwarking so you can send it to me "I didn't know it's a mobile" ....

I thought it's "simpriia rakba fi dahar zarafa mashaa el ba7ar tjeeeb mooya" ... b6il d7ik ya zool ... anywho...

by the way if Muhanad prove am wrong and he is right he will be the one deserves it