mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Puzzles (https://www.mersenneforum.org/forumdisplay.php?f=18)
-   -   December 2015 (https://www.mersenneforum.org/showthread.php?t=20719)

Xyzzy 2015-12-01 17:49

December 2015
 
[url]https://www.research.ibm.com/haifa/ponderthis/challenges/December2015.html[/url]

LaurV 2015-12-02 02:20

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 [URL="https://ro.wikipedia.org/wiki/Felix_C"]Felix C256[/URL] (you can use [URL="https://translate.google.com/translate?hl=en&sl=ro&u=https://ro.wikipedia.org/wiki/Felix_C"]translation[/URL], not very good, but English), our school had one, using [URL="https://en.wikipedia.org/wiki/Punched_card"]punched cards[/URL] with EBCDIC coding, we took turns on the about 60 card punchers in 4 or 5 rooms to "write" our projects (we had all [URL="http://www.technikum29.de/en/computer/punchcard"]these sorts[/URL] 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.

R. Gerbicz 2015-12-02 05:35

"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.

axn 2015-12-02 10:47

[QUOTE=R. Gerbicz;417981]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]

[QUOTE] Find a formula to convert the 52 EBCDIC letters into ASCII using no more than 4 operators.[/QUOTE]

I am confused. How does your formula achieve the problem statement?

R. Gerbicz 2015-12-02 16:43

[QUOTE=axn;417997]I am confused. How does your formula achieve the problem statement?[/QUOTE]

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.

science_man_88 2015-12-02 17:31

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.

Batalov 2015-12-02 18:45

[QUOTE=science_man_88;418019][TEX]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} [/TEX]...[/QUOTE]
Simpler still, f(x) = [SPOILER]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?[/SPOILER]

lavalamp 2015-12-08 14:10

An interesting problem. Here's what I have so far:

[SPOILER]f(x) = 97 - ((x AND 64) / 2) + (x AND 15) + ((x AND 48) / 2) - (((x-16) AND 32) / 32)[/SPOILER]

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...

lavalamp 2015-12-08 23:16

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:

[SPOILER]f(x) = x - ( (x AND 48)^17 % 37 ) - 32 - 1.5*(x AND 64)[/SPOILER]

[SPOILER]f(x) = (x - ( (x AND 48)^17 % 37 ) XOR 224) + (x AND 64)/2[/SPOILER]

science_man_88 2015-12-09 00:59

[QUOTE=lavalamp;418651][SPOILER]f(x) = (x - ( (x AND 48)^17 % 37 ) XOR 224) + (x AND 64)/2[/SPOILER][/QUOTE]

I'm guessing this doesn't scale down because [SPOILER] 17 and 37 don't have a common factor of 8 like the others ? [/SPOILER]

lavalamp 2015-12-10 23:39

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.


All times are UTC. The time now is 03:17.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.