Failed Tests

### Factor Arrays Vocabuary

As a referance:

``````IN: scratchpad
USING: prettyprint kernel arrays ;

! <array> (n element -- array) : array of n element's
5 1 <array> .  ! { 1 1 1 1 1 }
8 "H" <array> .
! 1array ( x -- array ) : 1 element array from x
{ 1 } 1 1array = .
! 2array  ...
"Hello" "World" 2array .
! 3array  ...
1 2 3 3array .
! 4array ...
0 1 1array 2 3 2array  3 4 5 3array  4array .
! >array (seq -- array ) converts stuff to arrays
"Hello" >array .
! array? / pair? ( object -- ? ) determines if something is an array
{ } array? .
"Hello" array? .
"Hello" >array array? .
1 array? .``````

### Binets Formula

(aka directly computing the fibbonaci sequence)

``````def binet(n):
sqrt5 = 5 ** 0.5
phi = (1 + sqrt5) / 2
psi = (1 - sqrt5) / 2
return int((phi ** n - psi ** n) / sqrt5)``````

### Animal Factory

without the Animal factory, `rat.speak` would return an AttributeError instead of a NotImplementedError.

``````class Animal:
def speak(self): raise NotImplementedError

class Dog(Animal):
def speak(self): return "Woof!"
class Cat(Animal):
def speak(self): return "Meow!"

class Rat(Animal):
pass

class AnimalFactory:
def create_animal(self, animal_type):
match animal_type:
case "dog": return Dog()
case "cat": return Cat()
case "rat": return Rat()``````

### Best way to randomly generate a Boolean value (but it's cleaner)

Code
Diff
• ``````RandomBool=lambda:bool(ord('}')>ord(open('/dev/urandom','rb').read(True^False)))^\
__import__("secrets").choice([__import__("random").getrandbits(1),
__import__("random").getrandbits(1)])
# might as well make it worse...``````
• # This is also terribad, and the previous randint ones are better, but why not keep having fun
• __import__("secrets").choice([__import__("random").getrandbits(1),
• __import__("random").getrandbits(1)])
• # might as well make it worse...

### Oh, so <i>that's</i> what all of the modules do :)

