![]() |
[QUOTE=science_man_88;235945]see my first idea was to invert a vector of some kind but I bet that's slow as well.[/QUOTE]
Probably, especially since I don't know of a fast way to re-join it. |
[QUOTE=CRGreathouse;235947]Probably, especially since I don't know of a fast way to re-join it.[/QUOTE]
I was thinking of just inverting the index but that overwrites half the indexes improperly lol [CODE]v=vector(input());a=#v;forstep(i=a,1,-1,v=concat(v,v[i]));[/CODE] this might work with you vector shift code on the end to shift out the first a values. and i may change it to Vec to allow the <93> stuff then the hard part is making a code to convert the strings into individual or groups of digits to test the primality. [B][U]NOTE[/U][/B]:this was not my original code. |
That would be extremely slow. Here's the right way of doing that:
[code]rev(n)={ my(v=eval(Vec(Str(n))),u=vector(#v,i,v[#v+1-i])); sum(i=0,#u-1,u[#u-i]*10^i) };[/code] My code (last post) takes 4.17 seconds to reverse the numbers from 1 to a million; this code takes 9.2 seconds. Both can be improved substantially, but I would rather start from that one than this. |
True story
[QUOTE=davar55;235544]The digits 0, 1, 2, 5, 6, 8, and 9 have a kind of collective symmetry
upon turning a decimal number 180 degrees (clockwise), with 0, 1, and 8 transforming to themselves, 2 and 5 also (using some imagination), and 6 and 9 transforming into each other. If a number and its upside down transform are both prime (and different), like 19 and 61, or 109 and 601, these numbers are "partners". Find as large a pair of partners as possible that contain all 7 of these digits at least once. (I include the last condition because it might be too easy to find a rep-unit or a form 10^n + 9).[/QUOTE] The other day, my front door was repainted. I opted for Oxford blue. The painter jested that the whole estate would end up looking like a Butlin's holiday camp. He needed to unscrew the number 19 from the door, and we jested about the four different ways they might get reinstated. The numbers sat outside for a few days until some well-meaning person screwed them back on. I now live at number16. David [URL="http://www.youtube.com/watch?v=Hr97qzUVdgE"]You're Sixteen[/URL] |
[QUOTE=science_man_88;235935]are you making a string reversing code I've tried but I can't get tit to work right now lol if i do maybe i can finally care about this.[/QUOTE]
String reversal is not enough. We're talking about string "rotation". And no, I don't do string reversal/rotation -- instead I've chosen patterns that gives me matched pairs directly. |
[QUOTE=science_man_88;235935]are you making a string reversing code I've tried but I can't get tit to work right now lol if i do maybe i can finally care about this.[/QUOTE]
As others have said, you need rotation, not reversal. I do it with a vector of bytes: [CODE]void rotVec(char *vecin, char *vecout, int num) { int i; for (i=0; i<num; i++) { switch (vecin[i]) { case 0: case 1: case 8: case 2: case 5: vecout[num-i-1] = vecin[i]; break; case 6: vecout[num-i-1] = 9; break; case 9: vecout[num-i-1] = 6; break; } } return; }[/CODE] Extremely straightforward... but effective enough. It can rotate a vector of 10 million entries in 50 milliseconds or so, but of course I never need to rotate anything that big. |
1268*10^3605+8951 and 1268*10^3605+8951 ? :rolleyes:
Yeah, ok, you want different. Let's search for these now. |
[QUOTE=Batalov;236029]1268*10^3605+8951 and 1268*10^3605+8951 ? :rolleyes:
Yeah, ok, you want different. Let's search for these now.[/QUOTE] it must be a A002385 because you list the same number twice hence it's the same backwards and forwards. |
[quote=science_man_88;236065]it must be a A002385 because you list the same number twice hence it's the same backwards and forwards.[/quote]
I really specified the OP to make this an interesting and solvable puzzle. This last result is a perfect extension, and would make a nice sequence too. Anyone want to work on the first 100 integers in those two sequences? |
The OP defined upside down partnered primes.
The example of a big one that partnered itself was an add-on to the original puzzle, and the sequence of these would be another related new sequence. If anyone would compute, say, the first 100 terms of each of these sequences, it might be interesting. We already have some big ones. |
Just learned that M1061 has been factored, as P1 x P2 (two prime factors).
Since 1061 and 1901 are prime upside-down partners , I ran factorbd on 2^1901-1 and found a P501 as largest factor. I think it computed rather than did a lookup. Is this P501 previously unrecorded? Just thought I'd ask. |
| All times are UTC. The time now is 05:34. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.