新しい投稿

查找

ダイジェスト
· 2025年1月1日

Résumé de la communauté des développeurs d'InterSystems, Décembre 2024

Bonjour, voici la newsletter de la communauté des développeurs de Décembre 2024.
Statistiques générales
✓ Nouvelles publications 16 publiées le Décembre :
 6 nouveaux articles
 10 nouvelles annonces
✓ Nouveaux membres 1 ayant rejoint le Décembre
✓ Publications 1,073 publiées depuis le début
✓ Membres 155 ayant rejoint depuis le début
Meilleures publications
Les meilleurs auteurs du mois
Articles
Annonces
#InterSystems IRIS
#Communauté des développeurs officielle
#IRIS contest
#Global Masters
#Autre
Décembre, 2024Month at a GlanceInterSystems Developer Community
ダイジェスト
· 2025年1月1日

InterSystems開発者コミュニティのダイジェスト、12月 2024

12月 2024開発者コミュニティ ニュースレターへようこそ。
全体統計
16 件の新しい投稿が公開 (12月 月):
 11件の新着記事
 3の新しい発表
 2の新しい質問
3 人の新メンバーが参加 (12月 月)
1,413 件の投稿が公開 (全期間)
310 人のメンバーが参加 (全期間)
トップ記事
IRIS技術ガイド
Hiroshi Sato順
今月のトップ作家
記事
#InterSystems IRIS
openpyxl data_only=Trueとしても式の入っているセルの値がnoneになる
Hiroshi Sato順
CSP/RESTのPOSTデータに日本語が含まれる場合の処理のおまじない Parameter CONVERTINPUTSTREAM = 1
Hiroshi Sato順
詳説: RAG、ベクトル検索、および IRIS RAG アプリにおける IRIS での実装方法
Toshihiko Minamoto順
既存のセキュリティ設定をプログラムで変更する方法
Megumi Kakechi順
IRIS技術ガイド
Hiroshi Sato順
HTTPアウトバウンドアダプタを使用して、クエリパラメータとボディを両方送付する方法
Mihoko Iijima順
Interoperability(Ensemble)の大量にたまったイベントログやメッセージをAPIを利用して削除する方法
Mihoko Iijima順
IISにインストールしたCachéのCSPゲートウェイからIRISのWebゲートウェイにアップグレードする方法
Mihoko Iijima順
別の場所に保存したジャーナルを見る方法
Megumi Kakechi順
#InterSystems IRIS for Health
お知らせ
質問
12月, 2024Month at a GlanceInterSystems Developer Community
ダイジェスト
· 2025年1月1日

InterSystems 开发者社区摘要,十二月 2024

您好,欢迎阅读 十二月 2024 开发人员社区通讯。
统计信息
✓ 十二月发布了 32 篇新帖子:
 29篇新文章
 1 new announcement
 2个新问题
✓ 十二月有 29 位新成员加入
✓ 所有时间发布了 2,316 篇帖子
✓ 所有时间有 2,100 位成员加入
最高职位
本月最佳作家
文章
#InterSystems IRIS
#InterSystems IRIS for Health
第三十八章 终端输入 输出 - USER命令
按姚 鑫
第三十九章 终端输入 输出 - terminator
按姚 鑫
第四十章 终端输入 输出 - OPEN 和 USE 命令的关键字参数
按姚 鑫
第四十章 终端输入 输出 - 用于OPEN和USE的字母代码协议
按姚 鑫
第四十一章 终端输入 输出 - 协议终止符
按姚 鑫
第四十二章 终端输入 输出 - 显式终止符
按姚 鑫
第四十三章 终端输入 输出 - READ 命令
按姚 鑫
第四十四章 终端输入 输出 - 特殊协议字符影响终端 I O
按姚 鑫
第四十五章 终端输入 输出 - WRITE 命令
按姚 鑫
第四十六章 终端输入 输出 - CLOSE 命令
按姚 鑫
第四十七章 终端输入 输出 - DTM PC 控制台的助记符空间
按姚 鑫
第四十九章 终端输入 输出 - 转义序列编程
按姚 鑫
第五十章 File 输入 输出
按姚 鑫
第五十一章 File 输入 输出 - 文件路径名工具
按姚 鑫
第五十二章 File 输入 输出 - OPEN模式参数
按姚 鑫
第五十三章 File 输入 输出 - OPEN模式参数
按姚 鑫
第五十四章 File 输入 输出 - OPEN 参数关键字
按姚 鑫
第五十五章 File 输入 输出 - 与非 InterSystems IRIS 软件的交互
按姚 鑫
第五十六章 File 输入 输出 - USE 命令
按姚 鑫
第五十七章 File 输入 输出 - READ 命令
按姚 鑫
第五十八章 File 输入 输出 - WRITE 命令
按姚 鑫
第五十九章 假脱机设备
按姚 鑫
第六十章 假脱机设备 - WRITE 命令
按姚 鑫
第六十一章 假脱机设备 - 假脱机和特殊变量
按姚 鑫
#InterSystems IRIS BI (DeepSee)
公告
#开发者社区官方
问题
十二月, 2024Month at a GlanceInterSystems Developer Community
記事
· 2024年12月31日 2m read

