4
$\begingroup$

The park bench has been compromised as a safe location, so you decide to meet in the lobby of the nearest hotel. Again, the envelopes are traded securely, along with the money you are receiving for each code. This code comes with a note.

“This is the hardest code yet. No more programs to crack this one, at least not easily, and this time there is some conversion involved. The next envelope you get will be much harder. Much, much, MUCH harder.”

Crack the Code #3

Digits are referred to as A-B-C-D in the clues. "A + B" is the sum of the first and second digit. All math follows the standard order of operations

Clues

  • There are no repeated digits.
  • One of the digits is a four.
  • The number is prime.
  • The hexadecimal representation of this number is an English word (according to m-w.com).

What four digit number matches these criteria? Also, if you want, post your methodology for finding the correct answer, as this will help me in the future.

Note: I am pretty sure that only one number matches all these clues. However, I may have miscalculated. Please correct me in the comments. If you find the answer, put it in a spoiler so the question is not ruined for those who want to solve it.

$\endgroup$

3 Answers 3

4
$\begingroup$

answer (edited again. fixed after question clarification)

4013 = 0xFAD or FAD

how i came up with it

hex representation must be only 3 digits, it must end in b,d,f or it would not be prime. Then an educated guess assuming ??d.

$\endgroup$
4
  • $\begingroup$ Sorry, this isn't the answer. It doesn't satisfy the second or fourth requirement, as L is not a valid character in hexadecimal. $\endgroup$
    – mdc32
    Commented Oct 24, 2014 at 0:21
  • $\begingroup$ ack. I see what I did wrong. assumed 4 digit hex number. (and assumed calculator spelling rules) $\endgroup$ Commented Oct 24, 2014 at 0:24
  • $\begingroup$ I still don't understand where you are getting the L from. It's not a hexadecimal character, and the hex doesn't have to be 4 digits/characters. $\endgroup$
    – mdc32
    Commented Oct 24, 2014 at 0:26
  • $\begingroup$ When spelling things on calculators, like 80085 for BOOBS, rules are relaxed and for some reason that occured to me first. 1 can be used for both i and l generally. In any case, have the right answer now. $\endgroup$ Commented Oct 24, 2014 at 0:28
1
$\begingroup$

The only one I can find is

4013, with hex representation "fad"

As with crack the code 3, I used a simple Java frame to run through the possibilities, and manually looked at the output in this case. I'm not sure this one is possible to do by hand in any sensible time frame (unlike #3 which could be done by hand relatively easily with some mathematical thinking).

$\endgroup$
1
$\begingroup$

I gotta give it to you, this one took me 5 minutes extra to figure out.

public class ThirdCodeCrackerProblem implements SingleSolution<List<String>> {

    public static void main(String[] args) {
        SingleSolution<List<String>> thirdCodeCrackerProblem = new ThirdCodeCrackerProblem();
        System.out.println(Arrays.toString(thirdCodeCrackerProblem.solveSingle().toArray()));
    }

    @Override
    public List<String> solveSingle() {
        return IntStream.rangeClosed(1000, 9999).parallel() // There are four digits
            .filter(this::prime) // The number is prime.
            .filter(value -> {
                List<Integer> s = seperate(value);
                if (a(s) == 4 || b(s) == 4 || c(s) == 4 || d(s) == 4) {
                    return true;
                }
                return false;
            }) // One of the digits is a four.
            .filter(value -> {
                List<Integer> s = seperate(value);
                if (a(s) != b(s) && a(s) != c(s) && a(s) != d(s) && b(s) != c(s) && b(s) != d(s) && c(s) != d(s)) {
                    return true;
                }
                return false;
            }) // No digits are repeated.
            .mapToObj(value -> Integer.toHexString(value)) // The hexadecimal representation of this number...
            .filter(s -> !s.matches(".*\\d.*")) // Removing the numbers that contain a number
            .filter(s -> s.matches(".*[aeuoyi].*")) // Only leaving the words with a vowel in it
            .collect(Collectors.toList());
    }

    private boolean prime(int n) {
        if (n%2==0) return false;
        for(int i=3;i*i<=n;i+=2) {
            if(n%i==0)
                return false;
        }
        return true;
    }

    private List<Integer> seperate(Integer n) {
        List<Integer> result = new ArrayList<>();
        while (n > 0) {
            result.add(n % 10);
            n = n / 10;
        }
        Collections.reverse(result);
        return result;
    }

    private Integer a(List<Integer> l) {return l.get(0);}
    private Integer b(List<Integer> l) {return l.get(1);}
    private Integer c(List<Integer> l) {return l.get(2);}
    private Integer d(List<Integer> l) {return l.get(3);}
}

This program resulted in:

[abd, fad, fef]

And after using the site provided there was one correct answer:

fad

And after converting the answer back to decimal, I got:

4013

$\endgroup$
4
  • $\begingroup$ This is the right answer, but I still have one comment. D**, in your first spoiler, is an English word. The restriction requiring a four makes it the wrong answer. $\endgroup$
    – mdc32
    Commented Oct 24, 2014 at 21:20
  • $\begingroup$ @mdc32 The problem is actually that I forgot to remove repeating digits. Fixed the answer. $\endgroup$
    – Martijn
    Commented Oct 24, 2014 at 21:42
  • 1
    $\begingroup$ @mdc32 Do you happen to know sites that have similar questions like these on them. I'm really enjoying this! Keep it up! $\endgroup$
    – Martijn
    Commented Oct 27, 2014 at 18:04
  • 1
    $\begingroup$ Sorry, I've just been making these up on my own. You're right though, a website with some of the would be really fun. I haven't put any of these out in the past couple days because I've been working on pretty hard one because it's #5 (shhh... don't tell anyone :P) $\endgroup$
    – mdc32
    Commented Oct 27, 2014 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.