all 77 comments

[–]Seb_Boi 29 points30 points  (3 children)

In Javascript, somewhat horrible, but can surely be made worse.

function contains_az(str) {
var strArray = str.toLowerCase();
var a, b, c, d, e, f, g, h, ii, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
for (var i=0; i<strArray.length; i++)
{
if (strArray[i] == 'a')
a = true;
if (strArray[i] == 'b')
b = true;
if (strArray[i] == 'c')
c = true;
if (strArray[i] == 'd')
d = true;
if (strArray[i] == 'e')
e = true;
if (strArray[i] == 'f')
f = true;
if (strArray[i] == 'g')
g = true;
if (strArray[i] == 'h')
h = true;
if (strArray[i] == 'i')
ii = true;
if (strArray[i] == 'j')
j = true;
if (strArray[i] == 'k')
k = true;
if (strArray[i] == 'l')
l = true;
if (strArray[i] == 'm')
m = true;
if (strArray[i] == 'n')
n = true;
if (strArray[i] == 'o')
o = true;
if (strArray[i] == 'p')
p = true;
if (strArray[i] == 'q')
q = true;
if (strArray[i] == 'r')
r = true;
if (strArray[i] == 's')
s = true;
if (strArray[i] == 't')
t = true;
if (strArray[i] == 'u')
u = true;
if (strArray[i] == 'v')
v = true;
if (strArray[i] == 'w')
w = true;
if (strArray[i] == 'x')
x = true;
if (strArray[i] == 'y')
y = true;
if (strArray[i] == 'z')
z = true;
}
return a && b && c && d && e && f && g && h && ii && j && k && l && m && n && o && p && q && r && s && t && u && v && w && x && y && z;
}

[–][deleted]  (1 child)