Fundamentals
Code
Diff
• ``````import __future__
import _weakrefset
import grp
import reprlib
import _abc
import _xxsubinterpreters
import gzip
import requests
import _ast
import _xxtestfuzz
import hashlib
import resource
import _asyncio
import abc
import heapq
# import retrying
import _bisect
import aifc
import hmac
import rlcompleter
import _blake2
import antigravity
import html
import runpy
#import appdirs
#import html5lib
import sched
import _bz2
import argparse
import http
import secrets
import _codecs
import array
import idna
import select
import _codecs_cn
import ast
import imaplib
import selectors
import _codecs_hk
import asynchat
import imghdr
import setuptools
import _codecs_iso2022
import asyncio
import imp
import shelve
import _codecs_jp
import asyncore
import importlib
import shlex
import _codecs_kr
import atexit
import inspect
import shutil
import _codecs_tw
import audioop
import io
import signal
import _collections
import base64
import site
import _collections_abc
import bdb
import itertools
import six
import _compat_pickle
import binascii
import json
import smtpd
import _compression
import binhex
import keyword
import smtplib
import _contextvars
import bisect
import lib2to3
import sndhdr
import _crypt
import builtins
import linecache
import socket
import _csv
import bz2
import locale
import socketserver
import _ctypes
import cProfile
#import lockfile
import spwd
import _ctypes_test
#import cachecontrol
import logging
import sqlite3
import _curses
import calendar
import lzma
import sre_compile
import _curses_panel
import certifi
import mailbox
import sre_constants
import _datetime
import cgi
import mailcap
import sre_parse
import _dbm
import cgitb
#import main
import ssl
import _decimal
#import chardet
import marshal
import stat
import chunk
import math
import statistics
import _elementtree
import cmath
import mimetypes
import string
import _functools
import cmd
import mmap
import stringprep
import _gdbm
import code
import modulefinder
import struct
import _hashlib
import codecs
#import msgpack
import subprocess
import _heapq
import codeop
import multiprocessing
import sunau
import _imp
import collections
import netrc
#import symbol
import _io
#import colorama
import nntplib
import symtable
import _json
import colorsys
import ntpath
import sys
import _locale
import compileall
import nturl2path
import sysconfig
import _lsprof
import concurrent
import numbers
import syslog
import _lzma
import configparser
import numpy
import tabnanny
import _markupbase
import contextlib
import opcode
import tarfile
import _md5
#import contextlib2
import operator
import telnetlib
import _multibytecodec
import contextvars
import optparse
import tempfile
import _multiprocessing
import copy
#import ordered_set
import termios
import _opcode
import copyreg
import os
import textwrap
import _operator
import crypt
import ossaudiodev
#import this
import _osx_support
import csv
import packaging
import _pickle
import ctypes
import pandas
import time
import _posixshmem
import curses
#import parser
import timeit
import _posixsubprocess
import dataclasses
import pathlib
import token
import _py_abc
import datetime
import pdb
import tokenize
import _pydecimal
import dateutil
#import pep517
#import toml
import _pyio
import dbm
import pickle
import trace
import _queue
import decimal
import pickletools
import traceback
import _random
import difflib
import pip
import tracemalloc
import _sha1
import dis
import pipes
import tty
import _sha256
#import distlib
import pkg_resources
import turtle
import _sha3
#import distro
import pkgutil
import turtledemo
import _sha512
import platform
import types
import _signal
import doctest
import plistlib
import typing
import _sitebuiltins
import poplib
import unicodedata
import _socket
import posix
import unittest
import _sqlite3
import email
import posixpath
import urllib
import _sre
import encodings
import pprint
import urllib3
import _ssl
import ensurepip
import profile
import uu
import _stat
import enum
#import progress
import uuid
import _statistics
import errno
import pstats
import venv
import _string
import faulthandler
import pty
import warnings
import _strptime
import fcntl
import pwd
import wave
import _struct
import filecmp
import py_compile
import weakref
import _symtable
import fileinput
import pyclbr
import webbrowser
import fnmatch
import pydoc
#import webencodings
import _testbuffer
#import formatter
import pydoc_data
import wsgiref
import _testcapi
import fractions
import pyexpat
import xdrlib
import _testimportmultiple
import ftplib
import pyparsing
import xml
import _testinternalcapi
import functools
#import pytoml
import xmlrpc
import _testmultiphase
import gc
import pytz
import xxlimited
import genericpath
import queue
import xxsubtype
import getopt
import quopri
import zipapp
import _tracemalloc
import getpass
import random
import zipfile
import _warnings
import gettext
import re
import zipimport
import _weakref
import glob
import zlib``````
• import __future__
• import _weakrefset
• import grp
• import reprlib
• import _abc
• import _xxsubinterpreters
• import gzip
• import requests
• import _ast
• import _xxtestfuzz
• import hashlib
• import resource
• import _asyncio
• import abc
• import heapq
• # import retrying
• import _bisect
• import aifc
• import hmac
• import rlcompleter
• import _blake2
• import antigravity
• import html
• import runpy
• #import appdirs
• #import html5lib
• import sched
• import _bz2
• import argparse
• import http
• import secrets
• import _codecs
• import array
• import idna
• import select
• import _codecs_cn
• import ast
• import imaplib
• import selectors
• import _codecs_hk
• import asynchat
• import imghdr
• import setuptools
• import _codecs_iso2022
• import asyncio
• import imp
• import shelve
• import _codecs_jp
• import asyncore
• import importlib
• import shlex
• import _codecs_kr
• import atexit
• import inspect
• import shutil
• import _codecs_tw
• import audioop
• import io
• import signal
• import _collections
• import base64
• import site
• import _collections_abc
• import bdb
• import itertools
• import six
• import _compat_pickle
• import binascii
• import json
• import smtpd
• import _compression
• import binhex
• import keyword
• import smtplib
• import _contextvars
• import bisect
• import lib2to3
• import sndhdr
• import _crypt
• import builtins
• import linecache
• import socket
• import _csv
• import bz2
• import locale
• import socketserver
• import _ctypes
• import cProfile
• #import lockfile
• import spwd
• import _ctypes_test
• #import cachecontrol
• import logging
• import sqlite3
• import _curses
• import calendar
• import lzma
• import sre_compile
• import _curses_panel
• import certifi
• import mailbox
• import sre_constants
• import _datetime
• import cgi
• import mailcap
• import sre_parse
• import _dbm
• import cgitb
• #import main
• import ssl
• import _decimal
• #import chardet
• import marshal
• import stat
• import chunk
• import math
• import statistics
• import _elementtree
• import cmath
• import mimetypes
• import string
• import _functools
• import cmd
• import mmap
• import stringprep
• import _gdbm
• import code
• import modulefinder
• import struct
• import _hashlib
• import codecs
• #import msgpack
• import subprocess
• import _heapq
• import codeop
• import multiprocessing
• import sunau
• import _imp
• import collections
• import netrc
• #import symbol
• import _io
• #import colorama
• import nntplib
• import symtable
• import _json
• import colorsys
• import ntpath
• import sys
• import _locale
• import compileall
• import nturl2path
• import sysconfig
• import _lsprof
• import concurrent
• import numbers
• import syslog
• import _lzma
• import configparser
• import numpy
• import tabnanny
• import _markupbase
• import contextlib
• import opcode
• import tarfile
• import _md5
• #import contextlib2
• import operator
• import telnetlib
• import _multibytecodec
• import contextvars
• import optparse
• import tempfile
• import _multiprocessing
• import copy
• #import ordered_set
• import termios
• import _opcode
• import copyreg
• import os
• import textwrap
• import _operator
• import crypt
• import ossaudiodev
• import this
• #import this
• import _osx_support
• import csv
• import packaging
• import _pickle
• import ctypes
• import pandas
• import time
• import _posixshmem
• import curses
• #import parser
• import timeit
• import _posixsubprocess
• import dataclasses
• import pathlib
• import token
• import _py_abc
• import datetime
• import pdb
• import tokenize
• import _pydecimal
• import dateutil
• #import pep517
• #import toml
• import _pyio
• import dbm
• import pickle
• import trace
• import _queue
• import decimal
• import pickletools
• import traceback
• import _random
• import difflib
• import pip
• import tracemalloc
• import _sha1
• import dis
• import pipes
• import tty
• import _sha256
• #import distlib
• import pkg_resources
• import turtle
• import _sha3
• #import distro
• import pkgutil
• import turtledemo
• import _sha512
• import platform
• import types
• import _signal
• import doctest
• import plistlib
• import typing
• import _sitebuiltins
• import poplib
• import unicodedata
• import _socket
• import posix
• import unittest
• import _sqlite3
• import email
• import posixpath
• import urllib
• import _sre
• import encodings
• import pprint
• import urllib3
• import _ssl
• import ensurepip
• import profile
• import uu
• import _stat
• import enum
• #import progress
• import uuid
• import _statistics
• import errno
• import pstats
• import venv
• import _string
• import faulthandler
• import pty
• import warnings
• import _strptime
• import fcntl
• import pwd
• import wave
• import _struct
• import filecmp
• import py_compile
• import weakref
• import _symtable
• import fileinput
• import pyclbr
• import webbrowser
• import fnmatch
• import pydoc
• #import webencodings
• import _testbuffer
• #import formatter
• import pydoc_data
• import wsgiref
• import _testcapi
• import fractions
• import pyexpat
• import xdrlib
• import _testimportmultiple
• import ftplib
• import pyparsing
• import xml
• import _testinternalcapi
• import functools
• #import pytoml
• import xmlrpc
• import _testmultiphase
• import gc
• import pytz
• import xxlimited
• import genericpath
• import queue
• import xxsubtype
• import getopt
• import quopri
• import zipapp
• import _tracemalloc
• import getpass
• import random
• import zipfile
• import _warnings
• import gettext
• import re
• import zipimport
• import _weakref
• import glob
• import zlib
Failed Tests

### arhamsc's Kumite #2

Code
Diff
• ``print                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ("hello")``
• print ("hello")
• print ("hello")

### [BF] Print all values less than or equal to byte as numerical string (0-99 only)

minified.

Code
Diff
• ``>,+[-[-<+>>>+<<]>>>+[[-]<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->[-]>>+>+<<<]]]]]]]]]<]>>[>]++++++[-<++++++++>]>>]<<<[.[-]<<<]<[->+>[-]+<<]>>[+++[->++++++++<]>.[-]<]<]``
• >,+
• [-
• [-<+>>>+<<]>>>+
• [[-]<
• [->+<
• [->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<
• [->[-]>>+>+<<<]
• ]]]]]]]]<
• ]>>[>]++++++[-<++++++++>]>>
• ]<<<[.[-]<<<]
• <[->+>[-]+<<]>>[+++[->++++++++<]>.[-]<]<
• ]
• >,+[-[-<+>>>+<<]>>>+[[-]<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->[-]>>+>+<<<]]]]]]]]]<]>>[>]++++++[-<++++++++>]>>]<<<[.[-]<<<]<[->+>[-]+<<]>>[+++[->++++++++<]>.[-]<]<]

### Did you know....

Codewars can format html stuff!
Woah, nested descriptions!

ππππ