第六十一章 假脱机设备 - 假脱机和特殊变量

第六十一章 假脱机设备 - 假脱机和特殊变量

写入 ^SPOOL 时,IRIS 会不断更新 $X$Y特殊变量。$X 表示写入当前索引行的字符数,$Y 包含当前 OPEN 期间写入的行数。请注意,$Y 的值不一定与 node 索引相同。例如:

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
記事
· 2024年12月31日 6m read

My little Advent of Code 2024 journey

You'll find the original text and all my Advent of Code efforts in different programming languages in https://bitbucket.org/janihur/advent-of-code/src/master/

ObjectScript code discussed here is found in https://bitbucket.org/janihur/advent-of-code/src/master/objectscript

I have been using ObjectScript only on last 1,5 years maybe 30% of my working time but the code at work is very different than in these puzzles. You can find my random code snippets and learning notes from https://github.com/janihur/objectscript-ex

This is the first time using ObjectScript during the contest. Earlier this year I practiced a bit with first 5 puzzles from 2018.

Before the event I made version 2 of my input data load routine. The main motivation is to be able to make the data available directly from the VS Code editor without making data files available for IRIS instance.

The solutions expect a data from object that implements aoc.data.base "iterator" interface. The class can be created from the input data:

python3 data-import-v2.py PUZZLE_INPUT_FILE

This will generate data classes:

  • aoc.example<YEAR><DAY>.cls - will be create only if PUZZLE_INPUT_FILE-example exists
  • aoc.input<YEAR><DAY>.cls

The solution classes have the interface with parameter defining if it should load the example or the actual puzzle data:

ClassMethod Solve(useExampleData As %Boolean = 0)

Some solutions uses companion classes, so be sure to load them too:

  • aoc.Coord
  • aoc.list
  • aoc.stack
  • aoc.StopWatch
  • aoc.str
  • aoc.topo
  • aoc24.Guard

Day 1

The data loading pattern works just fine. The trick is to use regular expressions (especially %Regex.Matcher class) to split the string.

I struggled with sorting as the language seems to have no sorting on any of it's peculiar data types so I implemented the simple and inefficient Bubble sort that luckily works here just fast enough.

However on the process I realised the sorting is builtin feature of the versatile multidimensional array data type:

All siblings are automatically sorted numerically or alphabetically as they are added to the tree.

Because you can freely define your array indices I have effectively started using one-based array types. This very nicely eliminates those off-by-one errors I frequently have with languages with zero-based indexing.

Day 2

Algorithm part of the puzzle was still easy for me and I scored both parts on the first try. However I fell on the same trap than the most and I had to rewrite my part 1 solution to be more general so it could be applied also to part 2.

Here I had to take a next deep dive on the features of multidimensional array, especially on merge and kill commands. This was probably the first time I had to use these functions in the actual code. I'm starting to see the point of multidimensional array thought it is well hidden behind obscure syntax and fragmented documentation.