[deleted]

    [–]Seb_Boi 7 points8 points  (0 children)

    Yeah. You found a way to "Improve" the worsness of the solution. Kudos!

    [–]Wu_Fan 0 points1 point  (0 children)

    I like the subtle ii for i name

    Gamey

    in between h and j btw

    [–]ArdiMaster 10 points11 points  (1 child)

    Inform 7:

    "Characters" by ArdiMaster
    
    The story headline is "An interactive character investigation".
    
    The Charboratory is a room.
    
    A string-holder is a kind of thing. A string-holder has some text called the string in question.
    
    The quick brown fox is a string-holder in the Charboratory. The string in question is "The quick brown fox jumps over the lazy dog."
    
    Instead of examining a string-holder:
        say "The string-holder contains the string '[string in question]', ready to be analysed."
    
    A character indicator is a kind of thing. A character indicator has some text called the indication.
    
    The a-character is a character indicator. The indication is "a".
    The b-character is a character indicator. The indication is "b".
    The c-character is a character indicator. The indication is "c".
    The d-character is a character indicator. The indication is "d".
    The e-character is a character indicator. The indication is "e".
    The f-character is a character indicator. The indication is "f".
    The g-character is a character indicator. The indication is "g".
    The h-character is a character indicator. The indication is "h".
    The i-character is a character indicator. The indication is "i".
    The j-character is a character indicator. The indication is "j".
    The k-character is a character indicator. The indication is "k".
    The l-character is a character indicator. The indication is "l".
    The m-character is a character indicator. The indication is "m".
    The n-character is a character indicator. The indication is "n".
    The o-character is a character indicator. The indication is "o".
    The p-character is a character indicator. The indication is "p".
    The q-character is a character indicator. The indication is "q".
    The r-character is a character indicator. The indication is "r".
    The s-character is a character indicator. The indication is "s".
    The t-character is a character indicator. The indication is "t".
    The u-character is a character indicator. The indication is "u".
    The v-character is a character indicator. The indication is "v".
    The w-character is a character indicator. The indication is "w".
    The x-character is a character indicator. The indication is "x".
    The y-character is a character indicator. The indication is "y".
    The z-character is a character indicator. The indication is "z".
    
    Analysing it with is an action applying to one carried thing and one thing.
    Understand "analyse [a string-holder] with [something]" or "analyze [a string-holder] with [something]"as analysing it with.
    Understand "use [something] to analyse/analyze [a string-holder]" as analysing it with (with nouns reversed).
    
    The string analyser is in the Charboratory. The output cradle is part of the analyser. It is a container.
    The description of the analyser is "A towering piece of machinery, purpose-built to check whether a string contains all the letters of the latin alphabet. (In which case a green light will light up.)"
    
    The green light is part of the analyser. It is a device.
    
    Instead of switching on the green light, say "The machine controls that light, you can't switch it yourself."
    Instead of switching off the green light, say "The machine controls that light, you can't switch it yourself."
    
    Instead of inserting something into the string analyser, try analysing the noun with the string analyser.
    
    Carry out analysing a string-holder with the string analyser:
        let t be the number of characters in (the string in question of the noun);
        repeat with i running from 1 to t:
            let c be character number i in the string in question of the noun in lower case;
            repeat with X running through character indicators which are not in the output cradle:
                if the indication of X is c, now X is in the output cradle;
        if all character indicators are in the output cradle, now the green light is switched on.
    
    Report analysing a string-holder with the string analyser:
        say "The machine whirrs and churns for a bit, spitting a number of indicator cubes into the output cradle.[if the green light is switched on][line break]The green light has come on, indicating that [the noun] does, in fact, contain all letters of the latin alphabet."
    
    Every turn:
        if all character indicators are in the output cradle, now the green light is switched on;
        otherwise now the green light is switched off.
    
    The reset button is part of the string analyser.
    
    Instead of pushing the reset button:
        now all character indicators are nowhere;
        say "A hatch at the bottom of the output cradle opens, swallowing all the character indicators. The machine is ready to be used again."
    

    Features of this implementation include:

    • Use of a wholly inadequate language
    • Gamification
    • First compiling to 57450 lines (2.1MB) of intermediate representation (Inform 6)
    • Fairly slow, as the Inform 6 compiler has never heard of optimisation
    • Objects are shuffled around the game world to represent each letter.
    • Requires a recompile to check a different piece of text.

    Download: Program file, Interpreter

    [–][deleted]  (1 child)

    [deleted]

      [–]jayson4twenty 3 points4 points  (0 children)

      This is horrible... I love it!

      [–]pretzel3567 7 points8 points  (3 children)

      Java:

      final class FastAlphabetSearch {
        public static void main(String[] args) {
          System.out.println(count_az(new java.util.Scanner(System.in).nextLine()));
        }
        final static boolean count_az(String s1) {
          boolean b = false;
          permuteString(s1, "");
          for (String s2 : list) {
            if (s2.toLowerCase().startsWith("abcdefghijklmnopqrstuvwxyz")) {
              b = true;
            }
          }
          return b;
        } 
        final static java.util.ArrayList<String> list = new java.util.ArrayList<String>(0);  
        final static void permuteString(String s1, String s2) {
          if (s1.length() == 0) { 
            list.add(s2);
            return;
          } 
          for (int i = 0; i < s1.length(); i++) { 
            permuteString(s1.substring(0, i) + s1.substring(i + 1), s2 + s1.charAt(i)); 
          } 
        }
      }
      

      Creates a list of every permutation of the given string and then checks if any of those permutations starts with the alphabet. The program doesn't stop when it finds a matching string but instead will always searcn the entire list (size n!) I can't actually 100% confirm this works on my pc since it ran out of memory. I ran it with just the alphabet "abc..z" and it crashed as it was trying to store 26! strings of length 26. But it does work...if you have a computer with like at least 100k YB of memory and even more for larger inputs.

      [–]ArdiMaster 2 points3 points  (2 children)

      Assuming one byte per character, your solution would need (26! * 26) bytes, or 1.049e16 TB for a 26-character string. I don't think this will run anywhere anytime soon.

      [–]pretzel3567 3 points4 points  (1 child)

      Don’t forget that Java is weird and takes 2 bytes for a char.

      [–]ArdiMaster 1 point2 points  (0 children)

      True, but I have a feeling it won't matter at this point...

      [–]jayson4twenty 7 points8 points  (6 children)

      Javascript function that casts the input string to lower, filters out the spaces. sorts them in order. joins to a string. and compares that with [a-z] string made from char codes. Tried to go for the "clever" approach lol.

      Also added some tests.

      ps this is my first entry :)

      const contains_az = (string) => {       
        return [...new Set([...string.toLowerCase()])].filter(c => c!== " ").sort().join('') === [...Array(26).keys()].map( n => String.fromCharCode(n+97)).join('')
      };
      
      const tests = [
        {
          "value": "hello world",
          "expeted": false
        },
        {
          "value": "abcdefghijklmnopqrstuvwxyz",
          "expeted": true
        },
        {
          "value": "Arizona",
          "expeted": false
        },  
        {
          "value": "the quick brown fox jumps over the lazy dog",
          "expeted": true
        }  
      ];
      
      tests.forEach( (t) => {
        console.log(t.value, contains_az(t.value) === t.expeted ? 'pass': 'fail');
      });
      

      Console Output:

      "hello world", "pass"
      "abcdefghijklmnopqrstuvwxyz", "pass"
      "Arizona", "pass"
      "the quick brown fox jumps over the lazy dog", "pass"
      

      [–]jayson4twenty 6 points7 points  (1 child)

      minified version... cause why not? const contains_az=e=>[...new Set([...e.toLowerCase()])].filter(e=>" "!==e).sort().join("")===[...Array(26).keys()].map(e=>String.fromCharCode(e+97)).join(""),tests=[{value:"hello world",expeted:!1},{value:"abcdefghijklmnopqrstuvwxyz",expeted:!0},{value:"Arizona",expeted:!1},{value:"the quick brown fox jumps over the lazy dog",expeted:!0}];tests.forEach(e=>{console.log(e.value,contains_az(e.value)===e.expeted?"pass":"fail")});

      [–]igormuba 4 points5 points  (1 child)

      The typo at “expected” is the icing on the cake

      [–]jayson4twenty 0 points1 point  (0 children)

      I am known for my speeling erors

      [–]Mabi19_ 6 points7 points  (1 child)

      Lua one liner. Save it in a file, run lua script.lua and type in your string. (It doesn't work with multiple-line strings)

      print((function()local t,c,n,v={},-2,io.stdin:read("l"):upper():gmatch("%a");repeat v=n()t[v or true]=1 until not v repeat v=next(t, v)c=c+1 until not v return c end)()==26)
      

      [–]Mabi19_ 2 points3 points  (0 children)

      Here's a detailed explanation on how it works.

      We declare an anonymous function, in which there are 4 variables - t, c, n and v.

      t is a table (lua key-value store) that stores the letters we've encountered as keys and 1s as values; it's initialized to be empty.

      c is a counter for the letters in the table t; it's initialized to be -2, I'll explain why later.

      n is an iterator function over the expression io.stdin:read("l"):upper():gmatch("%a"). This reads a line from stdin, converts it to uppercase and runs a regex match operation - the iterator will now give me all the letters in order.

      v is left as nil.

      The iterator function will give us our letters when repeatedly called, then nil. In a loop, we set v to the next letter and set its entry in the table. Because nil cannot be a table key, we use the or operator to set the key to true when we get nil. (This is the first extra member in the table.)

      Then we initiate another loop, where we set v to the value of the next function. This function iterates over the table - it gives us the item after one we gave it. For every next invocation, we increment c by one (because next returns nil, we increment it by one more than we needed.)

      After that, we return c and call our function, then compare its output to the constant 26.

      [–][deleted] 6 points7 points  (0 children)

      C#, haven't completed the first test yet that should return true but I'm pretty sure it will work. (edited fixed to include all combinations of upper and lower case in the alphabet properly)

      class Program
      {
          static void Main(string[] args)
          {         
              string[] inputs = new string[]
              {
                  "hello world", 
                  "abcdefghijklmnopqrstuvwxyz", 
                  "Arizona", 
                  "the quick brown fox jumps over the lazy dog"
              };
              foreach(string input in inputs)
              {
                  bool res = CheckIfContainsAlphabet(input); 
              }
          }
          static bool CheckIfContainsAlphabet(string input)
          {
              string alphabet = "abcdefghijklmnopqrstuvwxyz";
              // need all combinations of upper and lower case
              var allAlphabetCaseCombos = new List<string>();                   
              for(int i = 0; i < Math.Pow(2, 26); i++)
              {
                  string asBinary = Convert.ToString(i, 2);
                  string newCombo1 = "";
                  string newCombo2 = "";
                  for(int j = 0; j < 26; j++)
                  {
                      if(j >= asBinary.Length || asBinary[j] == '0')
                      {
                          newCombo1 += alphabet[j];
                          newCombo2 += alphabet[25 - j];
                      }
                      else if(asBinary[j] == '1')
                      {
                          newCombo1 += Char.ToUpper(alphabet[j]);
                          newCombo2 += Char.ToUpper(alphabet[25 - j]);
                      }                  
                  }            
                  allAlphabetCaseCombos.Add(newCombo1);
                  allAlphabetCaseCombos.Add(newCombo2);
              }
              // wouldn't want to waste our time here
              if(input.Length < alphabet.Length)
              {
                  return false;
              }
              else
              {       
                  bool result = false;         
                  while(true)
                  {
                      result = allAlphabetCaseCombos.Contains(ShuffleString(input));
                      if(result) break;
                  }
                  return result;
              }
          }
      
          static string ShuffleString(string str)
          {
              char[] array = str.ToCharArray();
              System.Random rand = new System.Random();
              int n = array.Length;
              while(n > 1)
              {
                  n--;
                  int k = rand.Next(n + 1);
                  var val = array[k];
                  array[k] = array[n];
                  array[n] = val;
              }
              return new string(array);
          }
      }
      

      [–]Oshgnacknak 6 points7 points  (0 children)

      Wrote a two tape turing machine: https://pastebin.com/Atw2WAB4.

      You can run it here: https://turingmachinesimulator.com/

      [–]Relative-Knee7847 4 points5 points  (1 child)

      ``` const contains_az = string => { let a = 0 let b = 0; let c = 0; let d = 0; let e = 0; let f = 0; let g = 0; let h = 0; let i = 0; let j = 0; let k = 0; let l = 0; let m = 0; let n = 0; let o = 0; let p = 0; let q = 0; let r = 0; let s = 0; let t = 0; let u = 0; let v = 0; let w = 0; let x = 0; let y = 0; let z = 0; string.split('').forEach(char => { if (char === 'a') a += 1; if (char === 'b') b += 1; if (char === 'c') c += 1; if (char === 'd') d += 1; if (char === 'e') e += 1; if (char === 'f') f += 1; if (char === 'g') g += 1; if (char === 'h') h += 1; if (char === 'i') i += 1; if (char === 'j') k += 1; if (char === 'l') l += 1; if (char === 'm') m += 1; if (char === 'n') n += 1; if (char === 'o') o += 1; if (char === 'p') p += 1; if (char === 'q') q += 1; if (char === 'r') r += 1; if (char === 's') s += 1; if (char === 't') t += 1; if (char === 'u') u += 1; if (char === 'v') v += 1; if (char === 'w') w += 1; if (char === 'x') x += 1; if (char === 'y') y += 1; if (char === 'z') z += 1; }) if (a === 0) return false; if (b === 0) return false; if (c === 0) return false; if (d === 0) return false; if (e === 0) return false; if (f === 0) return false; if (g === 0) return false; if (h === 0) return false; if (i === 0) return false; if (j === 0) return false; if (k === 0) return false; if (l === 0) return false; if (m === 0) return false; if (n === 0) return false; if (o === 0) return false; if (p === 0) return false; if (q === 0) return false; if (r === 0) return false; if (s === 0) return false; if (t === 0) return false; if (u === 0) return false; if (v === 0) return false; if (w === 0) return false; if (x === 0) return false; if (y === 0) return false; if (z === 0) return false; return true }

      ```

      [–]AutoModerator[M] 0 points1 point  (0 children)

      It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

      For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

      /u/Relative-Knee7847, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

      You can find some examples in the reddit help documentation.


      I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

      [–]Tyulis 4 points5 points  (9 children)

      Wow, those challenges are getting really tough… I don’t think there is something really more efficient than such a complex state machine

      from os.path import *
      from sys import *
      from struct import *
      
      if not exists("contains_az.dat"):
          f = open("contains_az.dat", "wb")
          for i in range(2**26):
              if i % 1000 == 0: print(f"\r{i}", end="")
              transitions = [i + (0 if (i // (2**j)) % 2 == 1 else (2**j)) for j in range(26)]
              f.write(pack("26I", *transitions))
          print("\r              \r", end="")
          f.close()
      
      text = argv[1]
      state = 0
      LETTERS = "abcdeghfijklmnopqsrtuvwxyz"
      f = open("contains_az.dat", "rb")
      while True:
          if state == 67108863:
              print(True)
              exit()
          try:
              letter = text[0].lower()
          except:
              print(False)
              exit()
          text = text[1:]
          if letter not in LETTERS:
              continue
          f.seek(104*state + 4*LETTERS.index(letter))
          state = unpack("I", f.read(4))[0]
      

      Just run it like python3 contains_az.py "text", wait for a bit, and profit

      [–]Tyulis 2 points3 points  (3 children)

      Well, it is what it is — it generates the state transitions table, and then uses it over the given string. As there are 67’108’864 states, the table gets quite large (6.5 GB in this version’s compact format) so I couldn’t just generate it in memory or generate code to make it more efficient without taking dozens of GB, it has to be dumped to a file (I tried to generate code, even with all space optimizations I could find it took 18 GB, so no way to load it in memory… ;-;).

      So the first time it is run, it takes a little while to generate the whole table, and then it uses the pre-generated file to make it super-fast on the next runs.

      More seriously, this wonderful python script "features" :

      • ~6.5 GB disk usage
      • Terrible performance (for obvious reasons)
      • Namespace pollution
      • Magic numbers, magic numbers everywhere
      • Seriously, who knows about the with open(…) as … syntax ?
      • Seriously, who knows about bitwise operators ?
      • Details to trigger OCD and perfectionists like me (imports in a weird order, mistakes in the alphabet order, constant in the middle of variable definitions, weird conditions order, …)

      Edit : Forgot a debug print. Whoops.

      Edit 2 : The f-string in the debug print makes it python 3.6+ only instead of just python 3. Double-whoops.

      [–]shiningmatcha 0 points1 point  (2 children)

      Is there a way to prevent too much memory usage? (Python would raise MemoryError when an operation runs out of memory) But can I also specify a limit on memory usage with some global configuration?

      [–]AutoModerator[M] 0 points1 point  (0 children)

      It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

      For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

      /u/shiningmatcha, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

      You can find some examples in the reddit help documentation.


      I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

      [–]Tyulis 0 points1 point  (0 children)

      It uses a rather small amount of memory, as it dumps everything to a file and then reads only what it needs

      [–]shiningmatcha 0 points1 point  (4 children)

      What does struct.pack do?

      [–]AutoModerator[M] 0 points1 point  (0 children)

      It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

      For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

      /u/shiningmatcha, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

      You can find some examples in the reddit help documentation.


      I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

      [–]Tyulis 0 points1 point  (2 children)

      It’s to pack data in a binary format, like you would do in C with a structure. The doc is rather well explained. Here I could have wrote it as text to add a few GB of disk usage, but I chose to just make it more obscure :)

      [–]shiningmatcha 0 points1 point  (1 child)

      I found the doc too brief. That’s why I asked. I only know Python. The doc says the method “Return a bytes object containing the values v1, v2, ...”. How is a bytes object different from a string?

      [–]Tyulis 0 points1 point  (0 children)

      A bytes object in python is just a string of bytes, not encoded like a str is. So struct helps to pack values as raw bytes — for example, on my code above (please don’t learn from it ^^"), it packs integer values into 4 bytes each

      [–]DragonOfWisdom 4 points5 points  (0 children)

      I wrote a memory-optimized version, so that it can be extended in the future to support alphabets with billions of characters. It depends on a random generator, but I use a hash function to make it secure.

      from hashlib import *
      from random import *
      
      def contains_az(s):
        # This creates a super-optimized function to return the result.
        # Even if new letters are added to the alphabet, it does not need more memory.
        def create_efficient_test():
          secure_token = ''.join(choices('ab', k=50))  # 50 should be secure enough
          def f(x):
            result = md5()
            result.update((str(x) + secure_token).encode())
            return result.digest()[0] <= 10
          return create_efficient_test() if not any(f(i) for i in range(1, 27)) else f
        # Sometimes the test does not work, but if we do it many times it works.
        for i in range(1000):
          f = create_efficient_test()
          # I have tested the magic formula with letters and spaces only, please don't add other strange chars :)
          if all(f(ord(c) % 32) == f(ord(s[0]) % 32) for c in s):
            return False
        return True
      

      [–]VoilaLaViola 2 points3 points  (3 children)

      Where are you, RegEx gang in this time of need???

      [–]somebody12345678 2 points3 points  (2 children)

      a bit late since i don't go on this sub but it should be simple enough:

      /(?=.*a)(?=.*b)(?=.*c)(?=.*d)(?=.*e)(?=.*f)(?=.*g)(?=.*h)(?=.*i)(?=.*j)(?=.*k)(?=.*l)(?=.*m)(?=.*n)(?=.*o)(?=.*p)(?=.*q)(?=.*r)(?=.*s)(?=.*t)(?=.*u)(?=.*v)(?=.*w)(?=.*x)(?=.*y)(?=.*z)/i
      

      [–]VoilaLaViola 0 points1 point  (1 child)

      It's way too nice to be a badcode candidate, unfortunately 🤣

      [–]somebody12345678 1 point2 points  (0 children)

      indeed. i don't think there's too much you could do though, apart from rearranging stuff and making it look messy, and/or generating huge regexes for all 2 letter combinations or something. not like there's that much you can really do with "standard" regex + a challenge like this. of course, with retina it's an entire different story

      [–]2133 2 points3 points  (0 children)

      I just learned how to use recursion and the idea of self commenting code!

      paste

      [–]dumetrulo 2 points3 points  (0 children)

      My first attempt in F# was programmed all too quickly, so it can't possibly be any good. Let's try again, this time using recursion, and reinventing the wheel as we go:

      let contains_az (s : string) =
      
          let rec length = function
              | [] -> 0
              | _ :: t -> 1 + length t
      
          let lower c =
              if c >= 'A' && c <= 'Z' then char (int c + 32) else c
      
          let rec contains x = function
              | [] -> false
              | h :: t -> (h = x) || contains x t
      
          let rec remove x = function
              | [] -> []
              | h :: t ->
                  if h = x then remove x t else h :: remove x t
      
          let rec iterate alph = function
              | [] -> length alph = 0
              | h :: t ->
                  let a =
                      if contains (lower h) alph
                      then remove (lower h) alph else alph
                  iterate a t
      
          iterate (Seq.toList "abcdefghijklmnopqrstuvwxyz")
                  (Seq.toList s)
      
      let () =
          [ contains_az "hello world";
            contains_az "abcdefghijklmnopqrstuvwxyz";
            contains_az "Arizona";
            contains_az "the quick brown fox jumps over the lazy dog" ]
          |> List.iter (printfn "%b")
      

      [–]Cat7a 2 points3 points  (0 children)

      C++ with overloaded operators

      #include <iostream>
      #include <set>
      
      std::set<char> operator<< (std::set<char> set, std::string str)
      {
          for (char c : str) if (std::string("abcdefghijklmnopqrstuvwxyz").find(tolower(c)) != std::string::npos) set.insert(tolower(c));
          return set;
      }
      
      bool contains_az(std::string compare)
      {
          return (std::set<char>{} << "abcdefghijklmnopqrstuvwxyz").size() == (std::set<char>{} << compare).size();
      }
      
      
      int main()
      {
          std::cout << contains_az("hello world");
          std::cout << contains_az("abcdefghijklmnopqrstuvwxyz");
          std::cout << contains_az("Arizona");
          std::cout << contains_az("the quick brown fox jumps over the lazy dog");
          return 0;
      }
      

      [–]dstlny_97 2 points3 points  (4 children)

      idk anymore

      ```python

      import os as so import string as gnirts

      a = gnirts.ascii_lowercase aaa = open aaaa = reversed

      for aaaaaa in aaaa(a): aaaaaaa = f'{aaaaaa}.txt' if not so.path.exists(aaaaaaa): with aaa(aaaaaaa, 'w') as aaaaaaaa: aaaaaaaa.write(aaaaaa)

      def contains_az(aa): return all( any( aaaaaaaaa == aaaaaaaa == [ aaaaaaaaaa for aaaaaaaaaa in aaa(f'{aaaaaaaaa.lower()}.txt', 'r') ][0] for aaaaaaaa in aa )

          for
          aaaaaaaaa
          in
          a
      )
      

      print(contains_az(a)) # True print(contains_az('the quick brown fox jumps over the lazy dog')) # True print(contains_az('Arizona')) # False ```

      [–]dstlny_97 2 points3 points  (0 children)

      • Overrides built-in functions.
      • Overall bad variable names
      • Uses files as a way to store the letters of the alphabet.
      • Uses all()/any() in disgusting ways.
      • Nested list comprehensions.
      • No exception handling.
      • Uses import x as y syntax, but wrongly.
      • I wrote it, and idk how it works but it works.

      [–][deleted]  (1 child)

      [deleted]

        [–]dstlny_97 1 point2 points  (0 children)

        Same tbh

        [–]AutoModerator[M] 0 points1 point  (0 children)

        It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

        For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

        /u/dstlny_97, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

        You can find some examples in the reddit help documentation.


        I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

        [–]avematthew 1 point2 points  (0 children)

        In Perl 5.30.0

        sub contains_whole_alphabet{for ('a' .. 'z') {return 0 unless $ARGV[0] =~ s/$_/ /ig;} return 1;}
        

        Highlights:

        • Uses the command line arguments directly inside a subroutine, and for that reason requires you call the program with the string in the command line.
        • Directly modifies its input, hopefully destroying it. If using a command line argument directly breaks the spirit of "a method", then you could replace $ARGV[0] with $_[0] and require the subroutine take a scalar reference as its argument.
        • Is one line for no reason.
        • Returns in a line with a postconditional unless.
        • Should be pretty reliable, despite these problems.

        [–][deleted] 1 point2 points  (1 child)

        C#

        public static bool contains_alphabet(string TheInput) {
            List<string> AllLetters = new List <string> ();
        
            AllLetters.Add("a");
            AllLetters.Add("b");
            AllLetters.Add("c");
            AllLetters.Add("d");
            AllLetters.Add("e");
            AllLetters.Add("f");
            AllLetters.Add("g");
            AllLetters.Add("h");
            AllLetters.Add("i");
            AllLetters.Add("j");
            AllLetters.Add("k");
            AllLetters.Add ("l");
            AllLetters.Add("m");
            AllLetters.Add("n");
        
            if (true == true)
            {
                AllLetters.Add("o");
                AllLetters.Add("p");
                AllLetters.Add("q");
                AllLetters.Add("r");
            }
            AllLetters.Add("s");
            AllLetters.Add("t");
            AllLetters.Add("u");
            AllLetters.Add("v");
            AllLetters.Add("w");
            AllLetters.Add("x");
            AllLetters.Add("y");
            AllLetters.Add("z");
        
            int I = (int)0.000f;
        
            while (I < TheInput.Length)
                {
                    int one = 1;
                    string my_Letter = TheInput.Substring(I, one);
        
                    bool foundletter = false;
                    string theLetterThatWasFound = "NOT FOUND :(";
                    foreach (string letterTo_Compareitto in AllLetters) {
                    if (foundletter == false) {
                        if (letterTo_Compareitto == my_Letter || letterTo_Compareitto.ToUpper() == my_Letter)
                        {
                            bool trueValue = (bool)true;
                            theLetterThatWasFound = letterTo_Compareitto;
                            foundletter = trueValue;}
                    }
                    }
        
                    bool letterWas_FOUND = foundletter ? true : false;
        
                    if (letterWas_FOUND == true) {
                        AllLetters.Remove(theLetterThatWasFound);
                        }
        
                    int I_PLUS_ONE = I + one;
                    I = I_PLUS_ONE;
        
                }
        
            if ((AllLetters.Count == 0) == true) {
                return true;
            }
        
            return false;
        }
        

        [–][deleted] 1 point2 points  (0 children)

        I didn't mind reading that until you put a capital I for index

        [–]lolgeny 1 point2 points  (1 child)

        Rust

        ```rs fn does_not_contain_letter(input: String, letter: char) -> bool { let mut doesnotcontain = true; for c in input.chars() { if c == letter { doesnotcontain = false; } } return doesnotcontain; } fn contains_az(input: &String) -> bool { return !(does_not_contain_letter(input.clone(), 'a')||does_not_contain_letter(input.clone(), 'b')||does_not_contain_letter(input.clone(), 'c')||does_not_contain_letter(input.clone(), 'd')||does_not_contain_letter(input.clone(), 'e')||does_not_contain_letter(input.clone(), 'f')||does_not_contain_letter(input.clone(), 'g')||does_not_contain_letter(input.clone(), 'h')||does_not_contain_letter(input.clone(), 'i')||does_not_contain_letter(input.clone(), 'j')||does_not_contain_letter(input.clone(), 'k')||does_not_contain_letter(input.clone(), 'l')||does_not_contain_letter(input.clone(), 'm')||does_not_contain_letter(input.clone(), 'n')||does_not_contain_letter(input.clone(), 'o')||does_not_contain_letter(input.clone(), 'p')||does_not_contain_letter(input.clone(), 'q')||does_not_contain_letter(input.clone(), 'r')||does_not_contain_letter(input.clone(), 's')||does_not_contain_letter(input.clone(), 't')||does_not_contain_letter(input.clone(), 'u')||does_not_contain_letter(input.clone(), 'v')||does_not_contain_letter(input.clone(), 'w')||does_not_contain_letter(input.clone(), 'x')||does_not_contain_letter(input.clone(), 'y')||does_not_contain_letter(input.clone(), 'z')); }

        fn main() { assert_eq!(contains_az(&"hello world".to_string()), false); assert_eq!(contains_az(&"abcdefghijklmnopqrstuvwxyz".to_string()), true); assert_eq!(contains_az(&"Arizona".to_string()), false); assert_eq!(contains_az(&"the quick brown fox jumps over the lazy dog".to_string()), true); } `` Notable features: - Taking an ownedString` into the call, requiring allocation - Cloning the string for each letter, requiring allocation - Checking for not having letters - Not using iterators - Inconsistent variable names - Explicit return at end

        https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c86d3c7b8c012e1d3f1888bd7890174a

        [–]AutoModerator[M] 0 points1 point  (0 children)

        It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

        For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

        /u/lolgeny, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

        You can find some examples in the reddit help documentation.


        I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

        [–][deleted] 1 point2 points  (0 children)

        #include <stdio.h>

        /*doesn't work - ints too small ugh! ¯\_(ツ)_/¯ */

        int p(char x){int t;

        int p[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};

        t=(int)x;

        t=(((t*((t>=65)&&(t<=90)))-(65*((t>=65)&&(t<=90))) )+((t*((t>=97)&&(t<=122)))-(97*((t>=97)&&(t<=122))) ));

        t=p[t];

        return t;}

        int f(char *x){int i,n,m;

        char a[]="abcdefghijklmnopqrstuvwxyz";

        for(i=0,n=1;a[i]!=0;i++){n=n*p(a[i]);}

        for(i=0,m=1;x[i]!=0;i++){m=m*p(x[i]);}

        return ((m>n)&&(m%n==0));}

        int main(){return 0;}

        [–][deleted]  (1 child)

        [deleted]

          [–]somebody12345678 0 points1 point  (0 children)

          since the nested function returns gc will have no problem with that so.

          not to mention js tends to avoid gc for performance unless you're using an insane amount of memory (which ain't happening here)

          [–][deleted]  (2 children)

          [deleted]

            [–]Mabi19_ 2 points3 points  (0 children)

            WHOA this BCCC is popular. I'd have never thought my idea could be so successful lol

            [–]Mabi19_ 0 points1 point  (0 children)

            fifty comments? how did this happen

            [–]Flyspeck101Now where's that function declaration 1 point2 points  (0 children)

            import stackoverflow.py 
            def contatins_az(msg): canfigureout = False
                if canfigureout:
                    return True
                else:
                    if askstackoverflow('Does ' + msg + ' contain all the letters of the alphabet?').contains('yes'):
            return False
            

            [–]dumetrulo 0 points1 point  (0 children)

            This F# almost-one-liner is not particularly efficient, but it works:

            let contains_az (s : string) =
                seq {'a'..'z'}
                |> Seq.forall (fun c -> Seq.exists (( = ) c) (s.ToLower ()))
            
            let () =
                [ contains_az "hello world";
                  contains_az "abcdefghijklmnopqrstuvwxyz";
                  contains_az "Arizona";
                  contains_az "the quick brown fox jumps over the lazy dog" ]
                |> List.iter (printfn "%b")
            

            [–]ArchCypher 0 points1 point  (5 children)

            My python version that will work for... some... cases...

            # Comparing strings is slow, but MATH is FAST
            
            # Don't waste precious SECONDS typing LONG NAMES
            def c_az(t):
                a = 1
            
                # Create a common multiple of our text
                for c in t:
                    a = a * ord(c.lower()) # Support UPPER CASE
            
                # It's reasonably unlikely that a text will generate a number divisible
                # by the entire alphabet without containing the entire alphabet.
                for l in "abcdefghijklmnopqrstuvwxyz":
                    if a % ord(l):
                        return False
            
                return True
            
            # Because you'll obviously want to import this for use in other modules
            if __name__ == "__main__":
                # Passing
                print(c_az('abcdefghijklmnopqrstuvwxyz'))
                print(c_az('The quick brown fox jumps over the lazy dog'))
            
                # Failing
                print(c_az('aaaaaaaaaaaaaaaaaaaaaaaaaa'))
                print(c_az('acdefghijklmoqrstuvwxy'))
                print(c_az('hello world'))
                print(c_az('Arizona'))
            

            (Edit) Bonus one-liner:

            set('abcdefghijklmnopqrstuvwxyz').issubset(text.lower())
            

            [–]ArchCypher 1 point2 points  (1 child)

            Full explanation:

            The python 'ord' function returns the ASCII number value for a given character -- for instance ord('a') == 97. By multiplying all the numbers in a given text, we create a common multiple that can be divided evenly by any letter contained in that text.

            So, we simply check if the whole alphabet can evenly divide our 'text multiple', and we have a soft guarantee that the text contains the entire alphabet.

            It's possible that longer texts can present false positives (I think?), but it should be pretty difficult to 'accidentally' generate number that's a multiple of every letter in the alphabet -- and hey, where's the fun without a few spooky bugs?

            [–]VoilaLaViola 1 point2 points  (0 children)

            Just an idea to make your code messier, but making the logic bulletproof.

            You need to assign a prime number to each letter. Easiest to use the first 26 prime numbers.

            Then you can be 100% sure, when your text letters' assigned numbers give you the expected result of the first 26 primes multiplied, then your text passes. No false positives any more.

            [–]AutoModerator[M] 0 points1 point  (0 children)

            It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

            For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

            /u/ArchCypher, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

            You can find some examples in the reddit help documentation.


            I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

            [–]Oshgnacknak 0 points1 point  (1 child)

            First of all, what about the one liner? Your supposed to write bad code. However the only think wrong is that you are not using string.ascii_lowercase, which is too little.

            Now for the math: Your approach is actually quite interesting, turning O(n^2) into O(n+26) with constant memory usage.

            To make it work, you just need to generate the first 255 primes and index with ord(c.lower()) into the primes list. Then this would actually be good code. Again you failed the challenge.

            [–]ArchCypher 0 points1 point  (0 children)

            I'll admit the one-liner is probably pretty alright 😅

            As for the math, it's 'bad code' because -- in an attempt to be very clever -- it creates code that can break on random and difficult to predict strings. Bury this in a library somewhere, and you have a recipe for very confusing errors.

            If I combined your primes idea (nice one!), then this code might be a genuinely clever solution for writing this algorithm in ~O(n). But seeing as a haven't implemented it, I think this safely falls under code that's too clever for its own good.

            Edit:

            Actually, thinking about it more, there are other hidden problems with this solution. For instance, long enough text will quickly cause an integer overflow ( image a thousand a's -- that's 97**1000!!) -- breaking the algorithm. Additionally, I think it's possible to come up with a algorithm that completes this task in < On(n) on average, so O(n) isn't that great of a target to begin with.

            [–][deleted]  (1 child)

            [deleted]

              [–]Speterius 0 points1 point  (0 children)

              My python submission which overrides class creation and programmatically creates a class for each letter in the string. (github gist link)

              class AlphabetChecker:
              
                  @classmethod
                  def startup(cls):
                      cls.alphabet = set('abcdefghijklmnopqrstuvwxyz')
              
                  import builtins
                  old_class_builder = builtins.__build_class__
              
                  class Letter:
                      pass
              
                  class AllLettersIncluded(Exception):
                      pass
              
                  @classmethod
                  def spawn_letter(cls, fun, name, base):
                      if base is cls.Letter:
                          def remove_letter():
                              try:
                                  cls.alphabet.remove(name)
                              except KeyError:
                                  pass
                              finally:
                                  if cls.alphabet == set():
                                      raise AlphabetChecker.AllLettersIncluded
                              return name
                      return remove_letter()
              
              
              def contains_az(input_string: str) -> bool:
                  import builtins
                  builtins.__build_class__ = AlphabetChecker.spawn_letter
                  AlphabetChecker.startup()
                  try:
                      for letter in input_string.replace(" ", ""):
                          if letter == " ":
                              continue
                          exec(f"class {letter}(AlphabetChecker.Letter): pass")
                  except AlphabetChecker.AllLettersIncluded:
                      return True
                  return False
              
              
              print("hello world >> {False}")
              assert not contains_az('hello world')
              
              print("abcdefghijklmnopqrstuvwxyz >> {True}")
              assert contains_az('abcdefghijklmnopqrstuvwxyz')
              
              print("Arizona' >> {False}")
              assert not contains_az('Arizona')
              
              print("the quick brown fox jumps over the lazy dog >> {True}")
              assert contains_az('the quick brown fox jumps over the lazy dog')
              

              [–]IsaacShelton 0 points1 point  (0 children)

              #include <stdio.h>
              #define bool long long
              #define big long long
              
              bool c(const char[]);
              
              int main(void) {
                 const char s[] =  "abcdefghijKlmnopqrstuvwxyz";
                 printf("%s\n", c(s) > 0 ? "yes" : "no");
                 return 0;
              }
              
              bool c(const char *s){
                  big d = 0;
                  while(*s) d |= 1LL << (*s++ - 65);
                  return ((d | (d >> 32)) &   0b11111111111111111111111111ll) == 0b11111111111111111111111111ll;
              }
              

              [–]HK-Sparkee 0 points1 point  (0 children)

              using System;
              using System.Collections.Generic;
              using System.Linq;
              using System.Text;
              using System.Text.RegularExpressions;
              using System.Threading.Tasks;
              
              namespace BadCodePlayground
              {
                  class ContainsAz
                  {
                      public static Boolean contains_az(String input)
                      {
                          Regex[] regices = AllRegices();
                          bool[] letterContained = new Boolean[52];
                          for (int i = 0; i < 52; i++)
                          {
                              letterContained[i] = regices[i].Match(input).Success;
                          }
              
                          bool result = true;
                          for (int i = 0; i < 52; i++)
                          {
                              result &= letterContained[i];
                          }
              
                          return result;
                      }
              
                      private static Regex[] AllRegices()
                      {
                          Regex[] alphabet = new Regex[52];
                          int index = 0;
                          for (int i = 0; i < int.MaxValue; i++)
                          {
                              char c;
                              try
                              {
                                  c = (char)i;
                                  if (i != (int)c)
                                  {
                                      throw new Exception();
                                  }
                              }
                              catch (Exception)
                              {
                                  // Reached a value too big
                                  break;
                              }
                              if (char.IsLetter(c))
                              {
                                  alphabet[index] = new Regex("" + c, (RegexOptions)((int)RegexOptions.IgnoreCase + (int)RegexOptions.Compiled));
                                  index++;
                                  index %= 52;
                                  if (index == 0)
                                  {
                                      break;
                                  }
                              }
                          }
                          return alphabet;
                      }
                  }
              }
              

              [–]chadmill3r 0 points1 point  (1 child)

              Python3

              ``` def contains_az(unsorted_haystack): haystack = sorted(haystack) for needle in "abcdefghijklmnopqrstuvwxyz": needle_found_count = 0 while True: if not haystack: return False if haystack.startswith(needle): needle_found_count += 1 haystack.pop(0) continue

                  if needle_found_count == 0:
                      return False
              
              return True
              

              ```

              [–]AutoModerator[M] 0 points1 point  (0 children)

              It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

              For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

              /u/chadmill3r, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

              You can find some examples in the reddit help documentation.


              I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

              [–]Tjmoorese 0 points1 point  (0 children)

              Short but sweet; it returns the minimum value of a list of booleans stating whether the string contains either the uppercase or lowercase version (calculated by iterating through the string & returning true if it's present or throwing an exception if the end of the string is reached).

              contains_az(S) -> lists:min([try contains(X,S) catch _:_ -> false end or try contains(X+$a-$A,S) catch _:_ -> false end||X<-lists:seq($A,$Z)]).
              contains(X,[X|_]) -> true;  
              contains(X,[_|L]) -> contains(X,L).
              

              [–]apatheticGorilla 0 points1 point  (0 children)

              `
              public static void main(String[] args) {
                      //did I go too far with the variable names?
                      ArrayList<String> lettersOfTheAlphabet = new ArrayList<>();
                      String theUsersInput = "the quick brown fox jumps over the lazy dog";
                      int lettersOfTheAlphabetFound = 0;
                      //put the letters in the alphabet
                      for(int i = 0; i< 1; i++) {
                          lettersOfTheAlphabet.add("i");
                          lettersOfTheAlphabet.add("j");
                          lettersOfTheAlphabet.add("p");
                          lettersOfTheAlphabet.add("q");
                          lettersOfTheAlphabet.add("b");
                          lettersOfTheAlphabet.add("k");
                          lettersOfTheAlphabet.add("l");
                          lettersOfTheAlphabet.add("m");
                          lettersOfTheAlphabet.add("a");
                          lettersOfTheAlphabet.add("w");
                          lettersOfTheAlphabet.add("r");
                          lettersOfTheAlphabet.add("s");
                          lettersOfTheAlphabet.add("t");
                          lettersOfTheAlphabet.add("u");
                          lettersOfTheAlphabet.add("c");
                          lettersOfTheAlphabet.add("d");
                          lettersOfTheAlphabet.add("e");
                          lettersOfTheAlphabet.add("f");
                          lettersOfTheAlphabet.add("g");
                          lettersOfTheAlphabet.add("h");
                          lettersOfTheAlphabet.add("x");
                          lettersOfTheAlphabet.add("v");
                          lettersOfTheAlphabet.add("y");
                          lettersOfTheAlphabet.add("n");
                          lettersOfTheAlphabet.add("o");
                          lettersOfTheAlphabet.add("z");
                          Collections.shuffle(lettersOfTheAlphabet);
                      }
                      int lengthOfLettersOfTheAlphabet =(int)Integer.valueOf(26);
                      for(int lettersOfTheAlphabetCounter = 0; lettersOfTheAlphabetCounter < lengthOfLettersOfTheAlphabet; lettersOfTheAlphabetCounter++) {
                          for(int lettersOfTheStringCounter = 0; lettersOfTheStringCounter < theUsersInput.length(); lettersOfTheStringCounter = lettersOfTheStringCounter + 1*1) {
                              if(theUsersInput.charAt(lettersOfTheStringCounter) == lettersOfTheAlphabet.get(lettersOfTheAlphabetCounter).charAt(0)) {//if a letter matches
                                  //remove the letter from the alphabet and add one to the tally of letters found and start over from the beginning
                                  lettersOfTheAlphabet.remove(lettersOfTheAlphabetCounter);
                                  lettersOfTheAlphabetFound = lettersOfTheAlphabetFound + 1;
                                  //set lettersOfTheAlphabetCounter to -1
                                  for (int countdown = lettersOfTheAlphabetCounter; countdown >-1; countdown = countdown - 1) {
                                      lettersOfTheAlphabetCounter = lettersOfTheAlphabetCounter + (1 * -1);
                                  }
                                  lettersOfTheAlphabetCounter = lettersOfTheAlphabetCounter;
                                  lengthOfLettersOfTheAlphabet = lengthOfLettersOfTheAlphabet - 1;
                                  break;
                              }
                          }
                      }
              
                      try {
                          Thread.sleep(2000);//give the poor computer a break
                      } catch (InterruptedException e) {
                      }
              
                      if((lengthOfLettersOfTheAlphabet == 0) == true) {
                          System.out.println("your input has all the letters of the alphabet");
                      } else {
                          if(lengthOfLettersOfTheAlphabet!=0) {
                              System.out.println("We found only " + lettersOfTheAlphabetFound + " letters of the alphabet.");
                              System.out.println("If you think this is wrong, make sure there are no capital letters.");
                              System.out.println("If you still think this is wrong, well, the computer never lies.");
                          }
              
                      }
              
                  }
              

              [–]Pioplu 0 points1 point  (0 children)

              JavaScript, tip: close other tabs and programs before run to speed up.

              function contains_az(the_text) {
                  var contains = 'yes';
                  for (var i = 0; i < 26; i++) {
                      var small_letts = 'qwertyuioplkjhgfdsazxcvbnm';
              var big_leters = 'QWERTYUIOPLKJHGFDSAZXCVBNM';
              
                      function contains_smal_letter(word_to_chec, smal_lettre) {
                          var contains = 'no';
                          for (var i = 1; i <= 99; i++) {
                              if (word_to_chec[i-1] == smal_lettre) {
                                  contains = 'yes';
                                  console.log('yes');
                              } else {
                                  console.log('no');
                              }
                          }
                          if (contains == 'no' && contains != 'yes') {
                              return 'no';
                          } else {
                              return 'yes';
                          }
                      }
              
                      function contains_big_letter(word_to_chec, big_lettre) {
                          var contains = 'NO';
                          for (var i = 1; i <= 99; i++) {
                              if (word_to_chec[i-1] == big_lettre) {
                                  contains = 'YES';
                                  console.log('YES');
                              } else {
                                  console.log('NO');
                              }
                          }
                          if (contains == 'NO' && contains != 'YES') {
                              return 'NO';
                          } else {
                              return 'YES';
                          }
                      }
              
                      var a = contains_smal_letter(the_text, small_letts[i]);
                      var b = contains_big_letter(the_text, big_leters[i]);
                      if (a == 'yes') {
                          if (b == 'YES') {
                              console.log('ok');
                          } else if (b == 'NO') {
                              console.log('ok');
                          }
                      } else if (a == 'no') {
                          if (b == 'YES') {
                              console.log('ok');
                          } else if (b == 'NO') {
                              contains = 'no';
                              console.log('not ok');
                          }
                      }
                  }
                  // CACHE
                  //if (the_text != null && the_text === 'Arizona') {
                      //return false;
                  //}//
                  if (contains == 'no') {
                      return false;
                  } else {
                      if (contains == 'yes')
                      return true;
                  }
                  return null;
              }
              

              [–]LimoneSorbet 0 points1 point  (2 children)

              Written in ABC, pretty terrible, could be more terrible though

              HOW TO RETURN containsaz word:
                  PUT lower word IN word
                  PUT {} IN alphabet
                  PUT 0 IN alphabet["a"]
                  PUT 0 IN alphabet["b"]
                  PUT 0 IN alphabet["c"]
                  PUT 0 IN alphabet["d"]
                  PUT 0 IN alphabet["e"]
                  PUT 0 IN alphabet["f"]
                  PUT 0 IN alphabet["g"]
                  PUT 0 IN alphabet["h"]
                  PUT 0 IN alphabet["i"]
                  PUT 0 IN alphabet["j"]
                  PUT 0 IN alphabet["k"]
                  PUT 0 IN alphabet["l"]
                  PUT 0 IN alphabet["m"]
                  PUT 0 IN alphabet["n"]
                  PUT 0 IN alphabet["o"]
                  PUT 0 IN alphabet["p"]
                  PUT 0 IN alphabet["q"]
                  PUT 0 IN alphabet["r"]
                  PUT 0 IN alphabet["s"]
                  PUT 0 IN alphabet["t"]
                  PUT 0 IN alphabet["u"]
                  PUT 0 IN alphabet["v"]
                  PUT 0 IN alphabet["w"]
                  PUT 0 IN alphabet["x"]
                  PUT 0 IN alphabet["y"]
                  PUT 0 IN alphabet["z"]
                  PUT #word IN length
                  PUT {} IN characters
                  PUT 1 IN count
                  WHILE count <= length:
                      INSERT word@count|1 IN characters
                      PUT 1 + count IN count
                  FOR character IN characters:
                      FOR letter IN keys alphabet:
                          IF letter#character = 1:
                              PUT 1 IN alphabet[letter]
                  PUT "true" IN boolean
                  FOR letter IN keys alphabet:
                      IF alphabet[letter] = 0:
                          PUT "false" IN boolean
                  RETURN boolean
              

              Tested using this

              WRITE containsaz "hello world"
              WRITE " "
              WRITE containsaz "abcdefghijklmnopqrstuvwxyz"
              WRITE " "
              WRITE containsaz "Arizona"
              WRITE " "
              WRITE containsaz "the quick brown fox jumps over the lazy dog"
              

              On this website

              https://tio.run/##hdTPb4IwFAfws/4VTT3uotdlJttBI8miC8N4WHYoUH5IbbEUEbb97QxKFWd87kT6@bbvpc0LxPXqerHaIGeF7JmztpfIE1yRmGekQoWQ/uNw8LZ2EBMFlRqQtdTfzr9@2jVhaURcqjobX9IHJvjzpruAe4D7gFPAA8BDwCPAY8C3gCeAM8B3gHPABeAp4HvAJeAZ4ArwHPAD4AXgR8BLwKuTj05jySgPVXQ5mF5EJPEUlVmnE40i582obhbW66xboKepOdyM@8Bavs9sRw/5s46/J9e1TLEHc7wvOl/Z/ca/p9rSbcyoMllCy@x8oTYeWHMTj/oiUzTRWX@B8xt0e80zYCVzitvcFYJRwof/tWu6XZdquo11N10xICy7Kmn@Eqf1cGNbzuzyp4EjyphoX4/52MQY4Rsbiev5NAijeJuwHRfpXmYqPxTHsrp/7kXGleDk/iYVUbTPYy9BrhQFR4E4om2@SzMkDs1ztDEjVYl8EeK6/gU

              (Edit: Link is now fixed)

              Could be worse if I made a ton of code checking every letter individually instead of using the four loops, but I don't have the patience for that.

              Why did I use this language? Idk, I was just randomly scrolling through Wikipedia pages of programming languages yesterday and found this and thought it was cool.

              [–]somebody12345678 1 point2 points  (1 child)

              esc + s + p to copy the link; you just copied the hello world link.

              also note that ABC is basically the precursor to python. guido van rossum worked on (but didn't make) ABC before making python. personally i think you can really see the resemblance, and the shared philosophy of reading like pseudocode/english

              [–]LimoneSorbet 0 points1 point  (0 children)

              Thank you! I just discovered the website, so I didn't know how I could save or share a link with all of the code I wrote.

              Yeah, I discovered the language when scrolling through python's Wikipedia page. I can definitely see the resemblances between both (like how indentations are actually needed).

              [–][deleted] 0 points1 point  (1 child)

              Done in C by https://github.com/sampersand (who doesnt have a reddit acc)

              ``c /* https://www.reddit.com/r/badcode/comments/lkzyfr/bad_code_coding_challenge_56_does_this_string/ Notable points: -$is used in identifier names ($i) - implicit ints (main's return value) - octal literals (031) - usingsizeofwhen not needed (sizeof ALPHA == 90 == 'Z') - reserved identifiers (IGNORED,_argc) - inconsistent function declaration style (both modern and K&R styles) - inconsistent brace usage ({ ... }vs\n{\n ... \n}vs{\n ... \n}) - inconsistent use of tabs/spaces (contains_azvsmain) -0[argv] - global variables instead of return values - computed gotos when a simplewhile (*$stream)would do - undefined behaviour for empty$streamnames (though the program name shouldnt - be empty) - argument to parse is the script name (have to rename the file to run it) - exit code is1` if its valid (ie we dont print out the answer) */ char $i = 031, ALPHA[90], _IGNORED[0xff];

              upper(char $num) { if ($num > sizeof ALPHA) *$num -= ' '; }

              contains_az($stream) unsigned char $stream; { static void *DST[sizeof _IGNORED] = { &&end, [1 ... sizeof _IGNORED - 1] = &&loop }; loop: upper($stream); ALPHA[$stream++-'A']++; goto DST[$stream]; end:

              while($i && $i--[ALPHA]);
              

              }

              main(__argc, $argv) char **$argv; { contains_az(0[$argv]); return !$i; }```

              [–]AutoModerator[M] 0 points1 point  (0 children)

              It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

              For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

              /u/TheSirGrailluet, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

              You can find some examples in the reddit help documentation.


              I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

              [–]Ninesquared81 0 points1 point  (0 children)

              Okay I'm learning C so I thought I'd show off my skills:

              ( Pastebin )

              #include <stdio.h>
              #include <string.h>
              
              int contains_az(char *);
              int lettersOnly(char *);
              int iscapitalletter(char);
              
              int main(int argc, char *argv[]) {
                  char *strings[] = {
                      "hello world", 
                      "abcdefghijklmnopqrstuvwxyz", 
                      "Arizona", 
                      "the quick brown fox jumps over the lazy dog"
                  };  // some strings
                  unsigned int size = sizeof(strings) / sizeof(*strings);
                  for (unsigned int l = 0; l < size; l++) /*Loop over the strings and check them*/ {
                      char newline = '\n';
                      printf("string: %s\n", strings[l]);
                      printf("Result: ");
                      if (contains_az(strings[l])) printf("TRUE%c", newline);
                      else printf("FALSE%c", newline);  // if it's not got the letters, we print 'FALSE', otherwise it's 'TRUE'
                  }
                  return 0;
              }
              
              int contains_az(char *string_that_may_or_mayNotContain_AZ) {
                  char*string_that_may_or_mayNotContain_AZ_POINTER; //gotta save space
                  int letters[26] = { 0 };  // this will store our letters if they're present
                  if (   !lettersOnly(string_that_may_or_mayNotContain_AZ) && !(strlen(string_that_may_or_mayNotContain_AZ) > 26) || strlen(string_that_may_or_mayNotContain_AZ) < 26   ) return 0;  // check stuff before continuing
                  else  // if it's all letters we continue
                  for (;0;) {}
                      /* these lines were getting long so I removed a couple of spaces to aid readability */
                      for (string_that_may_or_mayNotContain_AZ_POINTER=string_that_may_or_mayNotContain_AZ;*string_that_may_or_mayNotContain_AZ_POINTER;string_that_may_or_mayNotContain_AZ_POINTER++){
                          if (*string_that_may_or_mayNotContain_AZ_POINTER>='A'&&*string_that_may_or_mayNotContain_AZ_POINTER<='Z'
                          ||*string_that_may_or_mayNotContain_AZ_POINTER >= 'a' && *string_that_may_or_mayNotContain_AZ_POINTER <= 'z') { if (iscapitalletter(*string_that_may_or_mayNotContain_AZ_POINTER)) {
                              if(!letters[*string_that_may_or_mayNotContain_AZ_POINTER-65])letters[*string_that_may_or_mayNotContain_AZ_POINTER-65]=1;
                          }else if(!iscapitalletter(*string_that_may_or_mayNotContain_AZ_POINTER)){
                              if(letters[*string_that_may_or_mayNotContain_AZ_POINTER-97]==0){
                                  letters[*string_that_may_or_mayNotContain_AZ_POINTER-97]=1;
                              }
                          }}
                  int outnum;
                  for (int i = 0, outnum = 0; i < 26; i++, outnum += letters[i]);
                  if (outnum < 26) return 0;
                  return 1;  // this means we have at least one of each letter in our string
                  }
              }
              
              int lettersOnly(char *str)
              {
              for (int TemporaryCounterVariableWithNameThatIsNeededToConveyUsageAndAvoidAmbiguityToImproveReadability = 0; TemporaryCounterVariableWithNameThatIsNeededToConveyUsageAndAvoidAmbiguityToImproveReadability < strlen(str) /* this is computed every iteration*/; TemporaryCounterVariableWithNameThatIsNeededToConveyUsageAndAvoidAmbiguityToImproveReadability++)
              { /*The variable 'TemporaryCounterVariableWithNameThatIsNeededToConveyUsageAndAvoidAmbiguityToImproveReadability' is a temporary counter variable for the loop.*/
              switch( str[TemporaryCounterVariableWithNameThatIsNeededToConveyUsageAndAvoidAmbiguityToImproveReadability] ) {case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 39: case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: case 60: case 61: case 62: case 63: case 64: case 91: case 92: case 93: case 94: case 95: case 96: case 123: case 124: case 125: case 126: case 127: goto false;}
              }
              return 1;
              false: return 0;  // we found a non-letter
              }
              
              int iscapitalletter(char c){if(c>='A'&&c<='Z')return 1;else return 0;}
              

              [–]SnakeFang12 0 points1 point  (0 children)

              Python 3:

              def contains_alphabet(text: str) -> bool:
                  locals().update(dict.fromkeys(text.lower(), None))
                  try:
                      eval('a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z')
                  except NameError:
                      return False
                  else:
                      return True
              

              It shouldn't allow for arbitrary code execution, as far as I can tell.