\_(oUo)_/

go try it!

Or see an html reference here.

It also works in the console. Press the run button!

``````x = """
<main>
<p>
The formatter recognizes whitespace,
so be careful with indentation.
<p>The formatter can <b>also</b> do...</p>
<b>Bold words</b>
<i>italics</i>
<em>emphasis</em>
<mark>highlights</mark>
<small>small text</small>
<sub>sub</sub> Text

<sup>sup</sup> Text

<u>Underline... </u>
<abbr title="National Aeronautics and Space Administration">NASA</abbr> (Abbriviations)
<strike>strikethrough</strike>
<del> deprecated info </del> <ins> new info </ins>
<s> not relevant </s>
<time datetime="2020-08-17 08:00">Monday at 8:00 AM</time> (smart time formatting)
</p>
</main>
<code>
// code blocks don't really show up different on the console...
#include <iostream>

using namespace std;

int main()
{
cout << "Hello World!" << endl;
return 0;
}
</code>
<table>
<tr>
<th>Numbers</th>
<th>Letters</th>
<th>Colors</th>
</tr>
<tfoot>
<tr>
<td>123</td>
<td>ABC</td>
<td>RGB</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>1</td>
<td>A</td>
<td>Red</td>
</tr>
<tr>
<td>2</td>
<td>B</td>
<td>Green</td>
</tr>
<tr>
<td>3</td>
<td>C</td>
<td>Blue</td>
</tr>
</tbody>
</table>
<details>
<summary>This part's really cool...</summary>
<p>If you wanted to hide stuff,</p>
<p>Make some details section,</p>
<p>Or if you liked drop down menus,</p>
<p>You can do that now!</p>
</details>
<section>
<h3>Section 123</h3>
<p>yay,  html. </p>
</section>
<ul>
<li>List items!</li>
<li>List items!</li>
</ul>
<select>
<optgroup label="Choice [1-3]">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</optgroup>
<optgroup label="Choice [4-6]">
<option value="4">Four</option>
<option value="5">Five</option>
<option value="6">Six</option>
</optgroup>
</select>
<div>yoooooo a circle</div>
</div>
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>
<textarea id="textarea" name="textarea" rows="4" cols="40">
Hello \(οΏ£οΈΆοΏ£*\))
Click and drag the bottem right corner to resize!
</textarea>
<fieldset>
<legend>Info Stealing Form:</legend>
<label for="name">Name</label><br>
<input name="name" id="name"><br>
<label for="dob">Date of Birth<label><br>
<input name="dob" id="dob" type="date">
<label for="name">Social Security Number:</label><br>
<input name="SSN" id="no, this isn't collected anywhere."><br>
</fieldset>
<form action="" method="get">
<label for="Rating">Select your reaction from this kumite:</label>
<input list="reactions" name="Rating" id="Rating">
<datalist id="reactions">
<option value="WOAH!!">
<option value="Nice.">
<option value="Meh.">
<option value="BOOOOOOOOO!">
</datalist>
<input type="submit">
</form>
"""
print(x)``````
Failed Tests

### Best way to randomly generate a Boolean value (but it's cleaner)

see the og as well.

Code
Diff
• ``````from random import choice
class Random_Bool(object):
def __repr__(self):
return repr(self.r())

def __init__(self):

self.r =  lambda: choice([True,False])

random_boolean = Random_Bool()
``````
• from dataclasses import dataclass
• from random import choice,randint
• class returnable_argument:
• def get__approx_value_of(variable, get_type = False):
• try:
• if exec(f"{get_type}"):
• return (variable, type(variable))
• return variable
• except (SyntaxError, TypeError, NameError) as Error:
• print(f'Warning: {Error} was raised and excepted with values: {Error.args}')
• @dataclass
• class _Random_Bool(object):
• def __repr__(_______, __________ = '___________'):
• assert "no, but acually yes"
• _____,_,__=locals,bool,int;x=1;_1_ =__import__("random").choice
• ________ = lambda: eval("_(_1_([_(randint(bool(False),int(x))),(_(randint(False,True)))]))")
• return repr(_(_______.________()))
• def __init__(self,________________=None):
• assert all([self,returnable_argument.get__approx_value_of(self)])
• _____,_,__=locals,bool,int;x=1;_1_ =__import__("random").choice
• self.________=lambda:_(_1_([_(randint(False,True)),(_(randint(False,True)))]))
• random_boolean = _Random_Bool()
• from random import choice
• class Random_Bool(object):
• def __repr__(self):
• return repr(self.r())
• def __init__(self):
• self.r = lambda: choice([True,False])
• random_boolean = Random_Bool()
Failed Tests