Oh, and I had to implement string split as the platform doesn't have it but only more primitive string operations:

ClassMethod splitInputLine(
    line As %String,
    Output levels)
{
    kill levels
    for i=1:1:$length(line," ") {
        set levels(i) = $piece(line," ",i)
    }
    set levels("size") = i // feeling clever!
}

Note the clever use of subscripts!

Day 3

So far there has been no need for computer science stuff but logical reasoning has been enough.

No new ObjectScript tricks today but maybe I should put one or two potentially reusable class (i.e. static) methods into a dedicated package in the spirit of over-engineering!

Day 4

I struggled in part 1 to build the diagonals - that was a huge time sink. I also had to study the %Regex.Matcher a bit more to get the matching right.

Part 2 was a breeze compared to part 1 but I made a typo and submitted wrong answer first (first time this year).

Day 5

In the first look to the example data the puzzle looked like a case for topological sort but it turned out the validation of updates in part 1 was not a sorting problem.

But then in part 2 topological sort was indeed needed. I have used topological sort only once before (in another Advent of Code puzzle) in my career and never with ObjectScript. I implemented it in a companion class (aoc.topo) and at the same time I added also two other small helpers with better ergonomics: aoc.list and aoc.str.

I also found a valid use case for goto command too!

Overall all this took some much time that this year day 5 was the point I fell behind.

Day 6

I had no time for the puzzles in three days so now I have permanently fallen behind the daily schedule.

This is the first case where the data have to be processed as 2d array so I had to make a few new preparations. I also created two new classes:

  • aoc.Coord - to help me passing and calculating new coordinates (positions)
  • aoc24.Guard - simulating the guard's movement

Part 1 was straightforward but I struggled a bit in part 2. However it didn't took too much time to figure out the following solution:

  1. reduce the search space to the visited positions only (65% reduction)
  2. set an obstackle in every visited positions (except the guard's initial position)
  3. simulate guard's movement as in part 1
    1. there is a loop if the guard hits the obstacle second time from the same direction
    2. there is no loop if the guard walks out of the area in the same way than in part 1

In my hardware the part 2 took ~90 seconds so clearly this is non-optimal brute force algorithm. One optimization idea (search space reduction) not implemented is to set the guard's initial position next to the new obstacle.

In the beginning I tried to check if there is a certain obstacle patterns that will lead to the loop but as I couldn't figure them out immediately I abandoned the approach.

Day 7

Part 1

I bet there is a mathematical number theory that solves this problem but with my limited mathematical skills I just started to calculate all possible equations and discard the equation when it's value exceeded the expected value. I googled "parsing mathematical expressions" for implementation ideas and ended maybe a bit over-complex solution to use stacks to save the current operation and it's operands. In every iteration of equation numbers I had two new stacks for holding add and multiply operators. If the value exceeded the expected value I discarded the stack, otherwise the stack was kept for next iteration. Essentially the stack is just an elaborate accumulator.

My stack class is aoc.stack. I was also interested to correctly record the execution time so enter aoc.StopWatch. (I really need to pay attention to the de-facto standard naming convention.)

In this puzzle I had a lot of silly mistakes, e.g. at one point I forgot to rename one variable, that took far too long to troubleshoot.

Part 2

The part 2 introduced a new operation and so the search space exploded as it very often does here. Occasionally this might render brute force approaches more or less "useless". For sure it's an indication there have to be a more clever approach. Anyway I didn't have any better ideas than to run through all the valid combinations as in part 1.

During the next weeks I had zero effort on Advent Of Code. Just on the New Year's Eve I decided to out to the internet for the solutions, run into a recursive Python solution in 15 seconds and decided go no further in the lands of computer science nor mathematics. Essentially I just had to add the concatenation operation exactly the same way I already used for addition. Yes, the execution time exploded but was still just 70 seconds (2 secs in part 1) in my hardware.

I scored the star on the first try.

Later I refactored the code so that the both parts use the same solution helper methods.

1 Comment
ディスカッション (1)1
続けるにはログインするか新規登録を行ってください