![]() |
|
|
#1 |
|
"Mike"
Aug 2002
25·257 Posts |
|
|
|
|
|
|
#2 |
|
Romulan Interpreter
Jun 2011
Thailand
7·1,373 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 |
|
|
|
|
|
#3 |
|
"Robert Gerbicz"
Oct 2005
Hungary
22×7×53 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. |
|
|
|
|
|
#4 | ||
|
Jun 2003
22·3·421 Posts |
Quote:
Quote:
|
||
|
|
|
|
|
#5 |
|
"Robert Gerbicz"
Oct 2005
Hungary
22·7·53 Posts |
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.
|
|
|
|
|
|
#6 |
|
"Forget I exist"
Jul 2009
Dumbassville
100000110000002 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. |
|
|
|
|
|
#7 |
|
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2
36×13 Posts |
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? |
|
|
|
|
|
#8 |
|
Oct 2007
Manchester, UK
5×271 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... |
|
|
|
|
|
#9 |
|
Oct 2007
Manchester, UK
5·271 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 |
|
|
|
|
|
#10 |
|
"Forget I exist"
Jul 2009
Dumbassville
203008 Posts |
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 |
|
|
|
|
|
#11 |
|
Oct 2007
Manchester, UK
5·271 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 |
| December 2017 | Batalov | Puzzles | 4 | 2018-01-04 04:33 |
| December 2016 | Xyzzy | Puzzles | 11 | 2017-01-24 12:27 |
| December 2014 | Xyzzy | Puzzles | 13 | 2015-01-02 19:41 |
| Conference in Amsterdam 1-2 December | fivemack | Information & Answers | 6 | 2011-12-12 13:13 |
| Server update in December | ltd | Prime Sierpinski Project | 4 | 2010-12-17 13:14 |