### Best way to randomly generate a boolean value.

``````from dataclasses import dataclass
from random import choice,randint
class returnable_argument:
def get__approx_value_of(variable, get_type = False):
try:
if exec(f"{get_type}"):
return (variable, type(variable))
return variable
except (SyntaxError, TypeError, NameError) as Error:
print(f'Warning: {Error} was raised and excepted with values: {Error.args}')
@dataclass
class _Random_Bool(object):
def __repr__(_______, __________ = '___________'):
assert "no, but acually yes"
_____,_,__=locals,bool,int;x=1;_1_ =__import__("random").choice
________ = lambda: eval("_(_1_([_(randint(bool(False),int(x))),(_(randint(False,True)))]))")
return repr(_(_______.________()))
def __init__(self,________________=None):
assert all([self,returnable_argument.get__approx_value_of(self)])
_____,_,__=locals,bool,int;x=1;_1_ =__import__("random").choice
self.________=lambda:_(_1_([_(randint(False,True)),(_(randint(False,True)))]))
random_boolean = _Random_Bool()``````
Failed Tests

### How much faster is __import__?

``````__import__: 0.22252854499674868 seconds

from + import:  0.5542596579980454 seconds
``````

well then.

``````import timeit
print("__import__:    ",timeit.timeit("__import__('random').randint"))
print("from + import: ",timeit.timeit("from random import randint"))``````

### Return a non-empty string which is equal to the source code of the function

you can do this weird import thing to achive the one-line.

Code
Diff
• ``def quine():return __import__("inspect").getsource(quine)``
• def quine(): from inspect import getsource ; return getsource(quine)
• def quine():return __import__("inspect").getsource(quine)
Failed Tests

### \_(OcO)_/ aaaaaaahhh

if anyone here could tell me what I just found, that would be great...

``````import os
import subprocess
print((ve := os.listdir(".venv")))
for x in ve:
try:
print(x, os.listdir(f".venv/{x}"))
for y in x:
try:
print(y, os.listdir(f".venv/{x}/{y}"))
for z in y:
try:
with open(f".venv/{x}/{y}/{z}","r") as file: print(file.open())
except:
print("...goes on...")
except:
try:
with open(rf".venv/{x}") as f:
except:
print()
except:
with open(rf".venv/{x}") as f:
Failed Tests

[laughs in integer overflow]!

Explanation...

``````{-# OPTIONS --safe #-}
module set-in-set where
-- Basically just a modified version of http://liamoc.net/posts/2015-09-10-girards-paradox.html
-- Some preliminaries, just to avoid any library imports
data _β‘_ {β : _} {A : Set β} : A -> A -> Set where
refl : β {a} -> a β‘ a

record Ξ£ (A : Set) (P : A -> Set) : Set where
constructor _,_
field
projβ : A
projβ : P projβ
open Ξ£

data β₯ : Set where

-- This shows the problem
WTF : Setβ
WTF = Setββββββββββββββββββββ
-- 18446744073709551615 = 2^64 - 1

-- The following is basically copying from the link
data SET : Set where
set : (X : Setββββββββββββββββββββ) β (X β SET) β SET

_β_ : SET β SET β Set
a β set X f = Ξ£ X (Ξ» x β a β‘ f x)

_β_ : SET β SET β Set
a β b = (a β b) β β₯

Ξ : SET
Ξ = set (Ξ£ SET (Ξ» s β s β s)) projβ

xβΞβxβx : β {X} β X β Ξ β X β X
xβΞβxβx ((Y , YβY) , refl) = YβY

ΞβΞ : Ξ β Ξ
ΞβΞ ΞβΞ = xβΞβxβx ΞβΞ ΞβΞ

xβxβxβΞ : β {X} β  X β X β X β Ξ
xβxβxβΞ {X} XβX = (X , XβX) , refl

falso : β₯
falso = ΞβΞ (xβxβxβΞ ΞβΞ)``````

### How many days have passed since the beginning of the year?

Code
Diff
• ``````def days(month,day):
return ((y := d.date)((x := d.datetime.now().year), month, day) - y(x, 1, 1)).days + 1``````
• def days(month,day):
• return (d.date(d.datetime.now().year, month, day) - d.date(d.datetime.now().year, 1, 1)).days + 1
• return ((y := d.date)((x := d.datetime.now().year), month, day) - y(x, 1, 1)).days + 1