Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16371 > unrolled thread
| Started by | Ulrich Arndt <ulrich.arndt@data2knowledge.de> |
|---|---|
| First post | 2014-01-03 09:34 +0000 |
| Last post | 2014-01-13 07:14 +0000 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: For 2014? Ulrich Arndt <ulrich.arndt@data2knowledge.de> - 2014-01-03 09:34 +0000
Re: For 2014? Costa Bravo <q13a27tt@aol.com> - 2014-01-07 07:49 +0000
Re: For 2014? Ulrich Arndt <ulrich.arndt@data2knowledge.de> - 2014-01-10 07:38 +0000
Re: For 2014? Boguś <telemorele@wp.pl> - 2014-01-12 07:24 +0000
Re: For 2014? Ulrich Arndt <ulrich.arndt@data2knowledge.de> - 2014-01-13 07:14 +0000
| From | Ulrich Arndt <ulrich.arndt@data2knowledge.de> |
|---|---|
| Date | 2014-01-03 09:34 +0000 |
| Subject | Re: For 2014? |
| Message-ID | <la606o$faj$1@smc.vnet.net> |
Thanks for sharing. Was obviously not aware of this.
Here a tweet conform code e.g. 139 chars - output could be nicer but 140 is a strong limitation given the long function names...
l=Range[9];r=StringJoin[Riffle[ToString/@l,#]]&/@Tuples[{"+","-","*","/",""},8];Grid[{#,Extract[r,Position[ToExpression/@r,#]]}&/@(l+2010)]
Ulrich
Am 28.12.2013 um 23:45 schrieb carlson@wolfram.com:
> I wrote a blog post about this a while ago which has a downloadable notebook with code. There's also a reference to a post by Hans Havermann on the same topic.
>
> http://blog.wolfram.com/2012/02/02/happy-109876-54321/
>
> Chris
>
>
> On Dec 26, 2013, at 5:24 AM, Ulrich Arndt <ulrich.arndt@data2knowledge.de> wrote:
>
>> Actually it has to be SeedRandom[1992] - was late ;-).
>>
>> But also an complete check is possible - and therefore much better...
>>
>> char = CharacterRange["1", "9"]
>> type = {"+", "-", "*", "/", ""}
>>
>> t = Tuples[type, 8];
>> r = StringJoin[Riffle[char, #]] & /@ t;
>> e = ToExpression[#] & /@ r;
>> p = Position[e, 2014]
>> Extract[r, p]
>>
>> Works also for reversed number list.
>>
>> Ulrich
>>
>> Am 24.12.2013 um 22:05 schrieb Ulrich Arndt:
>>
>>> 123 + 45*6*7 - 8 + 9
>>>
>>> Generate is maybe a bit wrong - search ;-)
>>>
>>> char = CharacterRange["1", "9"]
>>> type = {"+", "-", "*", "/", ""}
>>> RandomSeed[1992]
>>> r = Table[StringJoin[Riffle[char, RandomChoice[type, 8]]], {1000000}];
>>> e = ToExpression[#] & /@ r;
>>> p = Position[e, 2014]
>>> Union[Extract[r, p]]
>>>
>>> 2015
>>> 1*2-3+4*567*8/9, 12*3+45*6*7+89, 12*34*5-6*7+8+9
>>>
>>>
>>>
>>>
>>>
>>>
>>> Am 24.12.2013 um 08:17 schrieb Harvey P. Dale:
>>>
>>>> There are some nice (very simple) math puzzles using consecutive integers that produce years. For example, 10+(9 x 8 x (7/6) x 5 x 4)+321 and 0-12+(34 x 56)+7 x (8+9) both yield 2011, and (10 x 9 x 8) + 7 + 6 - 5 + (4 x 321) yields 2012.
>>>>
>>>> Two questions: (1) can anyone generate a similar puzzle yielding 2014 and (2) is there a general Mathematica program that can generate these?
>>>>
>>>> Best,
>>>>
>>>> Harvey
>>>>
>>>
>>>
>>
>>
>>
>
[toc] | [next] | [standalone]
| From | Costa Bravo <q13a27tt@aol.com> |
|---|---|
| Date | 2014-01-07 07:49 +0000 |
| Message-ID | <lagbi5$780$1@smc.vnet.net> |
| In reply to | #16371 |
Ulrich Arndt wrote:
>
> l=Range[9];r=StringJoin[Riffle[ToString/@l,#]]&/@Tuples[{"+","-","*","/",""},8];Grid[{#,Extract[r,Position[ToExpression/@r,#]]}&/@(l+2010)]
>
faster
l=Range[9];re=ToExpression[r=StringJoin[Riffle[ToString/@l,#]]&/@Tuples[{"+","-","*","/",""},8]];Grid[{#,Extract[r,Position[re,#]]}&/@(l+2010)]
--
Costa
[toc] | [prev] | [next] | [standalone]
| From | Ulrich Arndt <ulrich.arndt@data2knowledge.de> |
|---|---|
| Date | 2014-01-10 07:38 +0000 |
| Message-ID | <lao80v$pmm$1@smc.vnet.net> |
| In reply to | #16371 |
Yes, this is much faster - 5 times on my machine.
Problem is that we get 141 chars even if we replace the re by b ;-).
But can someone explain the reason for the huge processing time difference?
Ulrich
Am 07.01.2014 um 08:54 schrieb Costa Bravo:
> Ulrich Arndt wrote:
>>
>>
l=Range[9];r=StringJoin[Riffle[ToString/@l,#]]&/@Tuples[{"+","-","*","/",""},8];Grid[{#,Extract[r,Position[ToExpression/@r,#]]}&/@(l+2010)]
>>
> faster
>
>
l=Range[9];re=ToExpression[r=StringJoin[Riffle[ToString/@l,#]]&/@Tuples[{"+","-","*","/",""},8]];Grid[{#,Extract[r,Position[re,#]]}&/@(l+2010)]
>
> --
> Costa
>
[toc] | [prev] | [next] | [standalone]
| From | Boguś <telemorele@wp.pl> |
|---|---|
| Date | 2014-01-12 07:24 +0000 |
| Message-ID | <latg0b$8s7$1@smc.vnet.net> |
| In reply to | #16400 |
Ulrich Arndt wrote:
> Yes, this is much faster - 5 times on my machine.
> Problem is that we get 141 chars even if we replace the re by b ;-).
>
> But can someone explain the reason for the huge processing time difference?
>
> Ulrich
>
l=Range[9];r=StringJoin[Riffle[ToString/@l,#]]&/@Tuples[{"+","-","*","/",""},8];Grid[{#,Extract[r,Position[ToExpression/@r,#]]}&/@(l+2010)]
Position[ToExpression/@r,#]
^^^^^ This is the slowest process. 9 times repeated
--
Costa
[toc] | [prev] | [next] | [standalone]
| From | Ulrich Arndt <ulrich.arndt@data2knowledge.de> |
|---|---|
| Date | 2014-01-13 07:14 +0000 |
| Message-ID | <lb03pg$dt3$1@smc.vnet.net> |
| In reply to | #16400 |
Hahaha, it's sometimes to easy to fool yourself ;-).
I was always reading this in a way that it will be done only once as it the same for all calls...
Thanks Ulrich
Am 12.01.2014 um 08:32 schrieb Bogu=C5=9B:
> Ulrich Arndt wrote:
>> Yes, this is much faster - 5 times on my machine.
>> Problem is that we get 141 chars even if we replace the re by b ;-).
>>
>> But can someone explain the reason for the huge processing time difference?
>>
>> Ulrich
>>
>
>
> =
l=Range[9];r=StringJoin[Riffle[ToString/@l,#]]&/@Tuples[{"+","-","*","/",""},8];Grid[{#,Extract[r,Position[ToExpression/@r,#]]}&/@(l+2010)]
>
> Position[ToExpression/@r,#]
> ^^^^^ This is the slowest process. 9 times repeated
>
> --
> Costa
>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web