My take on this is that there are three output groups of digits.
The first two are pairs provided all inputs are < 10. The last
output group of digits is the product of the first two output
pairs minus the last input digit. Those first two output pairs
are easily seen to be the products of the first input with each
of the remaining two inputs.
It's not clear what's required if the last group is > 99, so
I'll assume that is not the case for this fun:
So:
fun =: 1&{ (100 #. ] , (-~ +/)) {. * }.
fun"1]5 3 2,9 2 4, 8 6 3,5 4 5,:7 2 5
151022 183652 482466 202541 143547
However,
fun 9 9 9 NB. is wrong ?!
818253
Mike
On 14/12/2014 08:01, robert therriault wrote:
Last kick at this one. I didn't like having 1 2&{ repeated!
fun=: 100 #. ({. (* , *&(+/)) 1 2&{) - 0 0, 1&{
fun 7 2 5
143547
Cheers, bob
On Dec 13, 2014, at 11:25 PM, robert therriault <[email protected]> wrote:
Thanks Skip
Tacit version and I'm done on this one.
fun=: 100 #. ({. * 1 2&{),({. * [: +/ 1 2&{)-1&{
fun 5 3 2
151022
fun 9 2 4
183652
fun 8 6 3
482466
fun 5 4 5
202541
fun 7 2 5
143547
Cheers, bob
ps. Only my mom calls me Robert (and that is when I have done something wrong!)
On Dec 13, 2014, at 10:30 PM, Skip Cave <[email protected]> wrote:
Good job Robert!. Your solution is more concise than mine. However, this
was the paper and pencil solution.....
rb =:]#~(' '~:]) NB. Remove all blanks
fun =. 3 : ' rb ":|.(a+b-1{y),(b=.*/0 2 {y),(a=.*/0 1 {y)'
fun 5 3 2
151022
fun 9 2 4
183652
fun 8 6 3
482466
fun 5 4 5
202541
fun 7 2 5
143547
I'm sure there is a more concise way to write
​my function, but I'm not good enough in J to shrink it any further.
Skip
On Sat, Dec 13, 2014 at 6:59 PM, robert therriault <[email protected]>
wrote:
Hey Skip,
I'm sure that there are more elegant ways but, here goes.
fun=: 3 : 0
​'a b c'=. y
​(a*b*10000)+(a*c*100)+(a*b+c)-b
​)
fun 5 3 2
151022
fun 9 2 4
183652
fun 8 6 3
482466
fun 5 4 5
202541
fun 7 2 5
143547
Cheers, bob
On Dec 13, 2014, at 3:17 PM, Skip Cave <[email protected]> wrote:
Oops! printing mistake...
fun 5 3 2
151022
fun 9 2 4
183652
fun 8 6 3
482466
fun 5 4 5
202541
fun 7 2 5
???
Skip Cave
Cave Consulting LLC
----------------------------------------------------------------------
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2014.0.4794 / Virus Database: 4235/8734 - Release Date: 12/14/14
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm