🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #1975

Re: Good C Interview questions?

#1975
From: Tanmoy Bhattacharya
Date: Thu, 15 Feb 1996 03:13
42 lines
2235 bytes
In article <4fsv1e$2u7@solutions.solon.com> sl14@crux5.cit.cornell.edu
(S. Lee) writes: 
<snip>
   :Picture a table like the following:
   :
   :  A B C D E F G ... Z
   :A A B C D E F G ... Z
   :B B C D E F G H ... A
   :C C D E F G H I ... B
   :: : : : : : : : ::: :
   :Z Z A B C D E F ... Y
   :
   :The students were supposed to match each character in a plaintext string
   :with each character in a key string to produce the ciphertext, as an
   :exercise to string handling.  Of 21 students, none realized that the
   :table can be computed.  Many actually typed in the lookup table, one
   :even read it from a file.  I tend to blame this phenomenon on TV and
   :debuggers ;)

   First, you don't need a lookup table.  The function is just S1[i] - S2[i]
   + 'A'.  I catch it when I read the table, but I already know how to
   handle strings.

Careful. S1[i] < S2[i] is possible.

Careful. Why assume ASCII? If S1[i] is guaranteed larger than S2[i],

  " ABCDEFGHIJKLMNOPQRSTUVWXYZ"[ (unsigned)(S1[i] - S2[i]) <= 26?
                                 (S1[i]-S2[i]+1) : 0 ]

makes no further assumption. The obfuscation can ofcourse be trivially
removed.

Cheers
Tanmoy
--
tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
<http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
Technical Details
Message-ID: <4fu8cu$9js@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4emaqj$3ng@solutions.solon.com> <4ep1s1$5se@solutions.solon.com> <4fjnch$oqq@solutions.solon.com> <4fp1ks$h6r@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: tanmoy@qcd.Lanl.GOV (Tanmoy Bhattacharya)
Newsgroups: comp.lang.c.moderated
Subject: Re: Good C Interview questions?
Date: 14 Feb 1996 21:13:34 -0600
Organization: Los Alamos National Laboratory
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4fu8cu$9js@solutions.solon.com>
References: <4emaqj$3ng@solutions.solon.com> <4ep1s1$5se@solutions.solon.com>
 <4fjnch$oqq@solutions.solon.com> <4fp1ks$h6r@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com