├── .gitignore ├── .idea ├── checkstyle-idea.xml ├── coding-challenge.iml ├── dbnavigator.xml ├── misc.xml ├── modules.xml ├── qaplug_profiles.xml ├── vcs.xml └── workspace.xml ├── no-1 ├── .gitattributes ├── .gitignore ├── .vscode │ └── settings.json ├── Coding Challenge 1.pdf ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── wc │ │ │ │ ├── Ccwc.java │ │ │ │ ├── Result.java │ │ │ │ └── Wc.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ ├── java │ │ └── CcwcTest.java │ │ └── resources │ │ └── text.txt ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── readme.md ├── settings.gradle └── wc.sh ├── no-11 ├── .gitattributes ├── .gitignore ├── .vscode │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── web │ │ │ │ ├── Listener.java │ │ │ │ ├── Result.java │ │ │ │ ├── Server.java │ │ │ │ └── http │ │ │ │ ├── Http11Handler.java │ │ │ │ ├── HttpMessageUtils.java │ │ │ │ ├── HttpScanner.java │ │ │ │ ├── HttpWebRequest.java │ │ │ │ ├── HttpWebResponse.java │ │ │ │ ├── IHttpHandler.java │ │ │ │ ├── InternalRequest.java │ │ │ │ ├── MediaType.java │ │ │ │ ├── Status.java │ │ │ │ ├── StatusType.java │ │ │ │ └── servlets │ │ │ │ ├── NoServlet.java │ │ │ │ ├── Routes.java │ │ │ │ ├── StaticFileServlet.java │ │ │ │ ├── WebServlet.java │ │ │ │ └── examples │ │ │ │ ├── HelloRest.java │ │ │ │ └── HelloWorldRest.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ ├── java │ │ ├── HttpScannerTest.java │ │ └── InternalRequestTest.java │ │ └── resources │ │ └── tests │ │ ├── hello-post.txt │ │ └── hello.txt ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── parallel.sh ├── run.sh ├── settings.gradle └── www │ ├── demo │ └── index.htm │ ├── index.html │ └── logo-coding-challenges.png ├── no-16 ├── .gitattributes ├── .gitignore ├── .vscode │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── irc │ │ │ │ ├── IIrcMessageProcotol.java │ │ │ │ ├── IIrcSenderProtocol.java │ │ │ │ ├── Irc.java │ │ │ │ ├── IrcClient.java │ │ │ │ ├── Result.java │ │ │ │ ├── handler │ │ │ │ └── IrcProtocolHandler.java │ │ │ │ └── message │ │ │ │ ├── IrcGeneralMessage.java │ │ │ │ ├── IrcMessage.java │ │ │ │ ├── IrcNameReply.java │ │ │ │ ├── IrcPingMessage.java │ │ │ │ └── IrcPrivMessage.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ ├── java │ │ ├── IrcClientTest.java │ │ └── IrcMessagesTest.java │ │ └── resources │ │ └── tests │ │ ├── generalmsg-valid-1.txt │ │ ├── namereply-valid.txt │ │ ├── ping-invalid.txt │ │ ├── ping-valid.txt │ │ ├── privmsg-invalid.txt │ │ └── privmsg-valid.txt ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── irc.sh ├── readme.md └── settings.gradle ├── no-17 ├── .gitattributes ├── .gitignore ├── .vscode │ ├── launch.json │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ ├── listener │ │ │ │ ├── IListenerHandler.java │ │ │ │ ├── Listener.java │ │ │ │ └── StringHandler.java │ │ │ └── memcached │ │ │ │ ├── Mem.java │ │ │ │ ├── Result.java │ │ │ │ ├── client │ │ │ │ ├── MemcachedClient.java │ │ │ │ └── ServerConfiguration.java │ │ │ │ ├── commands │ │ │ │ ├── AddCommand.java │ │ │ │ ├── AppendCommand.java │ │ │ │ ├── CasCommand.java │ │ │ │ ├── Command.java │ │ │ │ ├── CommandLine.java │ │ │ │ ├── Data.java │ │ │ │ ├── DataCommand.java │ │ │ │ ├── DecrCommand.java │ │ │ │ ├── DeleteCommand.java │ │ │ │ ├── GetCommand.java │ │ │ │ ├── IncrCommand.java │ │ │ │ ├── PrependCommand.java │ │ │ │ ├── ReplaceCommand.java │ │ │ │ ├── Response.java │ │ │ │ ├── SetCommand.java │ │ │ │ ├── ValidationCode.java │ │ │ │ └── ValidationException.java │ │ │ │ └── server │ │ │ │ ├── MemcachedServer.java │ │ │ │ ├── cache │ │ │ │ ├── CacheContext.java │ │ │ │ ├── ExpirationPolicies.java │ │ │ │ ├── ExpirationPolicy.java │ │ │ │ ├── ExpireIn.java │ │ │ │ ├── LRUCache.java │ │ │ │ ├── MemCache.java │ │ │ │ └── NoExpiration.java │ │ │ │ └── handler │ │ │ │ └── MemcachedHandler.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ └── java │ │ ├── ClientTest.java │ │ ├── CommandTest.java │ │ ├── MemcachedTest.java │ │ └── ResponseTest.java ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── mac-memcached.sh ├── mem-cli.sh ├── memcached.sh ├── readme-commands.md ├── readme.md └── settings.gradle ├── no-19 ├── .gitattributes ├── .gitignore ├── .vscode │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── bot │ │ │ │ ├── Bot.java │ │ │ │ ├── DiscortBot.java │ │ │ │ ├── Result.java │ │ │ │ └── commands │ │ │ │ ├── BotRequest.java │ │ │ │ ├── BotResponse.java │ │ │ │ ├── ChallengeCmd.java │ │ │ │ ├── Cmd.java │ │ │ │ ├── HelloCmd.java │ │ │ │ ├── PingCmd.java │ │ │ │ └── QuotesCmd.java │ │ └── resources │ │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ │ ├── challenges.json │ │ │ └── quotes.json │ │ └── test │ │ └── java │ │ └── BotTest.java ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images │ └── bot-step1-success.png ├── readme.md ├── run.sh └── settings.gradle ├── no-2 ├── .gitattributes ├── .gitignore ├── .idea │ ├── $PROJECT_FILE$ │ ├── checkstyle-idea.xml │ ├── compiler.xml │ ├── dbnavigator.xml │ ├── gradle.xml │ ├── jarRepositories.xml │ ├── misc.xml │ ├── qaplug_profiles.xml │ ├── vcs.xml │ └── workspace.xml ├── .vscode │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── json │ │ │ │ ├── Json.java │ │ │ │ ├── JsonParser.java │ │ │ │ ├── JsonParserException.java │ │ │ │ ├── JsonSerializeOptions.java │ │ │ │ ├── Lexer.java │ │ │ │ ├── Result.java │ │ │ │ └── model │ │ │ │ ├── JArray.java │ │ │ │ ├── JElement.java │ │ │ │ ├── JMember.java │ │ │ │ ├── JObject.java │ │ │ │ ├── JValue.java │ │ │ │ ├── JValueBoolean.java │ │ │ │ ├── JValueNull.java │ │ │ │ ├── JValueNumber.java │ │ │ │ ├── JValueString.java │ │ │ │ ├── JsonBuilder.java │ │ │ │ └── Serializer.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ ├── java │ │ ├── JsonParserTest.java │ │ ├── JsonTest.java │ │ └── LexerTest.java │ │ └── resources │ │ └── tests │ │ ├── step1 │ │ ├── invalid.json │ │ └── valid.json │ │ ├── step2 │ │ ├── invalid.json │ │ ├── invalid2.json │ │ ├── invalid3.json │ │ ├── invalid4.json │ │ ├── invalid5.json │ │ ├── valid.json │ │ └── valid2.json │ │ ├── step3 │ │ ├── invalid.json │ │ └── valid.json │ │ ├── step4 │ │ ├── invalid.json │ │ ├── valid.json │ │ ├── valid2.json │ │ └── valid3.json │ │ └── step5 │ │ ├── invalid.json │ │ ├── invalid10.json │ │ ├── invalid11.json │ │ ├── invalid12.json │ │ ├── invalid13.json │ │ ├── invalid14.json │ │ ├── invalid15.json │ │ ├── invalid2.json │ │ ├── invalid3.json │ │ ├── invalid4.json │ │ ├── invalid5.json │ │ ├── invalid6.json │ │ ├── invalid7.json │ │ ├── invalid8.json │ │ ├── invalid9.json │ │ ├── valid.json │ │ ├── valid2.json │ │ ├── valid3.json │ │ ├── valid4.json │ │ ├── valid5.json │ │ └── valid6.json ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── json.sh └── settings.gradle ├── no-22 ├── .gitattributes ├── .gitignore ├── .idea │ ├── .gitignore │ ├── checkstyle-idea.xml │ ├── compiler.xml │ ├── dbnavigator.xml │ ├── gradle.xml │ ├── jarRepositories.xml │ ├── misc.xml │ ├── modules.xml │ ├── modules │ │ └── app │ │ │ ├── coding-challenge.no-22.app.main.iml │ │ │ └── no-22.app.main.iml │ ├── uiDesigner.xml │ └── vcs.xml ├── .vscode │ ├── launch.json │ └── settings.json ├── app │ ├── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── src │ │ ├── main │ │ ├── java │ │ │ └── dns │ │ │ │ ├── DnsMessage.java │ │ │ │ ├── DnsQuestion.java │ │ │ │ ├── DnsResolver.java │ │ │ │ ├── DnsResourceRecord.java │ │ │ │ ├── DnsResponseMessage.java │ │ │ │ ├── DnsServer.java │ │ │ │ ├── Flags.java │ │ │ │ ├── HeaderFlags.java │ │ │ │ ├── OctetHelper.java │ │ │ │ ├── OctetReader.java │ │ │ │ ├── OctetWriter.java │ │ │ │ └── Result.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ └── java │ │ ├── DnsMessageTests.java │ │ ├── DnsResolverTest.java │ │ ├── DnsServerTest.java │ │ └── OctetReaderWriterTest.java ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── readme.md ├── run.sh └── settings.gradle ├── no-25 ├── .gitattributes ├── .gitignore ├── .vscode │ ├── launch.json │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── nats │ │ │ │ ├── Nats.java │ │ │ │ ├── NatsCli.java │ │ │ │ ├── NatsServer.java │ │ │ │ ├── Result.java │ │ │ │ ├── listener │ │ │ │ ├── IListenerHandler.java │ │ │ │ ├── Listener.java │ │ │ │ └── StringHandler.java │ │ │ │ ├── protocol │ │ │ │ ├── NatsHandler.java │ │ │ │ ├── NatsLineParser.java │ │ │ │ ├── NatsParser.java │ │ │ │ └── commands │ │ │ │ │ ├── Connect.java │ │ │ │ │ ├── Err.java │ │ │ │ │ ├── ICmd.java │ │ │ │ │ ├── Info.java │ │ │ │ │ ├── Msg.java │ │ │ │ │ ├── Ping.java │ │ │ │ │ ├── Pong.java │ │ │ │ │ ├── Pub.java │ │ │ │ │ └── Sub.java │ │ │ │ └── runtime │ │ │ │ ├── NatsContext.java │ │ │ │ ├── NatsRuntime.java │ │ │ │ ├── Subject.java │ │ │ │ ├── Subscription.java │ │ │ │ ├── Subscriptions.java │ │ │ │ └── Topic.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ └── java │ │ ├── MockRequest.java │ │ ├── NatsCliTest.java │ │ ├── NatsLineParserTests.java │ │ └── SubjectTests.java ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── nats-cli.sh ├── nats-server-mac.sh ├── nats-server.sh └── settings.gradle ├── no-3 ├── .gitattributes ├── .gitignore ├── .idea │ ├── $PROJECT_FILE$ │ ├── checkstyle-idea.xml │ ├── compiler.xml │ ├── dbnavigator.xml │ ├── gradle.xml │ ├── jarRepositories.xml │ ├── misc.xml │ ├── qaplug_profiles.xml │ ├── vcs.xml │ └── workspace.xml ├── .vscode │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── compress │ │ │ │ ├── Compress.java │ │ │ │ ├── Compressor.java │ │ │ │ ├── model │ │ │ │ ├── Encoding.java │ │ │ │ ├── HuffInternalNode.java │ │ │ │ ├── HuffLeafNode.java │ │ │ │ ├── HuffNode.java │ │ │ │ ├── HuffmanCodingTree.java │ │ │ │ └── Traverser.java │ │ │ │ └── printer │ │ │ │ └── BinaryTreePrinter.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ ├── java │ │ ├── CompressTest.java │ │ └── HuffmanCodingTreeTest.java │ │ └── resources │ │ └── tests │ │ ├── aa.txt │ │ ├── little.txt │ │ ├── little.txt+huffman.txt │ │ └── readme.txt ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── no-30 ├── .gitattributes ├── .gitignore ├── .idea │ ├── SltSettings.xml │ ├── checkstyle-idea.xml │ ├── compiler.xml │ ├── dbnavigator.xml │ ├── gradle.xml │ ├── jarRepositories.xml │ ├── misc.xml │ ├── modules.xml │ ├── modules │ │ ├── app │ │ │ ├── no-30.app.main.iml │ │ │ └── no-30.app.test.iml │ │ └── no-30.iml │ ├── qaplug_profiles.xml │ ├── uiDesigner.xml │ ├── vcs.xml │ └── workspace.xml ├── .vscode │ ├── launch.json │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── lisp │ │ │ │ ├── Lisp.java │ │ │ │ ├── LispConsole.java │ │ │ │ ├── Result.java │ │ │ │ └── parser │ │ │ │ ├── BuiltInLibrary.java │ │ │ │ ├── Context.java │ │ │ │ ├── DefunBuiltIn.java │ │ │ │ ├── ILispBuiltInFunction.java │ │ │ │ ├── ILispFunction.java │ │ │ │ ├── LispRuntime.java │ │ │ │ ├── Parser.java │ │ │ │ ├── Tensor.java │ │ │ │ ├── TensorInitializer.java │ │ │ │ ├── Token.java │ │ │ │ ├── TokenValue.java │ │ │ │ └── Tokenizer.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ ├── java │ │ ├── BuiltInTests.java │ │ ├── DefunTests.java │ │ ├── LispTokenizerTests.java │ │ ├── NeuronalNetworkTests.java │ │ ├── TensorTests.java │ │ └── TokenValueApplyTests.java │ │ └── resources │ │ ├── tests.step5 │ │ └── final.step.lisp │ │ └── tests │ │ └── step1 │ │ ├── valid-builtins.txt │ │ ├── valid.atoms.txt │ │ ├── valid.defun.txt │ │ ├── valid.keywords.txt │ │ ├── valid.nn.lisp │ │ ├── valid.s-expressions.txt │ │ ├── valid.strings.txt │ │ ├── valid2.nn.lisp │ │ └── valid3.nn.lisp ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lisp.sh ├── readme.md ├── repl.sh └── settings.gradle ├── no-31 ├── .gitattributes ├── .gitignore ├── .idea │ ├── $PROJECT_FILE$ │ ├── .gitignore │ ├── checkstyle-idea.xml │ ├── compiler.xml │ ├── dbnavigator.xml │ ├── gradle.xml │ ├── jarRepositories.xml │ ├── misc.xml │ ├── modules.xml │ ├── modules │ │ ├── app │ │ │ └── no-31.app.main.iml │ │ └── no-31.iml │ ├── qaplug_profiles.xml │ ├── uiDesigner.xml │ └── vcs.xml ├── .vscode │ └── settings.json ├── Congratulations-Challenge-Complete.png ├── HELLO_WORLD.png ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ ├── com │ │ │ │ └── google │ │ │ │ │ └── zxing │ │ │ │ │ └── common │ │ │ │ │ └── reedsolomon │ │ │ │ │ ├── GenericGF.java │ │ │ │ │ ├── GenericGFPoly.java │ │ │ │ │ ├── ReedSolomonDecoder.java │ │ │ │ │ ├── ReedSolomonEncoder.java │ │ │ │ │ └── ReedSolomonException.java │ │ │ └── qr │ │ │ │ ├── BitAppender.java │ │ │ │ ├── BitConverter.java │ │ │ │ ├── EncodingMode.java │ │ │ │ ├── Mask.java │ │ │ │ ├── Modules.java │ │ │ │ ├── Point2d.java │ │ │ │ ├── Qr.java │ │ │ │ ├── QrCode.java │ │ │ │ ├── Quality.java │ │ │ │ ├── Rect.java │ │ │ │ ├── Region.java │ │ │ │ ├── Result.java │ │ │ │ ├── Version.java │ │ │ │ └── generator │ │ │ │ ├── Block.java │ │ │ │ ├── CanvasBitIterator.java │ │ │ │ ├── Masking.java │ │ │ │ ├── QrCanvas.java │ │ │ │ ├── QrCanvasFactory.java │ │ │ │ ├── QrCodeGenerator.java │ │ │ │ ├── QrImageCanvas.java │ │ │ │ ├── QrImageCanvasFactory.java │ │ │ │ ├── QrTextCanvas.java │ │ │ │ └── QrTextCanvasFactory.java │ │ └── resources │ │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ │ ├── alignment-pattners.txt │ │ │ ├── alphanumeric-map.txt │ │ │ ├── character-capacity.txt │ │ │ ├── error-correction-codewords-blocks.txt │ │ │ ├── mask-format-information.txt │ │ │ └── version-information-string.txt │ │ └── test │ │ ├── java │ │ ├── BitConverterTest.java │ │ ├── QrCodeTest.java │ │ ├── QrModeTest.java │ │ ├── RegionTest.java │ │ └── VersionTest.java │ │ └── resources │ │ └── tests │ │ └── step1 │ │ └── valid.modes.txt ├── awesome-challenge-qr.png ├── debugging.qr.png ├── debugging2.qr.png ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── qr.sh ├── readme.md └── settings.gradle ├── no-34 ├── .gitattributes ├── .gitignore ├── .idea │ ├── $PROJECT_FILE$ │ ├── .gitignore │ ├── checkstyle-idea.xml │ ├── compiler.xml │ ├── dbnavigator.xml │ ├── gradle.xml │ ├── jarRepositories.xml │ ├── misc.xml │ ├── modules.xml │ ├── modules │ │ ├── app │ │ │ ├── no-34.app.main.iml │ │ │ └── no-34.app.test.iml │ │ └── no-34.iml │ ├── qaplug_profiles.xml │ ├── uiDesigner.xml │ └── vcs.xml ├── .vscode │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ ├── jq │ │ │ │ ├── FileInput.java │ │ │ │ ├── Input.java │ │ │ │ ├── Jq.java │ │ │ │ ├── JsonQuery.java │ │ │ │ ├── ReaderInput.java │ │ │ │ ├── Result.java │ │ │ │ ├── SystemIn.java │ │ │ │ └── parser │ │ │ │ │ ├── JsonQueryNode.java │ │ │ │ │ ├── JsonQueryNodeArrayBuilder.java │ │ │ │ │ ├── JsonQueryNodeCurrent.java │ │ │ │ │ ├── JsonQueryNodeIndexed.java │ │ │ │ │ ├── JsonQueryNodeKeyd.java │ │ │ │ │ ├── JsonQueryNodeObjects.java │ │ │ │ │ ├── JsonQueryNodePipe.java │ │ │ │ │ └── JsonQueryParser.java │ │ │ └── json │ │ │ │ ├── Json.java │ │ │ │ ├── JsonParser.java │ │ │ │ ├── JsonParserException.java │ │ │ │ ├── JsonSerializeOptions.java │ │ │ │ ├── Lexer.java │ │ │ │ └── model │ │ │ │ ├── JArray.java │ │ │ │ ├── JElement.java │ │ │ │ ├── JMember.java │ │ │ │ ├── JObject.java │ │ │ │ ├── JValue.java │ │ │ │ ├── JValueBoolean.java │ │ │ │ ├── JValueNull.java │ │ │ │ ├── JValueNumber.java │ │ │ │ ├── JValueString.java │ │ │ │ ├── JsonBuilder.java │ │ │ │ └── Serializer.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ ├── java │ │ ├── IndentTest.java │ │ └── JqTest.java │ │ └── resources │ │ └── tests │ │ ├── github-commits.json │ │ ├── indent-test-array.json │ │ └── indent-test-object.json ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── jq.sh ├── readme.md └── settings.gradle ├── no-4 ├── .gitattributes ├── .gitignore ├── .vscode │ ├── launch.json │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── cut │ │ │ │ ├── Cut.java │ │ │ │ ├── Cutter.java │ │ │ │ ├── CutterException.java │ │ │ │ └── model │ │ │ │ ├── Result.java │ │ │ │ └── Shape.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ ├── java │ │ ├── CutTest.java │ │ └── ResultTest.java │ │ └── resources │ │ └── tests │ │ ├── fourchords.csv │ │ ├── sample.tsv │ │ └── samplenoheader.tsv ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── no-4.sh └── settings.gradle ├── no-5 ├── .gitattributes ├── .gitignore ├── .idea │ ├── $PROJECT_FILE$ │ ├── .gitignore │ ├── checkstyle-idea.xml │ ├── compiler.xml │ ├── dbnavigator.xml │ ├── gradle.xml │ ├── jarRepositories.xml │ ├── misc.xml │ ├── modules.xml │ ├── modules │ │ ├── app │ │ │ └── no-5.app.main.iml │ │ └── no-5.iml │ ├── qaplug_profiles.xml │ └── vcs.xml ├── .vscode │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── lb │ │ │ │ ├── LoadBalancer.java │ │ │ │ ├── Result.java │ │ │ │ ├── SimpleBackend.java │ │ │ │ ├── SimpleLoadBalancer.java │ │ │ │ └── strategies │ │ │ │ ├── LoadBalancerStrategy.java │ │ │ │ └── RoundRobin.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ └── java │ │ └── LoadBalancerTest.java ├── be-servers.sh ├── be.sh ├── chaos.sh ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lb.sh ├── readme.md ├── settings.gradle └── test.sh ├── no-8 ├── .gitattributes ├── .gitignore ├── .vscode │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── redis │ │ │ │ ├── Redis.java │ │ │ │ ├── RedisServer.java │ │ │ │ ├── Result.java │ │ │ │ └── resp │ │ │ │ ├── IResp.java │ │ │ │ ├── IRespBuilder.java │ │ │ │ ├── Resp.java │ │ │ │ ├── RespException.java │ │ │ │ ├── RespInlineCommandScanner.java │ │ │ │ ├── RespPipelineInlineScanner.java │ │ │ │ ├── RespRequest.java │ │ │ │ ├── RespResponse.java │ │ │ │ ├── RespScanner.java │ │ │ │ ├── cache │ │ │ │ ├── CacheMap.java │ │ │ │ ├── ExpirationPolicies.java │ │ │ │ ├── ExpirationPolicy.java │ │ │ │ ├── ExpireAt.java │ │ │ │ ├── ExpireIn.java │ │ │ │ ├── GetPolicy.java │ │ │ │ ├── KeepTtl.java │ │ │ │ ├── LRUCache.java │ │ │ │ ├── NoExpiration.java │ │ │ │ ├── RedisCache.java │ │ │ │ ├── SetIfExists.java │ │ │ │ └── SetIfNotExists.java │ │ │ │ ├── commands │ │ │ │ ├── RespCommand.java │ │ │ │ ├── RespCommandException.java │ │ │ │ ├── RespInlineCommand.java │ │ │ │ └── library │ │ │ │ │ ├── CmdCommand.java │ │ │ │ │ ├── CmdConfig.java │ │ │ │ │ ├── CmdDecr.java │ │ │ │ │ ├── CmdDecrBy.java │ │ │ │ │ ├── CmdDel.java │ │ │ │ │ ├── CmdEcho.java │ │ │ │ │ ├── CmdExists.java │ │ │ │ │ ├── CmdGet.java │ │ │ │ │ ├── CmdHGet.java │ │ │ │ │ ├── CmdHSet.java │ │ │ │ │ ├── CmdHmGet.java │ │ │ │ │ ├── CmdHmSet.java │ │ │ │ │ ├── CmdIncr.java │ │ │ │ │ ├── CmdIncrBy.java │ │ │ │ │ ├── CmdLPush.java │ │ │ │ │ ├── CmdPing.java │ │ │ │ │ ├── CmdRPush.java │ │ │ │ │ ├── CmdSave.java │ │ │ │ │ ├── CmdSet.java │ │ │ │ │ ├── RespCommandLibrary.java │ │ │ │ │ └── RespLibraryFunction.java │ │ │ │ └── types │ │ │ │ ├── CommandOption.java │ │ │ │ ├── RespArray.java │ │ │ │ ├── RespBulkString.java │ │ │ │ ├── RespError.java │ │ │ │ ├── RespInteger.java │ │ │ │ ├── RespNull.java │ │ │ │ ├── RespSimpleString.java │ │ │ │ ├── RespSortedMap.java │ │ │ │ └── RespType.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ ├── java │ │ ├── RedisCacheTests.java │ │ ├── RedisClientTests.java │ │ ├── RedisCmdTests.java │ │ ├── RedisSaveLoadTests.java │ │ ├── RespCommandsTests.java │ │ └── RespTypeTests.java │ │ └── resources │ │ ├── testcommands │ │ └── step1 │ │ │ ├── valid1.txt │ │ │ ├── valid2.txt │ │ │ └── valid3.txt │ │ └── tests │ │ └── step1 │ │ ├── invalid1.txt │ │ ├── invalid2.txt │ │ ├── valid1.txt │ │ ├── valid2.txt │ │ └── valid3.txt ├── generate-examples.sh ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── logs │ └── readme.md ├── redis.sh ├── redis_data.txt └── settings.gradle ├── no-84 ├── .gitattributes ├── .gitignore ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── gradle.xml │ ├── jarRepositories.xml │ ├── misc.xml │ ├── modules │ │ └── app │ │ │ └── no-84.app.main.iml │ ├── uiDesigner.xml │ └── vcs.xml ├── .vscode │ └── settings.json ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── mandelbrot │ │ │ │ ├── Mandel.java │ │ │ │ ├── Mandelbrot.java │ │ │ │ ├── MandelbrotExplorer.java │ │ │ │ ├── Pixel.java │ │ │ │ ├── Result.java │ │ │ │ └── contexts │ │ │ │ ├── MandelbrotAbstractContext.java │ │ │ │ ├── MandelbrotContext.java │ │ │ │ ├── MandelbrotGuiContext.java │ │ │ │ └── MandelbrotTerminalContext.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── MANIFEST.MF │ │ └── test │ │ └── java │ │ └── MandelbrotTest.java ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images │ ├── console-mandelbrot.jpg │ └── mandelbrot-lolo8304-zoomin-explorer.gif ├── mandelbrot.sh └── settings.gradle ├── no-85 ├── .gitattributes ├── .gitignore ├── .vscode │ └── settings.json ├── api-test │ └── Timezone-converter API │ │ ├── CET -- London to 5 cities.bru │ │ ├── CET -- Toronot.bru │ │ ├── CET -- cities-name=Zurich.bru │ │ ├── CET -- timezone counteis.bru │ │ ├── CET -- timezones.bru │ │ ├── bruno.json │ │ └── hello.bru ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── timezone │ │ │ │ ├── Result.java │ │ │ │ ├── SortedList.java │ │ │ │ ├── TimeConverterResponse.java │ │ │ │ ├── TimeResponse.java │ │ │ │ ├── Timezone.java │ │ │ │ ├── TimezoneAbbr.java │ │ │ │ ├── TimezoneAbbrJsonAdapter.java │ │ │ │ ├── TimezoneConverter.java │ │ │ │ ├── TimezoneDatabase.java │ │ │ │ ├── TimezoneOffset.java │ │ │ │ ├── UniqueList.java │ │ │ │ └── api │ │ │ │ ├── TimeZoneRequest.java │ │ │ │ └── TimezoneConverterController.java │ │ └── resources │ │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ │ └── tz │ │ │ └── timezones.csv │ │ └── test │ │ └── java │ │ ├── TimezoneDatabaseTest.java │ │ ├── TimezoneOffsetTest.java │ │ ├── TimezoneTest.java │ │ └── UniqueListTest.java ├── frontend │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── postcss.config.mjs │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ ├── src │ │ ├── .env │ │ ├── App.css │ │ ├── App.test.tsx │ │ ├── App.tsx │ │ ├── components │ │ │ ├── TimeZoneComparison.tsx │ │ │ ├── WorldMapWithTimezones.tsx │ │ │ ├── api-hooks.tsx │ │ │ ├── models.tsx │ │ │ └── timezones.tsx │ │ ├── index.css │ │ ├── index.tsx │ │ ├── logo.svg │ │ ├── react-app-env.d.ts │ │ ├── reportWebVitals.ts │ │ └── setupTests.ts │ └── tsconfig.json ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── readme.md ├── settings.gradle └── timezone.sh ├── no-9 └── readme.md └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | **/bin/** 25 | no-3/app/src/test/resources/tests/135-0.txt 26 | template/** 27 | **/dump*.* 28 | 29 | ## due to env. varable for TOKEN 30 | no-19/.vscode/launch.json 31 | -------------------------------------------------------------------------------- /.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10.12.0 5 | JavaOnly 6 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/coding-challenge.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 15 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /no-1/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-1/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | 7 | 8 | .idea/* -------------------------------------------------------------------------------- /no-1/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic" 3 | } -------------------------------------------------------------------------------- /no-1/Coding Challenge 1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-1/Coding Challenge 1.pdf -------------------------------------------------------------------------------- /no-1/app/src/main/java/wc/Result.java: -------------------------------------------------------------------------------- 1 | package wc; 2 | 3 | public class Result { 4 | 5 | public String fileName; 6 | public int countChars = -1; 7 | public int countLines = -1; 8 | public int countWords = -1; 9 | 10 | @Override 11 | public String toString() { 12 | var builder = new StringBuilder(); 13 | if (countLines >= 0) { 14 | builder.append("\t").append(this.countLines); 15 | } 16 | if (countWords >= 0) { 17 | builder.append("\t").append(this.countWords); 18 | } 19 | if (countChars >= 0) { 20 | builder.append("\t").append(this.countChars); 21 | } 22 | builder.append(" ").append(this.fileName); 23 | return builder.toString(); 24 | } 25 | 26 | 27 | } -------------------------------------------------------------------------------- /no-1/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: wc.Ccwc 2 | -------------------------------------------------------------------------------- /no-1/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-1/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-1' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-1/wc.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app "$@" -------------------------------------------------------------------------------- /no-11/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-11/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /no-11/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-11/app/src/main/java/web/Result.java: -------------------------------------------------------------------------------- 1 | package web; 2 | 3 | public class Result { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /no-11/app/src/main/java/web/http/IHttpHandler.java: -------------------------------------------------------------------------------- 1 | package web.http; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.util.Optional; 5 | 6 | import io.netty.channel.ChannelHandlerContext; 7 | 8 | public interface IHttpHandler { 9 | public Optional validAction(String action); 10 | 11 | public void request(ChannelHandlerContext ctx, ByteBuffer byteBuffer); 12 | 13 | public HttpWebResponse request(HttpWebRequest req); 14 | } 15 | -------------------------------------------------------------------------------- /no-11/app/src/main/java/web/http/StatusType.java: -------------------------------------------------------------------------------- 1 | package web.http; 2 | 3 | /* reused from javax.ws.rs.core */ 4 | public interface StatusType { 5 | public int getStatusCode(); 6 | 7 | public Status.Family getFamily(); 8 | 9 | public String getReasonPhrase(); 10 | } 11 | -------------------------------------------------------------------------------- /no-11/app/src/main/java/web/http/servlets/NoServlet.java: -------------------------------------------------------------------------------- 1 | package web.http.servlets; 2 | 3 | import web.http.HttpWebRequest; 4 | import web.http.HttpWebResponse; 5 | import web.http.Status; 6 | 7 | public class NoServlet implements WebServlet { 8 | 9 | @Override 10 | public HttpWebResponse request(HttpWebRequest req) { 11 | return HttpWebResponse 12 | .status(Status.NOT_FOUND) 13 | .build(req); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /no-11/app/src/main/java/web/http/servlets/WebServlet.java: -------------------------------------------------------------------------------- 1 | package web.http.servlets; 2 | 3 | import web.http.HttpWebRequest; 4 | import web.http.HttpWebResponse; 5 | 6 | public interface WebServlet { 7 | 8 | public HttpWebResponse request(HttpWebRequest req); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /no-11/app/src/main/java/web/http/servlets/examples/HelloRest.java: -------------------------------------------------------------------------------- 1 | package web.http.servlets.examples; 2 | 3 | import web.http.HttpWebRequest; 4 | import web.http.HttpWebResponse; 5 | import web.http.MediaType; 6 | import web.http.servlets.WebServlet; 7 | 8 | public class HelloRest implements WebServlet { 9 | 10 | @Override 11 | public HttpWebResponse request(HttpWebRequest req) { 12 | return HttpWebResponse 13 | .ok("{ \"hello\": \"hello\" }", MediaType.APPLICATION_JSON_TYPE) 14 | .build(req); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /no-11/app/src/main/java/web/http/servlets/examples/HelloWorldRest.java: -------------------------------------------------------------------------------- 1 | package web.http.servlets.examples; 2 | 3 | import web.http.HttpWebRequest; 4 | import web.http.HttpWebResponse; 5 | import web.http.MediaType; 6 | import web.http.servlets.WebServlet; 7 | 8 | public class HelloWorldRest implements WebServlet { 9 | 10 | @Override 11 | public HttpWebResponse request(HttpWebRequest req) { 12 | return HttpWebResponse 13 | .ok("{ \"hello\": \"world\" }", MediaType.APPLICATION_JSON_TYPE) 14 | .build(req); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /no-11/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: web.Server -------------------------------------------------------------------------------- /no-11/app/src/test/resources/tests/hello-post.txt: -------------------------------------------------------------------------------- 1 | POST /hello HTTP/1.1\r\n 2 | Host: localhost:8080\r\n 3 | User-Agent: curl/7.87.0\r\n 4 | Content-Length: 38\r\n 5 | Accept: */*\r\n 6 | \r\n 7 | this is a body text -------------------------------------------------------------------------------- /no-11/app/src/test/resources/tests/hello.txt: -------------------------------------------------------------------------------- 1 | GET /hello HTTP/1.1\r\n 2 | Host: localhost:8080\r\n 3 | User-Agent: curl/7.87.0\r\n 4 | Accept: */*\r\n 5 | \r\n 6 | -------------------------------------------------------------------------------- /no-11/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-11/parallel.sh: -------------------------------------------------------------------------------- 1 | curl -XGET http://localhost:8080/index.html & 2 | curl -XGET http://localhost:8080/index.html & 3 | curl -XGET http://localhost:8080/index.html & 4 | curl -XGET http://localhost:8080/index.html & 5 | curl -XGET http://localhost:8080/index.html & 6 | curl -XGET http://localhost:8080/index.html & 7 | curl -XGET http://localhost:8080/index.html & 8 | curl -XGET http://localhost:8080/index.html & 9 | curl -XGET http://localhost:8080/index.html & 10 | 11 | -------------------------------------------------------------------------------- /no-11/run.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app 2 | 3 | -------------------------------------------------------------------------------- /no-11/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-11' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-11/www/demo/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | index.htm file 6 | 7 | 8 | 9 |

