Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #284: Division with Macros

justindavis
10 - Fireball
Spoiler
challenge_284_solution_jdavis.PNGchallenge_284_solution_jdavis_macro.PNG
DawnDuong
13 - Pulsar
13 - Pulsar

Thank you for posting this challenge, it is really interesting. 

The most challenging aspect for me, personally, is how to make the solutions as generalised as possible, such as being able to take in unlimited number of digits and design the logic flow so that it can handle generalised the problem of adding numbers of different numbers of order of magnitudes (e.g. how to handle if the remainders when added together exceed the divisor).

I solved it using 3 iterative macros and this seems to work when tested with extra long numbers.

randreag
11 - Bolide

Here the challenge solved

Sashikumar
8 - Asteroid

Learned from solution.

Spoiler
sk_284_1.pngsk_284_2.png
Jquema
5 - Atom

I like this challenge. How long is the workflow suppose to run? Tried the solution via generate rows and it has been running for the past 20 minutes.

Watermark
12 - Quasar
12 - Quasar

Ok, kind of proud of this, took a little thought but love the result.  

4 tools  0.4 seconds, no macro needed.

Flexible and should work for any number to 30 digits.  'If' it doesn't it would be the tiniest of tweaks, the concept certainly does with almost zero hard code.

@patrick_digan since this challenge is your baby, and I tend to like a lot of your approaches, I'd be interested in your  take.

 

 

Spoiler
MT Solution 284.png

 

AngelosPachis
16 - Nebula

Thank you @patrick_digan for the challenge, that was brutal! Found this post really helpful to solve this challenge

 

https://www.geeksforgeeks.org/program-quotient-remainder-big-number/

 

Workflow:

 

Spoiler
AngelosPachis_0-1639325046000.png

 

 

Macro : 

 

Spoiler
AngelosPachis_1-1639325056917.png

 

 

 

 

ggruccio
ACE Emeritus
ACE Emeritus

Back after a short hiatus! I want that #300 Badge 😀

 

Really proud of this solution that simulates long division!

 

Spoiler
Iterative macro checks if each digit is divisible by the field and carries over the modulo * 10 to be added to the next digit.  For example 1 not divisible by 1234 so 1*10 carries over and added to the next digit....12 not divisible by 1234 so 12*10 or 120 carries over to the next digit, 123 not divisible by 1234 so 1230 carries over and added to the next digit.  1234 is divisible by 1234 so there I get my first result(the first 3 were 0) The macro is Iterative = to the length of the string (although capped at 100 runs).  Once I get the results of the macro I convert each individual divided number to a string and concatenate with  the Summarize tool back in the main workflow.
  ggruccio_1-1640294538060.png

 

 

 

 

atcodedog05
22 - Nova
22 - Nova

Here is my take on it

 

Spoiler
atcodedog05_0-1640881935328.png

 

LiuZhang
9 - Comet
Spoiler
MacroMacroWorkflowWorkflow

Quite interesting problem to have, I went for the long division route, so the macro should work for any length (Divisor is set Int16 currently). Though still need to improve the macro to set a stop condition.