mersenneforum.org December 2015
 Register FAQ Search Today's Posts Mark Forums Read

 2015-12-01, 17:49 #1 Xyzzy     "Mike" Aug 2002 22×3×5×7×19 Posts December 2015
 2015-12-02, 02:20 #2 LaurV Romulan Interpreter     Jun 2011 Thailand 23·19·61 Posts Technically, they should also define what an operator means, or give a link to the allowed operators table, same way they gave the link to the code sets. Otherwise, following their example, I have a solution with a single operator: "f(x)= x ebcdic_to_ascii" Joking apart, I started programming Fortran in ~1982 in high school, on a Felix C256 (you can use translation, not very good, but English), our school had one, using punched cards with EBCDIC coding, we took turns on the about 60 card punchers in 4 or 5 rooms to "write" our projects (we had all these sorts of equipment, hehe), and then give the pack of cards to the operators who were running the "monster", scheduling the jobs, and come the following days to take the listing with the results. We were not allowed in the monster's room, except when "official tours" were given by a teacher, for study purpose. Also, the programs had to be well written and come out with a solution in a minute or so, otherwise they were interrupted, because other people (i.e. boxes of cards) were waiting in the queue. It was not nice when you came after one or two days, or more, and find in the shelf your listing, saying "time limit", and no results... Later in life I already solved different versions of this "transmogrify" problem few times during my life, for practical reasons and/or for fun with colleagues. Last fiddled with by LaurV on 2015-12-02 at 02:24
 2015-12-02, 05:35 #3 R. Gerbicz     "Robert Gerbicz" Oct 2005 Hungary 5A216 Posts "Technically, they should also define what an operator means, or give a link to the allowed operators table, same way they gave the link to the code sets. Otherwise, following their example, I have a solution with a single operator: "f(x)= x ebcdic_to_ascii" " Or use no operator at all, reading the problem my first solution was: f(x)=10. (not submitted) Reading the problem I think this is an absolutely correct solution.
2015-12-02, 10:47   #4
axn

Jun 2003

23×607 Posts

Quote:
 Originally Posted by R. Gerbicz Or use no operator at all, reading the problem my first solution was: f(x)=10. (not submitted) Reading the problem I think this is an absolutely correct solution.
Quote:
 Find a formula to convert the 52 EBCDIC letters into ASCII using no more than 4 operators.
I am confused. How does your formula achieve the problem statement?

2015-12-02, 16:43   #5
R. Gerbicz

"Robert Gerbicz"
Oct 2005
Hungary

101101000102 Posts

Quote:
 Originally Posted by axn I am confused. How does your formula achieve the problem statement?
Right. Now I think that I understand the problem. So it asks to convert the 52 EBCDIC letters (a-z, A-Z) to their ASCII equivalent keeping also the case. It was poor wording, maybe the word "convert" and the example would give a hint about the real interpretation.

 2015-12-02, 17:31 #6 science_man_88     "Forget I exist" Jul 2009 Dumbassville 26×131 Posts a-i -> subtract 28 j-r -> subtract 39 s-z -> subtract 47 A-I -> subtract 128 J-R -> subtract 135 S-Z -> subtract 143 so for the index difference going one way we have: $f(X) =f(x)+100 - \begin{cases} 0, & \mbox{if }X\mbox{$\in$A-I} \\ 4, & \mbox{if }X\mbox{$\notin$A-I} \end{cases}$ not sure if this is what they mean.
2015-12-02, 18:45   #7
Batalov

"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

3×3,109 Posts

Quote:
 Originally Posted by science_man_88 $f(X) =f(x)+100 - \begin{cases} 0, & \mbox{if }X\mbox{\in A-I} \\ 4, & \mbox{if }X\mbox{\notin A-I} ... \end{cases}$...
Simpler still, f(x) = x - g(x\16), where g(z) has domain of only six values and maps {8,9,10,12,13,14} -> {32,39,47,128,135,143}
Now the trick is two make g(z) with only two OPs (two are already used - and integer division \ (or AND with 240 can be used)).
Could be that g(z) = b[SUP]z[/SUP] % p (or z[SUP]b[/SUP] % p) with some b and p remaining to be found?

 2015-12-08, 14:10 #8 lavalamp     Oct 2007 Manchester, UK 22×5×67 Posts An interesting problem. Here's what I have so far: f(x) = 97 - ((x AND 64) / 2) + (x AND 15) + ((x AND 48) / 2) - (((x-16) AND 32) / 32) I'm using 12 operators, so clearly there's room for optimisation. I agree with earlier comments about it being very unclear which operators are allowed. For instance, powers and other fancy stuff seems like cheating, since those would require several instructions for a CPU to perform. But then they do ask for a mathematical expression, not assembly code...
 2015-12-08, 23:16 #9 lavalamp     Oct 2007 Manchester, UK 53C16 Posts Batalov, I did a search for your g(z) function, sadly without much success. I searched for prime p less than 100,000 and all b < p. However, I did manage to reduce the number of operators to 8 in two different ways by using that trick: f(x) = x - ( (x AND 48)^17 % 37 ) - 32 - 1.5*(x AND 64) f(x) = (x - ( (x AND 48)^17 % 37 ) XOR 224) + (x AND 64)/2
2015-12-09, 00:59   #10
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts

Quote:
 Originally Posted by lavalamp f(x) = (x - ( (x AND 48)^17 % 37 ) XOR 224) + (x AND 64)/2
I'm guessing this doesn't scale down because 17 and 37 don't have a common factor of 8 like the others ?

Last fiddled with by science_man_88 on 2015-12-09 at 00:59

 2015-12-10, 23:39 #11 lavalamp     Oct 2007 Manchester, UK 101001111002 Posts I realised that I was possibly overthinking this a bit. I've come up with a 4 operation, but laughably inefficient, way of doing this now. Don't want to post the solution before the month is out though.

 Similar Threads Thread Thread Starter Forum Replies Last Post Batalov Puzzles 4 2018-01-04 04:33 Xyzzy Puzzles 11 2017-01-24 12:27 Xyzzy Puzzles 13 2015-01-02 19:41 fivemack Information & Answers 6 2011-12-12 13:13 ltd Prime Sierpinski Project 4 2010-12-17 13:14

All times are UTC. The time now is 21:24.

Sat Feb 27 21:24:12 UTC 2021 up 86 days, 17:35, 0 users, load averages: 1.51, 1.78, 1.77