this is a index.htm file

10 | 11 | 12 | -------------------------------------------------------------------------------- /no-11/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Simple Web Page 6 | 7 | 8 | 9 |

Test Web Page

10 |

My web server served this page!

11 | coding challenge logo 12 |

based on the challenge 13 |

14 | 15 | 16 | -------------------------------------------------------------------------------- /no-11/www/logo-coding-challenges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-11/www/logo-coding-challenges.png -------------------------------------------------------------------------------- /no-16/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-16/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /no-16/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-16/app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This generated file contains a sample Java application project to get you started. 5 | * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle 6 | * User Manual available at https://docs.gradle.org/7.3/userguide/building_java_projects.html 7 | */ 8 | apply plugin: "application" 9 | 10 | mainClassName = "irc.Irc" 11 | 12 | repositories { 13 | // Use Maven Central for resolving dependencies. 14 | mavenCentral() 15 | } 16 | 17 | dependencies { 18 | 19 | implementation 'info.picocli:picocli:4.7.1' 20 | annotationProcessor 'info.picocli:picocli-codegen:4.7.1' 21 | 22 | // Use JUnit Jupiter for testing. 23 | testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2' 24 | 25 | // This dependency is used by the application. 26 | } 27 | 28 | tasks.named('test') { 29 | // Use JUnit Platform for unit tests. 30 | useJUnitPlatform() 31 | } 32 | 33 | 34 | compileJava { 35 | options.compilerArgs += ["-Aproject=${project.group}/${project.name}"] 36 | } -------------------------------------------------------------------------------- /no-16/app/src/main/java/irc/IIrcMessageProcotol.java: -------------------------------------------------------------------------------- 1 | package irc; 2 | 3 | import java.io.IOException; 4 | import java.util.Optional; 5 | 6 | import irc.message.IrcMessage; 7 | 8 | public interface IIrcMessageProcotol { 9 | 10 | public IIrcSenderProtocol getMessageSender(); 11 | 12 | public void receiveRawMessage(String message) throws IOException; 13 | 14 | public Optional parseMessage(String message) throws IOException; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /no-16/app/src/main/java/irc/IIrcSenderProtocol.java: -------------------------------------------------------------------------------- 1 | package irc; 2 | 3 | import java.io.IOException; 4 | 5 | public interface IIrcSenderProtocol { 6 | 7 | void setNickName(String nickName) throws IOException; 8 | 9 | void joinChannel(String channel) throws IOException; 10 | 11 | void sendRawMessage(String message) throws IOException; 12 | 13 | void printMessage(String message) throws IOException; 14 | 15 | } -------------------------------------------------------------------------------- /no-16/app/src/main/java/irc/Result.java: -------------------------------------------------------------------------------- 1 | package irc; 2 | 3 | public class Result { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /no-16/app/src/main/java/irc/message/IrcMessage.java: -------------------------------------------------------------------------------- 1 | package irc.message; 2 | 3 | import java.io.IOException; 4 | 5 | import irc.IIrcSenderProtocol; 6 | 7 | public interface IrcMessage { 8 | 9 | public void handle(IIrcSenderProtocol sender) throws IOException; 10 | } -------------------------------------------------------------------------------- /no-16/app/src/main/java/irc/message/IrcPingMessage.java: -------------------------------------------------------------------------------- 1 | package irc.message; 2 | 3 | import java.io.IOException; 4 | import java.util.Optional; 5 | import java.util.regex.Matcher; 6 | import java.util.regex.Pattern; 7 | 8 | import irc.IIrcSenderProtocol; 9 | 10 | public class IrcPingMessage implements IrcMessage { 11 | 12 | private static final Pattern PING_PATTERN = Pattern.compile("^PING :([^: ]+)$"); 13 | 14 | public static Optional parsePing(String message) { 15 | Matcher matcher = PING_PATTERN.matcher(message); 16 | if (matcher.matches()) { 17 | return Optional.of(new IrcPingMessage(matcher.group(1))); 18 | } 19 | return Optional.empty(); 20 | } 21 | 22 | private String token; 23 | 24 | public IrcPingMessage(String token) { 25 | this.token = token; 26 | } 27 | 28 | @Override 29 | public void handle(IIrcSenderProtocol sender) throws IOException { 30 | sender.sendRawMessage("PONG " + this.token); 31 | } 32 | } -------------------------------------------------------------------------------- /no-16/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: Irc -------------------------------------------------------------------------------- /no-16/app/src/test/java/IrcClientTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | 5 | import java.io.File; 6 | import java.io.FileNotFoundException; 7 | import java.io.FileReader; 8 | import java.io.IOException; 9 | import java.io.Reader; 10 | import java.net.URISyntaxException; 11 | import java.net.URL; 12 | import java.nio.file.Paths; 13 | 14 | import org.junit.jupiter.api.AfterEach; 15 | import org.junit.jupiter.api.Test; 16 | 17 | class IrcClientTest { 18 | 19 | private Reader reader; 20 | 21 | void ReadReader(String testfile) throws FileNotFoundException, URISyntaxException { 22 | URL resource = IrcClientTest.class.getResource("tests/" + testfile); 23 | File file = Paths.get(resource.toURI()).toFile(); 24 | reader = new FileReader(file); 25 | } 26 | 27 | @AfterEach 28 | void CloseReader() throws IOException { 29 | if (reader != null) { 30 | reader.close(); 31 | } 32 | } 33 | 34 | @Test 35 | void test() throws URISyntaxException, IOException { 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /no-16/app/src/test/resources/tests/namereply-valid.txt: -------------------------------------------------------------------------------- 1 | :*.freenode.net 353 CCIRC = #cc :@CCIRC 2 | -------------------------------------------------------------------------------- /no-16/app/src/test/resources/tests/ping-invalid.txt: -------------------------------------------------------------------------------- 1 | PING :23 23 23 23 23 23 2 | PING :0987654321 asdf asdf asdf 3 | PING : 4 | PING : asdfasdf asdf asdf asd f 5 | PING : 123123123 6 | -------------------------------------------------------------------------------- /no-16/app/src/test/resources/tests/ping-valid.txt: -------------------------------------------------------------------------------- 1 | PING :1234567890 2 | PING :0987654321 3 | PING :abcdefghij 4 | PING :9876543210 5 | PING :qwertyuiop 6 | PING :wer_234_23 7 | PING :wer-w234-23 8 | -------------------------------------------------------------------------------- /no-16/app/src/test/resources/tests/privmsg-invalid.txt: -------------------------------------------------------------------------------- 1 | :irc.example.com 200 nickname :Welcome to the IRC server! 2 | :irc.example.com 302 nickname :You have been invited to join #channel. 3 | :irc.example.com 401 nickname target :No such nick/channel. 4 | :irc.example.com 404 nickname #channel :Cannot send to channel. 5 | :irc.example.com 421 nickname :Unknown command. 6 | :irc.example.com 433 nickname :Nickname is already in use. 7 | :irc.example.com 482 :You're not channel operator. 8 | :irc.example.com 491 :No O-lines for your host. 9 | :irc.example.com 501 :Unknown MODE flag. 10 | :irc.example.com 709 :SSL connection failed. 11 | :irc.example.com 718 :SASL account disabled. 12 | :irc.example.com 721 :SASL account in use. 13 | :irc.example.com PRIVMSG user Welcome to the channel! 14 | :irc.example.com PRIVMSG #channel message 15 | -------------------------------------------------------------------------------- /no-16/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-16/irc.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app $@ -------------------------------------------------------------------------------- /no-16/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-16' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-17/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-17/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /no-17/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic", 4 | "java.debug.settings.onBuildFailureProceed": true 5 | } -------------------------------------------------------------------------------- /no-17/app/src/main/java/listener/IListenerHandler.java: -------------------------------------------------------------------------------- 1 | package listener; 2 | 3 | import java.io.IOException; 4 | import java.nio.channels.SocketChannel; 5 | 6 | public interface IListenerHandler { 7 | public void request(SocketChannel clientSocketChannel) throws IOException; 8 | 9 | public StringBuilder registerBuffer(SocketChannel key); 10 | 11 | public void deregisterBuffer(SocketChannel key); 12 | 13 | public StringBuilder getBuffer(SocketChannel key); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /no-17/app/src/main/java/memcached/Result.java: -------------------------------------------------------------------------------- 1 | package memcached; 2 | 3 | public class Result { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /no-17/app/src/main/java/memcached/commands/CommandLine.java: -------------------------------------------------------------------------------- 1 | package memcached.commands; 2 | 3 | import java.util.Arrays; 4 | 5 | public class CommandLine { 6 | public final String line; 7 | 8 | public CommandLine(String[] tokens) { 9 | this(String.join(" ", tokens)); 10 | } 11 | 12 | public CommandLine(String line) { 13 | this.line = line; 14 | 15 | } 16 | 17 | public String[] getTokens() { 18 | return Arrays.asList(this.line.split(" ")).stream().filter((x) -> !x.isBlank()).toArray(String[]::new); 19 | } 20 | 21 | public Command asCommand() { 22 | return new Command(this, this.getTokens()); 23 | } 24 | 25 | public Command asDataCommand() { 26 | return new DataCommand(this, this.getTokens()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /no-17/app/src/main/java/memcached/commands/Data.java: -------------------------------------------------------------------------------- 1 | package memcached.commands; 2 | 3 | public class Data { 4 | public String data; 5 | 6 | public Data(String data) { 7 | this.data = data; 8 | } 9 | 10 | public void append(String appendData) { 11 | this.data = data + appendData; 12 | } 13 | 14 | public void prepend(String prependData) { 15 | this.data = prependData + data; 16 | } 17 | 18 | public int length() { 19 | return this.data.length(); 20 | } 21 | 22 | public void incr(String incrData) { 23 | var newValue = String.valueOf(Integer.parseInt(this.data) + Integer.parseInt(incrData)); 24 | this.data = newValue; 25 | } 26 | 27 | public void decr(String decrData) { 28 | var newValue = String.valueOf(Integer.parseInt(this.data) - Integer.parseInt(decrData)); 29 | this.data = newValue; 30 | } 31 | 32 | public int dataInt() { 33 | return Integer.parseInt(this.data); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /no-17/app/src/main/java/memcached/commands/Response.java: -------------------------------------------------------------------------------- 1 | package memcached.commands; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Response { 7 | public final List cmds; 8 | public String finalNote; 9 | 10 | public Response() { 11 | this.cmds = new ArrayList<>(); 12 | } 13 | 14 | public Response(String finalNote) { 15 | this.cmds = new ArrayList<>(); 16 | this.finalNote = finalNote; 17 | } 18 | 19 | public Response addValue(DataCommand cmd) { 20 | this.cmds.add(cmd); 21 | return this; 22 | } 23 | 24 | public String toResponseString() { 25 | var buffer = new StringBuilder(); 26 | for (DataCommand cmd : this.cmds) { 27 | buffer.append(cmd.toResponseString()); 28 | } 29 | buffer.append(this.finalNote + "\r\n"); 30 | return buffer.toString(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /no-17/app/src/main/java/memcached/commands/ValidationCode.java: -------------------------------------------------------------------------------- 1 | package memcached.commands; 2 | 3 | public enum ValidationCode { 4 | OK("OK"), 5 | STORED("STORED"), 6 | DELETED("DELETED"), 7 | ERROR("ERROR"), 8 | EXISTS("EXISTS"), 9 | NOT_FOUND("NOT_FOUND"), 10 | NOT_STORED("NOT_STORED"), 11 | CLIENT_ERROR_CANNOT_INCREMENT_OR_DECREMENT_NON_NUMERIC_VALUE( 12 | "CLIENT_ERROR cannot increment or decrement non-numeric value"); 13 | 14 | private String value; 15 | 16 | private ValidationCode(String value) { 17 | this.value = value; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return this.value; 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /no-17/app/src/main/java/memcached/commands/ValidationException.java: -------------------------------------------------------------------------------- 1 | package memcached.commands; 2 | 3 | public class ValidationException extends Exception { 4 | 5 | public ValidationException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /no-17/app/src/main/java/memcached/server/MemcachedServer.java: -------------------------------------------------------------------------------- 1 | package memcached.server; 2 | 3 | import listener.Listener; 4 | import memcached.server.handler.MemcachedHandler; 5 | 6 | public class MemcachedServer { 7 | private String serverName; 8 | private int port; 9 | private Listener listener; 10 | 11 | public MemcachedServer(String serverName, int port) throws InterruptedException { 12 | this.serverName = serverName; 13 | this.port = port; 14 | var handler = new MemcachedHandler(); 15 | this.listener = new Listener(this.port, handler); 16 | } 17 | 18 | public String getServerId() { 19 | return String.format("%s-%d", this.serverName, this.port); 20 | } 21 | 22 | public void start() { 23 | this.listener.start(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /no-17/app/src/main/java/memcached/server/cache/ExpirationPolicies.java: -------------------------------------------------------------------------------- 1 | package memcached.server.cache; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class ExpirationPolicies extends ExpirationPolicy { 7 | 8 | private List expirationPolicies; 9 | 10 | public ExpirationPolicies(ExpirationPolicy expirationPolicy) { 11 | this.expirationPolicies = new ArrayList<>(); 12 | this.add(expirationPolicy); 13 | } 14 | 15 | @Override 16 | public boolean tryApplyToCacheContext(CacheContext context) { 17 | var result = true; 18 | for (ExpirationPolicy expirationPolicy : expirationPolicies) { 19 | // false is stronger, and must call all in the pipeline 20 | result = expirationPolicy.tryApplyToCacheContext(context) && result; 21 | } 22 | return result; 23 | } 24 | 25 | public ExpirationPolicy add(ExpirationPolicy nextExpirationPolicy) { 26 | this.expirationPolicies.add(nextExpirationPolicy); 27 | return this; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /no-17/app/src/main/java/memcached/server/cache/ExpirationPolicy.java: -------------------------------------------------------------------------------- 1 | package memcached.server.cache; 2 | 3 | public abstract class ExpirationPolicy { 4 | 5 | public static final NoExpiration NONE = new NoExpiration(); 6 | 7 | public abstract boolean tryApplyToCacheContext(CacheContext context); 8 | 9 | public ExpirationPolicy add(ExpirationPolicy nextExpirationPolicy) { 10 | var newPolicies = new ExpirationPolicies(this); 11 | newPolicies.add(nextExpirationPolicy); 12 | return newPolicies; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /no-17/app/src/main/java/memcached/server/cache/ExpireIn.java: -------------------------------------------------------------------------------- 1 | package memcached.server.cache; 2 | 3 | import java.time.Duration; 4 | 5 | public class ExpireIn extends ExpirationPolicy { 6 | 7 | public final Duration duration; 8 | 9 | public static ExpireIn seconds(Integer sec) { 10 | return new ExpireIn(Duration.ofSeconds(sec)); 11 | } 12 | 13 | public ExpireIn(Duration duration) { 14 | this.duration = duration; 15 | } 16 | 17 | @Override 18 | public boolean tryApplyToCacheContext(CacheContext context) { 19 | return (context.isAlive()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /no-17/app/src/main/java/memcached/server/cache/NoExpiration.java: -------------------------------------------------------------------------------- 1 | package memcached.server.cache; 2 | 3 | public class NoExpiration extends ExpirationPolicy { 4 | 5 | @Override 6 | public boolean tryApplyToCacheContext(CacheContext context) { 7 | return true; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /no-17/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: Compress -------------------------------------------------------------------------------- /no-17/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-17/mac-memcached.sh: -------------------------------------------------------------------------------- 1 | /usr/local/opt/memcached/bin/memcached -l localhost -p 11212 -vv -------------------------------------------------------------------------------- /no-17/mem-cli.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app -servers 'localhost:11212' 2 | 3 | -------------------------------------------------------------------------------- /no-17/memcached.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app -s -p 11212 -------------------------------------------------------------------------------- /no-17/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-17' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-19/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-19/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /no-19/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-19/app/src/main/java/bot/DiscortBot.java: -------------------------------------------------------------------------------- 1 | package bot; 2 | 3 | /* 4 | * This Java source file was generated by the Gradle 'init' task. 5 | */ 6 | import java.util.concurrent.Callable; 7 | 8 | import picocli.CommandLine; 9 | import picocli.CommandLine.Command; 10 | import picocli.CommandLine.Option; 11 | 12 | @Command(name = "bot", mixinStandardHelpOptions = true, version = "bot 1.0", description = "This challenge is to build your own discort bot") 13 | public class DiscortBot implements Callable { 14 | 15 | public static void main(String[] args) { 16 | var bot = new DiscortBot(); 17 | var cmd = new CommandLine(bot); 18 | var exitCode = cmd.execute(args); 19 | cmd.getExecutionResult(); 20 | System.exit(exitCode); 21 | } 22 | 23 | @Option(names = "-t", required = true, description = "-t specifies the bot token for the client") 24 | String token; 25 | 26 | @Override 27 | public Result call() throws Exception { 28 | new Bot().start(this.token); 29 | return new Result(); 30 | } 31 | } -------------------------------------------------------------------------------- /no-19/app/src/main/java/bot/Result.java: -------------------------------------------------------------------------------- 1 | package bot; 2 | 3 | public class Result { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /no-19/app/src/main/java/bot/commands/BotResponse.java: -------------------------------------------------------------------------------- 1 | package bot.commands; 2 | 3 | import discord4j.core.object.entity.Message; 4 | import discord4j.core.object.entity.channel.MessageChannel; 5 | 6 | public class BotResponse { 7 | 8 | private Message message; 9 | 10 | public BotResponse(Message message) { 11 | this.message = message; 12 | 13 | } 14 | 15 | public void sendTextMessage(String content) { 16 | MessageChannel channel = message.getChannel().block(); 17 | if (channel != null) { 18 | channel.createMessage(content).block(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /no-19/app/src/main/java/bot/commands/Cmd.java: -------------------------------------------------------------------------------- 1 | package bot.commands; 2 | 3 | import discord4j.core.object.entity.Message; 4 | 5 | public interface Cmd { 6 | 7 | String commandPrefix(); 8 | 9 | void onMessage(BotRequest request, BotResponse response); 10 | 11 | } -------------------------------------------------------------------------------- /no-19/app/src/main/java/bot/commands/HelloCmd.java: -------------------------------------------------------------------------------- 1 | package bot.commands; 2 | 3 | import discord4j.core.object.entity.Message; 4 | 5 | public class HelloCmd implements Cmd { 6 | 7 | @Override 8 | public String commandPrefix() { 9 | return "!hello"; 10 | } 11 | 12 | @Override 13 | public void onMessage(BotRequest request, BotResponse response) { 14 | response.sendTextMessage("Hello, world!"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /no-19/app/src/main/java/bot/commands/PingCmd.java: -------------------------------------------------------------------------------- 1 | package bot.commands; 2 | 3 | import discord4j.core.object.entity.Message; 4 | 5 | public class PingCmd implements Cmd { 6 | 7 | @Override 8 | public String commandPrefix() { 9 | return "!ping"; 10 | } 11 | 12 | @Override 13 | public void onMessage(BotRequest request, BotResponse response) { 14 | response.sendTextMessage("Pong!"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /no-19/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: DiscortBot -------------------------------------------------------------------------------- /no-19/app/src/test/java/BotTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | 5 | import java.io.File; 6 | import java.io.FileNotFoundException; 7 | import java.io.FileReader; 8 | import java.io.IOException; 9 | import java.io.Reader; 10 | import java.net.URISyntaxException; 11 | import java.net.URL; 12 | import java.nio.file.Paths; 13 | 14 | import org.junit.jupiter.api.AfterEach; 15 | import org.junit.jupiter.api.Test; 16 | 17 | class BotTest { 18 | 19 | private Reader reader; 20 | 21 | void ReadReader(String testfile) throws FileNotFoundException, URISyntaxException { 22 | URL resource = BotTest.class.getResource("tests/" + testfile); 23 | File file = Paths.get(resource.toURI()).toFile(); 24 | reader = new FileReader(file); 25 | } 26 | 27 | @AfterEach 28 | void CloseReader() throws IOException { 29 | if (reader != null) { 30 | reader.close(); 31 | } 32 | } 33 | 34 | @Test 35 | void test() throws URISyntaxException, IOException { 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /no-19/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-19/images/bot-step1-success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-19/images/bot-step1-success.png -------------------------------------------------------------------------------- /no-19/run.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app "$@" -------------------------------------------------------------------------------- /no-19/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-19' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-2/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-2/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | 7 | .idea/* 8 | .vscode/* -------------------------------------------------------------------------------- /no-2/.idea/$PROJECT_FILE$: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /no-2/.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8.37 5 | JavaOnly 6 | 14 | 15 | -------------------------------------------------------------------------------- /no-2/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 20 | -------------------------------------------------------------------------------- /no-2/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | -------------------------------------------------------------------------------- /no-2/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /no-2/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /no-2/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /no-2/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-2/app/src/main/java/json/JsonParserException.java: -------------------------------------------------------------------------------- 1 | package json; 2 | public class JsonParserException extends Exception { 3 | 4 | public JsonParserException(String message) { 5 | super(message); 6 | } 7 | public JsonParserException(String message, Throwable cause) { 8 | super(message, cause); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /no-2/app/src/main/java/json/JsonSerializeOptions.java: -------------------------------------------------------------------------------- 1 | package json; 2 | 3 | public class JsonSerializeOptions { 4 | 5 | private final boolean compact; 6 | private final int indent; 7 | private final Character separator; 8 | 9 | public JsonSerializeOptions(boolean compact, int indent, Character separator) { 10 | this.compact = compact; 11 | this.indent = indent; 12 | this.separator = separator; 13 | } 14 | public JsonSerializeOptions() { 15 | this(false, 4, ' '); 16 | } 17 | public JsonSerializeOptions(boolean compact) { 18 | this(compact, 4, ' '); 19 | } 20 | 21 | public boolean isCompact(){return this.compact;} 22 | 23 | public String indentString(int count) { 24 | if (this.isCompact()) { 25 | return ""; 26 | } else { 27 | var builder = new StringBuilder(); 28 | for (int i = 0; i < this.indent * count; i++) { 29 | builder.append(this.separator); 30 | } 31 | return builder.toString(); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /no-2/app/src/main/java/json/Result.java: -------------------------------------------------------------------------------- 1 | package json; 2 | 3 | import json.model.JObject; 4 | import json.model.JsonBuilder; 5 | 6 | public class Result { 7 | private final JObject result; 8 | private final JsonParserException exception; 9 | 10 | public Result(JObject result) { 11 | this.result = result; 12 | this.exception = null; 13 | } 14 | public Result(JsonParserException exception) { 15 | this.result = null; 16 | this.exception = exception; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | if (this.result != null) { 22 | if (Json.verbose1()) { 23 | return result.serialize(new JsonBuilder(new JsonSerializeOptions(false))).toString(); 24 | } else { 25 | return result.serialize(new JsonBuilder(new JsonSerializeOptions(true))).toString(); 26 | } 27 | } else { 28 | return exception.getMessage(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /no-2/app/src/main/java/json/model/JElement.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public abstract class JElement implements Serializer { 4 | @Override 5 | public String toString() { 6 | return this.serialize(new JsonBuilder()).toString(); 7 | } 8 | 9 | public abstract JValue get(int index); 10 | public abstract JValue get(String key); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /no-2/app/src/main/java/json/model/JMember.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public class JMember extends JElement { 4 | 5 | private final String key; 6 | private final JValue value; 7 | 8 | public JMember(String key, JValue value) { 9 | this.key = key; 10 | this.value = value; 11 | } 12 | 13 | public String getKey() { return this.key; } 14 | public JValue getValue() { return this.value; } 15 | 16 | @Override 17 | public JsonBuilder serialize(JsonBuilder builder) { 18 | builder.append("\"").append(this.key).append("\": "); 19 | this.getValue().serialize(builder); 20 | return builder; 21 | } 22 | 23 | @Override 24 | public JValue get(int index) { 25 | return this.get(String.valueOf(index)); 26 | } 27 | 28 | @Override 29 | public JValue get(String key) { 30 | if (this.key.equals(key)) { 31 | return this.getValue(); 32 | } else { 33 | return null; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /no-2/app/src/main/java/json/model/JValueBoolean.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public class JValueBoolean extends JValue { 4 | 5 | public final Boolean bool; 6 | 7 | public JValueBoolean(Boolean bool) { 8 | this.bool = bool; 9 | } 10 | 11 | @Override 12 | public Object value() { 13 | return bool; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /no-2/app/src/main/java/json/model/JValueNull.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public class JValueNull extends JValue { 4 | 5 | public JValueNull() { 6 | } 7 | 8 | @Override 9 | public Object value() { 10 | return null; 11 | } 12 | 13 | @Override 14 | public JsonBuilder serialize(JsonBuilder builder) { 15 | builder.append("null"); 16 | return builder; 17 | } 18 | 19 | @Override 20 | public JValue get(int index) { 21 | return null; 22 | } 23 | 24 | @Override 25 | public JValue get(String key) { 26 | return null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /no-2/app/src/main/java/json/model/JValueNumber.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public class JValueNumber extends JValue { 4 | 5 | public final Number number; 6 | 7 | public JValueNumber(Number number) { 8 | this.number = number; 9 | } 10 | 11 | @Override 12 | public Object value() { 13 | return number; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /no-2/app/src/main/java/json/model/JValueString.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public class JValueString extends JValue { 4 | 5 | public final String string; 6 | 7 | public JValueString(String string) { 8 | this.string = string; 9 | } 10 | 11 | @Override 12 | public Object value() { 13 | return "\""+string+"\""; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /no-2/app/src/main/java/json/model/Serializer.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public interface Serializer { 4 | JsonBuilder serialize(JsonBuilder builder); 5 | } 6 | -------------------------------------------------------------------------------- /no-2/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: Json -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step1/invalid.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-2/app/src/test/resources/tests/step1/invalid.json -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step1/valid.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step2/invalid.json: -------------------------------------------------------------------------------- 1 | {"key": "value",} -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step2/invalid2.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "value\n", 3 | key2: "value" 4 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step2/invalid3.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "value", 3 | "value": "string \ \ does not finishe 4 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step2/invalid4.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "value", 3 | "value": falseNotAConstant asdf 4 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step2/invalid5.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "value", 3 | "value": 234234087234098273409287340293847209384720934872093487234234.0, 4 | "value": 234234087234098273409287340293847209384720934872093487234234, 5 | "value2": 234234234i 6 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step2/valid.json: -------------------------------------------------------------------------------- 1 | {"key": "value"} 2 | -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step2/valid2.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "value", 3 | "key2": "value" 4 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step3/invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "key1": true, 3 | "key2": False, 4 | "key3": null, 5 | "key4": "value", 6 | "key5": 101 7 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step3/valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "key1": true, 3 | "key2": false, 4 | "key3": null, 5 | "key4": "value", 6 | "key5": 101, 7 | "key6": [ "222", "234234", null ] 8 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step4/invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "value", 3 | "key-n": 101, 4 | "key-o": { 5 | "inner key": "inner value" 6 | }, 7 | "key-l": ['list value'] 8 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step4/valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "value", 3 | "key-n": 101, 4 | "key-o": { 5 | "key": "value", 6 | "key2": { 7 | "key": "value" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step4/valid2.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "value", 3 | "key-n": 101, 4 | "key-o": {}, 5 | "key-l": [] 6 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step4/valid3.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "value", 3 | "key-n": 101, 4 | "key-o": { 5 | "inner key": "inner value" 6 | }, 7 | "key-l": ["list value"] 8 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "value1", 3 | "key": "value2" 4 | } 5 | -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid10.json: -------------------------------------------------------------------------------- 1 | { 2 | "illegal_number_5": 123a 3 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid11.json: -------------------------------------------------------------------------------- 1 | { 2 | "illegal_number_6": 1.23.45 3 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid12.json: -------------------------------------------------------------------------------- 1 | { 2 | "illegal_number_7": 1,000 3 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid13.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "illegal_number_8": 1.23e+ 4 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid14.json: -------------------------------------------------------------------------------- 1 | { 2 | "illegal_number_9": 1.23e+5.6 3 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid15.json: -------------------------------------------------------------------------------- 1 | { 2 | "illegal_number_10": 1.23e5.6 3 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid2.json: -------------------------------------------------------------------------------- 1 | { 2 | "array": ["value1","value2","value3"], 3 | "array2": ["value10" "value20" "value30"] 4 | } 5 | -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid3.json: -------------------------------------------------------------------------------- 1 | { 2 | "no": 1e 3 | } 4 | -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid4.json: -------------------------------------------------------------------------------- 1 | { 2 | "no": 0. 3 | } 4 | -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid5.json: -------------------------------------------------------------------------------- 1 | { 2 | "no": 00001 3 | } 4 | -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid6.json: -------------------------------------------------------------------------------- 1 | { 2 | "no": 01.00 3 | } 4 | -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid7.json: -------------------------------------------------------------------------------- 1 | { 2 | "illegal_number_1": NaN 3 | } 4 | -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid8.json: -------------------------------------------------------------------------------- 1 | { 2 | "illegal_number_2": Infinity 3 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/invalid9.json: -------------------------------------------------------------------------------- 1 | { 2 | "illegal_number_4": +123 3 | } -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": "Hello, world!", 3 | "number": 42, 4 | "boolean": true, 5 | "null": null, 6 | "array": ["apple", "banana", "cherry"], 7 | "object": { 8 | "property": "value", 9 | "nested": { 10 | "foo": "bar" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/valid3.json: -------------------------------------------------------------------------------- 1 | { 2 | "integer": 42, 3 | "negative_integer": -123, 4 | "float": 3.14159265359, 5 | "negative_float": -2.71828182846, 6 | "scientific_notation": 1.23e4, 7 | "negative_scientific_notation": -5.67e-8, 8 | "big_integer": 9007199254740992, 9 | "negative_big_integer": -9007199254740992, 10 | "max_integer": 2147483647, 11 | "min_integer": -2147483648, 12 | "max_float": 3.4028235e38, 13 | "min_float": 1.17549435e-38, 14 | "infinity": 111111111111111111111111111111111111111111111111111111111, 15 | "negative_infinity": -111111111111111111111111111111111111111111111111111111111 16 | } 17 | -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/valid4.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": "Hello, world!", 3 | "number": 42.3e-1, 4 | "integer": 1234567890, 5 | "boolean": true, 6 | "null_value": null, 7 | "array": [ 8 | { 9 | "name": "Alice", 10 | "age": 25 11 | }, 12 | { 13 | "name": "Bob", 14 | "age": 30 15 | } 16 | ], 17 | "nested": { 18 | "object": { 19 | "foo": "bar", 20 | "baz": [1, 2, 3] 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /no-2/app/src/test/resources/tests/step5/valid6.json: -------------------------------------------------------------------------------- 1 | { 2 | "largeNumber": 9223372036854775807, 3 | 4 | "byte": 127, 5 | "short": 32767, 6 | "int": 2147483647, 7 | "long": 9223372036854775807, 8 | "float": 3.4028235E38, 9 | "double": 1.7976931348623157E308 10 | } -------------------------------------------------------------------------------- /no-2/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-2/json.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app "$@" 2 | -------------------------------------------------------------------------------- /no-2/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-2' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-22/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-22/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /no-22/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /no-22/.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10.12.0 5 | JavaOnly 6 | 14 | 15 | -------------------------------------------------------------------------------- /no-22/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /no-22/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | -------------------------------------------------------------------------------- /no-22/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /no-22/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /no-22/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-22/.idea/modules/app/coding-challenge.no-22.app.main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-22/.idea/modules/app/no-22.app.main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-22/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /no-22/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "type": "java", 10 | "name": "DnsResolver", 11 | "request": "launch", 12 | "mainClass": "dns.DnsResolver", 13 | "projectName": "app", 14 | "args": "-d www.doris-lorenz.ch" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /no-22/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic", 4 | "java.debug.settings.onBuildFailureProceed": true 5 | } -------------------------------------------------------------------------------- /no-22/app/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-22/app/src/main/java/dns/DnsResponseMessage.java: -------------------------------------------------------------------------------- 1 | package dns; 2 | 3 | public class DnsResponseMessage extends DnsMessage { 4 | private final String responseHexString; 5 | 6 | public DnsResponseMessage(DnsMessage request, String responseHexString) { 7 | super(request); 8 | this.responseHexString = responseHexString; 9 | } 10 | 11 | @SuppressWarnings("unused") 12 | @Override 13 | public OctetWriter write(OctetWriter writer) { 14 | writer.append(this.responseHexString); 15 | return writer; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /no-22/app/src/main/java/dns/Result.java: -------------------------------------------------------------------------------- 1 | package dns; 2 | 3 | 4 | public class Result { 5 | 6 | private final DnsMessage message; 7 | 8 | public Result(DnsMessage message){ 9 | this.message = message; 10 | } 11 | public Result(){ 12 | this.message = null; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return this.message != null ? String.join(",", message.getIpAddresses()) : ""; 18 | } 19 | 20 | public boolean hasMessage() { 21 | return this.message != null; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /no-22/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: dns.DnsResolver 2 | -------------------------------------------------------------------------------- /no-22/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-22/run.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app $@ 2 | -------------------------------------------------------------------------------- /no-22/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-22' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-25/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-25/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /no-25/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "java", 9 | "name": "Nats Server", 10 | "request": "launch", 11 | "mainClass": "nats.Nats", 12 | "projectName": "app", 13 | "args": [ 14 | "-h=localhost", 15 | "-p=4222", 16 | "-s" 17 | ] 18 | }, 19 | { 20 | "type": "java", 21 | "name": "Nats Cli", 22 | "request": "launch", 23 | "mainClass": "nats.Nats", 24 | "projectName": "app", 25 | "args": [ 26 | "-h=localhost", 27 | "-p=4222" 28 | ] 29 | } 30 | ] 31 | } -------------------------------------------------------------------------------- /no-25/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-25/app/src/main/java/nats/NatsServer.java: -------------------------------------------------------------------------------- 1 | package nats; 2 | 3 | import java.util.logging.Level; 4 | import java.util.logging.Logger; 5 | 6 | import nats.listener.Listener; 7 | import nats.protocol.NatsHandler; 8 | 9 | public class NatsServer { 10 | private static final Logger _logger = Logger.getLogger(NatsServer.class.getName()); 11 | public final int port; 12 | private Listener listener; 13 | private NatsHandler handler; 14 | 15 | public NatsServer(int port) throws InterruptedException { 16 | this.port = port; 17 | this.handler = new NatsHandler(this); 18 | this.listener = new Listener(this.port, handler); 19 | } 20 | 21 | public void start() { 22 | if (_logger.isLoggable(Level.INFO)) 23 | _logger.info("Start server on port " + this.port); 24 | this.listener.start(); 25 | } 26 | 27 | public void stop() { 28 | if (_logger.isLoggable(Level.INFO)) 29 | _logger.info("Shutdown server on port " + this.port); 30 | this.listener.stop(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /no-25/app/src/main/java/nats/Result.java: -------------------------------------------------------------------------------- 1 | package nats; 2 | 3 | public class Result { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /no-25/app/src/main/java/nats/listener/IListenerHandler.java: -------------------------------------------------------------------------------- 1 | package nats.listener; 2 | 3 | import java.io.IOException; 4 | import java.nio.channels.SelectionKey; 5 | import java.nio.channels.SocketChannel; 6 | 7 | public interface IListenerHandler { 8 | public void request(SocketChannel clientSocketChannel) throws IOException; 9 | 10 | public StringBuilder registerBuffer(SocketChannel key); 11 | 12 | public void deregisterBuffer(SocketChannel key); 13 | 14 | public StringBuilder getBuffer(SocketChannel key); 15 | 16 | public void acceptConnection(SocketChannel clientSocketChannel, SelectionKey key) throws IOException; 17 | 18 | public void write(SocketChannel clientSocketChannel, String data) throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /no-25/app/src/main/java/nats/protocol/commands/Err.java: -------------------------------------------------------------------------------- 1 | package nats.protocol.commands; 2 | 3 | import java.io.IOException; 4 | import java.util.Optional; 5 | 6 | import nats.protocol.NatsLineParser; 7 | import nats.runtime.NatsContext; 8 | 9 | public class Err implements ICmd { 10 | 11 | private String message; 12 | 13 | public Err() { 14 | } 15 | 16 | public Err(String message) { 17 | this.message = message; 18 | } 19 | 20 | public Err(NatsLineParser line) { 21 | this.message = line.nextToken().get().toString(); 22 | } 23 | 24 | @Override 25 | public Optional print() throws IOException { 26 | return Optional.of(String.format("ERR %s%s", this.message, CRLF)); 27 | } 28 | 29 | @Override 30 | public Optional executeCommand(NatsContext context) throws IOException { 31 | return Optional.empty(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /no-25/app/src/main/java/nats/protocol/commands/ICmd.java: -------------------------------------------------------------------------------- 1 | package nats.protocol.commands; 2 | 3 | import java.io.IOException; 4 | import java.util.Optional; 5 | 6 | import nats.runtime.NatsContext; 7 | 8 | public interface ICmd { 9 | public static final String CRLF = "" + '\r' + '\n'; 10 | 11 | public Optional print() throws IOException; 12 | 13 | public Optional executeCommand(NatsContext context) throws IOException; 14 | } 15 | -------------------------------------------------------------------------------- /no-25/app/src/main/java/nats/protocol/commands/Ping.java: -------------------------------------------------------------------------------- 1 | package nats.protocol.commands; 2 | 3 | import java.io.IOException; 4 | import java.util.Optional; 5 | 6 | import nats.protocol.NatsLineParser; 7 | import nats.runtime.NatsContext; 8 | 9 | public class Ping implements ICmd { 10 | 11 | public Ping() { 12 | } 13 | 14 | public Ping(NatsLineParser line) { 15 | } 16 | 17 | @Override 18 | public Optional print() throws IOException { 19 | return Optional.of("PING" + CRLF); 20 | } 21 | 22 | @Override 23 | public Optional executeCommand(NatsContext context) throws IOException { 24 | return new Pong().print(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /no-25/app/src/main/java/nats/protocol/commands/Pong.java: -------------------------------------------------------------------------------- 1 | package nats.protocol.commands; 2 | 3 | import java.io.IOException; 4 | import java.util.Optional; 5 | 6 | import nats.protocol.NatsLineParser; 7 | import nats.runtime.NatsContext; 8 | 9 | public class Pong implements ICmd { 10 | 11 | public Pong() { 12 | } 13 | 14 | public Pong(NatsLineParser line) { 15 | } 16 | 17 | @Override 18 | public Optional print() throws IOException { 19 | return Optional.of("PONG"); 20 | } 21 | 22 | @Override 23 | public Optional executeCommand(NatsContext context) throws IOException { 24 | return Optional.empty(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /no-25/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: nats.Nats -------------------------------------------------------------------------------- /no-25/app/src/test/java/MockRequest.java: -------------------------------------------------------------------------------- 1 | import java.io.IOException; 2 | 3 | import nats.protocol.NatsHandler; 4 | 5 | public class MockRequest extends NatsHandler.Request { 6 | 7 | private String[] additionalLines; 8 | private int index; 9 | 10 | public MockRequest(String... lines) { 11 | super(null, null); 12 | this.additionalLines = lines; 13 | this.index = 0; 14 | } 15 | 16 | @Override 17 | public int clientId() { 18 | return -42; 19 | } 20 | 21 | @Override 22 | public String readNextLine() throws IOException { 23 | if (this.index < additionalLines.length) { 24 | return this.additionalLines[this.index++]; 25 | } else { 26 | throw new IllegalCallerException("no more data available to read"); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /no-25/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-25/nats-cli.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app -h=localhost -p=4222 $* 2 | 3 | -------------------------------------------------------------------------------- /no-25/nats-server-mac.sh: -------------------------------------------------------------------------------- 1 | nats-server -V -p 4223 -------------------------------------------------------------------------------- /no-25/nats-server.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app -s -p=4222 2 | 3 | -------------------------------------------------------------------------------- /no-25/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-25' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-3/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-3/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | 7 | */.idea/** 8 | no-3/.idea/** 9 | -------------------------------------------------------------------------------- /no-3/.idea/$PROJECT_FILE$: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /no-3/.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8.37 5 | JavaOnly 6 | 14 | 15 | -------------------------------------------------------------------------------- /no-3/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 20 | -------------------------------------------------------------------------------- /no-3/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | -------------------------------------------------------------------------------- /no-3/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /no-3/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /no-3/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /no-3/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-3/app/src/main/java/compress/Compress.java: -------------------------------------------------------------------------------- 1 | package compress; 2 | /* 3 | * This Java source file was generated by the Gradle 'init' task. 4 | */ 5 | import java.io.File; 6 | import java.io.Reader; 7 | 8 | public class Compress { 9 | 10 | public static void main(String[] args) { 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /no-3/app/src/main/java/compress/model/Encoding.java: -------------------------------------------------------------------------------- 1 | package compress.model; 2 | 3 | import java.math.BigInteger; 4 | 5 | public class Encoding { 6 | private BigInteger code; 7 | private int bits; 8 | 9 | public Encoding(BigInteger code, int bits) { 10 | this.code = code; 11 | this.bits = bits; 12 | } 13 | public Encoding(BigInteger code) { 14 | this.code = code; 15 | this.bits = String.valueOf(code).length(); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /no-3/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: Compress -------------------------------------------------------------------------------- /no-3/app/src/test/resources/tests/aa.txt: -------------------------------------------------------------------------------- 1 | aaabbc -------------------------------------------------------------------------------- /no-3/app/src/test/resources/tests/little.txt: -------------------------------------------------------------------------------- 1 | To keep things simple, these examples for building Huffman trees uses a sorted list to keep the partial Huffman trees ordered by frequency. But a real implementation would use a heap to implement a priority queue keyed by the frequencies -------------------------------------------------------------------------------- /no-3/app/src/test/resources/tests/little.txt+huffman.txt: -------------------------------------------------------------------------------- 1 | 10 011011 011010 011010 1100 011001 111 1101 011000 011010 10 011101 111 1101 011010 011010 10 011101 1001 011011 011010 011000 111 1000 011101 011001 10 01000 10 010011 010100 010101 010110 010111 011000 011001 011010 011011 010010 011100 -------------------------------------------------------------------------------- /no-3/app/src/test/resources/tests/readme.txt: -------------------------------------------------------------------------------- 1 | download file from 2 | https://www.gutenberg.org/files/135/135-0.txt 3 | 4 | into this folder -------------------------------------------------------------------------------- /no-3/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-3/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-3' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-30/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-30/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /no-30/.idea/SltSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | -------------------------------------------------------------------------------- /no-30/.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8.37 5 | JavaOnly 6 | 14 | 15 | -------------------------------------------------------------------------------- /no-30/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 20 | -------------------------------------------------------------------------------- /no-30/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | -------------------------------------------------------------------------------- /no-30/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /no-30/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /no-30/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-30/.idea/modules/app/no-30.app.main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-30/.idea/modules/app/no-30.app.test.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /no-30/.idea/modules/no-30.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /no-30/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /no-30/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "java", 9 | "name": "Lisp-cli", 10 | "request": "launch", 11 | "mainClass": "lisp.Lisp", 12 | "projectName": "app", 13 | "args": [ 14 | ] 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /no-30/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-30/app/src/main/java/lisp/Result.java: -------------------------------------------------------------------------------- 1 | package lisp; 2 | 3 | public class Result { 4 | private String result; 5 | 6 | public Result(String result) { 7 | this.result = result; 8 | } 9 | 10 | @Override 11 | public String toString() { 12 | return this.result; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /no-30/app/src/main/java/lisp/parser/ILispBuiltInFunction.java: -------------------------------------------------------------------------------- 1 | package lisp.parser; 2 | 3 | import java.util.List; 4 | 5 | public interface ILispBuiltInFunction { 6 | ILispFunction apply(LispRuntime runtime, ILispFunction expr, String symbol, 7 | List pars); 8 | } -------------------------------------------------------------------------------- /no-30/app/src/main/java/lisp/parser/ILispFunction.java: -------------------------------------------------------------------------------- 1 | package lisp.parser; 2 | 3 | import java.util.List; 4 | 5 | public interface ILispFunction { 6 | ILispFunction apply(LispRuntime runtime); 7 | 8 | Object getObject(); 9 | 10 | Double getDouble(); 11 | Integer getInteger(); 12 | String getValue(); 13 | 14 | Token getToken(); 15 | 16 | ILispFunction get(int... indices); 17 | ILispFunction get(int index); 18 | 19 | ILispFunction set(int[] indices, ILispFunction value); 20 | ILispFunction set(int index, ILispFunction value); 21 | 22 | int[] dimensions(); 23 | 24 | ILispFunction getUnary(); 25 | 26 | List getExpression(); 27 | } 28 | -------------------------------------------------------------------------------- /no-30/app/src/main/java/lisp/parser/TensorInitializer.java: -------------------------------------------------------------------------------- 1 | package lisp.parser; 2 | 3 | public interface TensorInitializer { 4 | public TokenValue get(); 5 | } 6 | -------------------------------------------------------------------------------- /no-30/app/src/main/java/lisp/parser/Token.java: -------------------------------------------------------------------------------- 1 | package lisp.parser; 2 | 3 | public enum Token { 4 | 5 | LPAREN(false), 6 | RPAREN(false), 7 | 8 | S_EXPRESSION(false), 9 | 10 | QUOTE(false), // x=42; print 'x == 'x' and not 42 11 | 12 | SYMBOL(true), // name 13 | KEYWORD(true), // :key 14 | STRING(true), // "___" '___' 15 | PACKAGE(true), // abc::def 16 | 17 | BUILTIN(true), 18 | NUMBER_DOUBLE(true), 19 | NUMBER_INTEGER(true), 20 | 21 | T(true), 22 | NIL(true), 23 | 24 | COMMA(false), // For the comma character (,) 25 | DOT(false), // For the dot character (.) 26 | EOF(false), 27 | DYNAMIC_FUNCTION(true), 28 | FUNCTION_ARGUMENT_NAME(true); 29 | 30 | private final boolean isAtom; 31 | 32 | Token(boolean isAtom) { 33 | this.isAtom = isAtom; 34 | } 35 | 36 | public boolean isAtom() { 37 | return isAtom; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /no-30/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: lisp.Lisp -------------------------------------------------------------------------------- /no-30/app/src/test/resources/tests.step5/final.step.lisp: -------------------------------------------------------------------------------- 1 | (defun hello () (format t "Hello Coding Challenge World~%")) 2 | 3 | (defun doublen (n) 4 | (* n 2)) 5 | 6 | (defun fib (n) 7 | (if (< n 2) 8 | n 9 | (+ (fib (- n 1)) 10 | (fib (- n 2))))) 11 | 12 | (defun fact (n) 13 | (if (<= n 1) 14 | 1 15 | (* n (fact (- n 1))))) 16 | 17 | ;; own built in to define fast and fib as "pure functions" to cash results by arguments 18 | ;; if not then recursive operation of fib and fact are killing CPU and performance 19 | (pure fact fib) 20 | 21 | (hello) 22 | 23 | (format t "The double of 5 is ~D~%" (doublen 5)) 24 | 25 | (format t "Factorial of 5 is ~D~%" (fact 5)) 26 | 27 | (format t "The 7th number of the Fibonacci sequence is ~D~%" (fib 7)) 28 | 29 | (format t "The 42th number of the Fibonacci sequence is ~D~%" (fib 42)) 30 | (format t "The 100th number of the Fibonacci sequence is ~D~%" (fib 100)) 31 | -------------------------------------------------------------------------------- /no-30/app/src/test/resources/tests/step1/valid-builtins.txt: -------------------------------------------------------------------------------- 1 | (+ 2 3) 2 | (* 4 5) 3 | (- 10 3) 4 | (/ 15 3) 5 | (% 10 3) 6 | (= 5 5) 7 | (< 4 7) 8 | (> 8 3) 9 | (not true) 10 | (and true false) 11 | (or true false) 12 | (+ (+ 1 2 3) (* 10 2 3 4 2 5 6)) 13 | (print "Hello" "," "world!" 42) 14 | (format t "Hello Coding Challenge World~%") 15 | (format t "The double of 5 is ~D~%" (* 5 5)) 16 | (if (> 1 2) "TRUE 1 > 2" "FALSE 1 < 2") 17 | (if (> 1 2) "TRUE 1 > 2") 18 | (if (> 2 1) "TRUE 2 > 1") 19 | (> pi 3) 20 | pi 21 | e 22 | (setq a 42) 23 | (print a) 24 | (setq b '(1 2)) 25 | (print b) 26 | (setq bb 2532) 27 | (setq aa pi) (print (* e pi bb)) 28 | (setq xx pi) 29 | (print (* e pi xx)) 30 | (make-array 5 :element-type 'integer :initial-contents '(1 2 3 4 5)) 31 | (make-array '(3 4) :element-type 'float :initial-element 0.0) 32 | (make-array 3 :element-type 'string :initial-contents '("apple" "banana" "cherry")) 33 | (make-array 2 :initial-contents '(1 "two")) -------------------------------------------------------------------------------- /no-30/app/src/test/resources/tests/step1/valid.atoms.txt: -------------------------------------------------------------------------------- 1 | 1 2 | test 3 | atom 4 | 123 5 | 1313.0 6 | 0.0 7 | 0 8 | 1 9 | test 10 | atom 11 | 123 12 | 1313.0 13 | 0.0 14 | 0 15 | hello 16 | world 17 | my-variable 18 | example123 19 | special 20 | + 21 | +add 22 | - 23 | -subs 24 | / 25 | /div 26 | = 27 | =equal 28 | < 29 | 31 | >greaterthan 32 | ! 33 | !exclamation 34 | $ 35 | $dollar 36 | % 37 | %percentage 38 | &ersand 39 | | 40 | |pipe 41 | ? 42 | ?question 43 | ~ 44 | ~tilde 45 | _ 46 | _underscore 47 | :keyword 48 | abc 49 | variable123 50 | my-variable 51 | *special* 52 | /division 53 | 54 | >greater-than 55 | my-variable 56 | symbol-with-a-question? 57 | variable? 58 | ?predicate 59 | -------------------------------------------------------------------------------- /no-30/app/src/test/resources/tests/step1/valid.defun.txt: -------------------------------------------------------------------------------- 1 | (defun greet (name) (format "Hello, ~a!" name)) 2 | (defun multiply (x y) (* x y)) 3 | (multiply 4 5) 4 | (defun doublen (n) (* 2 n)) 5 | (doublen 10) 6 | (defun hello () 7 | (format t "Hello Coding Challenge World~%")) 8 | (hello) 9 | (defun doublen2 (n) 10 | (* n 2)) 11 | (doublen2 100) 12 | (defun fib (n) 13 | (if (< n 2) 14 | n 15 | (+ (fib (- n 1)) 16 | (fib (- n 2))))) 17 | (fib 20) 18 | (defun fact (n) 19 | (if (<= n 1) 20 | 1 21 | (* n (fact (- n 1))))) 22 | (fact 10) -------------------------------------------------------------------------------- /no-30/app/src/test/resources/tests/step1/valid.keywords.txt: -------------------------------------------------------------------------------- 1 | :example-keyword 2 | :name 3 | :color 4 | :size 5 | :input-value 6 | :output 7 | :configuration 8 | :options 9 | :parameter 10 | :version 11 | :debug-mode 12 | :language 13 | :username 14 | :password 15 | :auth-token 16 | :api-key 17 | :source-file 18 | :destination-path 19 | :file-type 20 | :is-active 21 | -------------------------------------------------------------------------------- /no-30/app/src/test/resources/tests/step1/valid.strings.txt: -------------------------------------------------------------------------------- 1 | "asdlfkjhasdf" 2 | "asdfasdfasdfasdf" 3 | "hello \"world\"" 4 | "hello 'world'" 5 | "hello \'world\'" 6 | "hello \'~S~\'" 7 | -------------------------------------------------------------------------------- /no-30/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-30/lisp.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app "$@" 2 | -------------------------------------------------------------------------------- /no-30/repl.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app 2 | -------------------------------------------------------------------------------- /no-30/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-30' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-31/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-31/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | /qr-*.png 7 | -------------------------------------------------------------------------------- /no-31/.idea/$PROJECT_FILE$: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /no-31/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /no-31/.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8.37 5 | JavaOnly 6 | 14 | 15 | -------------------------------------------------------------------------------- /no-31/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 20 | -------------------------------------------------------------------------------- /no-31/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | -------------------------------------------------------------------------------- /no-31/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /no-31/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /no-31/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-31/.idea/modules/app/no-31.app.main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-31/.idea/modules/no-31.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /no-31/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /no-31/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-31/Congratulations-Challenge-Complete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-31/Congratulations-Challenge-Complete.png -------------------------------------------------------------------------------- /no-31/HELLO_WORLD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-31/HELLO_WORLD.png -------------------------------------------------------------------------------- /no-31/app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This generated file contains a sample Java application project to get you started. 5 | * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle 6 | * User Manual available at https://docs.gradle.org/7.3/userguide/building_java_projects.html 7 | */ 8 | apply plugin: "application" 9 | 10 | mainClassName = "qr.Qr" 11 | 12 | repositories { 13 | // Use Maven Central for resolving dependencies. 14 | mavenCentral() 15 | } 16 | 17 | dependencies { 18 | 19 | implementation 'info.picocli:picocli:4.7.1' 20 | implementation 'org.apache.commons:commons-math3:3.6.1' 21 | annotationProcessor 'info.picocli:picocli-codegen:4.7.1' 22 | 23 | // Use JUnit Jupiter for testing. 24 | testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2' 25 | 26 | // This dependency is used by the application. 27 | } 28 | 29 | tasks.named('test') { 30 | useJUnitPlatform() 31 | } 32 | 33 | 34 | compileJava { 35 | options.compilerArgs += ["-Aproject=${project.group}/${project.name}"] 36 | } -------------------------------------------------------------------------------- /no-31/app/src/main/java/qr/BitAppender.java: -------------------------------------------------------------------------------- 1 | package qr; 2 | 3 | public interface BitAppender { 4 | StringBuilder appendBits(StringBuilder builder); 5 | } 6 | -------------------------------------------------------------------------------- /no-31/app/src/main/java/qr/Quality.java: -------------------------------------------------------------------------------- 1 | package qr; 2 | 3 | public enum Quality { 4 | 5 | L, 6 | M, 7 | Q, 8 | H; 9 | 10 | 11 | 12 | Quality() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /no-31/app/src/main/java/qr/Result.java: -------------------------------------------------------------------------------- 1 | package qr; 2 | 3 | public class Result { 4 | 5 | private final String outputFileName; 6 | 7 | public Result(String outputFileName) { 8 | this.outputFileName = outputFileName; 9 | } 10 | 11 | @Override 12 | public String toString() { 13 | return "'" + this.outputFileName + "' file generated"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /no-31/app/src/main/java/qr/generator/QrCanvasFactory.java: -------------------------------------------------------------------------------- 1 | package qr.generator; 2 | 3 | import qr.QrCode; 4 | 5 | public abstract class QrCanvasFactory { 6 | 7 | public static QrCanvasFactory INSTANCE = new QrTextCanvasFactory(); 8 | 9 | public QrCanvasFactory() { 10 | } 11 | 12 | public abstract QrCanvas newCanvasFromQrCode(QrCode qr); 13 | } 14 | -------------------------------------------------------------------------------- /no-31/app/src/main/java/qr/generator/QrImageCanvasFactory.java: -------------------------------------------------------------------------------- 1 | package qr.generator; 2 | 3 | import qr.QrCode; 4 | 5 | public class QrImageCanvasFactory extends QrCanvasFactory { 6 | 7 | private final int squareSize; 8 | 9 | public QrImageCanvasFactory(int squareSize) { 10 | 11 | this.squareSize = squareSize; 12 | } 13 | public QrCanvas newCanvasFromQrCode(QrCode qr) { 14 | return new QrImageCanvas(qr.version().modules().versionSize(), this.squareSize); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /no-31/app/src/main/java/qr/generator/QrTextCanvasFactory.java: -------------------------------------------------------------------------------- 1 | package qr.generator; 2 | 3 | import qr.QrCode; 4 | 5 | public class QrTextCanvasFactory extends QrCanvasFactory { 6 | 7 | public QrTextCanvasFactory() { 8 | 9 | } 10 | public QrCanvas newCanvasFromQrCode(QrCode qr) { 11 | return new QrTextCanvas(qr.version().modules().versionSize()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /no-31/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: qr.Qr 2 | 3 | -------------------------------------------------------------------------------- /no-31/app/src/main/resources/alignment-pattners.txt: -------------------------------------------------------------------------------- 1 | Version Center Module Row and Column 2 | 2 6 18 3 | 3 6 22 4 | 4 6 26 5 | 5 6 30 6 | 6 6 34 7 | 7 6 22 38 8 | 8 6 24 42 9 | 9 6 26 46 10 | 10 6 28 50 11 | 11 6 30 54 12 | 12 6 32 58 13 | 13 6 34 62 14 | 14 6 26 46 66 15 | 15 6 26 48 70 16 | 16 6 26 50 74 17 | 17 6 30 54 78 18 | 18 6 30 56 82 19 | 19 6 30 58 86 20 | 20 6 34 62 90 21 | 21 6 28 50 72 94 22 | 22 6 26 50 74 98 23 | 23 6 30 54 78 102 24 | 24 6 28 54 80 106 25 | 25 6 32 58 84 110 26 | 26 6 30 58 86 114 27 | 27 6 34 62 90 118 28 | 28 6 26 50 74 98 122 29 | 29 6 30 54 78 102 126 30 | 30 6 26 52 78 104 130 31 | 31 6 30 56 82 108 134 32 | 32 6 34 60 86 112 138 33 | 33 6 30 58 86 114 142 34 | 34 6 34 62 90 118 146 35 | 35 6 30 54 78 102 126 150 36 | 36 6 24 50 76 102 128 154 37 | 37 6 28 54 80 106 132 158 38 | 38 6 32 58 84 110 136 162 39 | 39 6 26 54 82 110 138 166 40 | 40 6 30 58 86 114 142 170 -------------------------------------------------------------------------------- /no-31/app/src/main/resources/alphanumeric-map.txt: -------------------------------------------------------------------------------- 1 | 0=0 2 | 1=1 3 | 2=2 4 | 3=3 5 | 4=4 6 | 5=5 7 | 6=6 8 | 7=7 9 | 8=8 10 | 9=9 11 | A=10 12 | B=11 13 | C=12 14 | D=13 15 | E=14 16 | F=15 17 | G=16 18 | H=17 19 | I=18 20 | J=19 21 | K=20 22 | L=21 23 | M=22 24 | N=23 25 | O=24 26 | P=25 27 | Q=26 28 | R=27 29 | S=28 30 | T=29 31 | U=30 32 | V=31 33 | W=32 34 | X=33 35 | Y=34 36 | Z=35 37 | =36 38 | $=37 39 | %=38 40 | *=39 41 | +=40 42 | -=41 43 | .=42 44 | /=43 45 | :=44 46 | -------------------------------------------------------------------------------- /no-31/app/src/main/resources/mask-format-information.txt: -------------------------------------------------------------------------------- 1 | ECC Level Mask Pattern Type Information Bits 2 | L 0 111011111000100 3 | L 1 111001011110011 4 | L 2 111110110101010 5 | L 3 111100010011101 6 | L 4 110011000101111 7 | L 5 110001100011000 8 | L 6 110110001000001 9 | L 7 110100101110110 10 | M 0 101010000010010 11 | M 1 101000100100101 12 | M 2 101111001111100 13 | M 3 101101101001011 14 | M 4 100010111111001 15 | M 5 100000011001110 16 | M 6 100111110010111 17 | M 7 100101010100000 18 | Q 0 011010101011111 19 | Q 1 011000001101000 20 | Q 2 011111100110001 21 | Q 3 011101000000110 22 | Q 4 010010010110100 23 | Q 5 010000110000011 24 | Q 6 010111011011010 25 | Q 7 010101111101101 26 | H 0 001011010001001 27 | H 1 001001110111110 28 | H 2 001110011100111 29 | H 3 001100111010000 30 | H 4 000011101100010 31 | H 5 000001001010101 32 | H 6 000110100001100 33 | H 7 000100000111011 34 | -------------------------------------------------------------------------------- /no-31/app/src/test/resources/tests/step1/valid.modes.txt: -------------------------------------------------------------------------------- 1 | 漢字QRコード=KANJI 2 | 234234243234=NUMERIC 3 | HTTPS://CODINGCHALLENGES.FYI/CHALLENGES/CHALLENGE-QR-GENERATOR=ALPHA_NUMERIC 4 | Lorenz Hänggi=BYTE 5 | 23423423424234漢=KANJI 6 | 234234234 =ALPHA_NUMERIC 7 | https://anywebsite.com?漢=KANJI 8 | -------------------------------------------------------------------------------- /no-31/awesome-challenge-qr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-31/awesome-challenge-qr.png -------------------------------------------------------------------------------- /no-31/debugging.qr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-31/debugging.qr.png -------------------------------------------------------------------------------- /no-31/debugging2.qr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-31/debugging2.qr.png -------------------------------------------------------------------------------- /no-31/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-31/qr.sh: -------------------------------------------------------------------------------- 1 | if [[ $@ == *"-v"* || $@ == *"-h"* ]]; then 2 | ./app/build/install/app/bin/app "$@" 3 | else 4 | filename=$(./app/build/install/app/bin/app "$@" | grep "file generated" | awk -F\' '{ print $2 }') 5 | if [ "${filename}" != "" ]; then 6 | echo "QR code created: ${filename}" 7 | open $filename 8 | fi 9 | fi 10 | 11 | -------------------------------------------------------------------------------- /no-31/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-31' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-34/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-34/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /no-34/.idea/$PROJECT_FILE$: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /no-34/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /no-34/.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8.37 5 | JavaOnly 6 | 14 | 15 | -------------------------------------------------------------------------------- /no-34/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 20 | -------------------------------------------------------------------------------- /no-34/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | -------------------------------------------------------------------------------- /no-34/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /no-34/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /no-34/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-34/.idea/modules/app/no-34.app.main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-34/.idea/modules/app/no-34.app.test.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /no-34/.idea/modules/no-34.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /no-34/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /no-34/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-34/app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This generated file contains a sample Java application project to get you started. 5 | * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle 6 | * User Manual available at https://docs.gradle.org/7.3/userguide/building_java_projects.html 7 | */ 8 | apply plugin: "application" 9 | 10 | mainClassName = "jq.Jq" 11 | 12 | repositories { 13 | // Use Maven Central for resolving dependencies. 14 | mavenCentral() 15 | } 16 | 17 | dependencies { 18 | implementation 'info.picocli:picocli:4.7.1' 19 | annotationProcessor 'info.picocli:picocli-codegen:4.7.1' 20 | 21 | // Use JUnit Jupiter for testing. 22 | testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2' 23 | 24 | // This dependency is used by the application. 25 | } 26 | 27 | tasks.named('test') { 28 | // Use JUnit Platform for unit tests. 29 | useJUnitPlatform() 30 | } 31 | 32 | 33 | compileJava { 34 | options.compilerArgs += ["-Aproject=${project.group}/${project.name}"] 35 | } -------------------------------------------------------------------------------- /no-34/app/src/main/java/jq/FileInput.java: -------------------------------------------------------------------------------- 1 | package jq; 2 | 3 | import java.io.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | public class FileInput implements Input { 8 | 9 | private final File[] files; 10 | private int index; 11 | 12 | public FileInput(File[] files) throws FileNotFoundException { 13 | this.files = files; 14 | this.index = this.files.length > 0 ? 0 : -1; 15 | } 16 | @Override 17 | public boolean hasNext() { 18 | return (this.index >= 0 && this.index < this.files.length); 19 | } 20 | 21 | @Override 22 | public Reader next() { 23 | try { 24 | return new FileReader(this.files[this.index++]); 25 | } catch (FileNotFoundException e) { 26 | throw new RuntimeException(e); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/jq/Input.java: -------------------------------------------------------------------------------- 1 | package jq; 2 | 3 | import java.io.InputStream; 4 | import java.io.Reader; 5 | import java.util.Iterator; 6 | 7 | public interface Input extends Iterator { 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/jq/ReaderInput.java: -------------------------------------------------------------------------------- 1 | package jq; 2 | 3 | import java.io.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | public class ReaderInput implements Input { 8 | 9 | 10 | private Reader reader; 11 | 12 | public ReaderInput(Reader reader) { 13 | this.reader = reader; 14 | } 15 | @Override 16 | public boolean hasNext() { 17 | return this.reader != null; 18 | } 19 | 20 | @Override 21 | public Reader next() { 22 | var r = this.reader; 23 | this.reader = null; 24 | return r; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/jq/Result.java: -------------------------------------------------------------------------------- 1 | package jq; 2 | 3 | public class Result { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/jq/SystemIn.java: -------------------------------------------------------------------------------- 1 | package jq; 2 | 3 | import java.io.InputStream; 4 | import java.io.InputStreamReader; 5 | import java.io.Reader; 6 | 7 | public class SystemIn implements Input { 8 | 9 | private InputStream stream; 10 | 11 | public SystemIn() { 12 | this.stream = System.in; 13 | } 14 | @Override 15 | public boolean hasNext() { 16 | return this.stream != null; 17 | } 18 | 19 | @Override 20 | public Reader next() { 21 | var in = this.stream; 22 | this.stream = null; 23 | return new InputStreamReader(in); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/jq/parser/JsonQueryNodeCurrent.java: -------------------------------------------------------------------------------- 1 | package jq.parser; 2 | 3 | import json.model.JValue; 4 | 5 | import java.util.function.Consumer; 6 | 7 | public class JsonQueryNodeCurrent extends JsonQueryNode{ 8 | public JsonQueryNodeCurrent(JsonQueryParser.TokenValue value) { 9 | super(value); 10 | } 11 | 12 | public JsonQueryNodeCurrent(JsonQueryParser.TokenValue value, JsonQueryNode parent) { 13 | super(value, parent); 14 | } 15 | 16 | @Override 17 | public JValue[] execute(JValue json, Consumer action) { 18 | if (this.nodes.size() == 1) { 19 | return this.child().execute(json, action); 20 | } else { 21 | action.accept(json); 22 | return new JValue[]{json}; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/jq/parser/JsonQueryNodeKeyd.java: -------------------------------------------------------------------------------- 1 | package jq.parser; 2 | 3 | import json.model.JArray; 4 | import json.model.JValue; 5 | 6 | import java.util.function.Consumer; 7 | 8 | public class JsonQueryNodeKeyd extends JsonQueryNode{ 9 | public JsonQueryNodeKeyd(JsonQueryParser.TokenValue value) { 10 | super(value); 11 | } 12 | 13 | public JsonQueryNodeKeyd(JsonQueryParser.TokenValue value, JsonQueryNode parent) { 14 | super(value, parent); 15 | } 16 | 17 | @Override 18 | public JValue[] execute(JValue json, Consumer action) { 19 | if (this.value != null) { 20 | var resultValue = json.get(this.value.value); 21 | if (this.nodes.size() > 0) { 22 | return this.child().execute(resultValue, action); 23 | } else { 24 | action.accept(resultValue); 25 | } 26 | return new JValue[] { resultValue }; 27 | } else { 28 | throw new IllegalArgumentException("Keyd query node must have a value"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/jq/parser/JsonQueryNodePipe.java: -------------------------------------------------------------------------------- 1 | package jq.parser; 2 | 3 | import json.model.JValue; 4 | 5 | import java.util.function.Consumer; 6 | 7 | public class JsonQueryNodePipe extends JsonQueryNode{ 8 | public JsonQueryNodePipe(JsonQueryParser.TokenValue value) { 9 | super(value); 10 | } 11 | 12 | public JsonQueryNodePipe(JsonQueryParser.TokenValue value, JsonQueryNode parent) { 13 | super(value, parent); 14 | } 15 | 16 | @Override 17 | public JValue[] execute(JValue json, Consumer action) { 18 | if (this.nodes.size() > 0) { 19 | return this.child().execute(json, action); 20 | } 21 | return new JValue[] {json}; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/json/Json.java: -------------------------------------------------------------------------------- 1 | package json; 2 | /* 3 | * This Java source file was generated by the Gradle 'init' task. 4 | */ 5 | 6 | public class Json { 7 | 8 | public static void main(String[] args) { 9 | } 10 | } -------------------------------------------------------------------------------- /no-34/app/src/main/java/json/JsonParserException.java: -------------------------------------------------------------------------------- 1 | package json; 2 | public class JsonParserException extends Exception { 3 | 4 | public JsonParserException(String message) { 5 | super(message); 6 | } 7 | public JsonParserException(String message, Throwable cause) { 8 | super(message, cause); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/json/JsonSerializeOptions.java: -------------------------------------------------------------------------------- 1 | package json; 2 | 3 | public class JsonSerializeOptions { 4 | 5 | private final boolean compact; 6 | private final int indent; 7 | private final Character separator; 8 | 9 | public JsonSerializeOptions(boolean compact, int indent, Character separator) { 10 | this.compact = compact; 11 | this.indent = indent; 12 | this.separator = separator; 13 | } 14 | public JsonSerializeOptions() { 15 | this(false, 4, ' '); 16 | } 17 | public JsonSerializeOptions(boolean compact) { 18 | this(compact, 4, ' '); 19 | } 20 | 21 | public boolean isCompact(){return this.compact;} 22 | 23 | public String indentString(int count) { 24 | if (this.isCompact()) { 25 | return ""; 26 | } else { 27 | var builder = new StringBuilder(); 28 | for (int i = 0; i < this.indent * count; i++) { 29 | builder.append(this.separator); 30 | } 31 | return builder.toString(); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/json/model/JElement.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public abstract class JElement implements Serializer { 4 | @Override 5 | public String toString() { 6 | return this.serialize(new JsonBuilder()).toString(); 7 | } 8 | 9 | public abstract JValue get(int index); 10 | public abstract JValue get(String key); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/json/model/JMember.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public class JMember extends JElement { 4 | 5 | private final String key; 6 | private final JValue value; 7 | 8 | public JMember(String key, JValue value) { 9 | this.key = key; 10 | this.value = value; 11 | } 12 | 13 | public String getKey() { return this.key; } 14 | public JValue getValue() { return this.value; } 15 | 16 | @Override 17 | public JsonBuilder serialize(JsonBuilder builder) { 18 | builder.append("\"").append(this.key).append("\": "); 19 | this.getValue().serialize(builder); 20 | return builder; 21 | } 22 | 23 | @Override 24 | public JValue get(int index) { 25 | return this.get(String.valueOf(index)); 26 | } 27 | 28 | @Override 29 | public JValue get(String key) { 30 | if (this.key.equals(key)) { 31 | return this.getValue(); 32 | } else { 33 | return null; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/json/model/JValueBoolean.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public class JValueBoolean extends JValue { 4 | 5 | public final Boolean bool; 6 | 7 | public JValueBoolean(Boolean bool) { 8 | this.bool = bool; 9 | } 10 | 11 | @Override 12 | public Object value() { 13 | return bool; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/json/model/JValueNull.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public class JValueNull extends JValue { 4 | 5 | public JValueNull() { 6 | } 7 | 8 | @Override 9 | public Object value() { 10 | return null; 11 | } 12 | 13 | @Override 14 | public JsonBuilder serialize(JsonBuilder builder) { 15 | builder.append("null"); 16 | return builder; 17 | } 18 | 19 | @Override 20 | public JValue get(int index) { 21 | return null; 22 | } 23 | 24 | @Override 25 | public JValue get(String key) { 26 | return null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/json/model/JValueNumber.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public class JValueNumber extends JValue { 4 | 5 | public final Number number; 6 | 7 | public JValueNumber(Number number) { 8 | this.number = number; 9 | } 10 | 11 | @Override 12 | public Object value() { 13 | return number; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/json/model/JValueString.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public class JValueString extends JValue { 4 | 5 | public final String string; 6 | 7 | public JValueString(String string) { 8 | this.string = string; 9 | } 10 | 11 | @Override 12 | public Object value() { 13 | return "\""+string+"\""; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /no-34/app/src/main/java/json/model/Serializer.java: -------------------------------------------------------------------------------- 1 | package json.model; 2 | 3 | public interface Serializer { 4 | JsonBuilder serialize(JsonBuilder builder); 5 | } 6 | -------------------------------------------------------------------------------- /no-34/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: jq.Jq 2 | -------------------------------------------------------------------------------- /no-34/app/src/test/resources/tests/indent-test-array.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "a1": "aaaa", 4 | "b1": "bbbb", 5 | "c1": { 6 | "due1": "22222", 7 | "two1": 22222 8 | }, 9 | "non-empty": [ 10 | "string", 234234, "another" 11 | ] 12 | }, 13 | { 14 | "a2": "aaaa", 15 | "b2": "bbbb", 16 | "c2": { 17 | "due2": "22222", 18 | "two2": 22222 19 | }, 20 | "empty": [] 21 | } 22 | ] -------------------------------------------------------------------------------- /no-34/app/src/test/resources/tests/indent-test-object.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "aaaa", 3 | "b": "bbbb", 4 | "c": { 5 | "due": "22222", 6 | "two": 22222, 7 | "empty": {} 8 | } 9 | } -------------------------------------------------------------------------------- /no-34/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-34/jq.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app "$@" 2 | 3 | -------------------------------------------------------------------------------- /no-34/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-34' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-4/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-4/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /no-4/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-4/app/src/main/java/cut/CutterException.java: -------------------------------------------------------------------------------- 1 | package cut; 2 | 3 | public class CutterException extends Exception { 4 | 5 | public CutterException(String string) { 6 | super(string); 7 | } 8 | 9 | public CutterException(String message, Throwable cause) { 10 | super(message, cause); 11 | } 12 | } -------------------------------------------------------------------------------- /no-4/app/src/main/java/cut/model/Shape.java: -------------------------------------------------------------------------------- 1 | package cut.model; 2 | 3 | public class Shape { 4 | public final int rows; 5 | public final int cols; 6 | public Shape(int rows, int cols) { 7 | this.rows = rows; 8 | this.cols = cols; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /no-4/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: cut.Cut -------------------------------------------------------------------------------- /no-4/app/src/test/resources/tests/sample.tsv: -------------------------------------------------------------------------------- 1 | f0 f1 f2 f3 f4 2 | 0 1 2 3 4 3 | 5 6 7 8 9 4 | 10 11 12 13 14 5 | 15 16 17 18 19 6 | 20 21 22 23 24 7 | -------------------------------------------------------------------------------- /no-4/app/src/test/resources/tests/samplenoheader.tsv: -------------------------------------------------------------------------------- 1 | 0 1 2 3 4 2 | 5 6 7 8 9 3 | 10 11 12 13 14 4 | 15 16 17 18 19 5 | 20 21 22 23 24 6 | -------------------------------------------------------------------------------- /no-4/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-4/no-4.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app $@ 2 | -------------------------------------------------------------------------------- /no-4/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-4' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-5/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-5/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | !**/gradle-wrapper.jar 7 | -------------------------------------------------------------------------------- /no-5/.idea/$PROJECT_FILE$: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /no-5/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /no-5/.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8.37 5 | JavaOnly 6 | 14 | 15 | -------------------------------------------------------------------------------- /no-5/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 20 | -------------------------------------------------------------------------------- /no-5/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | -------------------------------------------------------------------------------- /no-5/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /no-5/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /no-5/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-5/.idea/modules/app/no-5.app.main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-5/.idea/modules/no-5.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /no-5/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /no-5/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-5/app/src/main/java/lb/Result.java: -------------------------------------------------------------------------------- 1 | package lb; 2 | 3 | public class Result { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /no-5/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: lb.LoadBalancer -------------------------------------------------------------------------------- /no-5/be.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app -b -p=$1 2 | 3 | -------------------------------------------------------------------------------- /no-5/chaos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | scriptpath=`dirname "$0"` 4 | 5 | if [ -z "$1" ]; then 6 | echo "Usage: chaos.sh " 7 | exit 1 8 | fi 9 | 10 | for (( i=0; i<$1; i++ )) 11 | do 12 | allpid=$(ps -ef | grep "no-5/app" | grep -v grep | grep -v "blist" | awk '{ print $2 }' | tr '\n' ' ') 13 | IFS=' ' read -ra str_array <<< "$allpid" 14 | 15 | len=${#str_array[@]} 16 | if [ "0" != "$len" ]; then 17 | 18 | random_index=$(( $RANDOM % ${#str_array[@]} )) 19 | random_element=${str_array[$random_index]} 20 | 21 | echo "kill now $random_element" 22 | kill $random_element 23 | sleep 2 24 | fi 25 | 26 | done 27 | 28 | echo "wait 10s to see test.sh spread across less servers" 29 | sleep 10 30 | echo "start the missing ones again" 31 | 32 | ${scriptpath}/be-servers.sh -nokill 33 | 34 | -------------------------------------------------------------------------------- /no-5/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-5/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /no-5/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-5/lb.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app -p 8080 -blist="http://localhost:9000,http://localhost:9001,http://localhost:9002" | grep "be " 2 | 3 | -------------------------------------------------------------------------------- /no-5/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-5' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-5/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while true; do 4 | 5 | wget -qO- http://localhost:8080/hello & 6 | sleep 0.5 7 | 8 | done 9 | -------------------------------------------------------------------------------- /no-8/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-8/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | dump*.* 7 | -------------------------------------------------------------------------------- /no-8/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/Result.java: -------------------------------------------------------------------------------- 1 | package redis; 2 | 3 | public class Result { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/IResp.java: -------------------------------------------------------------------------------- 1 | package redis.resp; 2 | 3 | import java.util.Optional; 4 | 5 | public interface IResp { 6 | public Optional executeCommand(RespRequest request); 7 | } 8 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/IRespBuilder.java: -------------------------------------------------------------------------------- 1 | package redis.resp; 2 | 3 | import redis.resp.types.RespArray; 4 | import redis.resp.types.RespType; 5 | 6 | public interface IRespBuilder { 7 | public void toRespString(StringBuilder buffer); 8 | 9 | public RespType toRespType(); 10 | 11 | public void loadFrom(RespArray data) throws RespException; 12 | 13 | public static String toRespString(IRespBuilder object) { 14 | var builder = new StringBuilder(); 15 | object.toRespString(builder); 16 | return builder.toString(); 17 | } 18 | 19 | public static String toRespEscapedString(IRespBuilder object) { 20 | return RespScanner.convertNewLinesBack(toRespString(object)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/Resp.java: -------------------------------------------------------------------------------- 1 | package redis.resp; 2 | 3 | import java.util.Optional; 4 | 5 | public class Resp implements IResp { 6 | 7 | public Resp() { 8 | 9 | } 10 | 11 | @Override 12 | public Optional executeCommand(RespRequest request) { 13 | return Optional.empty(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/RespException.java: -------------------------------------------------------------------------------- 1 | package redis.resp; 2 | 3 | public class RespException extends Exception { 4 | 5 | public RespException(String message) { 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/cache/ExpireAt.java: -------------------------------------------------------------------------------- 1 | package redis.resp.cache; 2 | 3 | import java.time.Instant; 4 | 5 | import redis.resp.cache.RedisCache.RedisCacheContext; 6 | import redis.resp.types.RespType; 7 | 8 | public class ExpireAt extends ExpirationPolicy { 9 | 10 | public final Instant timestamp; 11 | 12 | public static ExpireAt seconds(Integer sec) { 13 | return new ExpireAt(Instant.ofEpochSecond(sec)); 14 | } 15 | 16 | public static ExpireAt milliseconds(Long ms) { 17 | return new ExpireAt(Instant.ofEpochMilli(ms)); 18 | } 19 | 20 | public ExpireAt(Instant timestamp) { 21 | this.timestamp = timestamp; 22 | } 23 | 24 | @Override 25 | public boolean tryApplyToCacheContext(RespType value, RedisCacheContext context) { 26 | context.setExpirationTime(this.timestamp); 27 | return context.isAlive(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/cache/ExpireIn.java: -------------------------------------------------------------------------------- 1 | package redis.resp.cache; 2 | 3 | import java.time.Duration; 4 | 5 | import redis.resp.cache.RedisCache.RedisCacheContext; 6 | import redis.resp.types.RespType; 7 | 8 | public class ExpireIn extends ExpirationPolicy { 9 | 10 | public final Duration duration; 11 | 12 | public static ExpireIn seconds(Integer sec) { 13 | return new ExpireIn(Duration.ofSeconds(sec)); 14 | } 15 | 16 | public static ExpireIn milliseconds(Long ms) { 17 | return new ExpireIn(Duration.ofMillis(ms)); 18 | } 19 | 20 | public ExpireIn(Duration duration) { 21 | this.duration = duration; 22 | } 23 | 24 | @Override 25 | public boolean tryApplyToCacheContext(RespType value, RedisCacheContext context) { 26 | context.setTTL(this.duration); 27 | return (context.isAlive()); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/cache/KeepTtl.java: -------------------------------------------------------------------------------- 1 | package redis.resp.cache; 2 | 3 | import redis.resp.cache.RedisCache.RedisCacheContext; 4 | import redis.resp.types.RespType; 5 | 6 | public class KeepTtl extends ExpirationPolicy { 7 | 8 | @Override 9 | public boolean tryApplyToCacheContext(RespType value, RedisCacheContext context) { 10 | context.keepTTL(); 11 | return (context.isAlive()); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/cache/NoExpiration.java: -------------------------------------------------------------------------------- 1 | package redis.resp.cache; 2 | 3 | import redis.resp.cache.RedisCache.RedisCacheContext; 4 | import redis.resp.types.RespType; 5 | 6 | public class NoExpiration extends ExpirationPolicy { 7 | 8 | @Override 9 | public boolean tryApplyToCacheContext(RespType value, RedisCacheContext context) { 10 | return true; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/cache/SetIfExists.java: -------------------------------------------------------------------------------- 1 | package redis.resp.cache; 2 | 3 | import redis.resp.cache.RedisCache.RedisCacheContext; 4 | import redis.resp.types.RespType; 5 | 6 | public class SetIfExists extends ExpirationPolicy { 7 | 8 | @Override 9 | public boolean tryApplyToCacheContext(RespType value, RedisCacheContext context) { 10 | return context.hasValueSet(); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/cache/SetIfNotExists.java: -------------------------------------------------------------------------------- 1 | package redis.resp.cache; 2 | 3 | import redis.resp.cache.RedisCache.RedisCacheContext; 4 | import redis.resp.types.RespType; 5 | 6 | public class SetIfNotExists extends ExpirationPolicy { 7 | 8 | @Override 9 | public boolean tryApplyToCacheContext(RespType value, RedisCacheContext context) { 10 | return context.hasNoValueSet(); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/commands/RespCommand.java: -------------------------------------------------------------------------------- 1 | package redis.resp.commands; 2 | 3 | import java.util.Optional; 4 | 5 | import redis.resp.types.RespArray; 6 | import redis.resp.types.RespType; 7 | 8 | public class RespCommand { 9 | public final RespArray array; 10 | 11 | public RespCommand(RespArray array) { 12 | this.array = array; 13 | } 14 | 15 | public Optional get(int index) { 16 | return array.get(index); 17 | } 18 | 19 | public Optional getValue(int index) { 20 | var value = array.get(index); 21 | if (value.isPresent()) { 22 | return Optional.of((T) value.get().value); 23 | } else { 24 | return Optional.empty(); 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/commands/RespCommandException.java: -------------------------------------------------------------------------------- 1 | package redis.resp.commands; 2 | 3 | public class RespCommandException extends Exception { 4 | 5 | public RespCommandException(String string) { 6 | super(string); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/commands/library/CmdHGet.java: -------------------------------------------------------------------------------- 1 | package redis.resp.commands.library; 2 | 3 | public class CmdHGet extends CmdHmGet { 4 | 5 | public CmdHGet(RespCommandLibrary library) { 6 | super(library); 7 | } 8 | 9 | @Override 10 | public String commandName() { 11 | return "HGET"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/commands/library/CmdHSet.java: -------------------------------------------------------------------------------- 1 | package redis.resp.commands.library; 2 | 3 | public class CmdHSet extends CmdHmSet { 4 | 5 | public CmdHSet(RespCommandLibrary library) { 6 | super(library); 7 | } 8 | 9 | @Override 10 | public String commandName() { 11 | return "HSET"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/types/CommandOption.java: -------------------------------------------------------------------------------- 1 | package redis.resp.types; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | public class CommandOption { 8 | public final String key; 9 | public final Optional value; 10 | public final List values; 11 | 12 | public CommandOption(String key) { 13 | this(key, Optional.empty()); 14 | } 15 | 16 | public CommandOption(String key, Optional value) { 17 | this.key = key; 18 | this.value = value; 19 | if (value.isPresent()) { 20 | this.values = Arrays.asList(value.get()); 21 | } else { 22 | this.values = Arrays.asList(); 23 | } 24 | } 25 | 26 | public CommandOption(String key, List values) { 27 | this.key = key; 28 | this.value = values.size() == 1 ? Optional.of(values.get(0)) : Optional.empty(); 29 | this.values = values; 30 | } 31 | 32 | public boolean isOption(String opt) { 33 | return this.key.equals(opt); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/types/RespError.java: -------------------------------------------------------------------------------- 1 | package redis.resp.types; 2 | 3 | public class RespError extends RespType { 4 | 5 | public RespError(String value) { 6 | super(value); 7 | } 8 | 9 | @Override 10 | public void toRespString(StringBuilder buffer) { 11 | buffer.append('-').append(value).append("\r\n"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/types/RespInteger.java: -------------------------------------------------------------------------------- 1 | package redis.resp.types; 2 | 3 | import redis.resp.RespException; 4 | 5 | public class RespInteger extends RespType { 6 | 7 | public RespInteger(Long value) { 8 | super(value); 9 | } 10 | 11 | public RespInteger(Integer value) { 12 | super((long) value); 13 | } 14 | 15 | @Override 16 | public Long intValue() { 17 | return this.value; 18 | } 19 | 20 | @Override 21 | public void toRespString(StringBuilder buffer) { 22 | buffer.append(':').append(value).append("\r\n"); 23 | } 24 | 25 | @Override 26 | public String stringValue() throws RespException { 27 | return String.valueOf(this.value); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /no-8/app/src/main/java/redis/resp/types/RespNull.java: -------------------------------------------------------------------------------- 1 | package redis.resp.types; 2 | 3 | public class RespNull extends RespBulkString { 4 | public static final RespNull NULL = new RespNull(); 5 | 6 | public RespNull() { 7 | super(-1, ""); 8 | } 9 | 10 | @Override 11 | public boolean isEmpty() { 12 | return true; 13 | } 14 | 15 | @Override 16 | public void toRespString(StringBuilder buffer) { 17 | buffer.append("$-1\r\n"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /no-8/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: redis.Redis -------------------------------------------------------------------------------- /no-8/app/src/test/resources/testcommands/step1/valid1.txt: -------------------------------------------------------------------------------- 1 | PING 2 | 1 3 | *1\r\n$4\r\nPING\r\n 4 | SET key1 value1 5 | 3 6 | 7 | GET key1 8 | 2 9 | 10 | INCR key1 11 | 2 12 | 13 | DECRBY key2 5 14 | 3 15 | 16 | HSET hash1 field1 value1 17 | 4 18 | 19 | HGET hash1 field1 20 | 3 21 | 22 | RPUSH list1 value1 value2 value3 23 | 5 24 | 25 | LPOP list1 26 | 2 27 | 28 | SADD set1 member1 member2 member3 29 | 5 30 | 31 | SMEMBERS set1 32 | 2 33 | 34 | -------------------------------------------------------------------------------- /no-8/app/src/test/resources/testcommands/step1/valid2.txt: -------------------------------------------------------------------------------- 1 | SMEMBERS "qutotes cars" 2 | 2 3 | 4 | SMEMBERS with\ escaped\ spaces with\ escaped\ spaces\ too 5 | 3 6 | 7 | SMEMBERS "qutotes cars" 8 | 2 9 | 10 | SMEMBERS with\ escaped\ spaces with\ escaped\ spaces\ too 11 | 3 12 | 13 | -------------------------------------------------------------------------------- /no-8/app/src/test/resources/testcommands/step1/valid3.txt: -------------------------------------------------------------------------------- 1 | SMEMBERS A1 2 | 2 3 | *2\r\n$8\r\nSMEMBERS\r\n$2\r\nA1\r\n 4 | SMEMBERS 1 5 | 2 6 | *2\r\n$8\r\nSMEMBERS\r\n:1\r\n 7 | SMEMBERS 1 2 8 | 3 9 | *3\r\n$8\r\nSMEMBERS\r\n:1\r\n:2\r\n 10 | SMEMBERS 1 ABC 11 | 3 12 | *3\r\n$8\r\nSMEMBERS\r\n:1\r\n$3\r\nABC\r\n 13 | -------------------------------------------------------------------------------- /no-8/app/src/test/resources/tests/step1/invalid1.txt: -------------------------------------------------------------------------------- 1 | +OK\n 2 | $4\r\nfoo\r\nbar\r\n 3 | :-123\n 4 | *2\r\n$3\r\nfoo\r\n 5 | -------------------------------------------------------------------------------- /no-8/app/src/test/resources/tests/step1/invalid2.txt: -------------------------------------------------------------------------------- 1 | *$5\r\nLPUSH\r\n$5\r\nmykey\r\n 2 | *2\r\n$5\r\nLPUSH\r\n$5\r\nmykey\r\n$5\r\nvalue\r\n$5\r\nextra\r\n 3 | *3\r\n$5\r\nLRANGE\r\n$5\r\nmykey\r\n 4 | *2\r\n$3\r\nSET\r\n$5\r\nmykey\r\n$6\r\nvalue\r\n 5 | *4\r\n$5\r\nLRANGE\r\n$5\r\nmykey\r\n$1\r\n0\r\n$2\r\n-1\r\n 6 | &2\r\n$5\r\nLPUSH\r\n$5\r\nmykey\r\n 7 | *2\r\n$5\r\nLPUSH\r\n$5\r\nmykey\r\n$5\r\nvalue\r\n&extra\r\n 8 | *3\r\n$5\r\nLRANGE\r\n$5\r\nmykey\r\n:one\r\n 9 | *2\r\n$3\r\nSET\r\n$5\r\nmykey\r\n$value\r\n 10 | *4\r\n$5\r\nLRANGE\r\n$5\r\nmykey\r\n$1\r\n0\r\n$2\r\n-1.5\r\n 11 | *5\r\n$5\r\nHMSET\r\n$5\r\nmykey\r\n$3\r\nfoo\r\n$3\r\nbar\r\n$3\r\nbaz\r\n$3\r\nqux\r\n 12 | -------------------------------------------------------------------------------- /no-8/app/src/test/resources/tests/step1/valid1.txt: -------------------------------------------------------------------------------- 1 | +OK\r\n 2 | -------------------------------------------------------------------------------- /no-8/app/src/test/resources/tests/step1/valid2.txt: -------------------------------------------------------------------------------- 1 | +OK\r\n 2 | $5\r\nhello\r\n 3 | :123\r\n 4 | *3\r\n$3\r\nfoo\r\n$3\r\nbar\r\n$3\r\nbaz\r\n 5 | *-1\r\n 6 | $-1\r\n 7 | -ERR unknown command\r\n 8 | $6\r\nfoobar\r\n 9 | :0\r\n 10 | *2\r\n$3\r\nfoo\r\n$3\r\nbar\r\n 11 | *-2\r\n 12 | $0\r\n\r\n 13 | *3\r\n$3\r\nSET\r\n$5\r\nmykey\r\n$7\r\nmyvalue\r\n 14 | *1\r\n$4\r\nPING\r\n 15 | -------------------------------------------------------------------------------- /no-8/app/src/test/resources/tests/step1/valid3.txt: -------------------------------------------------------------------------------- 1 | *6\r\n$5\r\nHMSET\r\n$5\r\nmykey\r\n$3\r\nfoo\r\n$3\r\nbar\r\n$3\r\nbaz\r\n$3\r\nqux\r\n 2 | *4\r\n$6\r\nLRANGE\r\n$5\r\nmykey\r\n$1\r\n0\r\n$1\r\n5\r\n 3 | *2\r\n$5\r\nhello\r\n$5\r\nworld\r\n 4 | *3\r\n:1\r\n:2\r\n:3\r\n -------------------------------------------------------------------------------- /no-8/generate-examples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Number of key-value pairs to generate 4 | num_pairs=2000 5 | 6 | # Output file path 7 | output_file="redis_data.txt" 8 | 9 | # Generate random key-value pairs and write them to the output file 10 | for ((i = 1; i <= num_pairs; i++)); do 11 | # Generate random key and value 12 | random_key=a$(cat /dev/urandom | LC_ALL=C tr -dc '[:print:]' | tr -dc 'a-zA-Z0-9' | head -c 20) 13 | random_value=$(cat /dev/urandom | LC_ALL=C tr -dc '[:print:]' | tr -dc 'a-zA-Z0-9'| head -c 400) 14 | 15 | # Write key-value pair to the output file 16 | echo "echo \"SET $random_key $random_value\" | redis-cli -p 6380" >> "$output_file" 17 | done 18 | 19 | echo "Random data generated and saved to $output_file." 20 | chmod u+x $output_file 21 | -------------------------------------------------------------------------------- /no-8/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /no-8/logs/readme.md: -------------------------------------------------------------------------------- 1 | logs -------------------------------------------------------------------------------- /no-8/redis.sh: -------------------------------------------------------------------------------- 1 | ./app/build/install/app/bin/app -p=6380 2 | 3 | -------------------------------------------------------------------------------- /no-8/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-8' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-84/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-84/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | 7 | .idea/** -------------------------------------------------------------------------------- /no-84/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /no-84/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /no-84/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 17 | 18 | -------------------------------------------------------------------------------- /no-84/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /no-84/.idea/modules/app/no-84.app.main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /no-84/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /no-84/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-84/app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This generated file contains a sample Java application project to get you started. 5 | * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle 6 | * User Manual available at https://docs.gradle.org/7.3/userguide/building_java_projects.html 7 | */ 8 | apply plugin: "application" 9 | 10 | mainClassName = "mandelbrot.Mandelbrot" 11 | 12 | repositories { 13 | // Use Maven Central for resolving dependencies. 14 | mavenCentral() 15 | } 16 | 17 | dependencies { 18 | 19 | implementation 'info.picocli:picocli:4.7.1' 20 | annotationProcessor 'info.picocli:picocli-codegen:4.7.1' 21 | 22 | // Use JUnit Jupiter for testing. 23 | testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2' 24 | 25 | // This dependency is used by the application. 26 | } 27 | 28 | tasks.named('test') { 29 | // Use JUnit Platform for unit tests. 30 | useJUnitPlatform() 31 | } 32 | 33 | 34 | compileJava { 35 | options.compilerArgs += ["-Aproject=${project.group}/${project.name}"] 36 | } -------------------------------------------------------------------------------- /no-84/app/src/main/java/mandelbrot/Pixel.java: -------------------------------------------------------------------------------- 1 | package mandelbrot; 2 | 3 | public class Pixel { 4 | 5 | public double x; 6 | public double y; 7 | public int i; 8 | 9 | public Pixel(double x, double y) { 10 | this(x, y, 0); 11 | } 12 | 13 | public Pixel(double x, double y, int i) { 14 | this.x = x; 15 | this.y = y; 16 | this.i = i; 17 | } 18 | 19 | public Pixel add(Pixel step) { 20 | return new Pixel(this.x + step.x, this.y + step.y); 21 | } 22 | 23 | public void inc(Pixel step) { 24 | this.x += step.x; 25 | this.y += step.y; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /no-84/app/src/main/java/mandelbrot/Result.java: -------------------------------------------------------------------------------- 1 | package mandelbrot; 2 | 3 | public class Result { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /no-84/app/src/main/java/mandelbrot/contexts/MandelbrotAbstractContext.java: -------------------------------------------------------------------------------- 1 | package mandelbrot.contexts; 2 | 3 | import mandelbrot.MandelbrotExplorer; 4 | 5 | public abstract class MandelbrotAbstractContext implements MandelbrotContext { 6 | 7 | private final int width; 8 | private final float max; 9 | private final MandelbrotExplorer explorer; 10 | 11 | public MandelbrotAbstractContext(MandelbrotExplorer explorer, int width, int max) { 12 | this.explorer = explorer; 13 | this.width = width; 14 | this.max = (float) max; 15 | } 16 | 17 | public void draw(int iterations, int x, int y) { 18 | var i = y * this.width + x; 19 | this.draw(iterations, i); 20 | } 21 | 22 | @Override 23 | public int maxIterations() { 24 | return (int)this.max; 25 | } 26 | 27 | @Override 28 | public int width() { 29 | return this.width; 30 | } 31 | 32 | @Override 33 | public MandelbrotExplorer explorer() { 34 | return this.explorer; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /no-84/app/src/main/java/mandelbrot/contexts/MandelbrotContext.java: -------------------------------------------------------------------------------- 1 | package mandelbrot.contexts; 2 | 3 | import mandelbrot.MandelbrotExplorer; 4 | 5 | public interface MandelbrotContext { 6 | void draw(int iterations, int x, int y); 7 | 8 | void draw(int iterations, int index); 9 | 10 | void printContext(long timeInMs); 11 | 12 | int maxIterations(); 13 | 14 | int width(); 15 | 16 | MandelbrotExplorer explorer(); 17 | } 18 | -------------------------------------------------------------------------------- /no-84/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: Compress -------------------------------------------------------------------------------- /no-84/app/src/test/java/MandelbrotTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | 5 | 6 | import org.junit.jupiter.api.AfterEach; 7 | import org.junit.jupiter.api.Test; 8 | 9 | 10 | import java.io.File; 11 | import java.io.FileNotFoundException; 12 | import java.io.FileReader; 13 | import java.io.IOException; 14 | import java.io.Reader; 15 | import java.net.URISyntaxException; 16 | import java.net.URL; 17 | import java.nio.file.Paths; 18 | 19 | class MandelbrotTest { 20 | 21 | private Reader reader; 22 | 23 | void ReadReader(String testfile) throws FileNotFoundException, URISyntaxException { 24 | URL resource = MandelbrotTest.class.getResource("tests/"+testfile); 25 | File file = Paths.get(resource.toURI()).toFile(); 26 | reader = new FileReader(file); 27 | } 28 | 29 | @AfterEach 30 | void CloseReader() throws IOException { 31 | if (reader != null) { 32 | reader.close(); 33 | } 34 | } 35 | 36 | @Test void test() throws URISyntaxException, IOException { 37 | 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /no-84/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Jan 12 15:50:44 CET 2025 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /no-84/images/console-mandelbrot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-84/images/console-mandelbrot.jpg -------------------------------------------------------------------------------- /no-84/images/mandelbrot-lolo8304-zoomin-explorer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-84/images/mandelbrot-lolo8304-zoomin-explorer.gif -------------------------------------------------------------------------------- /no-84/mandelbrot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ./app/build/install/app/bin/app "$@" 3 | 4 | -------------------------------------------------------------------------------- /no-84/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-84' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-85/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /no-85/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | .idea/* -------------------------------------------------------------------------------- /no-85/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /no-85/api-test/Timezone-converter API/CET -- London to 5 cities.bru: -------------------------------------------------------------------------------- 1 | meta { 2 | name: CET -> London to 5 cities 3 | type: http 4 | seq: 7 5 | } 6 | 7 | post { 8 | url: http://localhost:4567/timezone-converter?utc=2025-03-26T08:44:44.688522Z&hours=24 9 | body: json 10 | auth: inherit 11 | } 12 | 13 | params:query { 14 | utc: 2025-03-26T08:44:44.688522Z 15 | hours: 24 16 | } 17 | 18 | headers { 19 | Content-Type: application/json 20 | } 21 | 22 | body:json { 23 | { 24 | "source": "Europe/London", 25 | "cities": [ 26 | "Toronto", 27 | "Zurich", 28 | "Dubai", 29 | "Tokyo", 30 | "Sydney" 31 | ] 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /no-85/api-test/Timezone-converter API/CET -- Toronot.bru: -------------------------------------------------------------------------------- 1 | meta { 2 | name: CET -> Toronot 3 | type: http 4 | seq: 3 5 | } 6 | 7 | post { 8 | url: http://localhost:4567/timezone-converter?utc=2025-03-26T08:44:44.688522Z 9 | body: json 10 | auth: inherit 11 | } 12 | 13 | params:query { 14 | utc: 2025-03-26T08:44:44.688522Z 15 | } 16 | 17 | headers { 18 | Content-Type: application/json 19 | } 20 | 21 | body:json { 22 | { 23 | "source": "Europe/Zurich", 24 | "countries": [ 25 | "US", "CA", "AU" 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /no-85/api-test/Timezone-converter API/CET -- cities-name=Zurich.bru: -------------------------------------------------------------------------------- 1 | meta { 2 | name: CET -> cities?name=Zurich 3 | type: http 4 | seq: 6 5 | } 6 | 7 | get { 8 | url: http://localhost:4567/cities?name=Zurich 9 | body: none 10 | auth: inherit 11 | } 12 | 13 | params:query { 14 | name: Zurich 15 | } 16 | 17 | headers { 18 | Content-Type: application/json 19 | } 20 | 21 | body:json { 22 | { 23 | "source": "Europe/Zurich", 24 | "countries": [ 25 | "US", "CA", "AU" 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /no-85/api-test/Timezone-converter API/CET -- timezone counteis.bru: -------------------------------------------------------------------------------- 1 | meta { 2 | name: CET -> timezone counteis 3 | type: http 4 | seq: 5 5 | } 6 | 7 | get { 8 | url: http://localhost:4567/countries 9 | body: none 10 | auth: inherit 11 | } 12 | 13 | headers { 14 | Content-Type: application/json 15 | } 16 | 17 | body:json { 18 | { 19 | "source": "Europe/Zurich", 20 | "countries": [ 21 | "US", "CA", "AU" 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /no-85/api-test/Timezone-converter API/CET -- timezones.bru: -------------------------------------------------------------------------------- 1 | meta { 2 | name: CET -> timezones 3 | type: http 4 | seq: 4 5 | } 6 | 7 | get { 8 | url: http://localhost:4567/timezones 9 | body: none 10 | auth: inherit 11 | } 12 | 13 | headers { 14 | Content-Type: application/json 15 | } 16 | 17 | body:json { 18 | { 19 | "source": "Europe/Zurich", 20 | "countries": [ 21 | "US", "CA", "AU" 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /no-85/api-test/Timezone-converter API/bruno.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "name": "Timezone-converter API", 4 | "type": "collection", 5 | "ignore": [ 6 | "node_modules", 7 | ".git" 8 | ] 9 | } -------------------------------------------------------------------------------- /no-85/api-test/Timezone-converter API/hello.bru: -------------------------------------------------------------------------------- 1 | meta { 2 | name: hello 3 | type: http 4 | seq: 2 5 | } 6 | 7 | get { 8 | url: http://localhost:4567/hello 9 | body: none 10 | auth: inherit 11 | } 12 | -------------------------------------------------------------------------------- /no-85/app/src/main/java/timezone/Result.java: -------------------------------------------------------------------------------- 1 | package timezone; 2 | 3 | public class Result { 4 | 5 | } -------------------------------------------------------------------------------- /no-85/app/src/main/java/timezone/SortedList.java: -------------------------------------------------------------------------------- 1 | package timezone; 2 | 3 | import java.util.*; 4 | 5 | public class SortedList extends AbstractList { 6 | private final NavigableSet set; 7 | 8 | public SortedList(Comparator comparator) { 9 | this.set = new TreeSet<>(comparator); 10 | } 11 | 12 | @Override 13 | public boolean add(E element) { 14 | return set.add(element); // Fügt das Element hinzu und hält die Sortierung aufrecht 15 | } 16 | 17 | @Override 18 | public E get(int index) { 19 | return new ArrayList<>(set).get(index); // Konvertiert in eine Liste für den Indexzugriff 20 | } 21 | 22 | @Override 23 | public int size() { 24 | return set.size(); 25 | } 26 | 27 | @Override 28 | public boolean remove(Object o) { 29 | return set.remove(o); 30 | } 31 | 32 | @Override 33 | public void clear() { 34 | set.clear(); 35 | } 36 | 37 | @Override 38 | public Iterator iterator() { 39 | return set.iterator(); 40 | } 41 | } -------------------------------------------------------------------------------- /no-85/app/src/main/java/timezone/TimeConverterResponse.java: -------------------------------------------------------------------------------- 1 | package timezone; 2 | 3 | import java.util.List; 4 | 5 | public record TimeConverterResponse(TimeResponse source, List targets) { 6 | @Override 7 | public String toString() { 8 | return String.format("TimeConverterResponse{source=%s, targets=%s}", source, targets); 9 | } 10 | } -------------------------------------------------------------------------------- /no-85/app/src/main/java/timezone/TimeResponse.java: -------------------------------------------------------------------------------- 1 | package timezone; 2 | 3 | public record TimeResponse(String id, String offset, String time) { 4 | @Override 5 | public String toString() { 6 | return String.format("TimeResponse{id='%s', offset='%s', time='%s'}", id, offset, time); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /no-85/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: timezone.Timezone -------------------------------------------------------------------------------- /no-85/frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /no-85/frontend/postcss.config.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | "@tailwindcss/postcss": {}, 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /no-85/frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-85/frontend/public/favicon.ico -------------------------------------------------------------------------------- /no-85/frontend/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-85/frontend/public/logo192.png -------------------------------------------------------------------------------- /no-85/frontend/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lolo8304/coding-challenge/3b174a8ff395b1f34f59a6411ab736995f3ca285/no-85/frontend/public/logo512.png -------------------------------------------------------------------------------- /no-85/frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /no-85/frontend/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /no-85/frontend/src/.env: -------------------------------------------------------------------------------- 1 | REACT_APP_BASE_URL=http://localhost:4567 -------------------------------------------------------------------------------- /no-85/frontend/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /no-85/frontend/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render, screen } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | render(); 7 | const linkElement = screen.getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /no-85/frontend/src/App.tsx: -------------------------------------------------------------------------------- 1 | import "./App.css"; 2 | import TimeZoneComparison from "./components/TimeZoneComparison"; 3 | import TimezoneDropdown from "./components/timezones"; 4 | 5 | function App() { 6 | return ( 7 |
8 | 9 | 10 |
11 | ); 12 | } 13 | 14 | export default App; 15 | -------------------------------------------------------------------------------- /no-85/frontend/src/components/models.tsx: -------------------------------------------------------------------------------- 1 | export interface TimeZoneResults { 2 | source: TimeZoneResult; 3 | targets: TimeZoneResult[]; 4 | all: TimeZoneResult[]; 5 | } 6 | 7 | export interface TimeZoneResult { 8 | id: string; // "Asia/Tokyo; 9 | offset: string; // "+09:00"; 10 | offsetIndex: number; // 0; 11 | hours: Hours[]; 12 | } 13 | 14 | export interface Hours { 15 | hour: number; // 17; 16 | utcHour: number; // 9; 17 | time: string; // "2025-03-26T17:44:44.688522Z"; 18 | offset_to_utc: string; // "+09:00"; 19 | offset_to_source?: string; // "+09:00"; 20 | } 21 | -------------------------------------------------------------------------------- /no-85/frontend/src/index.css: -------------------------------------------------------------------------------- 1 | @import "tailwindcss"; 2 | body { 3 | margin: 0; 4 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 5 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 6 | sans-serif; 7 | -webkit-font-smoothing: antialiased; 8 | -moz-osx-font-smoothing: grayscale; 9 | } 10 | 11 | code { 12 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 13 | monospace; 14 | } 15 | -------------------------------------------------------------------------------- /no-85/frontend/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | const root = ReactDOM.createRoot( 8 | document.getElementById('root') as HTMLElement 9 | ); 10 | root.render( 11 | 12 | 13 | 14 | ); 15 | 16 | // If you want to start measuring performance in your app, pass a function 17 | // to log results (for example: reportWebVitals(console.log)) 18 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 19 | reportWebVitals(); 20 | -------------------------------------------------------------------------------- /no-85/frontend/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /no-85/frontend/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /no-85/frontend/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /no-85/frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /no-85/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Jan 12 15:50:44 CET 2025 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /no-85/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'no-85' 11 | include('app') 12 | -------------------------------------------------------------------------------- /no-85/timezone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ./app/build/install/app/bin/app "$@" 3 | 4 | -------------------------------------------------------------------------------- /no-9/readme.md: -------------------------------------------------------------------------------- 1 | # Codeing challenge 9 - Write your own grep tool 2 | 3 | check here on own repo - I used just my mobile phone and javascript 4 | 5 | https://github.com/lolo8304/coding-challenge-9 --------------------------------------------------------------------------------