كتب الكاتب الفاتح جبرا المتوفرة بمعرض الدوحة
|
Function لوجـه الله - يفضل كتابتهـا ب VB6.0
|
عندى 5 متغيرات.. a, b, c, d and f
داير مجموعهـم فى أى وقت.. بحيث a+b+c+d+f <> b+a+c+f+d، بمعنى لو غيرت ترتيب الجمـع تتغيـر النتيجـة أيضـا. الذى يستطيـع إيجاد الحل الصحيـح له جائـزة قيمـة، ويكون مستعـدا للتنازل عن حق إستعمال الفنكشن.
وبالله التوفيق..
|
|
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Ashrinkale)
|
الأخ 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
بالتوفيق
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Abureesh)
|
ابو الريش مرة كنت بقرا عن تاريخ الرياضيات صادفتني حاجة شبيه ليها وبسموها الارقام المتحابة كتحليل للعلاقات الغير متناهية لهذه الارقام وانو المكتشف منها لايتجاوز اصابع اليد عددا وقد بدأت مع الخوارزمي ولازالت تبحث في بيركلي..
يبدو اني ما افدتك بي شي
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Abureesh)
|
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 طريقة لجمعهم
الرجاء شرح المشكلة بتفصيل أكثر دقة
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: aosman)
|
Quote: الأخ ابوالريش عفوا كل المتغيرات String حصل خطأ في الكتابة |
الأخ عثمان،
مافى مشكلـة، وما زلت مرشحـا للجائزة الثانيـة.
الأخت مريــم، سلام ورمضان مبارك..
الجائزة قيمـة جـدا، وتعتمـد على ذكاء الحل.. just put as much intelligance in the solution as you can, and the result will be good
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Abureesh)
|
المهندس أبوالريش هات الحل: نجعل قيم الأرقام بالحساب الرقمى
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
تحياتى
بريمة
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Biraima M Adam)
|
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 بصـرف النظر عن نظام الحساب المتبع (هكس، باينرى، ديسيمال، أوكتال...الخ)
أصحى يا بريش.
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Abureesh)
|
طيب محاولة أخرى نفترض أن المعطيات فى شكل متوالية ونفترض: a != b !=c ومن ثم المتوالئة الأولى لا تساوى المتوالية الثانية أى جمع المتوالية الأولى لا يساوى حاصل جمع المتوالية الثانية :
a b c != b a c
وهذا يعنى عندما تضع a فى البداية هى أصغر من الرقم الذى يليها وهكذا
وعندما نضع b فى البداية فهى أصغر من a
يلا جيب الجائزة بدون كلام!
بريمة
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Abureesh)
|
Quote: دى كلهـا حتديك 3 لأنك ذكرت أنك بتستعمل أرقام وليس string.. يعنى حل الأخ عثمان زاتو لكن لخبطتو.. فى حالـة المتغيـر يكون رقـم تانى الجمع هو الجمع والنتيجـة 3 بصـرف النظر عن نظام الحساب المتبع (هكس، باينرى، ديسيمال، أوكتال...الخ)
أصحى يا بريش. |
ياصحبى أنت ذاتك مهود .. حاصل الجمع يساوى 2
أصحى يا بريش!!!
بريمة
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: AnwarKing)
|
Quote: طيب محاولة أخرى نفترض أن المعطيات فى شكل متوالية ونفترض: a != b !=c ومن ثم المتوالئة الأولى لا تساوى المتوالية الثانية أى جمع المتوالية الأولى لا يساوى حاصل جمع المتوالية الثانية :
|
أولا شكـرا على التنبيـه بأنى إتجريت ورا الغلط بتاعك حين جمعت 1+1 = 3
بعدين نظام التوالى دا الترابى زاتو خلاه..
ثم كيف تفترض على كيفك انو a <> b.. و أى متغير من ديل له الحق الكامل انو يعادل متغير اخر.. بل قد تكون لحظة فيها كل المتغيرات متسـاوية. و نصيحة ليك وليومك، حتى لو فرضنـا انو جهة ما طلبت منك حل لمشكلة، فعليك أن تقدم حلا عامـا وليس خاصـا، حتى لو كانت المشكلة خاصـة وفيها إفتراضك هذا.. دى نصيحة أخويـة سـاكت.
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Abureesh)
|
أبوالريش
Quote: أولا شكـرا على التنبيـه بأنى إتجريت ورا الغلط بتاعك حين جمعت 1+1 = 3
|
أنت كنت الغلطان .. أنا أتيت 011 وهى تعادل 3 وكذلك 101 وهى تعادل 5 و 110 وهى تعادل 6. وأنت جبت 3 من وين ما عارف! أنت بس ما عايز تعطينى الجائزة
الحل الأخير صحيح بغض النظر أنه خاص .. وهل المسألة المطروحة مسألة عامة!
جيب الجايزة يا زول
بريمة
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Abureesh)
|
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
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Abureesh)
|
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
| |
|
|
|
|
|
|
Re: Function لوجـه الله - يفضل كتابتهـا ب VB6.0 (Re: Abureesh)
|
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.
| |
|
|
|
|
|
|
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
|
يلا انا مستني الجائزة ...شكلها هي زاتها لغز لأنو عنوان موضوع اعلان الجائزة ما عارفو وين!!!
مودتي واتمنى ان اسمع منك قرياً لما تجي هونغ كونغ
أنور
| |
|
|
|
|
|
|
|