Тёмный
No video :(

[IBM Ponder This] July 2018 Solution 

srcmake
Подписаться 3,5 тыс.
Просмотров 354
50% 1

The solution for this July 2018's IBM challenge just requires basic programming. The trick to getting a bonus star is using a good data structure to be memory efficient (and even then, you'll need 13 GB of space and 30 minutes of time). In the video, we go over the logic and code for solving the problem.
Link to webpage: www.srcmake.co...
Link to data structures: www.srcmake.co...
Twitter: / srcmake
Twitch: / srcmake
Discord: / discord

Опубликовано:

 

26 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 6   
@ThomasEgense
@ThomasEgense 6 лет назад
Thank you for showing your solution. I did something very similar to yours as first attempt and got into the same memory problems. It did not scale. So I did another approach. Notice a solution with 7 obscure triplets (if it exists!) will have sum n,n+3,n+6,n+9,n+12,n+15,n+18. So if you instead make a loop for (a,b,c) that will have a given sum, you will only need 7 separate data structures to store the information. When you done with 'n' etc, you can garbage collect the first structure and create a new 'n+21'. Since you step 3 numbers every time, you will need to run it 3 times for n=0,1,2 (mod 3). Another nice benefit here is if your problem stops, you can always continue from where you got to, since this only needs to know the starting sum n. I checked all triplets (a,b,c) having sum < 32000 and only found those listed on solution page. All of them was found within 1 hour calculation, the largest with sum=14963. Almost two days later had checked up to 32000 and not found another solution with 6 obscure triplets in a row, and none with 7 of course. The 32000 limit was due to storing shorts requires a little more memory. Also I do not need to have 7 different data structures, since 6 will do. If I found another solution with 6 triplets I could just test if was 7 solution relative fast. At sum 32000 it took around 30 GB memory(I had too run it it 3 times for values 0,1,2 (mod 3).
@MrSCM-nw9dn
@MrSCM-nw9dn 6 лет назад
Notice that for a candidate triplet the product needs t least 5 factors, otherwise the sum cannot be the same.
@MrSCM-nw9dn
@MrSCM-nw9dn 6 лет назад
Consider it as a LP problem with a nonlineair component. Solve it with AMPL an KNITRO; here is the model:: param Top = 70; var A integer >= 1 = 2 = 3 = 1 = 2 = 3 = 1 = 2 = 3 = 1 = 2 = 3 = 1 = 2 = 3 = 1; s.t. Q02: C - B >= 1; s.t. Q03: F - E >= 1; s.t. Q04: G - F >= 1; s.t. Q05: abs(A - E) >= 1; s.t. Q06: A + B + C = E + F + G; s.t. Q07: A * B * C = E * F * G; s.t. Q12: F1 - E1 >= 1; s.t. Q13: G1 - F1 >= 1; s.t. Q14: abs(A + 1- E1) >= 1; s.t. Q15: A + B + C + 3 = E1 + F1 + G1; s.t. Q16: A * B * C + B * C + A * C + C + A * B + B + A + 1 = E1 * F1 * G1; s.t. Q22: F2 - E2 >= 1; s.t. Q23: G2 - F2 >= 1; s.t. Q24: abs(A + 2 - E2) >= 1; s.t. Q25: A + B + C + 6 = E2 + F2 + G2; s.t. Q26: A * B * C + 2 * B * C + 2 * A * C + 4 * C + 2 * A * B + 4 * B + 4 * A + 8 = E2 * F2 * G2; s.t. Q32: F3 - E3 >= 1; s.t. Q33: G3 - F3 >= 1; s.t. Q34: abs(A + 3 - E3) >= 1; s.t. Q35: A + B + C + 9 = E3 + F3 + G3; s.t. Q36: A * B * C + 3 * B * C + 3 * A * C + 9 * C + 3 * A * B + 9 * B + 9 * A + 27 = E3 * F3 * G3; And the commands to solve it: model c:\temp\ibm1807.mod; option solver knitroampl; solve; display A,B,C,E,F,G >IBM1807.out; display E1,F1,G1 >IBM1807.out; display E2,F2,G2 >IBM1807.out; display E3,F3,G3 >IBM1807.out; close IBM1807.out; This program gives also the alternative triplets.
Далее
Best Programming Languages To Learn In 2021
17:04
СМАЗАЛ ДВЕРЬ
00:31
Просмотров 161 тыс.
Only I get to bully my sister 😤
00:27
Просмотров 19 млн
Oh No! My Doll Fell In The Dirt🤧💩
00:17
Просмотров 2,8 млн
WHY IS THE STACK SO FAST?
13:46
Просмотров 148 тыс.
Segment Trees Explained and C++ Code
32:34
Просмотров 1,7 тыс.
How Linux Kernel Prints Text on Screen
12:46
Просмотров 66 тыс.
Premature Optimization
12:39
Просмотров 794 тыс.
NVIDIA Needs to STOP - RTX 3050 & Misleading Branding
11:35
It's time for change, it's time for Linux.
10:53
Просмотров 251 тыс.
microsoft doubles down on recording your screen
10:00
CircleCI Tutorial w/ Demo Project in 22 Mins
22:25
Просмотров 38 тыс.
Fast Inverse Square Root - A Quake III Algorithm
20:08
СМАЗАЛ ДВЕРЬ
00:31
Просмотров 161 тыс.